Counting one rectangle, twice
Worth reading first: Numbers that wrap · Two dials at once.
On a dial of eleven, some numbers are squares and some are not. are — they are — and the other five are not. Asking whether seven is a square modulo eleven is a question with a yes-or-no answer and no obvious structure to it.
Asking the same question the other way round — is eleven a square modulo seven? — looks like a different question about different objects. The two answers are connected, and quadratic reciprocity is the connection.
That figure is the whole theorem. What remains is to say why counting dots on two sides of a line answers two questions about remainders.
The symbol, and the criterion
Write for if is a non-zero square modulo and if it is not. Euler’s criterion says
which follows from Fermat’s little theorem: , so squares to one and must be ; and it is exactly for the squares, because the squares form the image of a two-to-one map and therefore make up half the residues.
The symbol is multiplicative — , immediately from the criterion — so knowing it for every prime determines it for every number. Together with the splitting of a composite modulus, that reduces every question about squares modulo anything to the two-prime case, which is the case reciprocity settles.
Quadratic reciprocity. For distinct odd primes and ,
In words: the two questions have the same answer, unless both primes leave remainder three on division by four, in which case they have opposite answers.
Gauss called it the theorema aureum, proved it eight different ways, and it was the result he returned to more often than any other. Over two hundred proofs are now known.
Gauss’s lemma: fold the top half down
The bridge from the symbol to a count is a lemma about where multiples land.
Take the multiples , reduce them modulo , and fold anything above down by replacing with . Two facts, both visible: the folded values are all different, and they are exactly in some order.
Multiplying the original multiples gives . Multiplying the folded ones gives again, with a sign of for each fold. Cancelling the factorial,
So the symbol is a parity, and parities can be counted.
Where the rectangle comes from
Counting folds is a count of for which exceeds , and Eisenstein’s contribution — he was twenty when he found it — is that this count has the same parity as a much tidier one:
And that sum is a count of lattice points. The term is the number of whole numbers with — the lattice points in column lying below the line .
So , where is the number of lattice points strictly below the diagonal of a by rectangle.
Now run the same argument with and swapped. By symmetry — reflecting the rectangle in its diagonal — the count for is the number of lattice points above the line.
Every point in the rectangle is on one side or the other, because no lattice point lies on the diagonal: a point on would need with and , and since and are distinct primes that is impossible. So
and multiplying the two symbols gives , which is the theorem.
Why this is a good proof
The argument is short and its shape is worth naming, because the shape is the reason it explains rather than merely verifies.
The two Legendre symbols look like statements about two different dials. Eisenstein’s count turns each into a statement about one geometric object — the same rectangle, examined from two sides — and the theorem becomes the observation that the two sides of a line account for all of it.
That is counting one collection two ways in its most consequential appearance. There is no computation in it beyond a floor function, no analysis, and no clever substitution; the entire content is that a rectangle has an inside and a diagonal misses every point of it.
It also explains the strange condition. The product of the symbols is exactly when and are both odd, which is when both primes are — and that is just the statement that a rectangle has an odd number of points only when both its sides are odd. A congruence condition that looks arbitrary in the theorem is a parity of a rectangle in the picture.
The clause that carries the most weight is the one easiest to skim: no lattice point lies on the diagonal. Without it the two counts would not add to the total, the parities would not compose, and the theorem would say nothing. It holds because and are distinct primes, so forces , and is smaller than . The whole result rests on an emptiness — a line through a grid missing every point of it — which is the same shape of argument as the walk that fills a coprime grid and stalls on a shared factor.
Every figure on this page checks that emptiness explicitly before counting anything, which is the only honest way to draw a proof whose load-bearing step is that something is absent.
Half of everything is a square
Before the theorem, it is worth being clear about how much structure there is to explain, because the raw facts look like noise.
So on any odd prime dial exactly half the non-zero residues are squares, and the halves are not random: the product of two squares is a square, the product of two non-squares is a square, and the product of a square and a non-square is not. The Legendre symbol is a group homomorphism onto , which is why multiplicativity was immediate above.
Beyond that, almost nothing about which residues are squares is predictable from the dial alone. The list for eleven is ; for thirteen it is ; and no pattern in either list survives to the other. What reciprocity supplies is the only general structure there is, and it does not describe the list — it relates one dial’s answer about a prime to another dial’s answer about a different prime.
That is worth stating plainly because it sets expectations correctly. The theorem does not say which numbers are squares modulo . It says that the answer for modulo and the answer for modulo are the same question asked twice, and everything computational follows from being able to switch between them.
What the picture cannot show
The rectangle is drawn for two small primes and the theorem is about all of them. That much is familiar; two other limits are specific to this result.
The picture handles two distinct odd primes, and the theorem has two supplements that no rectangle covers. Whether is a square modulo is decided by , and whether is a square is decided by . Both are proved by Gauss’s lemma directly — count the folds for and — and neither has a rectangle, because is not an odd prime and is not a prime at all. The three statements together are what is actually used, and the drawing carries only the largest of them.
More deeply, the picture explains the mechanism and not the significance. Reciprocity is the first case of a pattern that runs through the whole of algebraic number theory: whether a prime splits in a field is decided by a congruence condition on that prime. Cubic and biquadratic reciprocity extend it; Artin reciprocity, the central theorem of class field theory, is the general statement; and none of that is visible in a rectangle of dots. What the figure shows is exactly why the two-prime case is true and nothing about why anybody would look for a general version.
What it is used for
Reciprocity is not only beautiful; it is the reason the Legendre symbol can be computed quickly.
Deciding whether is a square modulo by Euler’s criterion needs a modular exponentiation. Deciding it by reciprocity needs a sequence of reductions: flip the symbol, reduce the top modulo the bottom, pull out factors of two using the supplement, and repeat. That is Euclid’s algorithm with a sign attached, and it runs in logarithmic time without any exponentiation at all.
The algorithm matters. Solovay–Strassen primality testing compares the Jacobi symbol, computed by reciprocity, against Euler’s criterion, computed by exponentiation, and a mismatch proves compositeness. Deciding whether a quadratic congruence has a solution — needed constantly in factoring algorithms, in elliptic curve arithmetic, and in choosing parameters for cryptographic groups — is a reciprocity computation.
There is a pleasing circularity in that. The theorem says two questions have linked answers; the algorithm exploits the link to answer either one cheaply; and the cheapness is what makes the theorem a tool rather than an ornament.
Working one out by hand
The algorithm is short enough to run through once, and doing so shows why the theorem is worth having computationally rather than only aesthetically.
Is a square modulo ? Both are odd, is prime, and . By multiplicativity the question splits, and by reciprocity each piece flips.
: both and are , so the symbols are opposite and . Now , and is not a square modulo , so and the piece is .
: , so the symbols agree and this is . Reducing, , so the question becomes . Nine is a square, so that factor is ; and , so by the second supplement .
So and is a square modulo — reached in four lines, without computing a single power, and without finding the square root. Euler’s criterion would have answered the same question with a -fold exponentiation, and for primes of cryptographic size the difference between the two methods is the difference between practical and not.
Notice what the computation never does. It does not produce the number whose square is ; deciding whether a square root exists and finding it are separate problems, and the second one is genuinely harder — for a general prime it needs the Tonelli–Shanks algorithm, and modulo a composite it is equivalent to factoring. This is the same split between existence and construction that the pigeonhole argument and Euclid’s proof about primes both run into, and here it has a practical consequence: the ease of the first problem and the difficulty of the second are together the basis of several cryptographic schemes.
Eight proofs, and why
Gauss found the first proof in 1796, aged nineteen, after a year of work, and published it in the Disquisitiones in 1801. He then published five more and left two in his papers.
The reason for the accumulation is not obsession. Gauss’s first proof is a long induction that convinces without explaining; each later proof came from a different direction — Gauss sums, counting arguments, cyclotomy — and each direction turned out to generalise differently. The proof by Gauss sums is the one that extends to higher reciprocity laws; the counting proof, refined by Eisenstein into the argument above, is the one that can be drawn.
A theorem with two hundred proofs is a theorem sitting at a junction. What the proofs have in common is only the statement; what they differ in is which larger theory they are the first case of, and finding out which of those theories exists was a century of work.
The history before Gauss is worth a line, because the theorem was seen before it was proved. Euler stated it, in a form he could not establish, some thirty years earlier; Legendre published a proof in 1785 that assumed, without noticing, a case of Dirichlet’s theorem on primes in arithmetic progressions — which would not be proved for another fifty years, and whose proof does not use reciprocity, so the argument was repairable rather than circular. Legendre also introduced the symbol and gave the theorem its modern shape.
That pattern — a statement recognised from numerical evidence long before anybody can prove it — is characteristic of this subject and it is the reason the habit of testing a claim matters so much here. Euler had tables. The tables were right, the pattern in them was real, and the distance from seeing it to proving it was three decades and a nineteen-year-old.
Where the ladder goes next
Quadratic residues decide more than they look. Whether is a square modulo is exactly the condition that decides which primes are sums of two squares, so the first supplement of this theorem and Fermat’s two-square theorem are the same statement in two languages.
The other direction leads out of elementary number theory altogether. The pattern “a congruence condition on decides how behaves in a larger structure” is class field theory, and reciprocity is its first and smallest case — reachable, as this essay shows, by drawing fifteen dots and a diagonal.
What links here
Computed from the collection, not written here: the essays that point at this one.
Shares its objects with
Essays that name at least two of the same things, and that neither author linked.
- Numbers that are their own parts — both name counting two ways, primes
- One way to factor, and no other — both name counting two ways, primes
- Pascal's triangle, in two colours — both name parity, primes
- The primes on a spiral, and a pattern nobody ordered — both name parity, primes
- The shape of a number's divisors — both name counting two ways, lattice
- The square that cannot shrink — both name counting two ways, parity
Named objects
A dashed tag is an object no other essay names yet.
Counting two waysGauss lemmaLatticeLegendre symbolModular arithmeticParityPrimesQuadratic reciprocityQuadratic residue