Difference of Squares

Learning goals

  • Apply a2−b2=(a+b)(a−b)a^2 - b^2 = (a + b)(a - b)
  • Spot two perfect squares joined by a minus
  • Write squared terms like 9x29x^2 as (3x)2(3x)^2, coefficient and all
  • Factor again when a factor is itself a difference
  • Explain why the difference-of-squares rule does not apply to a sum

Why a difference of squares always factors

Try a specific case first. Multiply (x+3)(x−3)(x + 3)(x - 3) the way you multiply any two binomials:

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

The middle terms, −3x-3x and +3x+3x, are opposites, so they cancel, leaving x2−9x^2 - 9. Read that equation from right to left: the difference of squares x2−9x^2 - 9 breaks apart into (x+3)(x−3)(x + 3)(x - 3).

The same cancellation works for any real aa and bb. Expanding proves the general identity.

Why a2−b2=(a+b)(a−b)a^2 - b^2 = (a + b)(a - b)#

First watch the cancellation with numbers:

(5+2)(5−2)=25−10+10−4=25−4=21.\begin{aligned} (5+2)(5-2) &= 25-10+10-4 \\ &=25-4=21. \end{aligned}

Expand the proposed factorization the way you expand any product of two binomials, multiplying every term of the first factor by every term of the second:

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

Since ab=baab = ba, the middle products −ab-ab and +ba+ba cancel:

a2−ab+ba−b2=a2−b2.a^2 - ab + ba - b^2 = a^2 - b^2.

Read backward, this gives a2−b2=(a+b)(a−b)a^2 - b^2 = (a + b)(a - b). The opposite signs make the cancellation work. Using two plus signs instead would give (a+b)2(a + b)^2, including the extra 2ab2ab term.

For positive lengths with a>ba > b, the identity also has a picture. Start with a square of side aa, whose area is a2a^2, and cut a smaller square of side bb out of one corner, removing area b2b^2. What is left is an L-shaped region of area a2−b2a^2 - b^2. Slice that L into two rectangles, turn the upper one and slide it beside the lower one. They line up into a single rectangle with sides a+ba + b and a−ba - b. No area is created or lost in the move, so the leftover a2−b2a^2 - b^2 must equal the rectangle’s area (a+b)(a−b)(a + b)(a - b).

Area model for the difference of two squaresA square of side a has a square of side b cut from one corner. Cut the remaining L into two rectangles, turn the upper one and slide it beside the lower one. They form a rectangle of width a plus b and height a minus b, so the two areas are equal.aabba² − b²↓a + ba − b(a + b)(a − b)
For positive lengths a greater than b, remove the small square, then turn the upper strip and place it beside the lower strip. The resulting rectangle has sides a plus b and a minus b, with the same area.

Recognizing a difference of squares

For the integer-coefficient pattern here, use a three-part test: exactly two terms; each the square of a term with integer coefficients and whole-number exponents; and a minus sign between them. Examples of perfect-square terms are 9=329=3^2, x4=(x2)2x^4=(x^2)^2, and 9x2=(3x)29x^2=(3x)^2.

A sum such as x2+9x^2+9 does not fit this identity. It has no real linear factors: x2+9x^2+9 is always positive, whereas a product of real linear factors would be zero at a root of either factor. The same reason works for x2+kx^2+k when k>0k>0, because x2≥0x^2\ge0. Still check for a common factor: 4x2+4=4(x2+1)4x^2+4=4(x^2+1). A sum of squares can still factor in some other way, as this one does.

With two variables, consider x2+4y2x^2+4y^2. For instance, 12+4⋅22=171^2+4\cdot2^2=17. To get zero, both nonnegative terms must be zero, so the only point where this expression is zero is (0,0)(0,0). For example, x−2yx-2y is zero at (2,1)(2,1), but x2+4y2=4+4=8x^2+4y^2=4+4=8 there. So x−2yx-2y cannot be a factor. In fact, no real linear factor works. A real linear factor in xx and yy would be zero along a line in the coordinate plane, as in the graphing chapter. A product containing that factor would be zero on the whole line, not only at one point. So this quadratic cannot be a product of real linear factors. The same reasoning applies to x2+ky2x^2+ky^2 for any positive constant kk.

