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
A product of real numbers is zero only when one of the factors is zero. No other number has this property: tells you nothing about on its own, which is why the equation must equal zero before you factor.
The method
- Write the equation in standard form (one side zero).
- Factor the left side (common factor, trinomials, special patterns).
- Set each factor equal to zero and solve.
- Check in the original equation.
With a leading coefficient other than 1:
Two special cases
No constant term. Factor out :
Note: It is tempting to divide both sides of by and get . That loses the root , because dividing by is dividing by zero when . Never divide by an expression that contains the variable; factor it out instead.
Perfect squares give one repeated root (a double root):
The parabola touches the x-axis at 5 without crossing it.
Roots and factors go both ways
If and are roots, then is an equation with exactly those roots. Multiplying out gives a formula worth remembering (Vieta's formulas):
This is the factor theorem for degree 2. It gives a quick check: the roots of are −5 and 3; their sum is and their product ✓.
In Python
SymPy factors and solves; NumPy builds a polynomial from its roots with np.poly and goes back with np.roots:
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 with , which must divide when :
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: gives , so (launch) or 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 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 .
Answer
or
Solution
.
Exercise 2: Move everything first
Solve .
Answer
or
Solution
Exercise 3: Leading coefficient
Solve .
Answer
or
Solution
Exercise 4: Don't divide by
Solve .
Answer
or
Solution
Dividing by would have lost .
Exercise 5: Build the equation
Find a quadratic equation with integer coefficients whose roots are and , and check with SymPy.
Answer
Solution
Using instead of keeps the coefficients integers.
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 .
- or
- or
- or
- only
Why can't you solve by setting and ?
- Because the equation is linear
- The zero product property only works when the product is 0
- Because 4 is not prime
- You can, it gives the right roots
The roots of are 6 and −2. What is ?
- 4
- −12
- −4
- 12