TExcelTAD
Home › Algebra › Solving by Factoring

Solving by Factoring

If a quadratic factors nicely, solving it takes two lines: write it as a product equal to zero, then set each factor to zero. The idea rests on one simple fact about multiplication, the zero product property. This lesson applies it, warns about the most common shortcut that loses a root, and shows how roots and factors are two views of the same thing.

The zero product property

If A⋅B=0, then A=0 or B=0 (or both).\text{If } A \cdot B = 0, \text{ then } A = 0 \text{ or } B = 0 \text{ (or both).}

A product of real numbers is zero only when one of the factors is zero. No other number has this property: A⋅B=6A \cdot B = 6 tells you nothing about AA on its own, which is why the equation must equal zero before you factor.

The method

  1. Write the equation in standard form ax2+bx+c=0ax^2 + bx + c = 0 (one side zero).
  2. Factor the left side (common factor, trinomials, special patterns).
  3. Set each factor equal to zero and solve.
  4. Check in the original equation.
x2+2x=15x2+2x−15=01. standard form(x+5)(x−3)=02. factorx+5=0orx−3=03. each factor zerox=−5orx=3check: 25−10=15 ✓,9+6=15 ✓\begin{aligned} &x^2 + 2x = 15 \\ &x^2 + 2x - 15 = 0 && \text{1. standard form} \\ &(x + 5)(x - 3) = 0 && \text{2. factor} \\ &x + 5 = 0 \quad\text{or}\quad x - 3 = 0 && \text{3. each factor zero} \\ &x = -5 \quad\text{or}\quad x = 3 \\ &\text{check: } 25 - 10 = 15\ \checkmark, \quad 9 + 6 = 15\ \checkmark \end{aligned}

With a leading coefficient other than 1:

6x2−x−2=0(2x+1)(3x−2)=0AC method: ac=−12, numbers 3 and −4x=−12orx=23\begin{aligned} &6x^2 - x - 2 = 0 \\ &(2x + 1)(3x - 2) = 0 && \text{AC method: } ac = -12, \text{ numbers } 3 \text{ and } -4 \\ &x = -\tfrac{1}{2} \quad\text{or}\quad x = \tfrac{2}{3} \end{aligned}

Two special cases

No constant term. Factor out xx:

4x2=12x4x2−12x=04x(x−3)=0→x=0 or x=3\begin{aligned} &4x^2 = 12x \\ &4x^2 - 12x = 0 \\ &4x(x - 3) = 0 \quad\to\quad x = 0 \text{ or } x = 3 \end{aligned}

Note: It is tempting to divide both sides of 4x2=12x4x^2 = 12x by 4x4x and get x=3x = 3. That loses the root x=0x = 0, because dividing by xx is dividing by zero when x=0x = 0. Never divide by an expression that contains the variable; factor it out instead.

Perfect squares give one repeated root (a double root):

x2−10x+25=0(x−5)2=0→x=5 (twice)\begin{aligned} &x^2 - 10x + 25 = 0 \\ &(x - 5)^2 = 0 \quad\to\quad x = 5 \text{ (twice)} \end{aligned}

The parabola y=x2−10x+25y = x^2 - 10x + 25 touches the x-axis at 5 without crossing it.

Roots and factors go both ways

