Factorization

Factorization (or factoring) is the reverse of expansion: instead of multiplying out, we write an algebraic expression as a product of simpler ones. For example,

$ x^2 - 2x - 3 = (x-3)(x+1). $

We say that $x-3$ and $x+1$ are factors of $x^2-2x-3$.

Illustration for Factorization
Figure 1

Quick Reference

Method Key Formula or Idea When to Use
Common Factor $ax+ay=a(x+y)$ Always check this first
Difference of Squares $A^2-B^2=(A+B)(A-B)$ Two perfect squares with a minus sign
Perfect Square Trinomial $A^2\pm2AB+B^2=(A\pm B)^2$ Middle term equals $\pm 2AB$
Difference of Cubes $A^3-B^3=(A-B)(A^2+AB+B^2)$ Two perfect cubes, minus sign
Sum of Cubes $A^3+B^3=(A+B)(A^2-AB+B^2)$ Two perfect cubes, plus sign
Inspection ($x^2+bx+c$) Find integers $p,q$ with $p+q=b$ and $pq=c$ Leading coefficient is 1
Inspection ($ax^2+bx+c$) Multiply by $a$; find $p+q=b$ and $pq=ac$ General quadratic trinomial
Completing the Square ($x^2+px+q$) Add and subtract $\tfrac{p^2}{4}$; apply $A^2-B^2$ Always works, including irrational roots
Grouping Group terms that share common factors Four or more terms

Why Is Factorization Important?

If we can write an equation in factored form $P \cdot Q = 0$, solving it reduces to solving two independent equations $P=0$ and $Q=0$. (Recall from Section: Sets of Numbers that if $ab=0$ then $a=0$ or $b=0$.) For example, because $x^2-2x-3=(x-3)(x+1)$, instead of solving

$ x^2-2x-3=0, $

we solve

$ x-3=0 \quad \text{and} \quad x+1=0, $

which gives at once

$ x=3 \quad \text{or} \quad x=-1. $

Similarly, because

$ x^3-8x^2+17x-10=(x-1)(x-2)(x-5), $

we immediately conclude

$ x^3-8x^2+17x-10=0 \iff x=1 \quad \text{or} \quad x=2 \quad \text{or} \quad x=5. $

Evaluating $x^3-8x^2+17x-10$ at those roots also reduces to a handful of arithmetic steps.

Factorization is not always possible, and even when it is, the factors are not always simpler. For example, $x^5-32$ factors into $(x-2)$ and $(x^4+2x^3+4x^2+8x+16)$, but solving $x^4+2x^3+4x^2+8x+16=0$ is harder than the original.

Another application is simplifying rational expressions. For example:

$ \frac{x^2-1}{x^2-2x-3} = \frac{(x-1)\cancel{(x+1)}}{(x-3)\cancel{(x+1)}} = \frac{x-1}{x-3} \qquad (x \neq -1). $

Now let's review the main factorization techniques.

Common Factors

When a factor appears in every term of an expression, factor it out using the distributive property in reverse.

Example 1.

Example. Factor each expression.

  1. $12x^3-15x^2$
  2. $4x^5-8x^4-16x^3-20x^2$
  3. $(2x-5)(3x-7)+4(3x-7)$
Solution
  1. The greatest common factor of $12x^3$ and $-15x^2$ is $3x^2$: $ 12x^3-15x^2 = 3x^2(4x-5). $
  2. The greatest common factor of all four terms is $4x^2$: $ 4x^5-8x^4-16x^3-20x^2 = 4x^2(x^3-2x^2-4x-5). $
  3. The common factor of $(2x-5)(3x-7)$ and $4(3x-7)$ is $(3x-7)$: $ \begin{aligned} (2x-5)(3x-7)+4(3x-7) &= (3x-7)\bigl[(2x-5)+4\bigr] \\ &= (3x-7)(2x-1). \end{aligned} $

Factoring fractional and negative exponents. In calculus, expressions with fractional or negative exponents often need to be factored. In that case, factor out the common base with the smallest exponent.

Example 2.

Example. Factor each expression.

  1. $x^{3/2}+4x^{1/2}-7x^{-1/2}$
  2. $(x-4)^{-3/5}+5(x-4)^{2/5}$
