The difference of two squares is the most recognizable special product in algebra: whenever one perfect square is subtracted from another, the expression factors into a sum times a difference. This calculator factors expressions such as 9x² − 25y² or x⁸ − 1 completely, and it can also evaluate a² − b² for two numbers the quick way.
How to use the difference of two squares calculator
- Choose Factor an expression or Evaluate a² − b².
- To factor, describe the first term by its coefficient and the powers of x and y, then describe the term being subtracted the same way. For 9x² − 25y², enter A = 9 with x power 2, and B = 25 with y power 2.
- To evaluate, type the two numbers a and b.
- The factored form appears on the tape, and the steps show the common factor, each square root and any repeated factoring.
The difference of two squares formula
You can confirm it with FOIL: (a + b)(a − b) = a² − ab + ab − b², and the two middle terms cancel. A term counts as a perfect square when its coefficient is a perfect square (1, 4, 9, 16, 25, … or a fraction like 1/4) and every variable has an even exponent, because (3x²y)² = 9x⁴y².
Worked example
Factor 9x² − 25y².
Recognize the squares: 9x² = (3x)² and 25y² = (5y)².
Apply the pattern with a = 3x and b = 5y: (3x − 5y)(3x + 5y).
Check: (3x − 5y)(3x + 5y) = 9x² + 15xy − 15xy − 25y² = 9x² − 25y². ✓
Factoring completely
Sometimes a factor is itself a difference of squares, and you keep going:
x⁴ − 16 = (x² − 4)(x² + 4) = (x − 2)(x + 2)(x² + 4)
x⁸ − 1 = (x⁴ − 1)(x⁴ + 1) = (x² − 1)(x² + 1)(x⁴ + 1) = (x − 1)(x + 1)(x² + 1)(x⁴ + 1)
The sum factors such as x² + 4 stop the process because a sum of two squares cannot be factored over the real numbers.
Take out the common factor first
2x² − 18 does not look like a difference of squares, since 2 and 18 are not perfect squares. Pull out the greatest common factor 2 and the pattern appears: 2(x² − 9) = 2(x − 3)(x + 3). Likewise 3x³ − 12x = 3x(x² − 4) = 3x(x − 2)(x + 2). The calculator always checks for a common factor before anything else.
Using the identity with numbers
Read backwards, the formula turns subtraction of squares into one multiplication: 47² − 43² = (47 + 43)(47 − 43) = 90 × 4 = 360, far easier than 2,209 − 1,849. Read forwards, it turns awkward products into squares. To find 52 × 48, write it as (50 + 2)(50 − 2) = 2,500 − 4 = 2,496. The same idea explains why consecutive perfect squares differ by odd numbers: (n + 1)² − n² = (n + 1 + n)(1) = 2n + 1.
Where it shows up
- Simplifying fractions: (x² − 9)/(x − 3) reduces to x + 3 once the numerator is factored.
- Rationalizing denominators: multiplying 1/(√5 − 2) by (√5 + 2)/(√5 + 2) turns the denominator into 5 − 4 = 1.
- Solving equations: x² − 49 = 0 becomes (x − 7)(x + 7) = 0, so x = 7 or x = −7.
For other binomial products use the FOIL calculator, and to check which numbers are perfect squares see the list of perfect squares.
Frequently asked questions
What is the difference of two squares formula?
a² − b² = (a + b)(a − b). Any expression made of one perfect square minus another perfect square splits into the sum of their square roots times the difference of their square roots.
Can a sum of two squares be factored?
Not with real numbers. An expression like x² + 9 has no real factors, which is why factoring stops at terms such as (x² + 4). Over the complex numbers it factors as (x + 3i)(x − 3i).
What if the coefficients are not perfect squares?
Then the expression does not factor with integer coefficients. It can still be written with square roots, for example 2x² − 5 = (√2x − √5)(√2x + √5), and the calculator shows that version too.
How does this help with mental math?
Products of two numbers equally spaced around a round number become easy: 47 × 43 = (45 + 2)(45 − 2) = 45² − 2² = 2,025 − 4 = 2,021. The Evaluate mode applies the identity in the other direction.