Lagrange’s Four-Square Theorem
Recommended post: 【Number Theory】 Number Theory Table of Contents
1. Theorem
2. Lemma
3. Proof
4. Application
1. Theorem
Every nonnegative integer $n$ can be expressed as the sum of the squares of four integers:
\[n = x_1^2 + x_2^2 + x_3^2 + x_4^2.\]Here, the $x_i$ may be zero. (ref)
For example,
\[23 = 3^2 + 3^2 + 2^2 + 1^2.\]2. Lemma
If both $m$ and $n$ are sums of the squares of four integers, then $mn$ is also a sum of the squares of four integers.
Let
\[m = a_1^2 + a_2^2 + a_3^2 + a_4^2, \qquad n = b_1^2 + b_2^2 + b_3^2 + b_4^2.\]This is because
\[\begin{aligned} mn ={}& (a_1b_1-a_2b_2-a_3b_3-a_4b_4)^2 \\ &+ (a_1b_2+a_2b_1+a_3b_4-a_4b_3)^2 \\ &+ (a_1b_3-a_2b_4+a_3b_1+a_4b_2)^2 \\ &+ (a_1b_4+a_2b_3-a_3b_2+a_4b_1)^2. \end{aligned}\]3. Proof
It is clear that the theorem holds for $n=1,2$.
For an odd prime $p$, consider the two sets
\[A=\left\{0^2,1^2,\ldots,\left(\frac{p-1}{2}\right)^2\right\},\] \[B=\left\{-1-0^2,-1-1^2,\ldots,-1-\left(\frac{p-1}{2}\right)^2\right\}.\]| Since $ | A | = | B | =(p+1)/2$, the two sets contain a total of $p+1$ elements. |
Therefore, we can find two elements $a^2\in A$ and $-1-b^2\in B$ that have the same remainder modulo $p$:
\[a^2\equiv -1-b^2 \pmod p.\]Thus, we can find an integer $k$ with $1\le k<p$ such that
\[pk=a^2+b^2+1^2+0^2. \tag{★}\]Now suppose that $1<k<p$ and $pk$ is a sum of four squares. We will show that there exists a smaller positive integer $k’<k$ such that $pk’$ is also a sum of four squares. (★★)
Suppose first that $k$ is even. Among $x_1,x_2,x_3,x_4$, there are an even number of even integers and an even number of odd integers, so they can be paired according to parity. For example, pair $(x_1,x_2)$ and $(x_3,x_4)$.
Then
\[\begin{aligned} \frac{pk}{2} &=\frac{x_1^2+x_2^2+x_3^2+x_4^2}{2} \\ &=\left(\frac{x_1+x_2}{2}\right)^2 +\left(\frac{x_1-x_2}{2}\right)^2 +\left(\frac{x_3+x_4}{2}\right)^2 +\left(\frac{x_3-x_4}{2}\right)^2, \end{aligned}\]so $k$ has been reduced to $k/2$.
Now suppose that $k$ is odd. For each $x_i$, we can define $y_i$ such that
\[-\frac{k}{2}<y_i<\frac{k}{2}\]and
\[y_1\equiv x_1,\qquad y_2\equiv -x_2,\qquad y_3\equiv -x_3,\qquad y_4\equiv -x_4 \pmod k.\]With this definition,
\[y_1^2+y_2^2+y_3^2+y_4^2<k^2. \tag{★★★}\]On the other hand,
\[y_1^2+y_2^2+y_3^2+y_4^2 \equiv x_1^2+x_2^2+x_3^2+x_4^2 =pk \equiv 0 \pmod k,\]so
\[y_1^2+y_2^2+y_3^2+y_4^2=kr.\]By (★★★), we obtain $0<r<k$.
We now have
\[pk=x_1^2+x_2^2+x_3^2+x_4^2,\] \[kr=y_1^2+y_2^2+y_3^2+y_4^2.\]By the lemma,
\[(pk)(kr)=pk^2r=z_1^2+z_2^2+z_3^2+z_4^2.\]Furthermore, from the proof of the lemma,
\[\begin{aligned} z_1 &=x_1y_1-x_2y_2-x_3y_3-x_4y_4 \\ &\equiv x_1^2+x_2^2+x_3^2+x_4^2 \equiv 0 \pmod k, \end{aligned}\] \[\begin{aligned} z_2 &=x_1y_2+x_2y_1+x_3y_4-x_4y_3 \\ &\equiv -x_1x_2+x_2x_1-x_3x_4+x_4x_3 =0 \pmod k, \end{aligned}\] \[\begin{aligned} z_3 &=x_1y_3-x_2y_4+x_3y_1+x_4y_2 \\ &\equiv -x_1x_3+x_2x_4+x_3x_1-x_4x_2 =0 \pmod k, \end{aligned}\] \[\begin{aligned} z_4 &=x_1y_4+x_2y_3-x_3y_2+x_4y_1 \\ &\equiv -x_1x_4-x_2x_3+x_3x_2+x_4x_1 =0 \pmod k. \end{aligned}\]Therefore,
\[\begin{aligned} pk^2r=z_1^2+z_2^2+z_3^2+z_4^2 &\iff pr=\left(\frac{z_1}{k}\right)^2 +\left(\frac{z_2}{k}\right)^2 +\left(\frac{z_3}{k}\right)^2 +\left(\frac{z_4}{k}\right)^2, \end{aligned}\]so $k$ has been reduced to $r$.
This proves (★★).
Applying infinite descent to (★★), we conclude that $p$ can also be expressed as a sum of four squares.
Every natural number $n\ge 2$ can be factored into primes as
\[n=p_1p_2\cdots p_r.\]Since each prime $p_i$ can be expressed as a sum of four squares, the lemma shows that $n$ can also be expressed as a sum of four squares.
4. Application
It has not yet been proved whether every nonnegative integer $n$ can be expressed as the sum of four cubes.
Input: 2026.06.24 00:48