Re: Re: Getting the small parts right or wrong. Order and Collect
- To: mathgroup at smc.vnet.net
- Subject: [mg63649] Re: [mg63631] Re: Getting the small parts right or wrong. Order and Collect
- From: Andrzej Kozlowski <akoz at mimuw.edu.pl>
- Date: Mon, 9 Jan 2006 04:48:25 -0500 (EST)
- References: <dpg11e$pm4$1@smc.vnet.net> <dplhq9$em8$1@smc.vnet.net> <200601070729.CAA06924@smc.vnet.net> <6FCF3227-C4E1-418A-BAC1-F3981F969878@mimuw.edu.pl> <dpo3gp$gaq$1@smc.vnet.net> <200601080832.DAA02327@smc.vnet.net>
- Sender: owner-wri-mathgroup at wolfram.com
On 8 Jan 2006, at 17:32, Richard Fateman wrote: > > "Andrzej Kozlowski" <akoz at mimuw.edu.pl> wrote in message > news:dpo3gp$gaq$1 at smc.vnet.net... >> On 7 Jan 2006, at 18:04, Andrzej Kozlowski wrote: >> >>> >>> >>> There is one very simple thing you can do, which I think completely >>> deals with your problem. >>> You can convert the output to TraditionalForm. >>> > > No, because TraditionalForm is only a hack on the display. If you > pick > out the parts of the expression in sequence by using %[[1]] etc, > you find > that the coefficients of the different powers of x are picked out > in the > StandardForm order, not the TraditionalForm order. What's "right" and "wrong" here is a matter of opinion. In my opinion there is nothing wrong with what Mathematica does here. I assumed you were concerned with "typesetting' and in this respect Mathematica behaves correctly in TraditionalForm. Since I always work with TraditionalForm for display I have no problems here. On the other hand I would never try to pick terms of a polynomial with %[[1]] as you suggest. This is indeed "entirely wrong". The "right" thing is, of course, to use Coefficient or for this sort of thing CoefficientList. Please observe carefull: CoefficientList[(1 + x + y)^3, x] {y^3 + 3*y^2 + 3*y + 1, 3*y^2 + 6*y + 3, 3*y + 3, 1} Who needs all the typing? Now you can pick terms as you like. You can even Reverse the list. The only thing you can't do is Apply Plus: which is of course what I though you wanted to do, for typesetting reasons. > > 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. > And of course picking out the coefficient of "1". Of course I only suggested this assuming you were working in TraditionalForm, like I do, and were concerned with the way things looked. > > Along those lines it is > better to do ... Table[Coefficient[(1+x+y)^3,x,i] ,{i,0,3}] where i > can also > be 0. > And the table keeps the coefficients from being randomly sorted. > > "Of course there is no way to make the powers of x ascend as you > originally seems to have wanted but then we can't have everything > even where Mathematica is concerned." Eh, this one can be solved > with Table and Coefficient. It is just that the EXAMPLE IN THE BOOK > is the mistake. > All of the above is a waste of time and effort because the obvious thing to do is to use CoefficientList. Andrzej Kozlowski
- References:
- Getting the small parts right or wrong. Order and Collect
- From: "Richard Fateman" <fateman@cs.berkeley.edu>
- Re: Getting the small parts right or wrong. Order and Collect
- From: "Richard Fateman" <fateman@cs.berkeley.edu>
- Getting the small parts right or wrong. Order and Collect