## You are here

Homeproof of Lagrange's four-square theorem

## Primary tabs

# proof of Lagrange’s four-square theorem

The following proof is essentially Lagrange’s original, from around 1770. First, we need three lemmas.

###### Lemma 1.

For any integers $a,b,c,d,w,x,y,z$,

$\displaystyle(a^{2}+b^{2}+c^{2}+d^{2})(w^{2}+x^{2}+y^{2}+z^{2})$ | $\displaystyle=$ | $\displaystyle(aw+bx+cy+dz)^{2}$ | ||

$\displaystyle+$ | $\displaystyle(ax-bw-cz+dy)^{2}$ | |||

$\displaystyle+$ | $\displaystyle(ay+bz-cw-dx)^{2}$ | |||

$\displaystyle+$ | $\displaystyle(az-by+cx-dw)^{2}.$ |

###### Lemma 2.

If $2m$ is a sum of two squares, then so is $m$.

###### Proof.

###### Lemma 3.

If $p$ is an odd prime, then $a^{2}+b^{2}+1=kp$ for some integers $a,b,k$ with $0<k<p$.

###### Proof.

Let $p=2n+1$. Consider the sets

$A:=\{a^{2}\mid a=0,1,...,n\}\quad\mbox{ and }\quad B:=\{-b^{2}-1\mid b=0,1,...% ,n\}.$ |

We have the following facts:

1. No two elements in $A$ are congruent mod $p$, for if $a^{2}\equiv c^{2}\;\;(\mathop{{\rm mod}}p)$, then either $p\mid(a-c)$ or $p\mid(a+c)$ by unique factorization of primes. Since $a-c,a+c\leq 2n<p$, and $0\leq a,c$, we must have $a=c$.

2. Similarly, no two elements in $B$ are congruent mod $p$.

3. Furthermore, $A\cap B=\varnothing$ since elements of $A$ are all non-negative, while elements of $B$ are all negative.

4. Therefore, $C:=A\cup B$ has $2n+2$, or $p+1$ elements.

Therefore, by the pigeonhole principle, two elements in $C$ must be congruent mod $p$. In addition, by the first two facts, the two elements must come from different sets. As a result, we have the following equation:

$a^{2}+b^{2}+1=kp$ |

for some $k$. Clearly $k$ is positive. Also, $p^{2}=(2n+1)^{2}>2n^{2}+1\geq a^{2}+b^{2}+1=kp$, so $p>k$. ∎

Basically, Lemma 3 says that for any prime $p$, some multiple $0<m<p$ of $p$ is a sum of four squares, since $a^{2}+b^{2}+1=a^{2}+b^{2}+1^{2}+0^{2}$.

###### Proof of Theorem.

By Lemma 1 we need only show that an arbitrary prime $p$ is a sum of four squares. Since that is trivial for $p=2$, suppose $p$ is odd. By Lemma 3, we know

$mp=a^{2}+b^{2}+c^{2}+d^{2}$ |

for some $m,a,b,c,d$ with $0<m<p$. If $m=1$, then we are done. To complete the proof, we will show that if $m>1$ then $np$ is a sum of four squares for some $n$ with $1\leq n<m$.

If $m$ is even, then none, two, or all four of $a,b,c,d$ are even; in any of those cases, we may break up $a,b,c,d$ into two groups, each group containing elements of the same parity. Then Lemma 2 allows us to take $n=m/2$.

Now assume $m$ is odd but $>1$. Write

$\displaystyle w$ | $\displaystyle\equiv$ | $\displaystyle a\;\;(\mathop{{\rm mod}}m)$ | ||

$\displaystyle x$ | $\displaystyle\equiv$ | $\displaystyle b\;\;(\mathop{{\rm mod}}m)$ | ||

$\displaystyle y$ | $\displaystyle\equiv$ | $\displaystyle c\;\;(\mathop{{\rm mod}}m)$ | ||

