Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
page
Difference of two squares calculator icon showing nested squares

Difference of Two Squares Calculator

Algebra

Difference of Two Squares Calculator

Try an example:
a² − b²
40
Factored: (10)(4)
How it's calculated

a² − b² always factors as (a+b)(a−b), since expanding that product cancels the cross terms.

The a²−b² = (a+b)(a−b) identity is one of the most useful factoring patterns in algebra, this calculator both factors it directly and works backward to find every way a given number can be expressed as a difference of two squares.

How to use this calculator

  1. Choose your mode: Factor a²−b², or Express N as a²−b².
  2. For factoring, enter values for a and b.
  3. For expressing, enter a target number N.
  4. Read the calculated difference, factored form, or all valid representations.

What this calculator does

a² − b² always factors as (a+b)(a−b), since expanding that product cancels the cross terms. In Express mode, this calculator finds every pair of integers a and b whose squares differ by exactly your target number N.

a² − b² = (a + b)(a − b)

Why some numbers can’t be expressed as a difference of two squares

Not every integer can be written as a difference of two squares, a number that’s exactly 2 more than a multiple of 4 (like N=6) cannot be expressed this way at all, because of how the factors (a+b) and (a−b) must both share the same parity (both even or both odd) for a and b to be integers. This calculator flags such cases as “impossible” rather than returning an incorrect result.

Frequently asked questions

Why does a²−b² always factor as (a+b)(a−b)?

Expanding (a+b)(a−b) gives a² − ab + ab − b², the middle cross terms cancel out exactly, leaving a² − b², this is a standard algebraic identity, not a coincidence specific to certain numbers.

Why can’t every number be expressed as a difference of two squares?

Numbers of the form 4k+2 (like 6, 10, 14) cannot be expressed as a difference of two squares, because the two factors (a+b) and (a−b) must share the same parity for a and b to both be integers, which rules out this specific class of numbers.