Continued fractions and Diophantine equations · Definition

Sum of two squares

elementary number theorycontinued fractions and diophantine equations

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.

\[n = x^{2} + y^{2}\]

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

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