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. The same cancellation happens for any two terms aa and bb in place of xx and 22, which gives two general identities, one for each sign:

a3+b3=(a+b)(a2−ab+b2),a3−b3=(a−b)(a2+ab+b2).\begin{aligned} a^3 + b^3 &= (a + b)(a^2 - ab + b^2), \\ a^3 - b^3 &= (a - b)(a^2 + ab + b^2). \end{aligned}

Expanding the products proves both identities for all real aa and bb.

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

First use a=3a=3 and b=2b=2. The product has two pairs of opposite middle terms:

(3+2)(9−6+4)=27−18+12+18−12+8=27+8=35.\begin{aligned} &(3+2)(9-6+4)\\ &\quad=27-18+12+18-12+8\\ &\quad=27+8=35. \end{aligned}

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.\begin{aligned} &(a + b)(a^2 - ab + b^2) \\ &\quad= a^3 - a^2 b + a b^2 \\ &\qquad {}+ a^2 b - a b^2 + b^3. \end{aligned}

As in the example with 33 and 22, 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, so they cancel for every aa and bb:

a3+(−a2b+a2b)+(ab2−ab2)+b3=a3+0+0+b3=a3+b3.\begin{aligned} &a^3 + (-a^2b + a^2b) \\ &\quad {}+ (ab^2 - ab^2) + b^3 \\ &= a^3 + 0 + 0 + b^3 = a^3 + b^3. \end{aligned}

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.\begin{aligned} &(a - b)(a^2 + ab + b^2) \\ &\quad= a^3 + a^2 b + a b^2 \\ &\qquad {}- a^2 b - a b^2 - b^3 \\ &\quad= a^3 - b^3. \end{aligned}

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

The next section shows how that cancellation and the last cube fix every sign in the two identities.

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:

The binomial’s sign gives the correct last cube, and the opposite middle sign makes the cross terms cancel. The last sign must be plus so that +ab2+ab^2 cancels −ab2-ab^2; changing it would leave unwanted middle terms. “Positive” names that plus sign; the value b2b^2 can be zero when b=0b=0.

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

Use one abab, not 2ab2ab, in the trinomial. The doubled product belongs to the different pattern (a+b)2=a2+2ab+b2(a + b)^2 = a^2 + 2ab + b^2.

Recognizing perfect cubes

For integer-coefficient factoring, a perfect cube is the cube of an integer or an integer-coefficient term, such as 2x2x. Look for those cubes in the expression. Here are the cubes of the whole numbers from 11 through 1010:

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}

A monomial is a single term, such as 8x38x^3, with whole-number variable exponents. It is a cube of another integer-coefficient monomial when its coefficient is an integer cube and every variable exponent is a multiple of 33. Cubing multiplies each exponent by 33. For example, 8x3=(2x)38x^3 = (2x)^3, 27x3=(3x)327x^3 = (3x)^3, and 64x3=(4x)364x^3 = (4x)^3. But 8x28x^2 does not qualify: its exponent 22 is not a multiple of 33.

The examples below use exponent 33, so the cube roots are terms like xx or 2x2x. Keep the coefficient with the variable: the cube root of 8x38x^3 is 2x2x, not 8x8x.

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

The pattern works just as well when the terms carry coefficients. Take the cube root of each term, coefficient and all, to get aa and bb, and use SOAP to 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 pattern works the same way with the number first:

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 has a plus sign. Its value is zero when x=0x=0.

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. Can that trinomial be factored too? 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.

We can also check why this quadratic has no real linear factors. Expanding a square gives

4(x2+4x+16)=(2x+4)2+48.4(x^2+4x+16)=(2x+4)^2+48.

The square is nonnegative, so the right side is positive for every real xx. Thus the quadratic cannot be zero, whereas a real linear factor would provide a zero. This uses the square pattern from Squares of Binomials to check the whole expression.

The same check works when the constant appears first. For the factor 9+3x+x29+3x+x^2, reorder the terms:

4(x2+3x+9)=(2x+3)2+27>0.4(x^2+3x+9)=(2x+3)^2+27>0.

Both checks use a square plus a positive constant. Here is why that works in general:

4(a2+ab+b2)=(2a+b)2+3b2,4(a2−ab+b2)=(2a−b)2+3b2.\begin{aligned} 4(a^2+ab+b^2)&=(2a+b)^2+3b^2, \\ 4(a^2-ab+b^2)&=(2a-b)^2+3b^2. \end{aligned}

Expand either square using the pattern from Squares of Binomials, then add 3b23b^2. The result is four times the trinomial on the left. If aa is a nonzero multiple of xx and bb is a nonzero constant, 3b23b^2 is a positive constant. Adding a square keeps the result positive, so the trinomial cannot have a real linear factor.

If the constant comes first, swap the names aa and bb. This does not change a2+ab+b2a^2+ab+b^2 or a2−ab+b2a^2-ab+b^2, so the same reasoning applies. These are the cases used in the worked examples. Remove any numerical common factor too. Other expressions substituted for aa and bb may have further factors; the stopping rule above is for a nonzero constant paired with a nonzero multiple of xx.

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

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

Neither 54x354x^3 nor 1616 is a perfect cube, but both are 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).

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. Factoring explains both of these misses.

Look at sixty-three, which is 26−12^6 - 1. Rewrite 262^6 as 434^3 and the 11 as 131^3, and you have a difference of cubes. The identity from this lesson gives the factor 4−14 - 1. So sixty-three is three times twenty-one. The same move rules out exponents divisible by three and greater than three: write the exponent as 3k3k, so 23k−1=(2k)3−12^{3k}-1=(2^k)^3-1 has the factor 2k−1>12^k-1>1 when k>1k>1. The exponent 33 itself gives 77, which is prime. Related factoring identities rule out other composite exponents.

Marin Mersenne, a French friar whose correspondence connected many mathematicians and their problems, published a list in 16441644 of exponents he believed produced primes of this form. Every exponent on his list was prime, but that was not enough to make every resulting number prime. The list contained errors, and the full range he considered was not settled until 19471947, more than three centuries later.

The numbers 2p−12^p-1 with prime pp are candidates; those that are themselves prime are called Mersenne primes. This article extract on Mersenne’s list shows how much work remained even after composite exponents were ruled out.

Your progress

See all your progress →