Solution
  1. The common base is $x$ and the smallest exponent is $-\tfrac{1}{2}$: $ x^{3/2}+4x^{1/2}-7x^{-1/2} = x^{-1/2}(x^2+4x-7). $ Check: $x^{-1/2}\cdot x^2 = x^{3/2}$ and $x^{-1/2}\cdot x = x^{1/2}$, as required.
  2. The common base is $(x-4)$ and the smallest exponent is $-\tfrac{3}{5}$: $ \begin{aligned} (x-4)^{-3/5}+5(x-4)^{2/5} &= (x-4)^{-3/5}\bigl[1+5(x-4)\bigr] \\ &= (x-4)^{-3/5}(5x-19). \end{aligned} $ Check: $(x-4)^{-3/5}\cdot 5(x-4)^1 = 5(x-4)^{2/5}$, using $-\tfrac{3}{5}+1=\tfrac{2}{5}$.

Special Factorization Formulas

When no common factor exists, the following formulas — each the reverse of a special product identity — often apply.

  1. $A^2-B^2=(A+B)(A-B)$   (Difference of Squares)
  2. $A^2\pm2AB+B^2=(A\pm B)^2$   (Perfect Square Trinomial)
  3. $A^3-B^3=(A-B)(A^2+AB+B^2)$   (Difference of Cubes)
  4. $A^3+B^3=(A+B)(A^2-AB+B^2)$   (Sum of Cubes)

How to remember Sum and Difference of Cubes: the SOAP rule. For a factored cubic $(A\pm B)(\ldots)$, the signs follow Same, Opposite, Always Positive.

SOAP mnemonic sign diagram for the sum and difference of cubes formulas
SOAP mnemonic applied to the factored forms of A³+B³ and A³−B³
Example 3.

Example. Factor each expression.

  1. $9x^2-49$
  2. $x^4-16$
  3. $x^2+10x+25$
  4. $x^3-27$
  5. $8x^3+64$
Solution
  1. Set $A=3x$ and $B=7$, then apply the Difference of Squares formula: $ \begin{aligned} 9x^2-49 &= (3x)^2-7^2 \\ &= (3x-7)(3x+7). \end{aligned} $
  2. Set $A=x^2$ and $B=4$: $ \begin{aligned} x^4-16 &= (x^2)^2-4^2 \\ &= (x^2-4)(x^2+4). \end{aligned} $ Since $x^2-4 = x^2-2^2$, apply the formula once more: $ \begin{aligned} x^4-16 &= (x^2-4)(x^2+4) \\ &= (x-2)(x+2)(x^2+4). \end{aligned} $
  3. Set $A=x$ and $B=5$. Since the middle term satisfies $10x = 2AB$, this is a Perfect Square Trinomial: $ x^2+10x+25 = (x+5)^2. $
  4. Set $A=x$ and $B=3$, then apply the Difference of Cubes formula: $ \begin{aligned} x^3-27 &= x^3-3^3 \\ &= (x-3)(x^2+3x+9). \end{aligned} $
  5. First factor out the common factor 8, then apply Sum of Cubes with $A=x$ and $B=2$: $ \begin{aligned} 8x^3+64 &= 8(x^3+8) \\ &= 8(x^3+2^3) \\ &= 8(x+2)(x^2-2x+4). \end{aligned} $
Example 4.

Example. Factor $9x^2-12xy+4y^2$.

Solution Since $9x^2=(3x)^2$ and $4y^2=(2y)^2$, and the middle term satisfies $12xy=2(3x)(2y)$, this is a Perfect Square Trinomial with a negative middle sign: $ 9x^2-12xy+4y^2 = (3x-2y)^2. $
Example 5.

Example. Factor $a^2+b^2+c^2+2ab+2ac+2bc$.

Solution Regroup to reveal a perfect square pattern: $ \begin{aligned} a^2+2ab+b^2+2ac+2bc+c^2 &= (a+b)^2+2(a+b)c+c^2 \\ &= (a+b+c)^2. \end{aligned} $
Example 6.

Example. Factor $x^2-y^2-z^2+2yz$.

