Difference of Cubes

Difference of Cubes is a factoring pattern that breaks down any cubic binomial subtraction into a linear and a quadratic factor.

a3b3=(ab)(a2+ab+b2)a^3 - b^3 = (a - b)(a^2 + ab + b^2)

Solve a problem with Difference of Cubes

Type the problem. The solver will use Difference of Cubes where Difference of Cubes is the right tool, and tell you when it is not.

Drag one in or paste from the clipboard. JPEG, PNG or WebP. You get the transcription to check before anything is solved.

How to get a better answer
  • Paste the whole problem, including the instruction word — "simplify", "solve for x" and "factor" lead to three different answers.
  • Say what you have already tried. "I got x = 4 and the book says 2" turns a solution into a diagnosis.
  • Set the level in the settings button. A calculus shortcut is not a better answer if you have not met derivatives yet.
  • For a photo, get the whole problem in frame and hold the page flat — you get the transcription to fix before anything is solved.

What each symbol means

What Difference of Cubes takes
aa
bb
Difference of Cubes
SymbolMeaning
aaThe first number or expression being cubed; it can be any real number or variable, and confusing it with bb will lead to an incorrect factorization.
bbThe number or expression being subtracted after being cubed; it represents what you're subtracting, and swapping it with aa changes the sign of the first factor from (ab)(a - b) to (ba)(b - a).

When to use it

Reach for Difference of Cubes when you need to factor an expression where one cubic term is subtracted from another.

Level

Usually taught in: Algebra II

Worked examples

1. Factor a simple cubic binomial with small integers

Problem

Factor x38x^3 - 8.
  1. x38=x323x^3 - 8 = x^3 - 2^3

    Identify each term as a perfect cube; 8=238 = 2^3, so we have a=xa = x and b=2b = 2.

  2. (ab)(a2+ab+b2)=(x2)(x2+x2+22)(a - b)(a^2 + ab + b^2) = (x - 2)(x^2 + x \cdot 2 + 2^2)

    Substitute a=xa = x and b=2b = 2 into the Difference of Cubes formula.

  3. (x2)(x2+2x+4)(x - 2)(x^2 + 2x + 4)

    Evaluate 22=42^2 = 4 and simplify x2=2xx \cdot 2 = 2x to get the final factorization.

Answer: (x2)(x2+2x+4)(x - 2)(x^2 + 2x + 4)

This problem uses the Difference of Cubes formula because we have two perfect cubes being subtracted. The pattern fits directly: x323x^3 - 2^3 factors into a linear term (x2)(x - 2) and a quadratic term (x2+2x+4)(x^2 + 2x + 4).

2. Factor a cubic binomial with composite variables

Problem

Factor 1000x3y31000 - x^3y^3.
  1. 1000x3y3=103(xy)31000 - x^3y^3 = 10^3 - (xy)^3

    Identify 1000=1031000 = 10^3 and x3y3=(xy)3x^3y^3 = (xy)^3, so this is a difference of cubes with a=10a = 10 and b=xyb = xy.

  2. (10xy)(102+10xy+(xy)2)(10 - xy)(10^2 + 10 \cdot xy + (xy)^2)

    Substitute a=10a = 10 and b=xyb = xy into the Difference of Cubes formula.

  3. (10xy)(100+10xy+x2y2)(10 - xy)(100 + 10xy + x^2y^2)

    Evaluate 102=10010^2 = 100 and (xy)2=x2y2(xy)^2 = x^2y^2; the middle term is 10xy=10xy10 \cdot xy = 10xy.

Answer: (10xy)(100+10xy+x2y2)(10 - xy)(100 + 10xy + x^2y^2)

This example requires more care because the second cubic term contains multiple variables. Recognizing that x3y3=(xy)3x^3y^3 = (xy)^3 allows us to apply the formula correctly; the key insight is treating xyxy as a single unit for the purpose of the formula.

3. Factor a cubic binomial in a road-trip cargo problem

Problem

A delivery truck travels a route with two legs. The first leg of the journey requires a cargo volume of (3x)3(3x)^3 cubic feet (where xx is a distance-based scaling factor), and the second leg requires only 88 cubic feet of cargo space. To calculate the difference in cargo volume needs, factor the expression (3x)38(3x)^3 - 8.
  1. (3x)38=(3x)323(3x)^3 - 8 = (3x)^3 - 2^3

    Identify 8=238 = 2^3, so this is a Difference of Cubes with a=3xa = 3x and b=2b = 2.

  2. (3x2)((3x)2+3x2+22)(3x - 2)((3x)^2 + 3x \cdot 2 + 2^2)

    Substitute a=3xa = 3x and b=2b = 2 into the Difference of Cubes formula.

  3. (3x2)(9x2+6x+4)(3x - 2)(9x^2 + 6x + 4)

    Evaluate (3x)2=9x2(3x)^2 = 9x^2, 3x2=6x3x \cdot 2 = 6x, and 22=42^2 = 4 to get the completely factored form.

Answer: (3x2)(9x2+6x+4)(3x - 2)(9x^2 + 6x + 4)

This real-world scenario shows how Difference of Cubes applies when coefficients and variables appear in the cubic term. The factored form (3x2)(9x2+6x+4)(3x - 2)(9x^2 + 6x + 4) represents the decomposition of the cargo volume difference in a simplified way that could be useful for further calculations or analysis.