If rr and ss are roots, then (x−r)(x−s)=0(x - r)(x - s) = 0 is an equation with exactly those roots. Multiplying out gives a formula worth remembering (Vieta's formulas):

(x−r)(x−s)=x2−(r+s)x+rssum of roots=r+s=−baproduct of roots=rs=ca\begin{aligned} &(x - r)(x - s) = x^2 - (r + s)x + rs \\ &\text{sum of roots} = r + s = -\frac{b}{a} \qquad \text{product of roots} = rs = \frac{c}{a} \end{aligned}

This is the factor theorem for degree 2. It gives a quick check: the roots of x2+2x−15=0x^2 + 2x - 15 = 0 are −5 and 3; their sum is −2=−b-2 = -b and their product −15=c-15 = c ✓.

In Python

SymPy factors and solves; NumPy builds a polynomial from its roots with np.poly and goes back with np.roots:

python · try it yourself
import numpy as np
import sympy as sp

x = sp.symbols("x")
eq = 6*x**2 - x - 2
print("factored:", sp.factor(eq))
print("roots:", sp.solve(eq, x))
print("roots of 4x² − 12x:", sp.solve(sp.Eq(4*x**2, 12*x), x))

coeffs = np.poly([-5, 3])               # monic polynomial with roots −5 and 3
print("from roots:", coeffs.tolist())
print("back to roots:", sorted(float(r) for r in np.roots(coeffs)))
factored: (2*x + 1)*(3*x - 2)
roots: [-1/2, 2/3]
roots of 4x² − 12x: [0, 3]
from roots: [1.0, 2.0, -15.0]
back to roots: [-5.0, 3.0]

A brute-force solver for quadratics with integer roots shows the factoring idea directly: look for integers rr with p(r)=0p(r) = 0, which must divide cc when a=1a = 1:

python · try it yourself
def integer_roots(a, b, c):
    roots = []
    for r in range(-abs(c), abs(c) + 1):
        if a * r * r + b * r + c == 0:
            roots.append(r)
    return roots

print(integer_roots(1, 2, -15))
print(integer_roots(1, -10, 25))
print(integer_roots(1, 0, -7))      # x² = 7: roots are not integers
[-5, 3]
[5]
[]

In software

  • Picking the right root. A physics question like "when does a ball thrown at 20 m/s from the ground land?" factors: 20t−5t2=020t - 5t^2 = 0 gives 5t(4−t)=05t(4 - t) = 0, so t=0t = 0 (launch) or t=4t = 4 s (landing). Code must choose the root that makes sense, here the positive nonzero one.
  • Polynomials from roots. Filters in audio code and control systems are designed by placing roots (zeros and poles) and multiplying the factors (x−r)(x - r) back together, exactly np.poly.
  • When factoring fails. Most quadratics with real-world coefficients do not factor over the integers. Programs therefore use the quadratic formula (carefully) rather than factoring.

Exercises

Exercise 1: Factor and solve

Solve x2−7x+12=0x^2 - 7x + 12 = 0.

Answer

x=3x = 3 or x=4x = 4

Solution

(x−3)(x−4)=0(x - 3)(x - 4) = 0.

Exercise 2: Move everything first

Solve x2=3x+28x^2 = 3x + 28.

Answer

x=7x = 7 or x=−4x = -4

Solution
x2−3x−28=0(x−7)(x+4)=0\begin{aligned} x^2 - 3x - 28 &= 0 \\ (x - 7)(x + 4) &= 0 \end{aligned}

Exercise 3: Leading coefficient

Solve 2x2+7x=152x^2 + 7x = 15.

Answer

x=32x = \frac{3}{2} or x=−5x = -5

Solution
2x2+7x−15=0;ac=−30, numbers 10 and −32x2+10x−3x−15=2x(x+5)−3(x+5)=(2x−3)(x+5)\begin{aligned} &2x^2 + 7x - 15 = 0; \quad ac = -30, \text{ numbers } 10 \text{ and } -3 \\ &2x^2 + 10x - 3x - 15 = 2x(x + 5) - 3(x + 5) = (2x - 3)(x + 5) \end{aligned}

Exercise 4: Don't divide by xx

Solve 5x2=−20x5x^2 = -20x.

Answer

x=0x = 0 or x=−4x = -4

Solution
5x2+20x=05x(x+4)=0\begin{aligned} 5x^2 + 20x &= 0 \\ 5x(x + 4) &= 0 \end{aligned}

Dividing by 5x5x would have lost x=0x = 0.

Exercise 5: Build the equation

Find a quadratic equation with integer coefficients whose roots are 23\frac{2}{3} and −1-1, and check with SymPy.

Answer

3x2+x−2=03x^2 + x - 2 = 0

Solution
(3x−2)(x+1)=3x2+3x−2x−2=3x2+x−2(3x - 2)(x + 1) = 3x^2 + 3x - 2x - 2 = 3x^2 + x - 2

Using (3x−2)(3x - 2) instead of (x−23)(x - \frac{2}{3}) keeps the coefficients integers.

python · try it yourself
import sympy as sp

x = sp.symbols("x")
p = sp.expand((3*x - 2)*(x + 1))
print(p, sp.solve(p, x))
3*x**2 + x - 2 [-1, 2/3]

Test yourself

Solve (x−4)(2x+6)=0(x - 4)(2x + 6) = 0.

  1. x=4x = 4 or x=3x = 3
  2. x=−4x = -4 or x=3x = 3
  3. x=4x = 4 or x=−3x = -3
  4. x=4x = 4 only

Why can't you solve (x−1)(x+2)=4(x - 1)(x + 2) = 4 by setting x−1=4x - 1 = 4 and x+2=4x + 2 = 4?

  1. Because the equation is linear
  2. The zero product property only works when the product is 0
  3. Because 4 is not prime
  4. You can, it gives the right roots

The roots of x2+bx+c=0x^2 + bx + c = 0 are 6 and −2. What is bb?

  1. 4
  2. −12
  3. −4
  4. 12