0% found this document useful (0 votes)
8 views7 pages

Ent 05

This chapter discusses the representation of natural numbers as sums of two integer squares, detailing the conditions under which a number can be expressed in this form. It presents Fermat's theorem and its proof, along with a characterization of natural numbers that can be expressed as such sums based on their prime factorization. Additionally, the chapter explores the number of representations of a given natural number as a sum of two squares and provides several related theorems.

Uploaded by

ahysm56
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views7 pages

Ent 05

This chapter discusses the representation of natural numbers as sums of two integer squares, detailing the conditions under which a number can be expressed in this form. It presents Fermat's theorem and its proof, along with a characterization of natural numbers that can be expressed as such sums based on their prime factorization. Additionally, the chapter explores the number of representations of a given natural number as a sum of two squares and provides several related theorems.

Uploaded by

ahysm56
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 7

CHAPTER 5

Sums of Integer Squares

!c W W L Chen, 1981, 2013.


This chapter originates from material used by the author
at Imperial College London between 1981 and 1990.
It is available free to all individuals,
on the understanding that it is not to be used for financial gain,
and may be downloaded and/or photocopied,
with or without permission from the author.
However, this document may not be kept on any information storage and retrieval system
without permission from the author,
unless such system is not accessible to any individuals other than its owners.

5.1. Sums of Two Squares


In this section, we characterize all natural numbers which are representable as the sum of two
integer squares. In other words, we determine all numbers n ∈ N such that the equation
n = x21 + x22
is soluble in x1 , x2 ∈ Z.
The first step in our argument is provided by the following result on the special case when n is a
prime congruent to 1 modulo 4.
Theorem 5.1 (Fermat). Suppose that p ∈ N is prime and p ≡ 1 mod 4. Then p is representable
as the sum of two integer squares; in other words, there exist x1 , x2 ∈ Z such that p = x21 + x22 .
We first give the original proof by Fermat using his method of descent. In the next section, we give
an alternative proof by Thue which contains ideas that we can develop further to study the number
of representations of a natural number as a sum of two integer squares.
Proof of Theorem 5.1. Since p ≡ 1 mod 4, it follows from Theorem 4.3 that (−1/p)L = 1, and
so −1 is a quadratic residue modulo p. The numbers
p−1 p−1
− , . . . , −1, 0, 1, . . . ,
2 2
form a complete set of residues modulo p. It follows that one of the elements, x0 say, satisfies
x20 + 1 ≡ 0 mod p. Since |x0 | < p/2, we must have
! p "2
p ! x20 + 1 < + 1 < p2 .
2
In particular, there exists m ∈ N satisfying 1 ! m < p such that mp can be expressed as a sum of two
integer squares. It now suffices to show that the least positive multiple of p which can be expressed
as a sum of two integer squares must be p itself.
We prove this by showing that if mp, where 1 < m < p, is a sum of two integer squares, then there
exists m0 ∈ N satisfying 1 ! m0 < m such that m0 p is also a sum of two integer squares. Suppose
now that 1 < m < p and
(5.1) mp = x21 + x22 ,
where x1 , x2 ∈ Z. We define y1 , y2 ∈ Z by writing
m m
(5.2) − < y1 < and y1 ≡ x1 mod m,
2 2
and
m m
(5.3) − < y2 < and y2 ≡ x2 mod m.
2 2
33
34 5. SUMS OF INTEGER SQUARES

