Fermat's Two Squares Theorem
Fermat first listed this theorem in 1640, but listed it without proof, as was usual for him. Euler gave the first written proof in 1747, by infinite descent.
The theorem is a starting point in the investigation of binary quadratic forms. Historically, two of the main questions have been:
- What numbers does a form represent?
- In how many ways can an integer be represented by a form ?
The theorem, with some study of the Gaussian integers , resolves these questions for the form .
This theorem is also a special case of another general question in commutative algebra: What is the behavior of prime ideals under ring homomorphisms? This theorem resolves this question for the canonical injection , as follows:
- The ideal becomes ;
- For , the ideal becomes , for some ; these ideals are then prime.
- For , the ideal remains prime.
Since 0 and 1 are the only quadratic residues mod 4, it follows that if is a prime number represented as the sum of two squares, then is even or . The converse is more interesting.
We use the fact that the set of Gaussian integers has a Euclidean algorithm. Hence it has unique prime factorization, and is a principal ideal domain (i.e., every ideal is a principal ideal). This is relevant because an integer can be represented (nontrivially) as a sum of two squares if and only if it has a (nontrivial) factorization in :
Now, suppose that is a prime congruent to 1 mod 4 that cannot be represented as a sum of two squares. Then is a Gaussian prime, so is a prime ideal, and hence a maximal ideal. In other words, is a field. But there is an element of for which . Then , , , and are four distinct roots of the second-degree polynomial in the commutative field . This is a contradiction.
Finally, we prove that the representation of a prime as a sum of two squares is unique. To this end, we note that if is a prime for which then and both have a prime norm; hence they are both Gaussian primes. Hence any such representation is unique up to multiplication by units. Since the only units in are and , the representation is unique up to order and the sign of and .