       Re: Why isn't Expand[] grouping terms by order?

• To: mathgroup at smc.vnet.net
• Subject: [mg87892] Re: Why isn't Expand[] grouping terms by order?
• From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
• Date: Sat, 19 Apr 2008 03:37:03 -0400 (EDT)
• Organization: The Open University, Milton Keynes, UK
• References: <fu9fq7\$cbn\$1@smc.vnet.net>

```p at dirac.org wrote:

> Consider this:
>
>    In:= Expand[ (1+a*x)*(1+b*x), x]
>
>                                  2
>    Out= 1 + a x + b x + a b x
>
>
> How can I coax Mathematica to give me this, instead:
>
>                                  2
>    Want= 1 + (a + b) x + a b x
>
> Why isn't Mathematica reporting the answer in terms of powers of x?

The function *Collect[]* is what you are looking for.

In:= Collect[(1 + a*x)*(1 + b*x), x]

Out= 1 + (a + b) x + a b x^2

In:= Expand[(1 + a*x)*(1 + b*x), x]

Out= 1 + a x + b x + a b x^2

In:= Collect[%, x]

Out= 1 + (a + b) x + a b x^2

Regards,
-- Jean-Marc

```

• Prev by Date: Re: Defining derivatives
• Next by Date: Re: Text does not show up in vertices of GraphPlot3D
• Previous by thread: Re: Why isn't Expand[] grouping terms by order?