How can I split a given polynomial as sum of factors in Mathematica?
For example, let's say I have this polynomial: $2\cdot x^2+7\cdot x+2$.
I would like the output to be $(x+1)(x+2)+x(x+4)$. Is there a way to do that with Mathematica?
Mathematica Stack Exchange is a question and answer site for users of Wolfram Mathematica. It only takes a minute to sign up.
Sign up to join this communityHow can I split a given polynomial as sum of factors in Mathematica?
For example, let's say I have this polynomial: $2\cdot x^2+7\cdot x+2$.
I would like the output to be $(x+1)(x+2)+x(x+4)$. Is there a way to do that with Mathematica?
expr = 2 x^2 + 7 x + 2;
expr2 = (x + a) (x + b) + x (x + c);
expr2 /. Solve[Equal @@ (CoefficientList[#, x] & /@ {expr, expr2}),
{a, b, c}, Integers][[-1]]
(1 + x) (2 + x) + x (4 + x)
Factor
anyway. $\endgroup$ – Sjoerd C. de Vries Mar 31 '15 at 6:15