I have a polynomial like this:
(a x + b c y + d z) (d x + e c y + g z)
I would like to rewrite it as something like this:
a d x^2 + b c^2 e y^2 + d g z^2 + (c (b d + a e)) x y + (d^2 + a g) x z + (c (d e + b g)) y z
i.e. keep all terms of different variables separate, collect all the coefficients for each term, and also simplify all the coefficients. How can we do this?
Collect
gives a nested collection, so it is not what I want.
(i.e. it gives this:
a d x^2 + b c^2 e y^2 + (c d e + b c g) y z + d g z^2 + x ((b c d + a c e) y + (d^2 + a g) z)
where the last term is a nested one)
The closest I can find is
expr=(a x + b c y + d z) (d x + e c y + g z);
Plus @@ MonomialList[Expand[expr], {x, y, z}]
which collects all the coefficients but refuses to simplify them, i.e.
a d x^2 + (b c d + a c e) x y + b c^2 e y^2 + (d^2 + a g) x z + (c d e + b c g) y z + d g z^2.
Comments
Post a Comment