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?
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.
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 ) as a sum of three squares. (Notice that 7 and 15 are both 7 (mod )…) 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 and , 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.