Difference of Two Squares Calculator
Factor any a^2 - b^2 expression into (a+b)(a-b) with step-by-step work.
Supports symbolic (px+q)(px-q) factoring and graphs the resulting parabola.
Difference of Two Squares
The difference of two squares is a special factoring pattern in algebra. Any expression of the form a^2 - b^2 can always be factored as (a + b)(a - b).
The identity:
a^2 - b^2 = (a + b)(a - b)
This works because expanding (a+b)(a-b) gives a^2 - ab + ab - b^2 = a^2 - b^2. The middle terms cancel.
With polynomial terms: If a = px (a polynomial), then:
(px)^2 - q^2 = (px + q)(px - q)
Examples:
| Expression | Factored Form |
|---|---|
| x^2 - 9 | (x + 3)(x - 3) |
| 4x^2 - 25 | (2x + 5)(2x - 5) |
| 16 - x^2 | (4 + x)(4 - x) |
| 49x^2 - 1 | (7x + 1)(7x - 1) |
Roots: Setting (px)^2 - q^2 = 0 gives roots x = q/p and x = -q/p. Mind the brackets: it is (px)^2, meaning p^2 x^2, not px^2. Written as px^2 - q^2 the roots would be x = ±q/√p instead, which is a different equation entirely. The two roots are always symmetric about the y-axis, because the expression has no x term to shift it off centre.
The sign you give q does not matter. It gets squared, so q = 3 and q = -3 describe the same expression x^2 - 9 and factor identically.
When does this NOT apply?
- Sum of squares: a^2 + b^2 cannot be factored over real numbers
- Expression must be a perfect square minus a perfect square
- a^2 - b^3 is NOT a difference of two squares
Multi-step factoring: Sometimes you need to apply the pattern more than once. For example: x^4 - 16 = (x^2 + 4)(x^2 - 4) = (x^2 + 4)(x+2)(x-2)
Why it matters: This pattern appears in simplifying fractions, solving equations, and in mental math. For example, 99 × 101 = (100-1)(100+1) = 100^2 - 1^2 = 10000 - 1 = 9999.
How we build and check this calculator
This calculator runs entirely in your browser, so the numbers you enter stay on your device. The math behind it is written by hand and tested against worked examples and standard references before the page goes live.
SuperGlobalCalculator is independently built and maintained. See how we build and verify our calculators.