Solution $ \begin{aligned} x^2-y^2-z^2+2yz &= x^2-(y^2-2yz+z^2) \\ &= x^2-(y-z)^2 \\ &= (x+y-z)(x-y+z). \end{aligned} $ The last step applies the Difference of Squares formula $A^2-B^2=(A+B)(A-B)$ with $A=x$ and $B=y-z$.
Example 7.

Example. Factor $x^4+x^2y^2+y^4$.

Solution Add and subtract $x^2y^2$ to complete a perfect square, then factor as a difference of squares: $ \begin{aligned} x^4+x^2y^2+y^4 &= x^4+2x^2y^2+y^4-x^2y^2 \\ &= (x^2+y^2)^2-(xy)^2 \\ &= (x^2+y^2+xy)(x^2+y^2-xy). \end{aligned} $

More Special Factorization Formulas. For any integer $n$:

  • Difference, even exponent: $A^{2n}-B^{2n}=(A^n-B^n)(A^n+B^n)$
  • Difference, any exponent: $A^n-B^n=(A-B)(A^{n-1}+A^{n-2}B+\cdots+AB^{n-2}+B^{n-1})$
  • Sum, odd exponent: $A^n+B^n=(A+B)(A^{n-1}-A^{n-2}B+\cdots-AB^{n-2}+B^{n-1})$
  • Sum, even exponent: $A^n+B^n$ cannot, in general, be factored over the reals.

Replacing $B$ by $-B$ in the difference formula (with $n$ odd) yields the sum formula.

Factoring x2 +bx+c by Inspection

Since

$ (x+p)(x+q) = x^2+(p+q)x+pq, $

a polynomial $x^2+bx+c$ factors over the integers whenever we can find integers $p$ and $q$ with

$ p+q=b \quad \text{and} \quad pq=c. $

By the Rational Root Theorem, when rational roots exist they must be integers, so we do not consider fractions such as $\tfrac{1}{2}$ or $\tfrac{3}{7}$ during inspection. In this section we find $p$ and $q$ by trial and error; a systematic method appears in the section on quadratic equations.

Example 8.

Example. Factor $x^2+13x+42$.

Solution We seek two integers $p$ and $q$ such that $pq=42$ and $p+q=13$. Since $pq=42$ is positive, $p$ and $q$ must be either both positive or both negative. Since $p+q=13$ is positive, $p$ and $q$ must be both positive. Therefore, we seek two positive integers whose product is 42 and whose sum is 13. The positive factor pairs of 42 are: $42\times1$, $21\times2$, $14\times3$, $7\times6$. The pair with sum 13 is $7$ and $6$. $ x^2+13x+42 = (x+7)(x+6). $
Example 9.

Example. Factor $x^2-9x-22$.

Solution Since $pq=-9$ is negative, $p$ and $q$ have opposite signs. Since $p+q=-22$ is negative, the one with the greater absolute value must be negative. Testing: $-22\times1$, $-11\times2$. The pair $-11$ and $2$ gives $-11+2=-9$. $ x^2-9x-22 = (x-11)(x+2). $
Example 10.

Example. Factor $x^2-13x+22$.

Solution Since $pq=22$ is positive and $p+q=-13$ is negative, both $p$ and $q$ must be negative. Testing negative factor pairs of 22, we find $-11$ and $-2$, since $(-11)+(-2)=-13$. $ x^2-13x+22 = (x-11)(x-2). $
Example 11.

Example. Factor each expression.

  1. $x^2+3x+2$
  2. $x^2-2x-15$
Solution
  1. Find $p$ and $q$ with $p+q=3$ and $pq=2$. By trial: $p=2$, $q=1$. $ x^2+3x+2 = (x+2)(x+1). $
  2. Find $p$ and $q$ with $p+q=-2$ and $pq=-15$. By trial: $p=-5$, $q=3$. $ x^2-2x-15 = (x-5)(x+3). $

Factoring ax2 +bx+c by Inspection

It is sometimes possible to factor $ax^2+bx+c$ by inspection when $a$, $b$, and $c$ are integers.

Multiplying and dividing by $a$, we reduce the expression to the form

$ ax^2+bx+c = \frac{(ax)^2+b(ax)+ac}{a}, $

