Algebra
Intermediate

Difference of Cubes

Factors the difference of two cubes.

Formula

a3−b3=(a−b)(a2+ab+b2)a^3 - b^3 = (a-b)(a^2 + ab + b^2)

Live Calculator

Members

Variables

a, bAny real numbers

Example

27 − 8 = 3³ − 2³ = (3−2)(9 + 6 + 4) = 1×19 = 19. ✓

How it works

The difference of cubes formula rewrites a subtraction of two perfect cubes into a product of a binomial and a quadratic. It works because multiplying (a-b)(a^2+ab+b^2) causes the middle terms to cancel, leaving exactly a^3-b^3. This is useful because factoring can simplify expressions, solve equations, and reveal hidden structure in algebraic problems.

When to use it

Use this when you see two terms that are both perfect cubes and they are being subtracted, such as x^3-8 or 64y^3-1. It is especially helpful in factoring polynomials, simplifying rational expressions, and solving cubic equations.

Worked example, step by step

Factor 125 - 8 125 - 8 = 5^3 - 2^3 = (5 - 2)(5^2 + 5·2 + 2^2) = (3)(25 + 10 + 4) = 3 × 39 = 117

Common mistakes to avoid

  • Using the same sign pattern as the square difference formula and writing (a-b)(a-b)(a+b)
  • Forgetting the middle term ab in the quadratic factor
  • Applying the formula to a sum of cubes instead of a difference of cubes

Did You Know?

Fermat's Last Theorem says a³ + b³ = c³ has no positive integer solutions — a claim that took 358 years to prove.

Share this formula

Reviewed & maintained by the FormulaWon editorial teamLast reviewed September 2026