Continued fractions and Diophantine equations · Definition
Sum of two squares
Before you start you need to know
Determining which integers are sums of two squares is a classic question in number theory. Fermat solved it for odd primes, and the general case relies on the ideas of quadratic residues.
Definition
An integer \(n\) is a sum of two squares if it can be written as the sum of the squares of two integers.
Fermat proved that an odd prime \(p\) is a sum of two squares if and only if \(p \equiv 1 \pmod{4}\). For a general integer, the identity \((a^2+b^2)(c^2+d^2) = (ac-bd)^2 + (ad+bc)^2\) shows that a product of sums of two squares is again a sum of two squares, and the complete criterion requires every prime \(q \equiv 3 \pmod{4}\) to appear with even exponent.
Take \(n = 45 = 3^2 \cdot 5\). The prime 3 appears with even exponent and \(5 \equiv 1 \pmod{4}\), so \(45\) is a sum of two squares; in fact \(45 = 3^2 + 6^2\).
A typical mistake is thinking that \(n \equiv 1 \pmod{4}\) is enough. For example, \(21 \equiv 1 \pmod{4}\), but \(21 = 3 \cdot 7\) has two primes \(\equiv 3 \pmod{4}\) with odd exponent, so it is not a sum of two squares.
Think about it
Why is 21 not a sum of two squares even though \(21 \equiv 1 \pmod{4}\)?
Because \(21 = 3 \cdot 7\), and the primes \(3\) and \(7\) are both \(\equiv 3 \pmod{4}\) with odd exponent.
Exercises 10
- According to Fermat's criterion, when is an odd prime \(p\) a sum of two squares?
- Which of these equalities is correct?
- Which of these numbers is NOT a sum of two squares?
- What is the first prime of the form \(4k+1\)?
- Is the number 2 a sum of two squares?
- Decide whether 37 is a sum of two squares using Fermat's criterion.
- Is 65 a sum of two squares?
- Is 63 a sum of two squares? (Recall that \(63 = 3^2 \cdot 7\).)
- Let \(n = 2 \cdot 5^2 \cdot 11\). Is \(n\) a sum of two squares?
- What is the smallest positive integer that can be written as a sum of two squares in two different ways, using positive integers?
References
- David M. Burton, Elementary Number Theory, 7th edition, McGraw-Hill, 2011. cap. 13
- Ivan Niven, Herbert S. Zuckerman, Hugh L. Montgomery, An Introduction to the Theory of Numbers, 5th edition, Wiley, 1991. cap. 3