What is the Difference of Two Squares?
A difference of two squares is any expression of the form \(a^2 - b^2\) — one perfect square subtracted from another. It is one of the most useful patterns in algebra because it always factors cleanly into a sum times a difference: $$a^2 - b^2 = (a + b)(a - b)$$ This calculator takes a binomial you type in, pulls out the greatest common factor (GCF), checks that both remaining terms are perfect squares, and returns the fully factored answer with each step shown.
How to use it
Type a two-term expression in the box, using the caret ^ for exponents, for example 4x^2 - 36y^4. The two terms must be joined by a plus or minus sign. Press calculate to get the factored form and a written solution. The tool handles a positive square minus a positive square directly, rearranges a negative-leading form like -4y^2 + 36 into 36 - 4y^2, and recurses when a resulting factor (such as \(x^2 - 4\)) is itself a difference of squares.
The formula explained
To square-root a perfect-square term, take the integer square root of the coefficient and halve every variable exponent: \(\sqrt{9y^4} = 3y^2\). Call the first root a and the second b; the identity then gives \((a + b)(a - b)\). A coefficient is a perfect square only if its exact integer root squared returns it, and a power \(v^n\) is a perfect square only when \(n\) is even.
Worked example
Factor \(4x^2 - 36y^4\). The GCF of 4 and 36 is 4, leaving \(4(x^2 - 9y^4)\). Here \(a = \sqrt{x^2} = x\) and \(b = \sqrt{9y^4} = 3y^2\). Applying the identity: $$x^2 - 9y^4 = (x + 3y^2)(x - 3y^2)$$ Re-attaching the GCF gives \(4(x + 3y^2)(x - 3y^2)\).
Perfect Squares Reference Table
A difference of two squares \(a^2 - b^2\) only works when both terms are perfect squares. Use this table to spot them quickly.
| n | n² | n | n² |
|---|---|---|---|
| 1 | 1 | 11 | 121 |
| 2 | 4 | 12 | 144 |
| 3 | 9 | 13 | 169 |
| 4 | 16 | 14 | 196 |
| 5 | 25 | 15 | 225 |
| 6 | 36 | 16 | 256 |
| 7 | 49 | 17 | 289 |
| 8 | 64 | 18 | 324 |
| 9 | 81 | 19 | 361 |
| 10 | 100 | 20 | 400 |
Variable powers
| Perfect square | Square root |
|---|---|
| \(x^2\) | \(x\) |
| \(x^4\) | \(x^2\) |
| \(x^6\) | \(x^3\) |
| \(x^8\) | \(x^4\) |
Note: a variable power is a perfect square only when its exponent is even. Terms such as \(x^3\), \(x^5\) or \(x^7\) are not perfect squares, so an expression like \(x^3 - 9\) does not fit the pattern directly.
More Worked Examples
Example 1: Repeated application, \(x^4 - 16\)
- Write each term as a square: \(x^4 = (x^2)^2\) and \(16 = 4^2\).
- Apply the pattern with \(a = x^2\) and \(b = 4\): $$x^4 - 16 = (x^2)^2 - 4^2 = (x^2 + 4)(x^2 - 4)$$
- The second factor \(x^2 - 4 = x^2 - 2^2\) is again a difference of two squares: \((x+2)(x-2)\).
- Result: $$x^4 - 16 = (x^2 + 4)(x + 2)(x - 2)$$ The factor \(x^2 + 4\) is a sum of squares and does not factor further over the real numbers.
Example 2: Negative leading term, \(-4y^2 + 36\)
- Reorder so the positive square comes first: \(36 - 4y^2\).
- Pull out the GCF, 4: \(4(9 - y^2)\).
- Write the inside as squares: \(9 - y^2 = 3^2 - y^2\), so \(a = 3\), \(b = y\).
- Factor: $$4(9 - y^2) = 4(3 + y)(3 - y)$$
- Check: \((3+y)(3-y) = 9 - y^2\), and \(4(9 - y^2) = 36 - 4y^2\), which matches the original.
Example 3: A non-example, \(x^2 + 25\)
Here the terms are added, not subtracted. Trying \((x+5)(x-5)\) gives \(x^2 - 25\), and \((x+5)^2 = x^2 + 10x + 25\); neither equals \(x^2 + 25\). A sum of two squares does not factor over the real numbers, so the pattern fails.
Likewise \(3x^2 - 10\) is a difference, but neither 3 nor 10 is a perfect square, so it cannot be factored with integer coefficients using this pattern. (With irrational numbers you could write \((\sqrt{3}x + \sqrt{10})(\sqrt{3}x - \sqrt{10})\), but this is not normally what is meant by factoring over the integers.)
FAQ
Can a sum of squares be factored? No. \(a^2 + b^2\) has no real factorization, so the calculator reports it is not a difference of two squares.
What if a coefficient isn't a perfect square? After the GCF is removed, both inner coefficients must be perfect squares (like 1, 4, 9, 16). If one is not, the binomial cannot be factored by this pattern.
Why pull out the GCF first? Removing the common factor shrinks the inner terms so hidden perfect squares (such as \(x^2 - 4\) inside \(3x^2 - 12\)) become visible.