Sum and Difference of Cubes

Learning goals

  • Factor a sum or difference of cubes into a binomial times a trinomial
  • Place the three signs correctly using the SOAP pattern
  • Explain why the middle terms must cancel to prove each identity
  • Pull out the greatest common factor before checking for a hidden cube pattern

Why a sum or difference of cubes factors

Try a specific case first: x3+8x^3 + 8. Since 8=238 = 2^3, both terms are perfect cubes, and the claim is that this factors as (x+2)(x2−2x+4)(x + 2)(x^2 - 2x + 4). Check that claim the way you check any proposed factoring, by expanding the product:

(x+2)(x2−2x+4)=x3−2x2+4x+2x2−4x+8.(x + 2)(x^2 - 2x + 4) = x^3 - 2x^2 + 4x + 2x^2 - 4x + 8.

The −2x2-2x^2 and +2x2+2x^2 cancel, and so do +4x+4x and −4x-4x, leaving x3+8x^3 + 8. Nothing about xx and 22 was special there; the same cancellation happens for any two terms aa and bb, which gives two general identities, one for each sign:

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

Each is a binomial times a trinomial, and neither asks to be taken on faith. The proof below confirms both in general, the same way you already confirmed the difference of squares: expand the right-hand side, multiplying every term of the binomial by every term of the trinomial, and see what survives.

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

Expand the product on the right, taking each term of a+ba + b against each term of a2−ab+b2a^2 - ab + b^2:

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

Just like the concrete case above, the two middle pairs, −a2b-a^2 b with +a2b+a^2 b and +ab2+a b^2 with −ab2-a b^2, are exact opposites and cancel, for every aa and bb, not just xx and 22:

a3−a2b+ab2+a2b−ab2+b3=a3+b3.a^3 - a^2 b + a b^2 + a^2 b - a b^2 + b^3 = a^3 + b^3.

Read right to left, that is the factoring rule for a sum of cubes. The difference identity works the same way:

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

The same two middle pairs cancel, only this time the surviving last term is −b3-b^3.

Nothing about that cancellation is arbitrary, and it is also what forces every sign in the two identities, which is the next thing to pin down.

The SOAP sign pattern

The two identities differ only in where the signs go, and there is a tidy way to remember the pattern. It is often called SOAP, for Same, Opposite, Always Positive, read across the three signs you have to fill in:

These are not three rules to accept blindly; the proof above forces all three. Same: the sign on bb decides whether the product ends in +b3+b^3 or −b3-b^3. Opposite: that sign on the middle term is exactly what makes the four cross terms cancel instead of piling up. Always Positive: that sign work all happens on the binomial’s bb, so the trinomial’s last term keeps a plain plus in both identities.

Check your understanding

In a3+b3=(a+b)(a2−ab+b2)a^3 + b^3 = (a + b)(a^2 - ab + b^2), why must the trinomial's middle term be −ab-ab and not +ab+ab?

Answer choices

One warning the pattern makes visible: the middle term is a single abab, not 2ab2ab. The doubled middle term belongs to a perfect-square trinomial like (a+b)2=a2+2ab+b2(a + b)^2 = a^2 + 2ab + b^2, which is a different animal. The cube trinomial never doubles it.

Recognizing perfect cubes

Before you can use either identity you have to see two perfect cubes. A perfect cube is a whole number, or a term with a whole-number coefficient, that is something cubed. The perfect cubes from 11 through 1010 are worth knowing on sight:

1=13,8=23,27=33,64=43,125=53,216=63,343=73,512=83,729=93,1000=103.\begin{aligned} 1 &= 1^3, &\qquad 8 &= 2^3, \\ 27 &= 3^3, &\qquad 64 &= 4^3, \\ 125 &= 5^3, &\qquad 216 &= 6^3, \\ 343 &= 7^3, &\qquad 512 &= 8^3, \\ 729 &= 9^3, &\qquad 1000 &= 10^3. \end{aligned}

