Section 13.5 All the Squares Fit to be Summed
There is one loose end. What are all the numbers we can represent as a sum of squares?
For instance, why are some composite numbers of the form not writeable as the sum of two squares? Also, many even numbers are representable – how do we tell which even numbers are writeable? We conclude our discussion by proving the full statement, after a couple of preliminary lemmas.
Proof.
Each of those primes is representable, so we can use Fact 13.1.9 to write all intermediate products as a sum of squares. Hence all such products are representable.
Example 13.5.2.
Lemma 13.5.3.
If the powers of prime factors of of the form are only even powers, then is writeable as a sum of two squares.
Proof.
First, (even if is not prime) is trivially always representable, since Now, rather than using Fact 13.1.9, let be the product of all prime factors of the form which is necessarily a perfect square given that all the powers are even. We can simply multiply this by which is possible by Lemma 13.5.1 since removes all primes of the form in the prime factorization. This yields
Example 13.5.4.
Theorem 13.5.5.
Proof.
From 13.5.1 and 13.5.3, the only case left to consider if has a prime of the form but to an odd power. This seemed to be the bottleneck in our exploration.
By way of contradiction, suppose that it is possible to write
First, divide this equation by any factors of common to and to get
The power of we divided by (so that ) must be an even power, since each term on the right-hand side is a perfect square and can only contribute even powers of primes by the Fundamental Theorem of Arithmetic.
Since had an odd power of we know still has an odd power of dividing it, yet
Take everything modulo to get the congruence
Since we can multiply this congruence by to get
This is a contradiction, as by Fact 13.3.2 there is no square root of modulo for finishing the proof!
Example 13.5.6.
This theorem fully explains why and the others mentioned in Fact 13.1.2 cannot be written as a sum of squares.
If the whole theorem still seems too neat and dried, it can be instructive to get insight by plugging in different below. When do you get an error, when not?
xxxxxxxxxx
n=20
print(factor(n))
print(two_squares(n))
(As a bonus, can you turn this into an interactive cell? See Sage note 12.6.8.)