Common mistakes

Where Difference of Cubes usually goes wrong
Answer came out wrong
Writing x327=(x3)(x26x+9)x^3 - 27 = (x - 3)(x^2 - 6x + 9) by using subtraction in the quadratic instead of addition.
The correct factorization is (x3)(x2+3x+9)(x - 3)(x^2 + 3x + 9) — use addition (abab) in the quadratic, not subtraction (ab-ab).
Writing x38=(x2)x^3 - 8 = (x - 2) and stopping, thinking the factorization is complete.
The complete factorization must be (x2)(x2+2x+4)(x - 2)(x^2 + 2x + 4); the quadratic factor cannot be ignored or simplified away.
Factoring x38x^3 - 8 using the Sum of Cubes pattern and writing (x2)(x22x+4)(x - 2)(x^2 - 2x + 4) with negative signs instead of positive.
For Difference of Cubes, use (ab)(a2+ab+b2)(a - b)(a^2 + ab + b^2) with positive signs in the quadratic factor: (x2)(x2+2x+4)(x - 2)(x^2 + 2x + 4).
The mistakeWhy it is wrongThe fix
Writing x327=(x3)(x26x+9)x^3 - 27 = (x - 3)(x^2 - 6x + 9) by using subtraction in the quadratic instead of addition.The middle term in the quadratic factor must always be abab with the same sign as in the formula, not ab-ab. This mistake often comes from confusing Difference of Cubes with (ab)3(a - b)^3 or misremembering the formula.The correct factorization is (x3)(x2+3x+9)(x - 3)(x^2 + 3x + 9) — use addition (abab) in the quadratic, not subtraction (ab-ab).
Writing x38=(x2)x^3 - 8 = (x - 2) and stopping, thinking the factorization is complete.The Difference of Cubes formula always produces two factors: a linear factor (ab)(a - b) and a quadratic factor (a2+ab+b2)(a^2 + ab + b^2). Omitting either factor leaves the expression incomplete.The complete factorization must be (x2)(x2+2x+4)(x - 2)(x^2 + 2x + 4); the quadratic factor cannot be ignored or simplified away.
Factoring x38x^3 - 8 using the Sum of Cubes pattern and writing (x2)(x22x+4)(x - 2)(x^2 - 2x + 4) with negative signs instead of positive.The Sum of Cubes formula a3+b3=(a+b)(a2ab+b2)a^3 + b^3 = (a + b)(a^2 - ab + b^2) is different from Difference of Cubes; using the wrong formula produces an incorrect middle term ab-ab instead of abab.For Difference of Cubes, use (ab)(a2+ab+b2)(a - b)(a^2 + ab + b^2) with positive signs in the quadratic factor: (x2)(x2+2x+4)(x - 2)(x^2 + 2x + 4).

Tips and when to use something else

  • The quadratic factor a2+ab+b2a^2 + ab + b^2 never factors further over the real numbers (its discriminant is negative), so you can always stop once you apply the formula.
  • You can check your answer by expanding the factored form using FOIL or distribution; if you get back the original expression, you factored correctly.
  • When you see a3b3a^3 - b^3, think Difference of Cubes immediately; but if you see a3+b3a^3 + b^3 instead, switch to the Sum of Cubes formula (a+b)(a2ab+b2)(a + b)(a^2 - ab + b^2) — the signs in the second factor change.
  • Don't forget to look for a Greatest Common Factor first — if your cubic binomial has one, factor it out before applying the Difference of Cubes formula.

Frequently asked questions

When do I use Difference of Cubes vs. Sum of Cubes?
Use Difference of Cubes (a3b3a^3 - b^3) when you have one cubic term being subtracted from another. Use Sum of Cubes (a3+b3a^3 + b^3) when the cubic terms are being added. The factorization formulas are different: Difference of Cubes uses (ab)(a2+ab+b2)(a - b)(a^2 + ab + b^2), while Sum of Cubes uses (a+b)(a2ab+b2)(a + b)(a^2 - ab + b^2).
Can the quadratic factor from Difference of Cubes be factored further?
No, the quadratic a2+ab+b2a^2 + ab + b^2 cannot be factored further over the real numbers. Its discriminant is negative, meaning it has no real roots and cannot be written as a product of two linear factors with real coefficients.
What if my expression has a negative sign first, like 8+x3-8 + x^3?
Rearrange to standard form by moving the positive cubic term first: x38x^3 - 8. Then apply the Difference of Cubes formula as usual to get (x2)(x2+2x+4)(x - 2)(x^2 + 2x + 4).
Why does the middle term in the quadratic factor use addition, not subtraction?
The formula a3b3=(ab)(a2+ab+b2)a^3 - b^3 = (a - b)(a^2 + ab + b^2) always has the middle term as +ab+ab because that's what arises when you expand (ab)(a2+ab+b2)(a - b)(a^2 + ab + b^2) step by step. If you used subtraction (ab-ab), the expansion would not equal a3b3a^3 - b^3.

Need a different method?

The full solver is not scoped to one formula — type any problem and it will pick the method.

Open the math solver

Reviewed 2026-09-18