Sums and differences of two squares

In number theory, much research has been done on the sums and differences of two squares . Here are some of their properties.

To recap, a square number is the product of a number n and itself (i.e. 2 × 2 = 4, thus 4 is a square number). The proper notation would be to write such a number as n2, pronounced "n squared".

Properties of Sums of Two Squares
A sum of two squares would look like a2 + b2.

According to the Pythagorean theorem, the sum of any two squares will be equal to the sum of another square (i.e. a2 + b2 = c2). For our purposes, we will just be talking about the squares of whole numbers.

It is impossible to factorize sums of two squares using real numbers. However, using complex numbers, you can always factorize a sum of two squares into a complex conjugate pair. For example, 2 = 12 + 12, and 2 = (1 + i)(1 − i). These complex conjugates are always what are called Gaussian primes, since they cannot be factorized further, just like how primes in the real numbers cannot be factorized further.

A number cannot be expressed as the sum of two squares if one of its prime factors is an odd power of a number that has a residue class 3 mod 4. That is, if N has a prime factor p where p = (4n + 3)2k + 1, then N ≠ a2 + b2. Ultimately, the proof of this boils down to N not being a square, given this property. This means that numbers like 3, 6, 7, 11, etc. cannot be expressed as the sum of two squares. This also implies that they cannot be factorized into complex conjugates.

Properties of Differences of Two Squares
Likewise, a difference of two squares would look like a2 − b2.

Unlike sums, differences of two squares can always be factorized as the product of a conjugate pair using real numbers. That is, (a + b)(a − b) = a2 − b2, and neither a nor b have to be complex.

A number cannot be expressed as the difference of two squares if it has a residue class 2 mod 4. That is, 4n + 2 ≠ a2 − b2. This means that numbers like 2, 6, 10, 14, etc. cannot be expressed as the difference of two squares.

Every odd number can be expressed as the difference of two consecutive squares.

Additional Notes
A number cannot be expressed as either the sum nor difference of two squares if it has a residue class 6 mod 8. That is, 8n + 6 ≠ a2 ± b2. This means that numbers like 6, 14, 22, 30, etc. cannot be expressed as either the sum nor difference of two squares. All of these have a prime factor of the form (4n + 3)2k + 1, and they all are of the form 4n + 2.