## Theorem 15: Lagrange’s theorem about sums of four squares

I found myself telling someone about this theorem the other day (as a way of introducing the area of my research), and remembered what a remarkable theorem it is.  So it seems like a good time to write about it, even if it does mean I’ll have two theorems by Lagrange in quite close succession!

Let’s think about writing numbers as sums of squares.  Which numbers can we write as sums of two squares?

$1 = 1^2 + 0^2$

$2 = 1^2 + 1^2$

$3 = ??$

$4 = 2^2 + 0^2$

$5 = 2^2 + 1^2$

$6 = ??$

$7 = ??$

$8 = 2^2 + 2^2$

$9 = 3^2 + 0^2$

$10 = 3^2 + 1^2$

$11 = ??$

$12 = ??$

$13 = 3^2 + 2^2$

$14 = ??$

$15 = ??$

$16 = 4^2 + 0^2$

$17 = 4^2 + 1^2$

$18 = 3^2 + 3^2$

$19 = ??$

$20 = 4^2 + 2^2$

and so on.

What can we conclude from that?  Well, some numbers can be written as sums of two squares, and some can’t.   (It might be that some numbers can be written as the sum of two squares in more than one way; I’m just thinking about whether there’s some way, rather than how many ways there are.)  OK, but as mathematicians we’d like to know more than that.  Can we predict which numbers can be written as sums of two squares and which can’t, without having to test lots of squares to see whether they work?

It turns out that the answer is yes — but that will be the subject of a future theorem of the week.  I’ll just mention it briefly now.

A theorem of Fermat gives a very nice way of describing exactly which numbers are sums of two squares.  For example, it says that an odd prime is a sum of two squares if and only if it is 1 more than a multiple of 4.  (Any odd prime is 1 more than a multiple of 4 or 3 more than a multiple of 4 — I’ll let you think about why!)  It’s not too hard to see why primes (indeed, any numbers) that are 3 more than multiples of 4 can’t be written as the sum of two squares.  The point is that any square number is either divisible by 4, or 1 more than a multiple of 4 (again, one for you to check).  So when we add two square numbers, the result can’t be 3 more than a multiple of 4.  It takes a bit more work to prove that if a prime is 1 more than a multiple of 4, then it is the sum of two squares; that’s not obvious at all (at least to me).  In particular, there are infinitely many numbers that are sums of two squares, and infinitely many that aren’t.  But, as I said above, this will all have to wait for a future week.

So some numbers can’t be made using just two squares, for example because of this business of the remainder when divided by 4.  What if we allow three squares?  Might we be able to make everything then?  Working mod 4 (thinking about the remainder on division by 4) doesn’t say that’s impossible, so we don’t have an obvious reason.  Let’s try the numbers from 1 to 20 again.

$1 = 1^2 + 0^2 + 0^2$

$2 = 1^2 + 1^2 + 0^2$

$3 = 1^2 + 1^2 + 1^2$

$4 = 2^2 + 0^2 + 0^2$

$5 = 2^2 + 1^2 + 0^2$

$6 = 2^2 + 1^2 + 1^2$

$7 = ??$

$8 = 2^2 + 2^2 + 0^2$

$9 = 3^2 + 0^2 + 0^2$

$10 = 3^2 + 1^2 + 0^2$

$11 = 3^2 + 1^2 + 1^2$

$12 = 2^2 + 2^2 + 2^2$

$13 = 3^2 + 2^2 + 0^2$

$14 = 3^2 + 2^2 + 1^2$

$15 = ??$

$16 = 4^2 + 0^2 + 0^2$

$17 = 4^2 + 1^2 + 0^2$

$18 = 4^2 + 1^2 + 1^2$

$19 = 3^2 + 3^2 + 1^2$

$20 = 4^2 + 2^2 + 0^2$.

So again there seem to be some numbers that can be written as sums of three squares, and some that can’t.  Can we say more than this?  Are there infinitely many of each sort?  There are obviously infinitely many that can (the squares themselves!).  Are there infinitely many that can’t, or was that just because there aren’t many squares less than 15 and so we ran out?  Last time, we saw that working mod 4 was a good idea.  This time, it turns out that working mod 8 is a good idea.  The squares mod 8 are 0, 1 and 4 (one for you to check).  So we can never hope to write a number that’s 7 (mod $8$) as a sum of three squares.  (Notice that 7 and 15 are both 7 (mod $8$)…)  So there are indeed infinitely many numbers that can’t be written as the sum of three squares.  Again, it turns out that one can classify which numbers can and which cannot be written in this form, and again I’m going to move swiftly on rather than telling you about it.

We were able to write more numbers as sums of three squares than sums of two squares (unsurprisingly).  What happens if we play the same game again, but this time allowing ourselves four squares?  Now $7 = 2^2 + 1^2 + 1^2 + 1^2$ and $15 = 3^2 + 2^2 + 1^2 + 1^2$, so the two numbers that were problematic last time are no longer problematic.  But that doesn’t tell us much: perhaps there’s some larger number that’s not the sum of four squares.  How can we tell?  This is where Lagrange’s theorem comes in.

Theorem (Lagrange) Every positive integer is the sum of four squares.

