Formal Book

4 Representing numbers as sums of two squares

Lemma 4.1 Lemma 1

For primes \(p = 4m + 1\) the equation \(s^2 \equiv -1 (\mod p)\) has two solutions \(s \in \{ 1, 2, \dots , p - 1\} \), for \(p = 2\) there is one such solution, while for primes of the form \(p = 4m + 3\) there is no solution.

Proof

TODO

Lemma 4.2 Lemma 2

No number \(n = 4m + 3\) is a sum of two squares.

Proof

TODO

Proposition 4.3 First proof

Every prime of the form \(p = 4m + 1\) is a sum of two squares, that is, it can be written as \(p = x^2 + y^2\) for some natural numbers \(x,y \in \mathbb {N}\).

Proof

TODO

Proposition 4.4 Second proof

Every prime of the form \(p = 4m + 1\) is a sum of two squares, that is, it can be written as \(p = x^2 + y^2\) for some natural numbers \(x,y \in \mathbb {N}\).

Proof

TODO (Zagier’s one line proof is in mathlib by now, follow this!)

Proposition 4.5 Third proof

Every prime of the form \(p = 4m + 1\) is a sum of two squares, that is, it can be written as \(p = x^2 + y^2\) for some natural numbers \(x,y \in \mathbb {N}\).

Proof

TODO

Theorem 4.6

A natural number \(n\) can be represented as a sum of two squares if and only if every prime factor of the form \(p = 4m + 3\) appears with an even exponent in the prime decomposition of \(n\).

Proof

TODO