Polynomials & Factoring

How to Factor the Difference of Squares

A difference of squares factors as a2−b2=(a+b)(a−b)a^2-b^2=(a+b)(a-b). Take the square root of each term, then write one bracket with a plus and one with a minus.

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

This is one of the special products of binomials, and it is the fastest factoring pattern in algebra because it needs no guessing. The pattern is picky, though: it needs two perfect squares and a subtraction sign, and most lost points come from disguised versions or from forcing the pattern onto a sum.

Why does the difference of squares formula work?

L-shaped area a squared minus b squared rearranged into an a plus b by a minus b rectangle
With a = 5 and b = 2, the L-shape of area 25 − 4 slides into a 7 by 3 rectangle.

Multiply the two brackets with the FOIL method and watch the middle:

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

The two middle terms are opposites, so they cancel. That cancellation is the entire mechanism. Factoring is just this multiplication read backward, and the brackets (a+b)(a+b) and (a−b)(a-b) are called conjugates because they differ only in one sign.

There is also a picture. Start with a square of side aa and cut a smaller square of side bb out of one corner. The leftover L-shape has area a2−b2a^2-b^2. Slice the L into two strips, one measuring aa by (a−b)(a-b) and the other measuring bb by (a−b)(a-b), and slide them together. They form a rectangle with length a+ba+b and width a−ba-b, and the area is the same. The algebra is area bookkeeping.

Quick check

Expand (7y+2)(7y−2)(7y+2)(7y-2).

How do you factor a difference of squares step by step?

The method is short, and the order matters more than it looks.

  1. Pull out any common factor first.
  2. Confirm there are exactly two terms with a minus sign between them.
  3. Check that each term is a perfect square: a square coefficient and only even exponents.
  4. Take the square root of each term to get aa and bb, then write (a+b)(a−b)(a+b)(a-b).
  5. Ask whether either bracket factors again.

Example 1. Factor 36x6−25y236x^6-25y^2. Rewrite each term as a square by halving the exponents and taking square roots of the coefficients:

36x6−25y2=(6x3)2−(5y)2.36x^6-25y^2=(6x^3)^2-(5y)^2.

So a=6x3a=6x^3 and b=5yb=5y, which gives

36x6−25y2=(6x3+5y)(6x3−5y).36x^6-25y^2=(6x^3+5y)(6x^3-5y).

Quick recognition test

A term is a perfect square when its coefficient is a square (1, 4, 9, 16, 25, 36, 49, 64, 81, 100) and every exponent is even. So x6x^6 and 49y249y^2 qualify, but x5x^5 and 48x248x^2 do not.

A difference of squares is really a trinomial with a zero middle term: x2−9=x2+0x−9x^2-9=x^2+0x-9. Factoring trinomials asks for two numbers with product −9-9 and sum 00, which gives 33 and −3-3. That explains why the brackets differ only in sign: the only way to get a zero sum is to use opposites.

Difference of squares with negatives, fractions and hidden squares

When the square comes second and the subtraction is hidden, reorder the terms. For −x2+16-x^2+16, rewrite it as 16−x216-x^2, which is 42−x24^2-x^2, so

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

Pulling out −1-1 instead gives −(x+4)(x−4)-(x+4)(x-4). Both answers are correct because 4−x=−(x−4)4-x=-(x-4). The slip to avoid is writing (x+4)(x−4)(x+4)(x-4) and dropping the minus sign, which gives x2−16x^2-16, the opposite of what was asked.

Fractions follow the same rule, because a fraction is a square when its numerator and denominator are both squares:

x29−425=(x3)2−(25)2=(x3+25)(x3−25).\frac{x^2}{9}-\frac{4}{25}=\left(\frac{x}{3}\right)^2-\left(\frac{2}{5}\right)^2=\left(\frac{x}{3}+\frac{2}{5}\right)\left(\frac{x}{3}-\frac{2}{5}\right).

The sneakiest case is a whole expression acting as one of the squares.

Example 2. Factor (x+1)2−9(x+1)^2-9. Here a=x+1a=x+1 and b=3b=3, so

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

Check by expanding both sides. The original is x2+2x+1−9=x2+2x−8x^2+2x+1-9=x^2+2x-8, and (x+4)(x−2)=x2−2x+4x−8=x2+2x−8(x+4)(x-2)=x^2-2x+4x-8=x^2+2x-8. They match. The trap is to expand first and then hunt for a pattern; keeping the bracket intact is faster and safer.

How to factor a difference of squares completely

Step cards factoring 3x⁴ − 48 completely, stopping at the unfactorable sum x² + 4
3x⁴ − 48 splits twice, and the sum x² + 4 is where it stops.

Most problems that lose points here are not wrong, just unfinished. Two habits fix that: take out the GCF first, and re-inspect every bracket afterward. A common factor can hide the pattern entirely, as in 50x2−18=2(25x2−9)=2(5x+3)(5x−3)50x^2-18=2(25x^2-9)=2(5x+3)(5x-3), so factoring out the GCF always comes first.

