Difference of Squares & Sum/Difference of Cubes

April 12, 2026

Problem

Factor x³−27 using the difference of cubes: a³−b³ = (a−b)(a²+ab+b²). Also show a²−b² = (a−b)(a+b).

Explanation

Three special factoring formulas

These three formulas should be memorized — they appear constantly on exams:

Difference of squares: a2b2=(ab)(a+b)a^2 - b^2 = (a - b)(a + b)

Difference of cubes: a3b3=(ab)(a2+ab+b2)a^3 - b^3 = (a - b)(a^2 + ab + b^2)

Sum of cubes: a3+b3=(a+b)(a2ab+b2)a^3 + b^3 = (a + b)(a^2 - ab + b^2)

Step-by-step: Factor x327x^3 - 27

Step 1 — Recognize the pattern. x327=x333x^3 - 27 = x^3 - 3^3. This is a difference of cubes with a=xa = x and b=3b = 3.

Step 2 — Apply the formula a3b3=(ab)(a2+ab+b2)a^3 - b^3 = (a - b)(a^2 + ab + b^2):

x327=(x3)(x2+3x+9)x^3 - 27 = (x - 3)(x^2 + 3x + 9)

Step 3 — Check by expanding:

(x3)(x2+3x+9)=x3+3x2+9x3x29x27=x327(x - 3)(x^2 + 3x + 9) = x^3 + 3x^2 + 9x - 3x^2 - 9x - 27 = x^3 - 27 \checkmark

Step 4 — Can we factor further? Check x2+3x+9x^2 + 3x + 9: discriminant =936=27<0= 9 - 36 = -27 < 0. No real roots, so this factor is irreducible over the reals.

More examples

Difference of squares: 4x225=(2x)252=(2x5)(2x+5)4x^2 - 25 = (2x)^2 - 5^2 = (2x - 5)(2x + 5)

Sum of cubes: 8x3+125=(2x)3+53=(2x+5)(4x210x+25)8x^3 + 125 = (2x)^3 + 5^3 = (2x + 5)(4x^2 - 10x + 25)

Memory trick for cubes

The factored form is always: (binomial)(trinomial). The binomial has the same sign as the original. The trinomial follows the pattern: "Square, Opposite Product, Square" — a2a^2, ab\mp ab, b2b^2 (the middle sign is opposite to the binomial's sign).

Common mistakes

  • Confusing difference and sum. a2b2a^2 - b^2 factors, but a2+b2a^2 + b^2 does NOT factor over the reals.
  • Forgetting to check if bb is a perfect cube/square. x312x^3 - 12 is NOT a difference of cubes because 12 isn't a perfect cube.
  • Sign errors in the trinomial. For a3b3a^3 - b^3: binomial is (ab)(a - b), trinomial is (a2+ab+b2)(a^2 + ab + b^2) — all positive inside.

Try it in the visualization

Select difference of squares, difference of cubes, or sum of cubes. Adjust aa and bb values. The factored form updates live, the graph confirms roots, and the expansion check verifies the answer.

Interactive Visualization

Parameters

a³−b³ (diff of cubes)
1.00
3.00
Your turn

Got your own math or physics problem?

Turn any problem into an interactive visualization like this one — powered by AI, generated in seconds. Free to try, no credit card required.

Sign Up Free to Try It30 free visualizations every day
Difference of Squares & Sum/Difference of Cubes | MathSpin