Sums of Three Squares

Introduction

I would like to present here a short and elementary proof of the following theorem.

Theorem 1

If \(m\) is a positive integer not of the form \(4^{a}(8n+7)\), then \(m\) is the sum of three squares.

Proof

We make use of an elegant method of Professor H. Davenport  [ 1 ] in the Geometry of Numbers.

Without loss of generality we will prove Theorem 1 only when \(m\) is square free. (In the following \(m\) will be assumed to be square free.) In Section 1 we shall prove Theorem 1 when \(m\equiv 3\) (mod 8). In Section 16 we will merely outline the proof when \(m\equiv 1, 2, 5, 6\) (mod 8), as the proof is almost identical except for minor changes.

We shall only assume the reader is familiar with the elementary facts of the law of quadratic reciprocity, Minkowski’s Theorem on lattice points contained within convex symmetric bodies; and when a positive integer is the sum of two squares.

1. Let \(m\) be a positive square free integer \(\equiv 3\) (mod 8), and \(m=p_{1}p_{2}\cdots p_{r}\) where \(p_{j}\)’s are primes. Denote by \(q\) a positive prime which satisfies

\begin{align} \label{eq:1} \tag {1} (-2q/p_{j})& =+1, \quad j=1, 2, \cdots , r \\ \label{eq:2} \tag {2} q& \equiv 1 \pmod{4} \end{align}

with \((a/b)\) denoting the Jacobi Symbol. We see that such a prime exists by Dirichlet’s theorem regarding primes in an arithmetic progression, as 1 and 2 merely necessitate that \(q\) lie within certain relatively prime residue classes (mod \(4m\)).

By 1 and 2

\begin{align*} 1& =\prod _{j=1}^{r}(-2q/p_{j})=\prod _{j=1}^{r}(-2/p_{j})(q/p_{j}) \\ \intertext {(3)} & =(-2/m)\prod _{j=1}^{r}(p_{j}/q) \\ & =(-2/m)(m/q)=(-2/m)(-m/q) \\ & =(-m/q) \end{align*}

as \(m\equiv 3\) (mod 8). Hence, as \(q\) is an odd prime we can find an odd integer \(b\) such that \(b^{2}\equiv -m\) (mod \(q\)), or

\begin{equation} b^{2}-qh_{1}=-m. \label{eq:4} \tag {4} \end{equation}
3

Considering 3 (mod 4) yields \(1-h_{1}\equiv +1\) (mod 4), or \(h_{1}=4h\) where \(h\) is a rational integer and

\begin{equation} b^{2}-4qh=-m. \label{eq:5} \tag {5} \end{equation}
4

Utilizing 1 we can find an integer \(t\) such that

\begin{equation} t^{2}\equiv -1/2q \pmod{m}. \label{eq:6} \tag {6} \end{equation}
5

We now consider the figure

\begin{equation} R^{2}+S^{2}+T^{2}{\lt}2m \label{eq:7} \tag {7} \end{equation}
6

where

\begin{align} R& =2tqx+tby+mz, \notag \\ S& =(2q)^{1/2}x+b/(2q)^{1/2}y, \label{eq:8} \tag {8} \\ T& =m^{1/2}/(2q)^{1/2}y \notag \end{align}

In the \((R, S, T)\) space 6 defines a convex, symmetric (about the origin) body of volume \(4/3\pi (2m)^{3/2}.\)

The determinant of the transformations 7 is \(m^{3/2}\). Hence, in the \((x, y, z)\) space, 6 represents a convex symmetric body of volume \(1/3(2^{7/2}\pi )\), and certainly \(1/3(2^{7/2}\pi ) {\gt} 8\).

Hence, by Minkowski’s Theorem on convex symmetric body in three dimensions of volume \({\gt}8\), we know there exist integer values of \(x, y, z\) not all zero which satisfy 6. Let \(x_{1}, y_{1}, z_{1}\) be the integers which satisfy 6 and 7, \(R_{1}, S_{1}, T_{1}\) the corresponding values of \(R, S, T\).

By 7

\[ R_{1}^{2}+S_{1}^{2}+T_{1}^{2}=(2tqx_{1}+tby_{1}+mz_{1})^{2} \]
\[ +((2q)^{1/2}x_{1}+b/(2q)^{1/2}y_{1})^{2}+(m^{1/2}/(2q)^{1/2}y_{1})^{2} \]
\begin{align} & \equiv t^{2}(2qx_{1}+by_{1})^{2}+1/2q(2qx_{1}+by_{1})^{2} \notag \\ & \equiv 0 \pmod{m} \label{eq:9} \tag {9} \end{align}

