This site is a work in progress. New lessons are added regularly. Contact us

Sum and Difference of Cubes

Learning goals

  • Apply a3+b3=(a+b)(a2ab+b2)a^3 + b^3 = (a + b)(a^2 - ab + b^2)
  • Place the signs with SOAP
  • Cube-root each term to find aa and bb
  • Note the single abab middle term, never 2ab2ab
  • Contrast a sum of cubes, which factors, with a sum of squares

Why a sum or difference of cubes factors

There are two identities to establish, one for each sign:

a3+b3=(a+b)(a2ab+b2),a3b3=(ab)(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. You can confirm both the same way you 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)(a2ab+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 a2ab+b2a^2 - ab + b^2:

(a+b)(a2ab+b2)=a3a2b+ab2+a2bab2+b3.(a + b)(a^2 - ab + b^2) = a^3 - a^2 b + a b^2 + a^2 b - a b^2 + b^3.

The first term is a3a^3 and the last is b3b^3. Look at the four terms in between. The pair a2b-a^2 b and +a2b+a^2 b are exact opposites and add to zero, and the pair +ab2+a b^2 and ab2-a b^2 are exact opposites and add to zero as well. All four vanish at once:

a3a2b+ab2+a2bab2+b3=a3+b3.a^3 - a^2 b + a b^2 + a^2 b - a b^2 + b^3 = a^3 + b^3.

Only the two cubes remain, so (a+b)(a2ab+b2)=a3+b3(a + b)(a^2 - ab + b^2) = a^3 + b^3 for every aa and bb. Read from right to left, that is the factoring rule for a sum of cubes.

The difference works by the same cancellation. Expand (ab)(a2+ab+b2)(a - b)(a^2 + ab + b^2) the same way:

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

Again the two middle pairs, +a2b+a^2 b with a2b-a^2 b and +ab2+a b^2 with ab2-a b^2, cancel, and this time the last term is b3-b^3, leaving a3b3a^3 - b^3. So (ab)(a2+ab+b2)=a3b3(a - b)(a^2 + ab + b^2) = a^3 - b^3, and the difference of cubes factors as well.

The whole mechanism is those four middle terms falling away in two matched pairs. Nothing about it is arbitrary, and in particular the signs are forced, 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 derivation above forces every one of them. Look back at the expansion of (a+b)(a2ab+b2)(a + b)(a^2 - ab + b^2). The final b3b^3 came from multiplying bb by the trinomial’s last term b2b^2. So the sign you put in front of the binomial’s bb is exactly what decides whether the result ends in +b3+b^3 or b3-b^3. That is the Same rule. The four middle terms cancelled only because the trinomial’s middle term carried the opposite sign from the binomial. Make both of those signs plus and the middle terms reinforce instead of cancelling, and no clean factorization survives. That is the Opposite rule. And the trinomial’s last term stayed +b2+b^2 in both cases, because b2b^2 is a square and all of the sign work is handled by the binomial. That is Always Positive.

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 number or term that is something cubed. The small perfect cubes are worth knowing on sight:

1=13,8=23,27=33,64=43,125=53,216=63,1000=103.1 = 1^3, \quad 8 = 2^3, \quad 27 = 3^3, \quad 64 = 4^3, \quad 125 = 5^3, \quad 216 = 6^3, \quad 1000 = 10^3.

Variable terms can be cubes too. A bare power like x3x^3 is (x)3(x)^3, and a term with a coefficient is a cube when the coefficient is a perfect cube: 8x3=(2x)38x^3 = (2x)^3, 27x3=(3x)327x^3 = (3x)^3, and 64x3=(4x)364x^3 = (4x)^3. 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?

x327x^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.

x264x^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)(4x26x+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 x364x^3 - 64 and 27x327 - x^3

For x364x^3 - 64, the cube roots are xx and 643=4\sqrt[3]{64} = 4, so a=xa = x and b=4b = 4. It is a difference, so the binomial is (x4)(x - 4), the middle sign is opposite that minus (so plus), and the last term is positive:

x364=(x4)(x2+4x+16).x^3 - 64 = (x - 4)(x^2 + 4x + 16).

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

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

The binomial (3x)(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 x23x+9x^2 - 3x + 9. It is tempting to keep going and try to factor that trinomial as well. Resist. For the cube pattern, that trinomial does not factor over the integers, and there is a concrete way to see why.

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. The 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.

The same happens every time: the cube trinomial has no integer factor pair. That the trinomial has no real factors at all is confirmed by tools in a later chapter. When a factorization reaches the binomial-times-trinomial stage, you are finished, unless a common factor was hiding in front.

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)(x22x+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 3x424x3x^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:

3x424x=3x(x38).3x^4 - 24x = 3x(x^3 - 8).

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

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

Keeping the common factor out front, the complete factorization is

3x424x=3x(x2)(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)(9x26x+4).27x^3 + 8 = (3x + 2)(9x^2 - 6x + 4).

So the complete factorization is

54x3+16=2(3x+2)(9x26x+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 2x31282x^3 - 128 completely.

Answer choices

Common mistakes

Practice

Multiple Choice Questions (MCQ)

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

Free Response Questions (FRQ)

Longer questions in parts, to be worked out on paper. Progressive hints, the answer on its own so you can check yourself and try again, then the full worked solution, plus a rubric to mark your own work against.

Free response Work it out on paper 5 questions 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 2612^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 414 - 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 the composite exponents. That step rests on nothing deeper than the identity you have just been using.