In view of (5.1), we have y12 + y22 ≡ x21 + x22 ≡ 0 mod m, so there exists m0 ∈ Z such that
(5.4) y12 + y22 = mm0 .
Combining (5.2)–(5.4), we have
! m "2
m2 ! m "2
mm0 ! , + =
2 2 2
so that m0 < m. On the other hand, we must have m0 $= 0, for otherwise y1 = y2 = 0, so that
x1 ≡ x2 ≡ 0 mod m, and so m2 | (x21 + x22 ), whence m | p, contradicting that 1 < m < p. We
therefore must have 1 ! m0 < m. Combining (5.1) and (5.4), we now have
(5.5) m0 pm2 = (x21 + x22 )(y12 + y22 ) = (x1 y1 + x2 y2 )2 + (x1 y2 − x2 y1 )2 .
By (5.1)–(5.3), we have
x1 y1 + x2 y2 ≡ x21 + x22 ≡ 0 mod m,
and
x1 y2 − x2 y1 ≡ x1 x2 − x2 x1 ≡ 0 mod m.
It follows that each term on the right-hand side of (5.5) is divisible by m2 , so that
# $2 # $2
x1 y1 + x2 y2 x1 y2 − x2 y1
m0 p = + ,
m m
and the proof is complete. %
We now determine all the natural numbers which are sums of two integer squares.
Theorem 5.2. Suppose that n ∈ N and n > 1, and the canonical decomposition of n is given by
n = 2r pr11 . . . prkk q1s1 . . . q!s! ,
where the integer r " 0 and r1 , . . . , rk , s1 , . . . , s! ∈ N, and p1 , . . . , pk , q1 , . . . , q! ∈ N are primes
satisfying p1 ≡ . . . ≡ pk ≡ 1 mod 4 and q1 ≡ . . . ≡ q! ≡ 3 mod 4. Then n is a sum of two integer
squares if and only if s1 , . . . , s! are all even.
Proof. Suppose first of all that n = x21 + x22 , where x1 , x2 ∈ Z. Then
(5.6) x21 + x22 ≡ 0 mod q1 .
Suppose on the contrary that s1 is odd. If q1 ! x2 , then it follows from Theorem 3.8 that there exists
x ∈ Z such that x2 x ≡ 1 mod q1 . Multiplying (5.6) by x2 gives (x1 x)2 ≡ −1 mod q1 , impossible
since −1 is a quadratic non-residue modulo q1 . It follows that q1 | x2 , and so q1 | x1 also. Writing
x1 = q1 y1 and x2 = q1 y2 , we have n = q12 (y12 + y22 ). Hence s1 " 3. Repeating the argument on
n/q12 yields s1 − 2 " 3. Repeating the argument a sufficient number of times leads eventually to a
contradiction. It follows that s1 must be even. A similar argument shows that s2 , . . . , s! are all even.
The converse follows from the identity
(5.7) (x21 + x22 )(y12 + y22 ) = (x1 y1 + x2 y2 )2 + (x1 y2 − x2 y1 )2 ,
on noting that we can apply Theorem 5.1 to each of the primes p1 , . . . , pk , that 2 is a sum of two
integer squares, and that qj2 = qj2 + 02 is a sum of two integer squares for every j = 1, . . . , !. %

5.2. Number of Representations


A natural question that arises concerns the number of ways any given n ∈ N can be represented
as a sum of two integer squares. Our starting point is the following alternative proof of Fermat’s
theorem by Thue.
Second Proof of Theorem 5.1. Let x = ( p−1
2 )!. Since 4 | (p − 1), it follows that
p−1
2 is an
even integer, and so
p−1 p−1 p−1
p−1 %
2 %
2 %
2

x2 = (−1) 2 r2 = r(−r) ≡ r(p − r) = (p − 1)! ≡ −1 mod p


r=1 r=1 r=1
by Wilson’s theorem. Hence the congruence
(5.8) x2 + 1 ≡ 0 mod p
5.2. NUMBER OF REPRESENTATIONS 35

