Re: Getting the small parts right or wrong. Order and Collect
- To: mathgroup at smc.vnet.net
- Subject: [mg63627] Re: [mg63607] Getting the small parts right or wrong. Order and Collect
- From: Bob Hanlon <hanlonr at cox.net>
- Date: Sun, 8 Jan 2006 03:32:48 -0500 (EST)
- Reply-to: hanlonr at cox.net
- Sender: owner-wri-mathgroup at wolfram.com
It appears that you have your default output format type set to StandardForm.
Either set your default to TraditionalForm or use
(expr=Collect[(1+x+y)^3,x])//TraditionalForm
x^3 + (3*y + 3)*x^2 + (3*y^2 + 6*y + 3)*x + y^3 + 3*y^2 + 3*y + 1
Bob Hanlon
>
> From: "Richard Fateman" <fateman at cs.berkeley.edu>
To: mathgroup at smc.vnet.net
> Subject: [mg63627] [mg63607] Getting the small parts right or wrong. Order and
Collect
>
> This example comes from the on-line help.
>
> Collect[(1 + x + y)^3, x]
>
> is supposed to collect the terms in the expression by powers of x. I
> expected the answer to look something like
>
> (.....)*x^0 + (......)*x^1 +(....)*x^2 + ..... etc.
>
> with some simplifications like x^0 -> 1, x^1 -> x in place, and perhaps
the
> whole thing ordered in reverse.
>
> But the result is
>
> 1 + x^3 + 3*y + 3*y^2 + y^3 + x^2*(3 + 3*y) + x*(3 + 6*y + 3*y^2)
>
> Yes I can explain why this answer is ordered this way, but it is not a
> property of computer algebra systems that is reflected by this, just a
> property of Mathematica. This is a poke to get it right.
>
> I even know I can do this..
>
> Replace[%21, {Plus :> List}, 1, Heads -> True]
>
> and make a list of the terms; I can then try sorting them some other way,
as
> long as I don't add them together. Oh, I can also rename the variables;
> Collect [(1+x+y)^3, y] works much better.
>
> RJF
>
>
>
>