Difference of Two Squares Calculator a²−b²
Type any expression like x^2-9, 4x^2-25 or x^4-16 and get the factorization (a−b)(a+b) with every step shown — plus an expand-back check that proves the answer.
Factor it
Worked examples
Example: x^2-9
- Step 1 — identify the squares: x^2 = (x)² and 9 = (3)².
- Step 2 — rewrite: x^2 − 9 = (x)² − (3)².
- Step 3 — apply the pattern a² − b² = (a−b)(a+b) with a = x, b = 3.
- Step 4 — verify by expanding back: (x − 3)(x + 3) = x^2 − 9 ✓ matches.
Example: 2x^2-8
- Step 0 — common factor: both terms share 2. Factor it out first:
- 2x^2 − 8 = 2(x^2 − 4)
- Step 1 — identify the squares: x^2 = (x)² and 4 = (2)².
- Step 2 — rewrite: x^2 − 4 = (x)² − (2)².
- Step 3 — apply the pattern a² − b² = (a−b)(a+b) with a = x, b = 2.
- Step 5 — verify by expanding back: 2(x − 2)(x + 2) = 2(x^2 − 4) ✓ matches.
Example: x^2+9
- Two terms, but BOTH have the same sign: x^2 + 9.
- This is a SUM of squares, not a difference. The pattern a² − b² = (a−b)(a+b) does not apply.
- Honest verdict: (x² + 3²) cannot be factored over the real numbers.
- Over the complex numbers it would be (x − 3i)(x + 3i) — but that is outside real-number factoring.
When it does not factor
| Input | Verdict |
|---|---|
x^2+9 | Sum of squares — does not factor over ℝ |
x^2-7 | 7 is not a perfect square — not a difference of two squares |
x^2+2x+1 | Trinomial — different pattern: (x+1)² |
x^3-8 | Odd exponents — not squares (x³−8 is a difference of cubes) |
What this tool is (and isn't)
This tool is the a² − b² pattern specialist. It recognizes the difference-of-two-squares pattern — including disguised forms like 4x²−25, 9−y², x⁴−16 (factored twice, down to (x−2)(x+2)(x²+4)), and (x+1)²−9 — pulls out common factors first, and proves each answer by expanding back.
Boundary vs Quadratic Equation Solver: that tool solves any quadratic ax²+bx+c = 0 (discriminant, quadratic formula, completing the square). Use it when your quadratic has an x term or isn't a clean difference of squares. Use this tool when you want the pure a²−b² pattern with pattern pedagogy.
Boundary vs Square Calculator: that tool computes squares and square roots of numbers. This tool factors algebraic expressions.
Frequently asked questions
What is the difference of two squares?
It is the algebraic pattern a² − b² = (a − b)(a + b). Any expression that can be written as one perfect square minus another perfect square factors this way — for example x² − 9 = (x − 3)(x + 3), because x² = (x)² and 9 = (3)².
How do you factor x² − 9 step by step?
Step 1 — identify the squares: x² = (x)² and 9 = (3)². Step 2 — rewrite: (x)² − (3)². Step 3 — apply a² − b² = (a−b)(a+b) with a = x, b = 3: (x − 3)(x + 3). Step 4 — verify by expanding: (x − 3)(x + 3) = x² + 3x − 3x − 9 = x² − 9 ✓.
How do you factor 4x² − 25?
Write each term as a square: 4x² = (2x)² and 25 = (5)², then apply the pattern: (2x − 5)(2x + 5). Expanding back: 4x² + 10x − 10x − 25 = 4x² − 25 ✓.
Can x⁴ − 16 be factored completely?
Yes — twice. First: x⁴ − 16 = (x²)² − (4)² = (x² − 4)(x² + 4). Then (x² − 4) is itself a difference of two squares: (x − 2)(x + 2). The complete factorization is (x − 2)(x + 2)(x² + 4); x² + 4 is a sum of squares and stops there.
Why can't x² + 9 be factored?
Because it is a sum of squares, not a difference. The pattern a² − b² = (a−b)(a+b) requires a minus sign. Over the real numbers, x² + 9 has no factorization; over the complex numbers it would be (x − 3i)(x + 3i).
What do you do first if there is a common factor, like 2x² − 8?
Factor out the GCF before applying the pattern: 2x² − 8 = 2(x² − 4) = 2(x − 2)(x + 2). Skipping this step is the most common mistake students make.
Does the order matter — is 9 − y² a difference of two squares?
Yes. The pattern only needs one square minus another: 9 − y² = (3)² − (y)² = (3 − y)(3 + y).
How can I check that my factorization is correct?
Expand it back (FOIL): (a−b)(a+b) = a² + ab − ab − b² = a² − b². The middle terms always cancel. If you don't get the original expression exactly, the factorization is wrong. This calculator runs that expand-back check on every answer.
When should I use this instead of a quadratic equation solver?
Use this calculator when your expression is exactly a square minus a square and you want the pattern-based factorization with steps. Use a general quadratic equation solver when the quadratic has an x term (like x² + 5x + 6) or you need roots of ax² + bx + c = 0 via the quadratic formula.
Can the squared terms be binomials, like (x+1)² − 9?
Yes. Treat (x+1) as a single base a: (x+1)² − 9 = ((x+1) − 3)((x+1) + 3), which simplifies to (x − 2)(x + 4).
Is x² − 7 a difference of two squares?
Not for exact rational factoring — 7 is not a perfect square, so the pattern a² − b² = (a−b)(a+b) has no rational a, b to use here. (Over the reals it would be (x − √7)(x + √7).)
What about x² + 2x + 1 — three terms?
That is a perfect-square trinomial, a different pattern: x² + 2x + 1 = (x + 1)². The difference-of-two-squares pattern needs exactly two terms.
Does this work with decimals or fractions?
Yes — everything is computed with exact rational arithmetic, never floating point. For example 0.25x² − 1 = (1/4)(x² − 4) = 1/4(x − 2)(x + 2).
Can I type ² or end my input with “= 0”?
Yes. Superscript characters (x²), the × sign, and a trailing “= 0” are normalized automatically, so “x² − 9 = 0” factors as (x − 3)(x + 3).
Free tool by NRTechStudio