is soluble. We now show that if x ∈ Z is a solution of (5.8), then there exist a, b ∈ Z such that
1 1
(5.9) |a| < p 2 , |b| < p 2 , ab $= 0 and ax ≡ b mod p.
If (5.9) holds, then 0 < a2 + b2 < 2p and
a2 + b2 ≡ a2 + (ax)2 = a2 (1 + x2 ) ≡ 0 mod p,
so that a2 + b2 = p. To prove (5.9), consider the numbers of the form ux − v, where u, v ∈ Z satisfy
1 1 1
0 ! u ! p 2 and 0 ! v ! p 2 . There are ([p 2 ] + 1)2 > p choices of such numbers u and v, and only
p residue classes modulo p. It follows from Dirichlet’s box principle that there exist two such pairs
u# , v # and u## , v ## such that u# x − v # and u## x − v ## belong to the same residue class modulo p and so
are congruent to each other modulo p. Now let a = u# − u## and b = v # − v ## . Then
ax − b = (u# − u## )x − (v # − v ## ) ≡ 0 mod p.
1 1
Clearly we have |a| < p 2 and |b| < p 2 . Finally, if b = 0, then we must have a ≡ 0 mod p, and so
a = 0, a contradiction. Hence b $= 0. Similarly a $= 0. %
Our first step towards finding a formula for the number of representations of a natural number as
a sum of two integer squares is the following generalization of the above proof of Fermat’s theorem.
Theorem 5.3. Suppose that n ∈ N and n > 1. For every solution x ∈ Z of the congruence
x2 + 1 ≡ 0 mod n, there exist unique positive integers a, b ∈ N such that
(5.10) (a, b) = 1, a2 + b2 = n and ax ≡ b mod n.
1
Proof. By considering numbers of the form ux − v, where u, v ∈ Z satisfy 0 ! u ! n 2 and
1
0 ! v ! n 2 , we can show as before that there exist non-zero numbers α, β ∈ Z such that
α2 + β 2 = n and αx ≡ β mod n.
Clearly, we may assume without loss of generality that α > 0.
If β > 0, then we let a = α and b = β. Clearly a2 + b2 = n and ax ≡ b mod n.
If β < 0, then we let a = −β and b = α. Again we have a2 + b2 = n. On the other hand, we have
bx ≡ −a mod n, so that bx2 ≡ −ax mod n. It now follows from the assumption x2 ≡ −1 mod n that
ax ≡ b mod n.
To show that (a, b) = 1, note that there exist k, ! ∈ Z such that
x2 + 1 = kn and b = ax + !n.
It follows that
n = a2 + b2 = a2 + (ax + !n)2 = a2 (1 + x2 ) + ax!n + (ax + !n)!n
= a2 kn + ax!n + b!n = (a(ak + x!) + b!)n,
and so a(ak + x!) + b! = 1, whence (a, b) = 1.
Finally, to show uniqueness, suppose that the conclusion holds also for the pair A, B ∈ N. Then
n2 = (a2 + b2 )(A2 + B 2 ) = (aA + bB)2 + (aB − bA)2 .
It follows that 0 < aA + bB ! n. On the other hand, note that
aA + bB ≡ aA + aAx2 = aA(1 + x2 ) ≡ 0 mod n.
We therefore must have aA + bB = n, and so aB − bA = 0. Since (a, b) = (A, B) = 1, we must
therefore have a = A and b = B. %
Theorem 5.4. Suppose that n ∈ N, and T (n) is equal to the number of solutions of the congruence
x2 + 1 ≡ 0 mod n. Then the number of solutions of the equation n = a2 + b2 with (a, b) = 1 is equal
to 4T (n).
Proof. Suppose first of all that n = 1. Clearly T (1) = 1 and the equation 1 = a2 + b2 has four
solutions, namely (a, b) = (±1, 0) and (a, b) = (0, ±1).
Suppose now that n > 1. We have already shown that for every solution x ∈ Z of the congruence
x2 + 1 ≡ 0 mod n, there exist unique positive integers a, b ∈ N such that (5.10) holds. Conversely,
suppose that a, b ∈ N satisfy (a, b) = 1 and n = a2 + b2 . It is easy to see that (a, n) = 1, and so the
congruence ax ≡ b mod n has unique solution.
36 5. SUMS OF INTEGER SQUARES

The above establishes a one-to-one correspondence between the solutions of x2 + 1 ≡ 0 mod n and
numbers a, b ∈ N such that (a, b) = 1 and n = a2 + b2 . The factor 4 occurs if we permit negative
values for a and b. %
Theorem 5.5. Suppose that n ∈ N, and T (n) is equal to the number of solutions of the congruence
x2 + 1 ≡ 0 mod n. Then T (n) = 0 if 4 | n or if n is divisible by a prime q ≡ 3 mod 4. Otherwise we
have T (n) = 2k , where k is the number of distinct odd prime factors of n.
Proof. Clearly the result is valid if n = 1, so we assume that n > 1. It is not too difficult to show
that T (n) is a multiplicative function. It follows that if the canonical decomposition of n is given by
n = 2r pr11 . . . prkk q1s1 . . . q!s! ,
where the integer r " 0 and r1 , . . . , rk , s1 , . . . , s! ∈ N, and p1 , . . . , pk , q1 , . . . , q! ∈ N are primes
satisfying p1 ≡ . . . ≡ pk ≡ 1 mod 4 and q1 ≡ . . . ≡ q! ≡ 3 mod 4, then
T (n) = T (2r )T (pr11 ) . . . T (prkk )T (q1s1 ) . . . T (q!s! ).
It is easy to check that T (2) = 1. Also, the congruence x2 ≡ −1 mod 4 has no solutions, and so
the congruence x2 ≡ −1 mod 2r has no solutions for any r " 2. Hence T (2r ) = 0 for every r " 2,
and so T (n) = 0 if 4 | n.
Suppose next that q ∈ N is a prime satisfying q ≡ 3 mod 4. Since −1 is a quadratic non-residue
modulo q, it follows that the congruence x2 ≡ −1 mod q has no solutions, and so the congruence
x2 ≡ −1 mod q s has no solutions for any s " 1. Hence T (q s ) = 0 for every s " 1, and so T (n) = 0 if
q | n.
To complete the proof, it suffices to show that for every prime p ∈ N satisfying p ≡ 1 mod 4,
we have T (pr ) = 2 for every r " 1. Suppose that r ∈ N is fixed. Any solution of the congruence
x2 ≡ −1 mod pr can be assumed to be an element in the set
R = {x ∈ N : 0 < x < pr , p ! x}.
Now any x ∈ R must satisfy the congruence x2 ≡ m mod pr for some number m ∈ N satisfying
0 < m < pr and (m/p)L = 1. There are 12 (p − 1) numbers m ∈ N satisfying 0 < m < p and
(m/p)L = 1, and so there are 12 (p − 1)pr−1 = 12 φ(pr ) numbers m ∈ N satisfying 0 < m < pr and
(m/p)L = 1. Suppose now that x2 ≡ y 2 mod pr and p ! x. Then pr | (x + y)(x − y), so that p | (x + y)
or p | (x − y); but not both, for otherwise p must divide their sum 2x, a contradiction. It follows
that pr | (x + y) or pr | (x − y), and so x ≡ ±y mod pr . Hence for each of the 12 φ(pr ) numbers
m ∈ N satisfying 0 < m < pr and (m/p)L = 1, there are at most two numbers x ∈ R such that
x2 ≡ m mod pr . Since R contains precisely φ(pr ) elements, it follows that for each of the 12 φ(pr )
numbers m ∈ N satisfying 0 < m < pr and (m/p)L = 1, there are precisely two numbers x ∈ R such
that x2 ≡ m mod pr . Note now that −1 is a quadratic residue modulo p. It follows that there are
precisely two numbers x ∈ R such that x2 ≡ −1 mod pr , and so T (pr ) = 2. %
Theorem 5.6. Suppose that n ∈ N, and S(n) is equal to the number of solutions of the equation
n = a2 + b2 in numbers a, b ∈ Z. Then
& !n"
S(n) = 4 T ,
2
d2
d |n

where for every n ∈ N, the number T (n) is equal to the number of solutions of the congruence
x2 + 1 ≡ 0 mod n.
Proof. Suppose that a, b ∈ Z satisfy d = (a, b). Clearly d2 | n. Now write a1 = a/d and b1 = b/d,
and identify the pair a, b with the pair a1 , b1 , where clearly
n
= a21 + b21 and (a1 , b1 ) = 1.
d2
The result now follows on noting Theorem 5.4. %
By the non-principal character modulo 4, we mean the function χ : N → R, defined for every m ∈ N
by

 0, if m ≡ 0 mod 2,
χ(m) = 1, if m ≡ 1 mod 4,

−1, if m ≡ 3 mod 4.
5.2. NUMBER OF REPRESENTATIONS 37

Theorem 5.7. Suppose that n ∈ N, and S(n) is equal to the number of solutions of the equation
n = a2 + b2 in numbers a, b ∈ Z. Then
&
S(n) = 4 χ(m),
m|n

where χ : N → R is the non-principal character modulo 4.

Proof. For every n ∈ N, write


&
χ(m) = W (n).
m|n

It is not difficult to show that the function χ(n) is multiplicative, and so it follows from Theorem 2.1
that the function W (n) is also multiplicative. On the other hand, recall that the function T (n) is
multiplicative. It follows from Theorem 5.6, in a way similar to the proof of Theorem 2.1, that if
(n1 , n2 ) = 1, then
S(n1 n2 ) S(n1 ) S(n2 )
= .
4 4 4
To complete the proof, it therefore suffices to show that for any prime p ∈ N and any r ∈ N, we have
S(pr )
= W (pr ),
4
since the result is obvious for n = 1.
Consider first of all
S(pr ) & # pr $
= T .
4 2 r
d2
d |p

If r is even, then

S(pr )  1, if p = 2,
= T (pr ) + T (pr−2 ) + . . . + T (p2 ) + T (1) = 1, if p ≡ 3 mod 4,
4 
r + 1, if p ≡ 1 mod 4.
If r is odd, then

S(pr )  1, if p = 2,
= T (pr ) + T (pr−2 ) + . . . + T (p3 ) + T (p) = 0, if p ≡ 3 mod 4,
4 
r + 1, if p ≡ 1 mod 4.
Hence

 1,
 if p = 2,
S(pr )  1, if p ≡ 3 mod 4 and r is even,
=
4 
 0, if p ≡ 3 mod 4 and r is odd,

r + 1, if p ≡ 1 mod 4.

Consider next W (pr ) = χ(pr ) + . . . + χ(p) + 1. We can show that χ(pu ) = (χ(p))u for every u ∈ N.
Hence


 1, if p = 2,

1, if p ≡ 3 mod 4 and r is even,
W (p ) = (χ(p)) + . . . + χ(p) + 1 =
r r

 0, if p ≡ 3 mod 4 and r is odd,

r + 1, if p ≡ 1 mod 4.
This completes the proof. %

Remark. The above treatment is due to Landau (1927) and is likely to have been influenced by
Dirichlet’s work concerning primes in arithmetic progressions.
38 5. SUMS OF INTEGER SQUARES

5.3. Sums of Four Squares


We now study the problem of representing natural numbers as sums of four integer squares, and
show that this is always possible.
Theorem 5.8 (Lagrange). Every n ∈ N is representable as the sum of four integer squares; in
other words, for every n ∈ N, there exist x1 , x2 , x3 , x4 ∈ Z such that n = x21 + x22 + x23 + x24 .
Proof. In view of the identity
(5.11) (x21 + x22 + x23 + x24 )(y12 + y22 + y32 + y42 )
2 2
= (x1 y1 + x2 y2 + x3 y3 + x4 y4 ) + (x1 y2 − x2 y1 + x3 y4 − x4 y3 )
2 2
+ (x1 y3 + x3 y1 − x2 y4 + x4 y2 ) + (x1 y4 − x4 y1 − x3 y2 + x2 y3 ) ,
it suffices to show that every prime can be expressed as a sum of four integer squares. Clearly
2 = 12 + 12 + 02 + 02 . On the other hand, it follows from Theorem 5.1 that every prime p ≡ 1 mod 4
is a sum of four integer squares. It therefore remains to prove that every prime q ≡ 3 mod 4 is a sum
of four integer squares.
Naturally the number 1 is a quadratic residue modulo q. Let a ∈ N be the smallest number in the
range 1 ! a ! q − 2 such that a + 1 is a quadratic non-residue modulo q, so that
# $ # $
a+1 a
= −1 and = 1.
q L q L
Since q ≡ 3 mod 4, it follows from Theorem 4.3 that (−1/q)L = −1, and so
# $ # $# $
−a − 1 −1 a+1
= = 1.
q L q L q L
In other words, there exist integers x1 and x2 in the complete set
q−1 q−1
− , . . . , −1, 0, 1, . . . ,
2 2
of residues modulo q such that x21 ≡ a mod q and x22 ≡ −a − 1 mod q. Hence
x21 + x22 + 12 + 02 ≡ 0 mod q
and
! q "2
q ! x21 + x22 + 1 < 2 + 1 < q2 .
2
In particular, there exists m ∈ N satisfying 1 ! m < q such that mq can be expressed as a sum of four
integer squares. It now suffices to show that the least positive multiple of q which can be expressed
as a sum of four integer squares must be q itself.
We prove this by showing that if mq, where 1 < m < q, is a sum of four integer squares, then there
exists m0 ∈ N satisfying 1 ! m0 < m such that m0 q is also a sum of four integer squares. Suppose
now that 1 < m < q and
(5.12) mq = x21 + x22 + x23 + x24 ,
where x1 , x2 , x3 , x4 ∈ Z. Suppose that m is even. Then the right hand side of (5.12) must be even. It
follows that an even number of the four terms x1 , x2 , x3 , x4 must be even, so we may assume without
loss of generality that x1 ≡ x2 mod 2 and x3 ≡ x4 mod 2. It follows that
# $2 # $2 # $2 # $2
m x1 + x2 x1 − x2 x3 + x4 x3 − x4
q= + + + .
2 2 2 2 2
We can therefore assume that m is odd. For i = 1, 2, 3, 4, let yi ∈ Z satisfy
m m
(5.13) − < yi < and yi ≡ xi mod m.
2 2
In view of (5.12) and (5.13), we have
y12 + y22 + y32 + y42 ≡ x21 + x22 + x23 + x24 ≡ 0 mod m,
so there exists m0 ∈ Z such that
(5.14) y12 + y22 + y32 + y42 = mm0 .
5.4. SUMS OF THREE SQUARES 39

Combining (5.13) and (5.14), we have


! m "2
mm0 < 4 = m2 ,
2
so that m0 < m. On the other hand, we must have m0 $= 0, for otherwise yi = 0 for every i = 1, . . . , 4,
so that xi ≡ 0 mod m, and so m2 | (x21 + x22 + x23 + x24 ), whence m | q, contradicting that 1 < m < q.
We therefore must have 1 ! m0 < m. Combining (5.11), (5.12) and (5.14), we now have
2 2
(5.15) m0 qm2 = (x1 y1 + x2 y2 + x3 y3 + x4 y4 ) + (x1 y2 − x2 y1 + x3 y4 − x4 y3 )
2 2
+ (x1 y3 + x3 y1 − x2 y4 + x4 y2 ) + (x1 y4 − x4 y1 − x3 y2 + x2 y3 ) .
By (5.12) and (5.13), we have
x1 y1 + x2 y2 + x3 y3 + x4 y4 ≡ x21 + x22 + x23 + x24 ≡ 0 mod m.
Also each of the terms
x1 y2 − x2 y1 + x3 y4 − x4 y3 , x1 y3 + x3 y1 − x2 y4 + x4 y2 , x1 y4 − x4 y1 − x3 y2 + x2 y3
is congruent to 0 modulo q. It follows that each term on the right hand side of (5.15) is divisible
by m2 , so that m0 q is a sum of four integer squares. %

5.4. Sums of Three Squares


The situation is very different in the case of three integer squares. The main reason is that there
is no analogue of (5.7) and (5.11) in this case. We only concern ourselves with the following simple
theorem.
Theorem 5.9. No integer of the form 4k (8m + 7), where k, m ∈ N ∪ {0}, can be represented as a
sum of three squares.
Proof. Note first of all that every integer square is congruent to 0, 1, 4 modulo 8, so that (8m + 7)
is never a sum of three squares for any m ∈ Z. Hence the conclusion of Theorem 5.9 is true for k = 0.
We now proceed by induction on k. Suppose that 4s (8m + 7) is never a sum of three squares for
any m ∈ Z. We show that 4s+1 (8m + 7) is never a sum of three squares for any m ∈ Z. Suppose on
the contrary that
4s+1 (8m + 7) = x21 + x22 + x23 ,
where x1 , x2 , x3 ∈ Z. Since x2 ≡ 0 mod 4 if x is even and x2 ≡ 1 mod 4 if x is odd, it follows that
each of x1 , x2 , x3 must be even, so that
! x "2 ! x "2 ! x "2
1 2 3
4s (8m + 7) = + + ,
2 2 2
a contradiction. %
A result of Legendre in 1798 says that every other natural number can be written as a sum of three
integer squares. The main idea involves binary and ternary quadratic forms, and we do not develop
these ideas here.

You might also like