Re: How can I force mathematica to collect a symbol from a polynomial
- To: mathgroup at smc.vnet.net
- Subject: [mg130423] Re: How can I force mathematica to collect a symbol from a polynomial
- From: Peter Pein <petsie at dordos.net>
- Date: Wed, 10 Apr 2013 00:52:47 -0400 (EDT)
- Delivered-to: l-mathgroup@mail-archive0.wolfram.com
- Delivered-to: l-mathgroup@wolfram.com
- Delivered-to: mathgroup-newout@smc.vnet.net
- Delivered-to: mathgroup-newsend@smc.vnet.net
- References: <kk0i2o$2te$1@smc.vnet.net>
Am 09.04.2013 10:04, schrieb syzhaoyu at gmail.com:
> Let's say I have a polynomial:
> a+b+c
> Is there any way I can force mathematica to produce the following result:
> a*(1+b/a+c/a)
>
> I think such transformation of polynomials should be very common; however, I have been trying all day and still can not get mathematica to do so automatically.
>
Try this:
FactorOut[pol_, var_] := var*HoldForm@Expand[pol/var] // ReleaseHold
FactorOut[a + b + c, a]
--> a (1 + b/a + c/a)
Collect[Expand[(a + b)^4 (x + y)^3 - (a - b)^4 (x - y)^3], x | y,
FactorOut[#, a^Exponent[#, a]] &]
--> a^3 (8 b + (8 b^3)/a^2) x^3 +
a^4 (6 + (36 b^2)/a^2 + (6 b^4)/a^4) x^2 y +
a^3 (24 b + (24 b^3)/a^2) x y^2 +
a^4 (2 + (12 b^2)/a^2 + (2 b^4)/a^4) y^3
etc.
Peter