Example 3. Factor completely: 3x4−483x^4-48.

3x4−48=3(x4−16)3x^4-48=3(x^4-16)

Now x4−16=(x2)2−42x^4-16=(x^2)^2-4^2, so

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

The second bracket is itself a difference of squares, x2−22x^2-2^2, so

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

The bracket x2+4x^2+4 is a sum and stays. To verify, (x+2)(x−2)=x2−4(x+2)(x-2)=x^2-4, then (x2+4)(x2−4)=x4−16(x^2+4)(x^2-4)=x^4-16, and multiplying by 3 returns 3x4−483x^4-48.

The pattern also surfaces after factoring by grouping. Take x3+2x2−9x−18x^3+2x^2-9x-18. Group it as x2(x+2)−9(x+2)x^2(x+2)-9(x+2), which equals (x+2)(x2−9)(x+2)(x^2-9), and the second bracket finishes as (x+3)(x−3)(x+3)(x-3). The full answer is (x+2)(x+3)(x−3)(x+2)(x+3)(x-3).

Why can’t you factor a sum of squares?

Try building x2+25x^2+25 from two real brackets. The product (x+5)(x+5)(x+5)(x+5) gives x2+10x+25x^2+10x+25, and (x+5)(x−5)(x+5)(x-5) gives x2−25x^2-25. A middle term either survives or cancels, and cancelling leaves a minus sign. No sign choice produces a plus.

A sharper argument uses roots. If x2+25x^2+25 had a real factor x−rx-r, then x=rx=r would make the expression zero. But x2+25x^2+25 is at least 2525 for every real xx, so it never touches zero. No real factor exists, which is why textbooks call it prime.

Expression Over the integers Over the reals Over the complex numbers
x2−9x^2-9 (x+3)(x−3)(x+3)(x-3) (x+3)(x−3)(x+3)(x-3) (x+3)(x−3)(x+3)(x-3)
x2−7x^2-7 prime (x+7)(x−7)(x+\sqrt{7})(x-\sqrt{7}) same as reals
x2+9x^2+9 prime prime (x+3i)(x−3i)(x+3i)(x-3i)

The table shows where the method fails and what “fails” means: it depends on which numbers you allow. In a typical Algebra 1 or 2 course, integers or reals are the default, so x2+9x^2+9 is the answer “prime” or “cannot be factored.”

The complex exception

Because i2=−1i^2=-1, a sum of squares does factor with imaginary numbers: a2+b2=(a+bi)(a−bi)a^2+b^2=(a+bi)(a-bi). Check: x2−25i2=x2+25x^2-25i^2=x^2+25.

One more wrinkle: a sum of squares with a common factor is still only partly factored until the factor is removed. Write 4x2+36=4(x2+9)4x^2+36=4(x^2+9), and stop there.

Quick check

Factor 4x2+254x^2+25 over the real numbers. If it cannot be factored, answer prime.

Difference of squares vs perfect square trinomial vs cubes

Three patterns look alike on a quick glance, and mixing them up is the classic error. A quick way to tell them apart:

  • x2−9x^2-9 has two terms and a minus sign: difference of squares, (x+3)(x−3)(x+3)(x-3).
  • x2−6x+9x^2-6x+9 has three terms with the middle equal to twice the product of the roots: a perfect square trinomial, (x−3)2(x-3)^2.
  • x3−27x^3-27 has two terms but cubes: a difference of cubes, covered in factoring sum and difference of cubes, (x−3)(x2+3x+9)(x-3)(x^2+3x+9).

Count the terms first, then check the exponents. The exponent test settles most confusion: even exponents suggest squares, multiples of 3 suggest cubes.

Some expressions are both. Consider x6−64x^6-64, which is (x3)2−82(x^3)^2-8^2 and also (x2)3−43(x^2)^3-4^3. Use squares first:

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

Starting with cubes gives (x2−4)(x4+4x2+16)(x^2-4)(x^4+4x^2+16), which hides further factoring, since x4+4x2+16=(x2+4)2−(2x)2=(x2+2x+4)(x2−2x+4)x^4+4x^2+16=(x^2+4)^2-(2x)^2=(x^2+2x+4)(x^2-2x+4). The squares-first route reaches the full answer with less work.

Using the difference of squares for mental math

The formula works on plain numbers whenever two factors sit equally far from a round midpoint. To compute 47×5347\times53, note that 47=50−347=50-3 and 53=50+353=50+3:

47×53=502−32=2500−9=2491.47\times53=50^2-3^2=2500-9=2491.

Try this: Compute 63×5763\times57 in your head by writing it as (60+3)(60−3)(60+3)(60-3). Then confirm with ordinary multiplication.

The same idea factors large numbers. Take 99919991, which sits just below 1002100^2. Since 9991=1002−329991=100^2-3^2, it equals (100−3)(100+3)=97×103(100-3)(100+3)=97\times103. This is Fermat’s factorization method, and it is why cryptographic systems avoid using two primes that are close together.

