For example, knowing that and , we can take , , , and , giving
or, on rewriting , we could take , , , and , giving
So some numbers can be written as the sum of two squares in more than one way: another example is
It follows from the above multiplication rule that if we can first decide which prime numbers can be written as the sum of two squares, then by combining them we can work out which numbers in general can be written in this way. This is another instance of the use of prime numbers as the building blocks for numbers in general. We now proceed to investigate the representation of prime numbers as the sum of two squares.
We have seen that , and that the odd primes of the form cannot be written as the sum of two squares. But what about the odd primes of the form ? We can certainly write:
This list illustrates the following general rule, which was first stated by Albert Girard in 1625 and in a letter from Fermat to Mersenne on Christmas Day 1640, and was eventually proved by Euler in 1754:
An odd prime number p can be written as the sum of two squares if and only if p has the form . Moreover, this can be done in only one way, apart from the order in which the two squares appear.
Before leaving this section, we ask a related question:
Which numbers can be written as the difference of two perfect squares?
This question is much easier to answer. Let’s look at some examples:
But 2, 6, 10, … cannot be written in this way, and it seems as though the following general rule applies:
Difference of two squares: A number can be written as the difference of two squares except when it has the form .
To see why this is, we note again that every perfect square has the form 4n or , and so the difference between two squares must have the form 4n, , or . So the difference between two squares can never be of the form . Moreover,
if , then we can write
if , then we can write
and if , then we can write
So every number can indeed be written as the difference of two squares, except when it has the form .Sums of more squares
We’ve seen that we cannot write every number as the sum of just two squares. Can we write every number as the sum of three squares (zero being allowed)? Certainly we have
But we cannot write 7 or 15 as the sum of only three squares. To see why, we note that every odd square has the form (see Chapter 2), and that every even square, being divisible by 4, has the form 8n or . But we cannot combine three numbers of the form 8n, , or to give a number of the form . Diophantus had claimed this result 1700 years ago, and Fermat proposed the following more general result, which was proved by Legendre in 1798:
Sum of three squares: Every number can be written as the sum of three squares, except when it has the form , for some integers m and k.
For example,
cannot be written as the sum of three squares, and nor can their multiples,
But these numbers can all be written as the sum of four squares: for example,
In fact, every positive integer without exception can be written as the sum of four squares. This remarkable result was stated by Claude Bachet de Méziriac in 1621, and was proved by Joseph-Louis Lagrange using ideas of Euler:
Lagrange’s four-square theorem: Every number can be written as the sum of four squares.
As with Fermat’s earlier result on the sum of two squares, it is enough to prove this for prime numbers only, and then to use a multiplication rule to obtain the general result. This rule, discovered by Euler, states that if m and n can each be written as the sum of four squares, then so can their product mn. This is because, for and , we have
For example, knowing that and , we can take , , , , , , , and , and write as a sum of four squares as follows:
Higher powers
Having looked at sums of squares, we now turn our attention to sums of cubes and higher powers. A well-known story concerns the Cambridge mathematician G. H. Hardy who in 1918 was visiting his friend and colleague Srinivasa Ramanujan, one of the most intuitive mathematicians of all time, who was seriously ill in hospital. Together they’d solved some important problems in number theory. Hardy, finding it difficult to think of anything to say, remarked that his taxicab to the hospital had the number 1729 which seemed to be rather a dull number. As Hardy recalled, Ramanujan replied: ‘No, Hardy! It is a very interesting number. It is the smallest number expressible as the sum of two cubes in two different ways.’(These are and .)Waring’s problem
As we have seen, Lagrange’s four-square theorem