Skip to main content
Logo image

Section 13.2 At Most One Way For Primes

Most of the rest of this chapter is dedicated to proving what we can about how to write numbers as sums of squares. We will begin our proofs by talking about how many ways we can write some numbers as a sum of squares. Namely, we’ll connect sums of squares to factorization.
Remember that the Brahmagupta-Fibonacci identity says that if two numbers are sums of two squares, so is their product. Remarkably, we can sort of do this backwards.
First, we need to say what we might mean by writing a number as a sum of squares in two essentially different ways. Compare
\begin{equation*} 13=3^2+2^2=2^2+3^2 \end{equation*}
to the situation
\begin{equation*} 25=5^2+0^2=3^2+4^2\text{.} \end{equation*}
We say the latter ways are essentially different, because they involve two different pairs of nonnegative integers.
It is not a coincidence that \(13\) is prime, while the number \(25\) which has two ways to be written is composite.
Assume first that
\begin{equation*} N = a^2+b^2 = c^2+d^2 \end{equation*}
with \(a,c\) odd and \(b,d\) even nonnegative integers. Then, assuming \(a\geq c\) and \(d\geq b\text{,}\) let
\begin{equation*} k=\gcd(a-c,d-b)\text{ and }n=\gcd(a+c,d+b)\text{.} \end{equation*}
Both \(k\) and \(n\) are even, and
\begin{equation*} \ell=\frac{a-c}{k}=\frac{d+b}{n}\text{ and }m=\frac{a+c}{n}=\frac{d-b}{k}\text{.} \end{equation*}
Then we get that
\begin{equation*} N=\left[\left(\frac{k}{2}\right)^2+\left(\frac{n}{2}\right)^2\right]\left(\ell^2+m^2\right)\text{.} \end{equation*}
There are some details remaining here, especially in terms of verifying all these numbers exist, but they mostly just use the definitions of gcd and parity. See Exercise Group 13.7.8–11.

Example 13.2.2.

Let’s examine \(N=25\text{.}\) First, what are \(a,b,c,d\text{?}\)
Once you have computed them, you should confirm that \(k=\gcd(2,4)=2\text{,}\) \(n=\gcd(8,4)=4\) which means \(\ell=1\) and \(m=2\text{.}\) This yields
\begin{equation*} 25=\left[\left(\frac{2}{2}\right)^2+\left(\frac{4}{2}\right)^2\right]\left(1^2+2^2\right)=5\cdot 5\text{.} \end{equation*}
So \(25\) is a product of numbers, each themselves writeable as a sum of two squares.

Remark 13.2.3.

This method for factoring is apparently due to Euler; see Wikipedia 5 , which references [E.5.3]. An interesting generalization for the situation where one has two different ways to write an odd integer as a sum of the form \(mx^2+ny^2\) for positive \(m,n\) may be found in [E.7.30].
It is now nearly trivial to prove the following.
This is clear for \(p=2\text{.}\) It remains to consider the case of \(p\) odd. If \(p\) is writeable in two different ways, it factors by Fact 13.2.1. But prime numbers don’t factor nontrivially, so there must be just one way to do it.
Note that there could be zero ways to write \(p\text{.}\) If \(p>2\) odd happens to be \(p\equiv 3\text{ (mod }4)\text{,}\) Fact 13.1.1 says as much, so the use of Fact 13.2.1 in the first paragraph is really only being applied to \(p\equiv 1\text{ (mod }4)\text{.}\)
For example, in Figure 13.2.5 we see that thirteen is only writeable as \(3^2+2^2\) (or \(2^2+3^2\)).
Thirteen in just one way
Figure 13.2.5. Thirteen in just one way
We can confirm Proposition 13.2.4 visually in many cases, in that each of the circles with radius squared a prime either has no lattice points, or its only positive lattice points are \((a,b)\) and \((b,a)\) for one \(a\) and \(b\text{.}\)'s_factorization_method