That’s it!  If we allow ourselves four squares, we can get everything.  No reasons mod 8 why we can’t, no reasons mod anything else why we can’t, no problems with running out of squares, no other reasons we haven’t even thought of.  Isn’t that pretty amazing?

So how does one go about proving a result like this?  We can’t hope to test each number in turn, because there are infinitely many.  We need a more cunning strategy.

I’m not going to tell you the whole proof, although it’s not terribly difficult.  The first step is to break down the task.  It turns out that if two numbers are both sums of four squares, then so is their product.  One way to see this is to quote an identity of Euler (which is easy enough to check by doing the algebra, even if it doesn’t reveal how one might have thought of it).  Another is to think about norms of quaternions (which encode the result we want).  However one proves it, it’s very useful here, because it means that it’s enough to show that every prime is the sum of four squares.  Why?  Well, the Fundamental Theorem of Arithmetic tells us that every positive integer is a product of primes.  If we know that primes are sums of four squares, and that products of sums of four squares are sums of four squares, then we must know that every positive integer is the sum of four squares.

That still leaves some work to do, because I haven’t given you any reason to believe that every prime number is the sum of four squares, and in fact I’m not going to (because this post is long enough already).  There are plenty of places where you can read about this if you’re interested, or you can ask in a comment below!

Why did I mention this theorem in the context of my research?  Well, it leads very naturally on to Waring’s problem, which is about writing numbers as sums of cubes, or fourth powers, or fifth powers, and so on.  And part of my research has been thinking about a possible generalisation of this.  But I liked Lagrange’s theorem before I started my research: I think it’s a very lovely result.

As usual, I’ll mention Davenport’s The Higher Arithmetic here, and as usual you’ll find this result in lots of other number theory books too.  Inevitably there’s a Wikipedia page about this theorem of Lagrange, and there’s one about Fermat’s theorem on sums of two squares too, if you can’t wait for me to write about it!  And here’s more about Waring’s problem.

### 10 Responses to “Theorem 15: Lagrange’s theorem about sums of four squares”

1. edmaths Says:

Dear theoremoftheweek, Dear all,

I have a question that is related to Lagrange’s theorem, and I thought that this post would be a nice place to ask…
If I’m right, Eugene Catalan conjectured that every number equal to 6 mod 12 should be the sum of three nonnegative squares.
We find a related result in the fifth edition of “Hardy and Wright”, but is the original conjecture from Eugene Catalan proved?
Thanks a lot!
Good luck with Waring…

2. edmaths Says:

Dear theoremoftheweek, Dear all,

I have a question that is related to Lagrange’s theorem, and I thought that this post was a nice place to ask…
If I’m right, Catalan conjectured that every number that is equal to 6 mod 12 should be the sum of exactly three nonnegative integers.
We find a result related to this conjecture of Eugene Catalan in “Hardy and Wright” (fifth edition), but does anyone know if the original conjecture is now proved?
Thanks!

3. Theorem 23: Waring’s problem « Theorem of the week Says:

[…] 23: Waring’s problem By theoremoftheweek I told you on a previous occasion about Lagrange’s theorem about sums of four squares, which says that every positive whole number can be written as the sum of four squares (including […]

4. Theorem 29: the law of quadratic reciprocity « Theorem of the week Says:

[…] I wrote about sums of squares (in my post about Lagrange’s theorem), I tried to persuade you that thinking about squares and modular arithmetic is a good idea.  In […]

5. Number Theory: Lecture 13 « Theorem of the week Says:

[…] Theorem 42 (Lagrange): Every natural number is a sum of four squares.  We are not going to prove this result in this course (although it’s not a terribly difficult theorem to prove). […]

6. pshirishreddy Says:

Now fixed, thanks.

7. Number Theory: Lecture 14 | Theorem of the week Says:

[…] Jones and Jones (Elementary number theory) has another explicit example of an application of Hensel’s lemma.  They also devote a chapter to questions about sums of squares, including the problems about sums of two squares and sums of four squares (see below).  Davenport (The Higher Arithmetic) presents another way of characterising the numbers that can be written as the sum of two squares, without using the theory of binary quadratic forms.  You might like to read that for another approach.  Baker (A concise introduction to the theory of numbers) follows the approach that we took in lectures, namely studying the sums of two squares via binary quadratic forms.  Both Baker and Davenport move on to discuss the question of which numbers can be written as the sum of four squares, which leads to a rather lovely (and perhaps surprising) theorem of Lagrange. […]

8. donbright Says:

thanks for writing this, it helped me understand the 4-square theorem.

just one slight issue… i was actually looking for the ’15 theorem’ and google took me here due to the title. lol

9. Groups and Group Actions: Lecture 8 | Theorem of the week Says:

[…] on this blog.  I’ve written about Lagrange’s Theorem (not be confused with another Lagrange’s Theorem that I’ve also written about), and about Fermat’s Little Theorem (that post outlines […]

10. Groups and Group Actions: Lecture 8 | Theorem of the week Says:

[…] before on this blog.  I’ve written about Lagrange’s Theorem (not be confused with another Lagrange’s Theorem that I’ve also written about), and about Fermat’s Little Theorem (that post outlines the three […]