Zagier's Windmills
Fermat's Christmas theorem · interactive proof

Zagier's Windmills

TheoremEvery prime p ≡ 1 (mod 4) is a sum of two squares.

Fermat announced this in a letter to Mersenne dated 25 December 1640. In 1990 Don Zagier gave a proof one sentence long; Alexander Spivak later noticed that the sentence describes pictures of windmills. Pick a prime, play with its windmills, and watch the proof hand you the two squares.

Choose a prime, 1 mod 4

One windmill, two involutions

A triple (x, y, z) of positive integers with x² + 4yz = p is drawn as an x×x square with four y×z sails attached in a pinwheel. Every cell is one unit, so the picture has exactly p cells. Call the set of all such triples S.

square x²four sails y×zthick line = outline
(1, 1, 10)

The proof as a walk

Start at the one windmill that ζ leaves alone, (1, 1, k) with p = 4k + 1. Apply τ, then ζ, then τ, and so on. Each map undoes itself, so the walk can never revisit a windmill, and it can only stop at a fixed point. The only ζ-fixed point is where we started, so the walk ends at a windmill with square sails.

All of S, sorted into pairs

An involution splits a finite set into 2-element orbits and fixed points, so the parity of |S| equals the parity of the number of fixed points. Toggle between the two involutions and count.

The proof, written out

S = { (x, y, z) ∈ ℕ³ : x² + 4yz = p }

S is finite and nonempty. Each coordinate is at most p, and (1, 1, k) ∈ S because p = 4k + 1. Note x is always odd.

Zagier's map is an involution of S. Define

ζ(x, y, z) =  (x + 2z, z, y − x − z)  if x < y − z,
     (2y − x, y, x − y + z)  if y − z < x < 2y,
     (x − 2y, x − y + z, y)  if x > 2y.

The boundary cases cannot occur: x = y − z would give p = (y + z)², and x = 2y would make p even. A direct substitution shows each output again satisfies x² + 4yz = p with positive entries, that case 1 is sent to case 3 and back, and case 2 to itself; in every case ζ(ζ(w)) = w. In pictures: ζ keeps the outline of the windmill and redraws the inside with a different central square (mirrored in case 2). The applet checks this cell by cell for every windmill you load.

ζ has exactly one fixed point. A fixed point must lie in case 2 (cases 1 and 3 change x), and there 2y − x = x forces x = y. Then p = x(x + 4z), and primality gives x = 1, so the fixed point is (1, 1, k): the plus-sign windmill.

So |S| is odd. The non-fixed points of ζ come in pairs, and there is one fixed point.

Hence τ has a fixed point. The swap τ(x, y, z) = (x, z, y) is also an involution of S; it flips each sail across the diagonal of the square through the sail's corner. An involution of a set of odd size has an odd number of fixed points, in particular at least one: some (x, y, y) ∈ S.

Conclusion. Then p = x² + 4y² = x² + (2y)². Geometrically, the four y×y sails slide together into one 2y×2y square. ∎

Full proof: the parity lemmasLemmas 2.3 and 2.4

Lemma 2.3. Let f : S → S be an involution which fixes only one point. Then |S| is odd.

Proof. For all points x ≠ q, f(x) ≠ 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. □

As (2.1) has exactly one fixed point, |S| = 2k + 1 is odd. Now let g : (x, y, z) ↦ (x, z, y) be an involution on S.

Lemma 2.4. Let f : S → 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. □

Here (2.1) is Zagier's map ζ, whose unique fixed point is (1, 1, k), and g is the swap τ. By Lemma 2.4, g has a fixed point (x, y, y), which gives p = x² + (2y)².

Zagier's original: D. Zagier, “A one-sentence proof that every prime p ≡ 1 (mod 4) is a sum of two squares”, Amer. Math. Monthly 97 (1990), 144. The proof is non-constructive as written, but the walk above, which alternates the two involutions, turns it into an algorithm. For p ≡ 3 (mod 4) the set S is empty, since x² + 4yz ≡ 1 (mod 4) for odd x.