and then factor the numerator with respect to $ax$ by finding two integers whose product is $ac$ and sum is $b$.

Example 12.

Example. Factor $6x^2+7x-5$.

Solution Multiply and divide by 6: $ 6x^2+7x-5 = \frac{(6x)^2+7(6x)-5\times6}{6} = \frac{(6x)^2+7(6x)-30}{6}. $ Let $u=6x$, then $ 6x^2+7x-5 = \frac{(6x)^2+7(6x)-30}{6}=\frac{u^2+7u-30}{6}. $ Now let's factor $u^2+7u-30$. We need two integers with product $-30$ and sum $7$. Since $pq$ is negative, the integers have opposite signs; since $p+q$ is positive, the larger in absolute value is positive. Factor pairs of $-30$: $30\times(-1)$, $10\times(-3)$, $6\times(-5)$. The pair $10$ and $-3$ satisfies $10+(-3)=7$. Therefore, $ u^2+7u-30 = (u+10)(u-3). $ Substitute $u=6x$: $ (6x)^2+7(6x)-30 = (6x+10)(6x-3). $ Divide by 6 and simplify: $ \begin{aligned} 6x^2+7x-5 &= \frac{(6x+10)(6x-3)}{6} \\ &= \frac{2(3x+5)\cdot 3(2x-1)}{6} \\ &= (3x+5)(2x-1). \end{aligned} $
Example 13.

Example. Factor $2x^2+7x+3$.

Solution Multiply and divide by 2, then find two integers with product $2\times3=6$ and sum $7$: they are $6$ and $1$. $ \begin{aligned} 2x^2+7x+3 &= \frac{(2x)^2+7(2x)+6}{2} \\ &= \frac{(2x+6)(2x+1)}{2} \\ &= (x+3)(2x+1). \end{aligned} $
Example 14.

Example. Factor $abx^2+(a^2+b^2)x+ab$.

Solution $ \begin{aligned} abx^2+(a^2+b^2)x+ab &= \frac{(abx)^2+(a^2+b^2)(abx)+a^2b^2}{ab} \\ &= \frac{(abx+a^2)(abx+b^2)}{ab} \\ &= (bx+a)(ax+b). \end{aligned} $
Example 15.

Example. Factor $16x^2+72x-63$.

Solution Notice that $16x^2=(4x)^2$ and $72x=18(4x)$, so we can treat $4x$ directly as the variable: $ \begin{aligned} 16x^2+72x-63 &= (4x)^2+18(4x)-63 \\ &= (4x+21)(4x-3). \end{aligned} $

Factoring x2+px+q by Completing the Square

While inspection applies only in particular cases, completing the square is perfectly general. The key identity is:

$ \left(x+\frac{p}{2}\right)^2 = x^2+px+\frac{p^2}{4}, $

so we can make $x^2+px$ a perfect square by adding $\frac{p^2}{4}$ — the square of half the coefficient of $x$. This process is called completing the square.

  1. Adding and subtracting $\frac{p^2}{4}$ leaves $x^2+px+q$ unchanged, but transforms it into a difference of squares:

$ \begin{aligned} x^2+px+q &= x^2+px+\frac{p^2}{4}-\frac{p^2}{4}+q \\ &= \left(x+\frac{p}{2}\right)^2-\frac{p^2-4q}{4} \\ &= \left(x+\frac{p+\sqrt{p^2-4q}}{2}\right)\!\left(x+\frac{p-\sqrt{p^2-4q}}{2}\right). \quad \text{(i)} \end{aligned} $

  1. For the general case $ax^2+bx+c = a\!\left(x^2+\frac{b}{a}x+\frac{c}{a}\right)$, substitute $p=\frac{b}{a}$ and $q=\frac{c}{a}$ into (i) and simplify:

$ ax^2+bx+c = a\left(x+\frac{b+\sqrt{b^2-4ac}}{2a}\right)\!\left(x+\frac{b-\sqrt{b^2-4ac}}{2a}\right). $

Example 16.

Example. Factor $x^2-6x+2$.

Solution $ \begin{aligned} x^2-6x+2 &= x^2-6x+3^2-3^2+2 \\ &= (x-3)^2-7 \\ &= (x-3+\sqrt{7})(x-3-\sqrt{7}). \end{aligned} $
Example 17.

