Re: Re: Getting the small parts right or wrong. Order and Collect
- To: mathgroup at smc.vnet.net
- Subject: [mg63702] Re: [mg63658] Re: Getting the small parts right or wrong. Order and Collect
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Tue, 10 Jan 2006 01:48:58 -0500 (EST)
- Sender: owner-wri-mathgroup at wolfram.com
On 9 Jan 2006, at 18:48, Bill Rowe wrote: >> Putting the coefficients in an array is plausible, but Andrzej >> other solution, which is > >> 1 + Plus @@ Table[Coefficient[(1 + x + y)^3, x^i]*x^i, {i, 1, 3}] > >> is wrong because it results in answers in the order 1, x^3, x^2, x. > > More importantly, this solution omits the terms with y but not x. > That is > > In[7]:= > (1 + Plus@@Table[Coefficient[(1+x+y)^3, x^i] x^i, {i, 1, 3}]])// > Simplify > Yes, that was another case of silly carelessness. I noticed that Plus @@ Table[Coefficient[(1 + x + y)^3, x^i] x^i, {i, 0, 3}] did not work and quickly thoughtlessly just moved 1 outside. Of course the best way to do this is by using CoefficientList but if one wanted to use Table and Coefficient it can also be done: Plus @@ Table[Coefficient[(1 + x + y)^3, x, 0]*x^i, {i, 0, 3}] (y^3 + 3*y^2 + 3*y + 1)*x^3 + (y^3 + 3*y^2 + 3*y + 1)* x^2 + (y^3 + 3*y^2 + 3*y + 1)*x + y^3 + 3*y^2 + 3*y + 1 Andrzej Kozlowski