Worked example 1 Which expressions are differences of squares?

Here we are testing for the integer-coefficient pattern: two terms, both squares of integer-coefficient terms, joined by a minus sign.

x2−49x^2 - 49 qualifies. It has two terms, both are perfect squares since x2=(x)2x^2 = (x)^2 and 49=7249 = 7^2, and they are subtracted. The terms being squared are xx and 77.

9x2−49x^2 - 4 qualifies too. Here 9x2=(3x)29x^2 = (3x)^2 and 4=224 = 2^2, with a minus between them, so the terms being squared are 3x3x and 22.

x2+16x^2 + 16 fails. Both terms are perfect squares, but they are added, not subtracted. This is a sum of squares, and it does not factor over the real numbers.

x2−5x^2 - 5 fails as well. It does have a minus sign, but 55 is not a perfect square of a whole number, since 5\sqrt{5} is not a whole number. So the second term does not meet this lesson’s test.

Only the first two fit the integer-coefficient square pattern here. The identity is more general: x2−5=(x+5)(x−5)x^2 - 5 = (x + \sqrt{5})(x - \sqrt{5}), but those factors have irrational constants.

Check your understanding

Which expression fits the difference-of-squares pattern with integer-coefficient factors?

Answer choices

Factoring when the terms carry coefficients

Keep each coefficient with its variable. Since (3x)2=9x2(3x)^2 = 9x^2, the term being squared in 9x29x^2 is 3x3x, not 9x9x. This is the same whole-term squaring used in the previous lesson.

The routine is always the same. Find what the first term is the square of to get AA, find what the second term is the square of to get BB, and write (A+B)(A−B)(A + B)(A - B). Then expand it in your head as a check: the two outer squares should return and the middle terms should cancel.

Worked example 2 Factor 9x2−169x^2 - 16 and 25−4x225 - 4x^2

For 9x2−169x^2 - 16, find what each term is the square of. The first term is 9x2=(3x)29x^2 = (3x)^2, and 16=4\sqrt{16} = 4, so A=3xA = 3x and B=4B = 4:

9x2−16=(3x)2−42=(3x+4)(3x−4).9x^2 - 16 = (3x)^2 - 4^2 = (3x + 4)(3x - 4).

Check it by expanding: (3x+4)(3x−4)=9x2−12x+12x−16=9x2−16(3x + 4)(3x - 4) = 9x^2 - 12x + 12x - 16 = 9x^2 - 16, because the middle terms cancel.

For 25−4x225 - 4x^2, the number comes first this time and the variable term second, so AA is whatever squares to give the first term and BB is whatever squares to give the second: 25=5\sqrt{25} = 5 gives A=5A = 5, and 4x2=(2x)24x^2 = (2x)^2 gives B=2xB = 2x:

25−4x2=52−(2x)2=(5+2x)(5−2x).25 - 4x^2 = 5^2 - (2x)^2 = (5 + 2x)(5 - 2x).

Both factors carry the same two terms, once added and once subtracted.

Worked example 3 Factor 49x2−64y249x^2 - 64y^2

The method is the same with a second variable. Find what each term is the square of, keeping each coefficient with its variable: 49x2=(7x)249x^2 = (7x)^2 and 64y2=(8y)264y^2 = (8y)^2.

49x2−64y2=(7x)2−(8y)2=(7x+8y)(7x−8y).49x^2 - 64y^2 = (7x)^2 - (8y)^2 = (7x + 8y)(7x - 8y).

Each term being squared includes its coefficient. The check is the usual one: the cross terms −56xy-56xy and +56xy+56xy cancel, leaving 49x2−64y249x^2 - 64y^2.

Check your understanding

Factor 49x2−2549x^2 - 25.

Answer choices

Factoring more than once

For a complete factorization with integer coefficients, inspect every new factor. A fourth power often needs two passes: x4x^4 is the square of x2x^2, and one resulting factor may still be a difference of squares.

Worked example 4 Factor x4−1x^4 - 1 completely

Read x4−1x^4 - 1 as (x2)2−12(x^2)^2 - 1^2, a difference of squares with x2x^2 and 11 as the terms being squared:

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