by 5, the selection of \(t\). Furthermore,

\begin{align} R_{1}^{2}+S_{1}^{2}+T_{1}^{2}& =R_{1}^{2}+((2q)^{1/2}x_{1}+b/(2q)^{1/2}y_{1})^{2}+(m^{1/2}/(2q)^{1/2}y_{1})^{2} \notag \\ & =R_{1}^{2}+1/2q(2qx_{1}+by_{1})^{2}+m/2qy_{1}^{2} \label{eq:10} \tag {10} \\ & =R_{1}^{2}+2(qx_{1}^{2}+bx_{1}y_{1}+hy_{1}^{2}). \notag \end{align}

Let \(v\) be the positive rational integer defined by

\begin{equation} v=qx_{1}^{2}+bx_{1}y_{1}+hy_{1}^2. \label{eq:11} \tag {11} \end{equation}
10

We note that \(R_{1}\) is a rational integer and by 8, 9, and 10 that \(m|R_{1}^{2}+2v\), but by 6 \(R_{1}^{2}+2v{\lt}2m\). Furthermore \(R_{1}^{2}+2v\ne 0\), by the nondegenerate triangular transformation 7 and the fact that not all \(x_{1}, y_{1}, z_{1}\) equal zero. Hence,

\begin{equation} R_{1}^{2}+2v=m. \label{eq:12} \tag {12} \end{equation}
11

Let \(p\) be an odd prime which exactly divides \(v\) to an odd power, i.e. \(p^{2n+1}||v\). If \(p\) does not divide \(m\), then by 11,

\begin{equation} (m/p)=+1. \label{eq:13} \tag {13} \end{equation}
12

By 10

\begin{equation} 4qv=(2qx_{1}+by_{1})^{2}+my_{1}^2. \label{eq:14} \tag {14} \end{equation}
13

If \(p|q\), then 4, \((-m/p)=1\). If \(p \nmid q\), then by 13

\[ p^{2n+1}||e^{2}+mf^{2} \text{ or } (-m/p)=1. \]

Thus, in either case,

\begin{equation} (-m/p)=+1 \label{eq:15} \tag {15} \end{equation}
14

which combined with 12 implies

\begin{equation} (-1/p)=1 \text{ or } p\equiv 1 \pmod{4}. \label{eq:16} \tag {16} \end{equation}
15

If \(p|v\), \(p|m\), then by 10 and 11

\[ R_{1}^{2}+2v=m \]

or

\begin{equation} R_{1}^{2}+\frac{1}{2q}((2qx_{1}+by_{1})^{2}+my_{1}^{2})=m \label{eq:17} \tag {17} \end{equation}
16

which implies \(p|R_{1}\), \(p|(2qx_{1}+by_{1})\), and thus as \(m\) is square free by dividing both sides of 16 by \(p\), yields

\[ \frac{1}{2q}\frac{m}{p}y_{1}^{2}=\frac{m}{p} \pmod{p} \]

or

\[ y_{1}^{2}\equiv 2q \pmod{p}, \quad \left(\frac{2q}{p}\right)=+1 \]

which combined with 1 gives \((-1/p)=+1\) or \(p\equiv 1\) (mod 4). Thus all odd primes which exactly divide \(v\) to an odd power are \(\equiv 1\) (mod 4). Thus \(2v\) is the sum of two square integers. By 11 this implies \(m\) is the sum of three square integers, which proves Theorem 1 when \(m\equiv 3\) (mod 8).

2. If \(m \equiv 1, 2, 5\) or \(6\) (mod 8), we alter the proof in Section 1 in the following ways. Let \(q\) be a prime, \((-q/p_{j})=+1\) for all odd prime divisors of \(m\), \(q\equiv 1\) (mod 4), and if \(m\) is even,

\[ m=2m_{1}, \quad (-2/q)=(-1)^{(m_{1}-1)/2}, \quad t^{2}\equiv -1/q \pmod{p_{j}}, \]

\(t\) odd, \(b^{2}-qh=-m\) and

\begin{align*} R& =tqX+tby+mz, \\ S& =q^{1/2}x+b/q^{1/2}y, \\ T& =m^{1/2}/q^{1/2}y. \end{align*}

The proof will proceed exactly as in Section 1, which will complete the proof when \(m\equiv 1, 2, 3, 5, 6\) (mod 8), and thus for all square free \(m\).