Example. Factor $3x^2-5x+1$.

Solution $ \begin{aligned} 3x^2-5x+1 &= 3\!\left[x^2-\tfrac{5}{3}x+\tfrac{1}{3}\right] \\ &= 3\!\left[x^2-\tfrac{5}{3}x+\left(\tfrac{5}{6}\right)^2-\left(\tfrac{5}{6}\right)^2+\tfrac{1}{3}\right] \\ &= 3\!\left[\left(x-\tfrac{5}{6}\right)^2-\tfrac{13}{36}\right] \\ &= 3\!\left(x-\tfrac{5}{6}+\tfrac{\sqrt{13}}{6}\right)\!\left(x-\tfrac{5}{6}-\tfrac{\sqrt{13}}{6}\right). \end{aligned} $
Example 18.

Example. Factor $x^2+8x+20$.

Solution $ \begin{aligned} x^2+8x+20 &= x^2+8x+4^2-4^2+20 \\ &= (x+4)^2+4 \\ &= (x+4)^2-(2\sqrt{-1})^2 \\ &= (x+4+2\sqrt{-1})(x+4-2\sqrt{-1}). \end{aligned} $ Here the sum of squares $(x+4)^2+4$ leads to complex numbers: $\sqrt{-1}=i$ in the complex number system. We treat this factorization symbolically for now and return to complex numbers later.

Factoring by Grouping

Sometimes a polynomial has no common factor shared by all terms, but can still be factored by grouping terms that share a common factor. This strategy works best for polynomials with four or more terms.

For example:

$ \begin{aligned} x^3+3x^2+4x+12 &= (x^3+3x^2)+(4x+12) \\ &= x^2(x+3)+4(x+3) \\ &= (x+3)(x^2+4). \end{aligned} $

Example 19.

Example. Factor $2x^3+x^2-18x-9$.

Solution Group the first two and last two terms: $ \begin{aligned} 2x^3+x^2-18x-9 &= (2x^3+x^2)-(18x+9) \\ &= x^2(2x+1)-9(2x+1) \\ &= (2x+1)(x^2-9) \\ &= (2x+1)(x-3)(x+3). \end{aligned} $ The last step uses the Difference of Squares formula on $x^2-9=x^2-3^2$.

Frequently Asked Questions

What is the first step in factoring any polynomial? Always check for a common factor first. Factor out the greatest common factor (GCF) from all terms before trying any other method. This simplifies all subsequent work and is easy to overlook.
What is the difference between factoring and expanding? Expanding (or distributing) turns a product like $(x-3)(x+1)$ into a sum: $x^2-2x-3$. Factoring is the reverse — it rewrites a sum as a product. The two operations undo each other, and you can verify any factorization by expanding the result.
How do I choose which factoring method to use? A practical order: (1) Always pull out the GCF first. (2) Count the terms: two terms often suggest Difference of Squares or Sum/Difference of Cubes; three terms suggest a trinomial method (inspection or completing the square); four or more terms suggest grouping. (3) Check whether the expression matches a special pattern such as a perfect square trinomial.
What does it mean for a polynomial to be prime or irreducible? A polynomial is prime (or irreducible) over the integers if it cannot be written as a product of two polynomials with integer coefficients, other than $\pm1$ times itself. For example, $x^2+1$ and $x^2+x+1$ are prime over the integers. When inspection fails to find integer values of $p$ and $q$, the polynomial may still factor using irrational roots via completing the square.
Can $A^2+B^2$ (a sum of squares) be factored over the reals? No. A sum of two perfect squares such as $x^2+4$ cannot be factored using real numbers. It factors only over the complex numbers: $x^2+4=(x+2i)(x-2i)$. This is why the Difference of Squares formula has a minus sign $A^2-B^2$ factors, but $A^2+B^2$ does not (over the reals).
When is completing the square necessary? Use completing the square when inspection fails and the roots are irrational or complex. It always produces a factorization (possibly involving square roots), whereas inspection only works when the roots are rational integers. Completing the square also underlies the quadratic formula, which gives the roots of any quadratic polynomial.