Now inspect each factor. The second one, x2−1x^2 - 1, is again a difference of squares, (x)2−12(x)^2 - 1^2, so it factors further:

x2−1=(x+1)(x−1).x^2 - 1 = (x + 1)(x - 1).

The first factor, x2+1x^2 + 1, is x2x^2 plus a positive number, so it has no real linear factors and the work stops there. Assembling the pieces gives the complete factorization:

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

Stopping at (x2+1)(x2−1)(x^2 + 1)(x^2 - 1) would be an error, because x2−1x^2 - 1 still comes apart. After every pass, look at each new factor and ask whether it is a difference of squares.

Check your understanding

Factor x4−1296x^4 - 1296 completely.

Answer choices

Pulling out a common factor first

An expression can hide a difference of squares behind a common factor. Take 2x2−82x^2 - 8. Neither 2x22x^2 nor 88 is a perfect square, so at first glance the pattern does not apply. But the two terms share a factor of 22, and once you pull it out, what is left is a clean difference of squares:

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

The habit to build is to factor out the greatest common factor first, then check whether what remains fits a special pattern. Skip that step and you either miss the difference of squares entirely or leave the factoring half-done.

Worked example 5 Factor 3x3−12x3x^3 - 12x completely

First find the greatest common factor of 3x33x^3 and 12x12x. They share a factor of 33 and a factor of xx, so the common factor is 3x3x:

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

What is left inside is x2−4x^2 - 4, a difference of squares with xx and 22 as the terms being squared:

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

So the complete factorization keeps the common factor out front:

3x3−12x=3x(x+2)(x−2).3x^3 - 12x = 3x(x + 2)(x - 2).

Check your understanding

Factor 2x2−182x^2 - 18 completely.

Answer choices

Solving equations and a mental-math shortcut

The pattern also gives a quick way to solve some equations. To solve x2−9=0x^2 - 9 = 0, factor the left side and use the zero-product property, which says a product is zero only when one of its factors is zero:

x2−9=0  ⟹  (x+3)(x−3)=0  ⟹  x=−3  or  x=3.x^2 - 9 = 0 \implies (x + 3)(x - 3) = 0 \implies x = -3 \ \text{ or } \ x = 3.

The same reasoning handles a2−b2=0a^2 - b^2 = 0 in general. Factoring gives (a+b)(a−b)=0(a + b)(a - b) = 0, so either a+b=0a + b = 0 or a−b=0a - b = 0, which means a=−ba = -b or a=ba = b. A difference of squares is zero exactly when the two quantities are equal or are exact opposites.

The identity is also a real arithmetic shortcut. A product of two numbers that sit the same distance on either side of a round number is a difference of squares in disguise. To multiply 51×4951 \times 49, notice that 51=50+151 = 50 + 1 and 49=50−149 = 50 - 1, so the product is (50+1)(50−1)(50 + 1)(50 - 1):

51×49=502−12=2500−1=2499.51 \times 49 = 50^2 - 1^2 = 2500 - 1 = 2499.

You have replaced a two-digit multiplication with a square and a subtraction. The same move gives 43×37=402−32=1600−9=159143 \times 37 = 40^2 - 3^2 = 1600 - 9 = 1591. Later in this chapter you will use the same (a+b)(a−b)(a + b)(a - b) product to clear square roots out of a denominator.

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)

Suppose someone multiplies two large integers and hands you only their product. How could you recover the factors without testing every smaller divisor? Multiplying can be much easier than undoing the work.

Pierre de Fermat was a French lawyer who did mathematics in his spare time. In the sixteen hundreds he found a shortcut for a whole class of numbers. His plan was to write the target as one square minus another. Then this lesson’s identity gave him the factors, a sum times a difference.

For an odd positive target, start at the smallest integer at least as large as its square root. Square that integer and subtract the target. If the result is a square, the identity supplies the factors. Otherwise, try the next integer.

Try it on 59595959. Its square root is a little under 7878, and the first two tries do not give a square. At 8080 the leftover is 441441, which is 2121 squared. So the number is 5959 times 101101.

The method is quickest when the two factors are close. Later methods developed the same idea of finding squares whose difference reveals factors. The description of Fermat’s method shows that connection.

Your progress

See all your progress →