Variable terms can be cubes too, but a term needs two things to qualify: its coefficient must be a perfect cube, and every variable’s exponent must be a multiple of 33 (since cubing multiplies an exponent by 33). A bare power like x3x^3 is (x)3(x)^3, and 8x3=(2x)38x^3 = (2x)^3, 27x3=(3x)327x^3 = (3x)^3, and 64x3=(4x)364x^3 = (4x)^3 all pass both tests. But 8x28x^2 is not a perfect cube, even though 88 is: the exponent 22 is not a multiple of 33. This lesson sticks to that plain case, exponent 33, so aa is always a single variable term like xx or 2x2x. To set up a factorization, take the cube root of each term to find aa and bb. The cube root of 8x38x^3 is 2x2x, not 8x8x, because you must cube both the 22 and the xx to rebuild 8x38x^3.

Worked example 1 Which expressions are sums or differences of cubes?

Ask two things of each expression: are both terms perfect cubes, and are they added or subtracted?

x3−27x^3 - 27 is a difference of cubes. Both terms are cubes, since x3=(x)3x^3 = (x)^3 and 27=3327 = 3^3, and they are subtracted, so a=xa = x and b=3b = 3.

8x3+18x^3 + 1 is a sum of cubes, since 8x3=(2x)38x^3 = (2x)^3 and 1=131 = 1^3. Here a=2xa = 2x and b=1b = 1.

x3+10x^3 + 10 is neither. The first term is a cube, but 1010 is not a perfect cube, since no whole number cubes to 1010.

x2−64x^2 - 64 is not a difference of cubes. The number 64=4364 = 4^3 is a cube, but x2x^2 is a square, not a cube, so the pattern does not apply. This one is a difference of squares instead.

Check your understanding

Which of these is a difference of two perfect cubes?

Answer choices

Factoring cubes that carry coefficients

Nothing in the pattern requires bare variables. Once you can take the cube root of each term, coefficient and all, you just read off aa and bb and let SOAP place the signs.

Worked example 2 Factor 8x3+278x^3 + 27

Take the cube root of each term. Since 8x3=(2x)38x^3 = (2x)^3, you have a=2xa = 2x, and since 27=3327 = 3^3, you have b=3b = 3. This is a sum, so the binomial keeps the same sign, (2x+3)(2x + 3), the trinomial’s middle term takes the opposite sign, and the last term is positive:

8x3+27=(2x)3+33=(2x+3)(4x2−6x+9).8x^3 + 27 = (2x)^3 + 3^3 = (2x + 3)(4x^2 - 6x + 9).

The trinomial terms are a2=(2x)2=4x2a^2 = (2x)^2 = 4x^2, then ab=(2x)(3)=6xab = (2x)(3) = 6x with a minus in front, then b2=32=9b^2 = 3^2 = 9. The middle term is 6x6x, a single abab, not 12x12x.

Worked example 3 Factor x3−64x^3 - 64 and 27−x327 - x^3

For x3−64x^3 - 64, the cube roots are xx and 643=4\sqrt[3]{64} = 4 (the small 33 marks a cube root instead of a square root, so 643\sqrt[3]{64} means the number that cubes to 6464), so a=xa = x and b=4b = 4. It is a difference, so the binomial is (x−4)(x - 4), the middle sign is opposite that minus (so plus), and the last term is positive:

x3−64=(x−4)(x2+4x+16).x^3 - 64 = (x - 4)(x^2 + 4x + 16).

For 27−x327 - x^3, read the terms in the order they appear as 33−x33^3 - x^3, a difference with a=3a = 3 and b=xb = x. The number comes first, and the pattern does not mind:

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

The binomial (3−x)(3 - x) matches the difference, the middle term +3x+3x is opposite that minus, and the last term x2x^2 is positive, exactly as SOAP predicts.

Check your understanding

Factor 8x3+18x^3 + 1.

Answer choices

Why the trinomial does not factor further

After you factor a sum or difference of cubes, you are left with a trinomial like x2+4x+16x^2 + 4x + 16 or x2−3x+9x^2 - 3x + 9. It is tempting to keep going and try to factor that trinomial as well; try it on x2+4x+16x^2 + 4x + 16 and see what happens.

To factor x2+4x+16x^2 + 4x + 16 into (x+p)(x+q)(x + p)(x + q) you would need two integers whose product is 1616 and whose sum is 44. Since both 1616 and 44 are positive, pp and qq must both be positive too (two negatives would multiply to a positive but add to a negative). The positive integer pairs that multiply to 1616 are 11 and 1616, 22 and 88, and 44 and 44, which sum to 1717, 1010, and 88. None of them sum to 44, so no such factoring exists.

