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
  • Leave a sum of squares unfactored once any common factor is removed

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

Nothing about 33 and xx was special. The claim is that the same cancellation happens for any aa and bb, so a2−b2a^2 - b^2 factors as (a+b)(a−b)(a + b)(a - b) in general. There is nothing to guess and nothing to memorize on faith, because you can check it directly. To confirm that the general factors really rebuild the general expression, multiply them out and see what survives.

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

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−a⋅b+b⋅a−b⋅b.(a + b)(a - b) = a\cdot a - a\cdot b + b\cdot a - b\cdot b.

The four products are a2a^2, then −ab-ab, then +ba+ba, then −b2-b^2. Now look hard at the two middle products. Because the order of multiplication does not matter, abab and baba are the same quantity, so −ab-ab and +ba+ba are exact opposites. They add to zero and disappear:

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

Only the two squares are left. So (a+b)(a−b)=a2−b2(a + b)(a - b) = a^2 - b^2 for every aa and bb. Read from right to left, that is the factoring rule: a difference of two squares splits into the sum of the roots times the difference of the roots. The cancellation of the middle terms is the entire mechanism, and it is also why a sum of squares behaves differently. Flip one sign, expand (a+b)(a+b)(a + b)(a + b) instead, and the two middle products become +ab+ab and +ba+ba, which reinforce rather than cancel.

The same fact 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 and slide them together, and 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. The remaining L-shaped region, of area a squared minus b squared, is cut into two rectangles that slide together to form a single 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)
Cutting a square of side b from the corner of a square of side a leaves an L of area a squared minus b squared. The L rearranges into a rectangle of sides a plus b and a minus b, so the two areas are equal.

Recognizing a difference of squares

Before you can use the pattern you have to spot it, and the test has three parts. The expression must have exactly two terms. Both terms must be perfect squares: in this course, that means each one can be written as some whole number, or some term built from whole numbers, squared. Each one may be a number like 9=329 = 3^2 or 25=5225 = 5^2, a variable power like x2=(x)2x^2 = (x)^2 or x4=(x2)2x^4 = (x^2)^2, or a whole term like 9x2=(3x)29x^2 = (3x)^2. And the two squares must be joined by a minus sign, one square subtracted from the other. When all three conditions hold, the expression is a difference of squares and factors as the sum times the difference of the two roots.

The minus sign is not a formality. A sum of two squares, like x2+9x^2 + 9, passes the first two conditions but fails the third. A sum like x2+9x^2 + 9 does not factor at all over the real numbers. That is not a hole in your method; there is genuinely no pair of real factors whose product is x2+9x^2 + 9. A later chapter, once numbers beyond the real line are on the table, comes back to this case. For now, once you have already pulled out any common factor, read a plus sign between the two remaining squares as a full stop and leave that part alone.

Worked example 1 Which expressions are differences of squares?

Run each one through the three-part test: two terms, both perfect squares, 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 roots 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 roots 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 are differences of squares.

Check your understanding

Which of these is a difference of squares?

Answer choices

Factoring when the terms carry coefficients

Nothing in the pattern requires the squares to be bare variables. A term like 9x29x^2 is a perfect square because 9x2=(3x)29x^2 = (3x)^2, so a difference such as 9x2−169x^2 - 16 factors exactly the way x2−16x^2 - 16 does. The one new skill is finding what each term is the square of, coefficient and all. The term 9x29x^2 is (3x)2(3x)^2, not (9x)2(9x)^2, because you have to square both the 33 and the xx to rebuild 9x29x^2.

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, with the middle terms canceling just as the pattern promises.

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 roots, once added and once subtracted.

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

A second variable changes nothing. 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 root captures its whole term. 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

Factoring is not finished until nothing that remains can be factored again. Sometimes one pass of the difference-of-squares rule leaves a factor that is itself a difference of squares, and then you apply the rule a second time. This comes up often with fourth powers, because x4=(x2)2x^4 = (x^2)^2 is a perfect square. After one factoring pass, a resulting factor built from x2x^2 can turn out to be a difference of squares in its own right.

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 roots x2x^2 and 11:

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 a sum of squares, so it does not factor over the real numbers 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 roots xx and 22:

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

Pulling out 3x3x first is what exposed the difference of squares. There was no square to see until the common factor was gone.

Check your understanding

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

Answer choices

Solving equations and a mental-math shortcut

The pattern turns certain equations into one-liners. 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. This pairing of a sum with a matching difference is worth holding onto for one more reason. The very same (a+b)(a−b)(a + b)(a - b) trick is what later lets you clear square roots out of a denominator when you simplify radical expressions.

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)

Ask someone to multiply two large numbers and tell you only the answer. Recovering the two numbers is far harder than the multiplication ever was. Testing every possible divisor works, but on a big enough number it outlasts a lifetime.

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. The moment he had that, this lesson’s identity handed him the factors. A difference of squares always splits into a sum times a difference.

The search itself is easy to describe. Start just above the square root of the target and climb one step at a time. At each stop, square the number you are standing on and subtract the target. If the leftover is a perfect square, you are finished.

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

The method is quickest when the two hidden factors sit near each other. Descendants of it still appear in factoring software today. That is a generous afterlife for a two-term identity you proved by canceling a single pair of middle terms.