randRangeNonZero( -10, 10 ) randRangeNonZero( -10, 10 )
1 SQUARE*A*B A*B SQUARE*(-A-B) -A-B

Factor the expression below completely. All coefficients should be integers.

plus(SQUARE + "x^2") + plus( LINEAR + "x" ) + CONSTANT

(x-A)(x-B)

When we factor a polynomial, we are basically reversing this process of multiplying linear expressions together:

\qquad \begin{eqnarray} (x + a)(x + b) \quad&=&\quad xx &+& xb + ax &+& ab \\ \\ &=&\quad x^2 &+& \green{(a + b)}x &+& \blue{ab} \end{eqnarray}

\qquad \begin{eqnarray} \hphantom{(x + a)(x + b) \quad}&\hphantom{=}&\hphantom{\quad xx }&\hphantom{+}&\hphantom{ (a + b)x }&\hphantom{+}& \\ &=&\quad x^2 & SIMPLELINEAR >= 0 ? "+" : ""& plus( "\\green{" + SIMPLELINEAR + "}x" )& SIMPLECONSTANT >= 0 ? "+" : ""& plus( "\\blue{" + SIMPLECONSTANT + "}" ) \end{eqnarray}

The coefficient on the x term is SIMPLELINEAR and the constant term is SIMPLECONSTANT, so to reverse the steps above, we need to find two numbers that add up to SIMPLELINEAR and multiply to SIMPLECONSTANT.

You can try out different factors of \blue{SIMPLECONSTANT} to see if you can find two that satisfy both conditions. If you're stuck and can't think of any, you can also rewrite the conditions as a system of equations and try solving for \pink{a} and \pink{b}:

\qquad \pink{a} + \pink{b} = \green{SIMPLELINEAR}

\qquad \pink{a} \times \pink{b} = \blue{SIMPLECONSTANT}

The two numbers \pink{-A} and \pink{-B} satisfy both conditions:

\qquad \pink{-A} + \pink{-B} = \green{SIMPLELINEAR}

\qquad \pink{-A} \times \pink{-B} = \blue{SIMPLECONSTANT}

So we can factor the expression as: (x A < 0 ? "+" : "" \pink{-A})(x B < 0 ? "+" : "" \pink{-B})