Difference of Two Squares Calculator

Factor a difference of two squares a² − b² into (a + b)(a − b). Enter the two square values to see the factored binomials and a step-by-step check.

Loading calculator…

The difference-of-squares identity

a2b2=(a+b)(ab)a^2 - b^2 = (a + b)(a - b)

Whenever you can write an expression as one perfect square minus another, it factors immediately into the sum of their roots times the difference of their roots. This calculator takes the two square values directly (e.g. 25 and 16, for 525^2 and 424^2), finds a=a2a=\sqrt{a^2} and b=b2b=\sqrt{b^2}, and shows the factored form.

Tip: This is exactly the reverse of FOIL: multiplying (a+b)(ab)(a+b)(a-b) back out gives a2ab+abb2a^2 - ab + ab - b^2, and the two middle terms always cancel, leaving a2b2a^2-b^2.

Worked example: two perfect squares

Factor 251625 - 16.

  1. Identify the squares: a=25=5a = \sqrt{25} = 5, b=16=4b = \sqrt{16} = 4.
  2. Apply the identity: a2b2=(a+b)(ab)a^2 - b^2 = (a+b)(a-b).
  3. Result: 2516=(5+4)(54)25 - 16 = (5+4)(5-4).
  4. Check: (5+4)(54)=9×1=9(5+4)(5-4) = 9 \times 1 = 9, which matches 2516=925-16=9.

Worked example: when a value isn't a perfect square

Factor 959 - 5.

  1. Identify the squares: a=9=3a = \sqrt{9} = 3 is a perfect square. b=5b = \sqrt{5} is not — 5 has no whole-number square root, so it stays under the radical.
  2. Apply the identity anyway: the identity a2b2=(a+b)(ab)a^2-b^2=(a+b)(a-b) holds for any real aa and bb, not just whole numbers.
  3. Result: 95=(3+5)(35)9 - 5 = (3+\sqrt{5})(3-\sqrt{5}).
  4. Check: (3+5)(35)=32(5)2=95=4(3+\sqrt{5})(3-\sqrt{5}) = 3^2 - (\sqrt{5})^2 = 9 - 5 = 4.

Quick reference

SquaresFactored form
251625 - 16(5+4)(54)(5+4)(5-4)
949 - 4(3+2)(32)(3+2)(3-2)
10036100 - 36(10+6)(106)(10+6)(10-6)
959 - 5(3+5)(35)(3+\sqrt{5})(3-\sqrt{5})

A mental-math shortcut

The identity turns an awkward subtraction into an easy multiplication. 43242243^2 - 42^2 is tedious to compute directly, but it factors as:

432422=(43+42)(4342)=85×1=8543^2 - 42^2 = (43+42)(43-42) = 85 \times 1 = 85

Any "square minus a nearby square" collapses to a sum times a small difference this way — a classic mental-arithmetic trick built entirely on this one identity.

Common mistakes

  • Assuming a sum of squares factors the same way. a2+b2a^2 + b^2 does not factor into real binomials — the cancellation that makes a2b2a^2-b^2 work only happens for a difference, never a sum.
  • Forgetting a common factor first. An expression like 4x2364x^2 - 36 has a GCF of 4 to pull out — 4(x29)=4(x+3)(x3)4(x^2-9) = 4(x+3)(x-3) — before the difference-of-squares pattern applies to what's left. This calculator factors the two square values you give it directly; pull out any shared factor yourself first.
  • Stopping too early. If the result still contains a difference of squares — like x41=(x2+1)(x21)x^4 - 1 = (x^2+1)(x^2-1) — the second factor factors again into (x+1)(x1)(x+1)(x-1).

The reverse of FOIL

FOIL expands two binomials into a polynomial; this calculator does the opposite for the special case where the expanded result is a pure difference of squares (no middle term). The FOIL calculator shows that forward direction — including the exact worked example (x+3)(x3)=x29(x+3)(x-3) = x^2-9 that this calculator reverses.

Setting a factored difference to zero

If a2b2=0a^2 - b^2 = 0, then (a+b)(ab)=0(a+b)(a-b)=0, so a=ba=b or a=ba=-b — the two roots of a very simple quadratic. The Quadratic Formula calculator solves the general case ax2+bx+c=0ax^2+bx+c=0, of which "difference of squares equals zero" is the special case with b=0b=0 in the quadratic's own coefficients.

Frequently asked questions

What is the difference of two squares?
It is the identity a2b2=(a+b)(ab)a^2 - b^2 = (a+b)(a-b): any expression that is one perfect square minus another perfect square factors into the sum of the two roots times their difference. It is the exact reverse of FOIL-ing (a+b)(ab)(a+b)(a-b) back out, since the middle terms ab-ab and +ab+ab cancel.
How do I find a and b from the two square values?
Take the square root of each value entered. For example, with 25 and 16, a=25=5a=\sqrt{25}=5 and b=16=4b=\sqrt{16}=4, so 2516=(5+4)(54)25-16=(5+4)(5-4).
What if one of the values is not a perfect square?
The identity still holds — aa or bb is just left as a radical instead of a whole number. For 959-5, a=9=3a=\sqrt{9}=3 is a perfect square but b=5b=\sqrt{5} is not, so it factors as (3+5)(35)(3+\sqrt{5})(3-\sqrt{5}), and multiplying that back out still gives exactly 95=49-5=4.
How is this the reverse of FOIL?
FOIL-ing (a+b)(ab)(a+b)(a-b) gives a2ab+abb2a^2 - ab + ab - b^2, and the two middle terms always cancel, leaving a2b2a^2-b^2. This calculator undoes that: starting from a2b2a^2-b^2, it recovers the two binomials (a+b)(a+b) and (ab)(a-b) that FOIL back out to it. See the [FOIL calculator](/en/calculators/algebra/foil) for that forward direction.
Can this pattern help with mental math?
Yes — 43242243^2 - 42^2 looks hard to compute directly, but it factors as (43+42)(4342)=85×1=85(43+42)(43-42) = 85 \times 1 = 85, which is easy to do in your head. Any "square minus a nearby square" reduces to a sum times a small difference this way.
Why doesn't a sum of two squares, a² + b², factor the same way?
A sum of two squares has no real-number factorization analogous to (a+b)(ab)(a+b)(a-b) — that identity relies on the middle terms canceling, which only happens for a *difference*. a2+b2a^2+b^2 stays irreducible over the real numbers (it does factor with complex numbers, but that is outside this calculator's scope).

Related calculators