Relevant For...

Sum of squares theorems are theorems in additive number theory concerning the expression of integers as sums of squares of other integers. For example, \(30 = 1^2 + 2^2 + 5^2\), so 30 can be expressed as a sum of three squares. However, brute force will reveal that 23 cannot be expressed as a sum of three squares. Sum of squares theorems give formulaic ways to differentiate which numbers can and cannot be expressed as sums of squares. This is especially useful for very large numbers, for which brute force methods are computationally impractical.

Sum of squares theorems have found various applications in applied number theory, such as cryptography and integer factoring algorithms. They are often used as intermediate steps in the proofs of other theorems in elementary number theory. Numerous results have been proven concerning what types of integers can be expressed as a sum of \(k\) squares for \(k \ge 2\), i.e. what form \(n\) must take such that \(n = a_1^2 + \dots + a_k^2\) for \(n, a_i \in \mathbb{Z}\).

Contents

Fermat's Theorem on the Sum of Two Squares

In the case that \(k=2\), Fermat's theorem on the sum of two squares says that an odd prime \(p\) is expressible as a sum of two squares if and only if \(p = 4n + 1\) for some positive integer \(n\). Formally, Fermat's theorem on the sum of two squares says

For example, odd primes \(5\), \(17\), and \(41\) are all congruent to \(1 \bmod 4\). As predicted by Fermat's theorem on the sum of two squares, each can be expressed as a sum of two squares: \(5 = 1^2 + 2^2\), \(17 = 1^2 + 4^2\), and \(41 = 4^2 + 5^2\). On the other hand, odd primes \(7\), \(19\), and \(31\) are all congruent to \(3 \bmod 4\) and cannot be expressed as a sum of two squares.

If the lengths from the vertices to point \(E\) are all different integers, what is the least possible value of \(AE + BE + CE + DE\)?

Proof

The first proof of Fermat's theorem on the sum of two squares was given by Leonhard Euler in 1749. It uses the technique of proof by infinite descent, which intuitively makes use of the fact that the positive integers are finitely bounded from below. The full proof is fairly involved, so a general outline of Euler's proof follows.

1. Use Diophantus' identity to show that the product of two numbers, each of which is a sum of two squares, is itself a sum of two squares.
\[\]
2. Using Diophantus' identity again, show that a number which is a sum of two squares and is divisible by a prime which is a sum of two squares implies the quotient is a sum of two squares.
\[\]
3. Using the result from (2), prove by contraposition that a number which can be written as a sum of two squares and is divisible by a number which is not a sum of two squares implies the quotient has a factor which is not a sum of two squares.
\[\]
4. By infinite descent, prove that if \(a\) and \(b\) are relatively prime, then every factor of \(a^2 + b^2\) is a sum of two squares.
\[\]
5. Using Fermat's Little Theorem, show that every prime of the form \(4n + 1\) is a sum of two squares.

Applications

If an odd integer \(n\) can be expressed as the product \(n=a^{2}b\) where all factors of \(b\) are congruent to \(1 \bmod 4\), then \(n\) can be expressed as a sum of two squares. This is equivalent to saying that \(n\) can be expressed as a sum of two squares if all prime factors of \(n\) congruent to \(3 \bmod 4\) have an even exponent. Finding \(x\), \(y\) such that \(b = x^2 + y^2\) implies \(n = (ax)^2 + (ay)^2\), which is a sum of two squares, so the proof reduces to showing that \(\exists\ x, y \in \mathbb{Z} \mid b = x^2 + y^2\) when \(b\) is a product of primes congruent \(1 \bmod 4\). The proof is relatively straightforward by repeated application of Fermat's theorem on the sum of two squares and the Brahmagupta-Fibonacci Identity.

One application of the prior result is that composite numbers that can be expressed as a sum of two squares are comparatively easy to factor. Euler's factorization method requires expressing a number \(n\) as a sum of two different sums of two squares, i.e. \(n = a^2 + b^2 = c^2 + d^2\). Using this knowledge, the algorithm deterministically determines nontrivial factors of \(n\). Unfortunately, the algorithm has seen limited use since there is no easy way to determine whether \(n\) has prime factors congruent to \(3 \bmod 4\) with odd exponents.

Legendre's Three Square Theorem

In the case that \(k=3\), Legendre's three square theorem says that a natural number \(n\) is expressible as a sum of three squares if and only if \(n \neq 4^a(8b+7)\) for integers \(a\) and \(b\). Formally, Legendre's three square theorem says

For example, \(13\), \(26\), and \(41\) cannot be expressed in the form \(4^a(8b+7)\) for some integers \(a\) and \(b\). As predicted by Legendre's three square theorem, each can be expressed as a sum of three squares: \(13 = 0^2 + 2^2 + 3^2\), \(26 = 1^2 + 3^2 + 4^2\), and \(41 = 3^2 + 4^2 + 4^2\). On the other hand, brute force will reveal that \(15 = 4^0(8 \cdot 1 + 7)\), \(28 = 4^1(8 \cdot 0 + 7)\), and \(92 = 4^1(8 \cdot 2 + 7)\) cannot be expressed as a sum of three squares.

The proof for Legendre's three square theorem is quite complicated, and so, is not included here. In fact, a proof for the case of \(k=4\) was found in 1770, a full 28 years before Legendre discovered his first proof for the case \(k=3\).

Lagrange's Four Square Theorem

In the case that \(k=4\), Lagrange's four square theorem, also known as Bachet's conjecture, says that every natural number \(n\) can be expressed as a sum of four squares. Formally, Lagrange's four square theorem says