$\displaystyle z$ | $\displaystyle\equiv$ | $\displaystyle d\;\;(\mathop{{\rm mod}}m)$ |

where $w,x,y,z$ are all in the interval $(-m/2,m/2)$. We have

$w^{2}+x^{2}+y^{2}+z^{2}<4\cdot\frac{m^{2}}{4}=m^{2}$ |

$w^{2}+x^{2}+y^{2}+z^{2}\equiv 0\;\;(\mathop{{\rm mod}}m).$ |

So $w^{2}+x^{2}+y^{2}+z^{2}=nm$ for some integer non-negative $n$. Since $w^{2}+x^{2}+y^{2}+z^{2}<m^{2}$, $n<m$. In addition, if $n=0$, then $w=x=y=z=0$, so that $a\equiv b\equiv c\equiv d\equiv 0\;\;(\mathop{{\rm mod}}m)$, which implies $mp=a^{2}+b^{2}+c^{2}+d^{2}=m^{2}q$, or that $m|p$. But $p$ is prime, forcing $m=p$, and contradicting $m<p$. So $0<n<m$. Look at the product $(a^{2}+b^{2}+c^{2}+d^{2})(w^{2}+x^{2}+y^{2}+z^{2})$ and examine Lemma 1. On the left is $nm^{2}p$. One the right, we have a sum of four squares. Evidently three of them

$ax-bw-cz+dy=(ax-bw)+(dy-cz)$ |

$ay+bz-cw-dx=(ay-cw)+(bz-dx)$ |

$az-by+cx-dw=(az-dw)+(cx-by)$ |

are multiples of $m$. The same is true of the other sum on the right in Lemma 1:

$aw+bx+cy+dz\equiv w^{2}+x^{2}+y^{2}+z^{2}\equiv 0\;\;(\mathop{{\rm mod}}m).$ |

The equation in Lemma 1 can therefore be divided through by $m^{2}$. The result is an expression for $np$ as a sum of four squares. Since $0<n<m$, the proof is complete. ∎

Remark: Lemma 3 can be improved: it is enough for $p$ to be an odd number, not necessarily prime. But that stronger statement requires a longer proof.

## Mathematics Subject Classification

11P05*no label found*

- Forums
- Planetary Bugs
- HS/Secondary
- University/Tertiary
- Graduate/Advanced
- Industry/Practice
- Research Topics
- LaTeX help
- Math Comptetitions
- Math History
- Math Humor
- PlanetMath Comments
- PlanetMath System Updates and News
- PlanetMath help
- PlanetMath.ORG
- Strategic Communications Development
- The Math Pub
- Testing messages (ignore)

- Other useful stuff
- Corrections

## Comments

## ?

I do not understand how if

2m=x^2+y^2,

then

m=((x-y)/2)^2+((x+y)/2)^2.

Does anyone want to explain?

## Re: ?

Well, just calculate it:

((x-y)/2)^2+((x+y)/2)^2=(x^2-2xy+y^2)/4+(x^2+2xy+y^2)/4

=(2x^2+2y^2)/4=(x^2+y^2)/2=2m/2=m

Hope this helps you.

--

"Do not meddle in the affairs of wizards for they are subtle and quick to anger."

## Re: ?

If you expand the lower expression you get

(x^2 -2xy +y^2 +x^2 +2xy +y^2) / 4

= (2x^2 +2y^2) / 4

= (x^2 + y^2) / 2 (dividing by 2)

= 2m / 2 (see upper expression)

= m

as required

yours professor pineapple

## Re: ?

2m = x^2 + y^2

m = (x^2 + y^2) / 2

m = (x^2 + 2xy + y^2 + x^2 - 2xy + y^2) / 4

m = (x^2 + 2xy + y^2) / 4 + (x^2 - 2xy + y^2) / 4

m = ((x + y)^2) / 2^2 + ((x - y)^2) / 2^2

m = ((x + y) / 2)^2 + ((x - y) / 2)^2