Lab · Elementary number theory
Zagier's Windmills
Fermat's Christmas theorem, proved by redrawing a picture.
On 25 December 1640 Fermat wrote to Mersenne that every prime $p \equiv 1 \pmod 4$ is a sum of two squares: $5 = 1^2 + 2^2$, $13 = 2^2 + 3^2$, $41 = 4^2 + 5^2$. In 1990 Don Zagier published a proof that is one sentence long. Alexander Spivak later noticed that the sentence is really about pictures of windmills.
Consider the finite set $$S = \{(x, y, z) \in \mathbb{N}^3 : x^2 + 4yz = p\}.$$ Draw $(x, y, z)$ as an $x \times x$ square with four $y \times z$ rectangles (the sails) attached in a pinwheel. The picture has exactly $x^2 + 4yz = p$ unit cells. In the applet, pick a prime, apply Zagier's map $\zeta$ and the swap $\tau$, and press Walk to the answer to watch the proof produce the two squares.
The proof
Zagier's involution. Define $\zeta : S \to S$ by $$\zeta(x, y, z) = \begin{cases} (x + 2z,\ z,\ y - x - z) & \text{if } x < y - z, \\ (2y - x,\ y,\ x - y + z) & \text{if } y - z < x < 2y, \\ (x - 2y,\ x - y + z,\ y) & \text{if } x > 2y. \end{cases} \tag{2.1}$$ The boundary cases cannot occur: $x = y - z$ would give $p = (y + z)^2$, and $x = 2y$ would make $p$ even. Substituting shows that each output lies in $S$, that the first and third cases are exchanged, and that the middle case is sent to itself; in every case $\zeta(\zeta(w)) = w$. In the picture, $\zeta$ keeps the outline of the windmill and redraws its inside with a different central square (mirrored in the middle case).
One fixed point. A fixed point of $\zeta$ must lie in the middle case, since the other two change $x$. There $2y - x = x$ forces $x = y$, so $p = x(x + 4z)$, and since $p$ is prime, $x = 1$. The only fixed point is $(1, 1, k)$ with $p = 4k + 1$: the plus-sign windmill.
Conclusion. So $|S|$ is odd. The swap $g(x, y, z) = (x, z, y)$ is another involution of $S$, so it has a fixed point $(x, y, y)$, and $$p = x^2 + 4y^2 = x^2 + (2y)^2.$$ Geometrically, the four $y \times y$ sails fit together into a single $2y \times 2y$ square. $\blacksquare$
Full proof: the parity lemmas
Lemma 2.3. Let $f : S \to S$ be an involution which fixes only one point. Then $|S|$ is odd.
Proof. For all points $x \neq q$, $f(x) \neq x$, and $f(f(x)) = x$. Then we can express $f$ as a permutation consisting of $k$ disjoint 2-cycles and one 1-cycle. As the $k$ transpositions are disjoint, no element appears in two transpositions, so there are $2k$ elements which are not fixed by $f$. As $f$ fixes 1 element, $f$ acts on a set of order $2k + 1$ for some natural number $k$; equivalently, $|S|$ is odd. $\square$
As (2.1) has exactly one fixed point, $|S| = 2k + 1$ is odd. Now let $g : (x, y, z) \mapsto (x, z, y)$ be an involution on $S$.
Lemma 2.4. Let $f : S \to S$ be a function, and let $|S|$ be odd. If $f$ has no fixed points, then $f$ isn't an involution.
Proof. If $f$ is an involution, then $f$ can be written as the product of disjoint 2-cycles, yet each 2-cycle acts on exactly 2 elements of $S$ and fixes all the others, so any composition of $n$ disjoint transpositions acts on $2n$ elements of $S$. So if $f$ acts on $2k + 1$ elements of $S$, then it cannot be expressed as the product of disjoint transpositions, and therefore $f$ isn't an involution. $\square$
By Lemma 2.4, $g$ has a fixed point $(x, y, y)$, which gives $p = x^2 + (2y)^2$.
From existence to an algorithm
As written, the proof only shows that a fixed point of $g$ exists. Alternating the two involutions finds one: start at $(1, 1, k)$ and apply $g$, $\zeta$, $g$, $\zeta, \dots$. Each map undoes itself, so the walk never revisits a triple, and it can only stop at a fixed point. The only fixed point of $\zeta$ is the starting point, so the walk ends at some $(x, y, y)$. For $p = 41$ it takes 10 steps and ends at $(5, 2, 2)$, giving $41 = 5^2 + 4^2$.
Since $p$ is odd, $x$ is odd, so $x^2 + 4yz \equiv 1 \pmod 4$. For $p \equiv 3 \pmod 4$ the set $S$ is empty, consistent with the fact that such primes are never sums of two squares.
Further reading
- D. Zagier, “A one-sentence proof that every prime $p \equiv 1 \pmod 4$ is a sum of two squares”, Amer. Math. Monthly 97 (1990), 144.
- M. Aigner and G. M. Ziegler, Proofs from THE BOOK, Springer, chapter “Representing numbers as sums of two squares”.