That is the pattern for every sum or difference of cubes in this lesson: once you have removed any common factor and applied the cube identity, you have the final, complete factorization with integer coefficients.

Pulling out a common factor first

An expression that is not a sum or difference of cubes as written can turn into one after you factor out a common factor. So always check for a common factor first. Take 2x3+162x^3 + 16. Neither 2x32x^3 nor 1616 is a perfect cube, so the pattern does not apply yet. But both terms are even, and once you pull out the 22, what is left is a clean sum of cubes:

2x3+16=2(x3+8)=2(x+2)(x2−2x+4).2x^3 + 16 = 2(x^3 + 8) = 2(x + 2)(x^2 - 2x + 4).

The habit is to factor out the greatest common factor first, then check whether what remains is a sum or difference of cubes. Skip that step and you either miss the cubes entirely or leave the answer half done.

Worked example 4 Factor 3x4−24x3x^4 - 24x completely

Find the greatest common factor of 3x43x^4 and 24x24x first. They share a factor of 33 and a factor of xx, so the common factor is 3x3x:

3x4−24x=3x(x3−8).3x^4 - 24x = 3x(x^3 - 8).

What is left inside is x3−8=x3−23x^3 - 8 = x^3 - 2^3, a difference of cubes with a=xa = x and b=2b = 2:

x3−8=(x−2)(x2+2x+4).x^3 - 8 = (x - 2)(x^2 + 2x + 4).

Keeping the common factor out front, the complete factorization is

3x4−24x=3x(x−2)(x2+2x+4).3x^4 - 24x = 3x(x - 2)(x^2 + 2x + 4).

There was no cube to see until the 3x3x came out.

Worked example 5 Factor 54x3+1654x^3 + 16 completely

The terms 54x354x^3 and 1616 are both even, and their greatest common factor is 22:

54x3+16=2(27x3+8).54x^3 + 16 = 2(27x^3 + 8).

Now 27x3+8=(3x)3+2327x^3 + 8 = (3x)^3 + 2^3 is a sum of cubes with a=3xa = 3x and b=2b = 2:

27x3+8=(3x+2)(9x2−6x+4).27x^3 + 8 = (3x + 2)(9x^2 - 6x + 4).

So the complete factorization is

54x3+16=2(3x+2)(9x2−6x+4).54x^3 + 16 = 2(3x + 2)(9x^2 - 6x + 4).

Pulling out the 22 is what turned 54x3+1654x^3 + 16, which is not itself a sum of cubes, into one that is.

Check your understanding

Factor 2x3−1282x^3 - 128 completely.

Answer choices

Common mistakes

Practice

Multiple Choice Questions (MCQ)

Progressively harder sets of questions. Each opens on its own page.

Core practice

Practice problems at the level of the course, to be worked out on paper. Hints one at a time, then the answer or the full worked solution, with your progress kept in this browser.

Core practice Work it out on paper 10 problems Start →
More practice (optional)

Extra sets, as hard as the Challenge set. Each one opens on its own page.

More resources (optional)

Other explanations of this lesson, if you want a second take.

A bit of history (optional)

Numbers one below a power of two look like promising hunting ground for primes. Three is prime, and so is seven. Fifteen is not, though, and neither is sixty-three. Something is choosing the winners here, and it is not chance.

Look at sixty-three, which is 26−12^6 - 1. Rewrite 262^6 as 434^3 and the 11 as 131^3, and a difference of cubes is staring back at you. The identity from this lesson delivers the factor 4−14 - 1 at once. So sixty-three is three times twenty-one. The same move disposes of every exponent divisible by three, and a close relative handles every other exponent that is not prime.

Marin Mersenne, a friar who kept half the mathematicians of Europe writing to one another, put the fact to work. In 16441644 he published a list of the exponents he believed produced primes. Every entry on it was itself a prime. He never needed to test the others, because the factoring pattern had ruled them out in advance. His list turned out to contain errors, and settling the last of them took nearly three centuries.

These numbers still carry his name, and the largest prime anyone has ever found is one of them. Each new search still begins by discarding composite exponents, using this identity for the ones divisible by three and its close relatives for the rest.