Differences of squares also reveal which whole numbers can be written that way. Every odd number 2k+12k+1 equals (k+1)2−k2(k+1)^2-k^2, and every multiple of four, 4k4k, equals (k+1)2−(k−1)2(k+1)^2-(k-1)^2. For example 15=82−7215=8^2-7^2 and 12=42−2212=4^2-2^2. Numbers leaving remainder 22 on division by 44, like 66 and 1010, can never be written this way, because the two factors (a+b)(a+b) and (a−b)(a-b) always have the same parity.

Where does the difference of squares show up in real problems?

The most common use is solving equations without the quadratic formula. For x2−9=0x^2-9=0, write (x+3)(x−3)=0(x+3)(x-3)=0, so x=3x=3 or x=−3x=-3. This links to the factor theorem: each root corresponds to a factor, and each factor to an xx-intercept on the graph. When a problem has this shape, factoring beats the heavy machinery in quadratic formula practice problems.

It also simplifies rational expressions. In

x2−9x2+x−6=(x+3)(x−3)(x+3)(x−2)=x−3x−2,\frac{x^2-9}{x^2+x-6}=\frac{(x+3)(x-3)}{(x+3)(x-2)}=\frac{x-3}{x-2},

the factor x+3x+3 cancels, with the restriction x≠−3x\neq-3 and x≠2x\neq2 kept from the original denominator.

Conjugates also remove roots from denominators. To rationalize 15−2\frac{1}{\sqrt{5}-2}, multiply the top and bottom by 5+2\sqrt{5}+2:

5+2(5)2−22=5+21=5+2.\frac{\sqrt{5}+2}{(\sqrt{5})^2-2^2}=\frac{\sqrt{5}+2}{1}=\sqrt{5}+2.

The same trick turns (3+2i)(3−2i)(3+2i)(3-2i) into the real number 9+4=139+4=13. In geometry, a washer with outer radius 55 and inner radius 33 has area π(52−32)=π(5+3)(5−3)=16π\pi(5^2-3^2)=\pi(5+3)(5-3)=16\pi.

Quick check

Multiply (7+3)(7−3)(\sqrt{7}+3)(\sqrt{7}-3).

How do you check a difference of squares factorization?

Multiply back. If the brackets are right, the middle terms cancel and you recover the original. If a middle term survives, the signs are wrong, which usually means both brackets carry the same sign.

A faster check substitutes a number. For 9x2−16=(3x+4)(3x−4)9x^2-16=(3x+4)(3x-4), try x=2x=2. The original gives 36−16=2036-16=20, and the factored form gives 10×2=2010\times2=20. Pick a value other than 00 or 11, since those can hide errors.

The most expensive habit to catch is writing (a−b)2(a-b)^2 when the answer is (a+b)(a−b)(a+b)(a-b). Squaring a difference gives a2−2ab+b2a^2-2ab+b^2, so (x−5)2=x2−10x+25(x-5)^2=x^2-10x+25, not x2−25x^2-25. If the original has no middle term, the factored form must have opposite signs. For more mixed problems, work through factoring practice problems and test each answer by multiplying back.

Practice problems

0 of 5 solved

  1. Factor x2−49x^2-49.

  2. Factor 16y2−8116y^2-81.

  3. Factor 25x2−36y425x^2-36y^4.

  4. Factor completely: 2x3−50x2x^3-50x.

  5. Factor completely: 81x4−1681x^4-16.

Common questions

What is the difference of squares formula?

It is a2−b2=(a+b)(a−b)a^2-b^2=(a+b)(a-b). Any expression made of one perfect square minus another perfect square factors into the sum of the square roots times the difference of the square roots.

Can you factor a sum of squares like x2+9x^2+9?

Not with real numbers. Over the complex numbers it factors as (x+3i)(x−3i)(x+3i)(x-3i), but in most algebra courses the answer for x2+9x^2+9 is simply prime.

Does (a−b)2(a-b)^2 equal a2−b2a^2-b^2?

No. Squaring a difference gives a2−2ab+b2a^2-2ab+b^2, which has a middle term. The difference of squares a2−b2a^2-b^2 has no middle term, because the cross terms cancel in (a+b)(a−b)(a+b)(a-b).

How do you factor x2−7x^2-7, where 7 is not a perfect square?

Over the integers it does not factor. Over the real numbers it does, because 7=(7)27=(\sqrt{7})^2, giving (x+7)(x−7)(x+\sqrt{7})(x-\sqrt{7}).

Do you take out the GCF before using the difference of squares?

Yes. A common factor often hides the pattern, as in 50x2−18=2(25x2−9)=2(5x+3)(5x−3)50x^2-18=2(25x^2-9)=2(5x+3)(5x-3). Pulling it out first also keeps the numbers small.

Which whole numbers can be written as a difference of two squares?

Every odd number and every multiple of 4 can. Numbers that leave a remainder of 2 when divided by 4, such as 6 and 10, never can.

Up next