0
$\begingroup$

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?

$\endgroup$
2
  • 1
    $\begingroup$ What you want is not really factorization, because that's about multiplication of factors. There's an infinity of terms that can be added to arrive at the same result. But have a look at Factor anyway. $\endgroup$ Mar 31, 2015 at 6:15
  • $\begingroup$ 'Factor' doesn't give a possible way to write factors as sum of products. $\endgroup$
    – Baymax
    Apr 7, 2015 at 6:04

1 Answer 1

1
$\begingroup$
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)

$\endgroup$
2
  • $\begingroup$ Thanks for the answer. But, is it possible to implement such a procedure symbolically and for any given polynomial not necessarily quadratic? $\endgroup$
    – Baymax
    Apr 7, 2015 at 6:05
  • $\begingroup$ I believe not. The target form (expr2) would have to be specified and generally not all polynomials of a given order can be expressed in the specified form (even if just quadratic). $\endgroup$
    – Bob Hanlon
    Apr 7, 2015 at 13:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.