Number theory — quadratic reciprocity
Quadratic reciprocity relates whether an odd prime is a square modulo another odd prime to whether is a square modulo . In words: for distinct odd primes , the two Legendre symbols and are equal unless both , in which case they differ in sign. It applies to solving congruences . Conjectured by Euler and Legendre, first fully proved by Gauss (1796–1801), who called it the "golden theorem."The law of quadratic reciprocity is one of the central results of elementary number theory. For an odd prime and an integer not divisible by , we say is a quadratic residue mod if has a solution, and a non-residue otherwise. The Legendre symbol encodes this as or . The remarkable, deeply non-obvious fact is that the solvability of controls and is controlled by the solvability of — a hidden symmetry between two apparently independent questions. The surprising fact: a question about primes "looking forward" (is a square mod ?) is answered by a question "looking backward" (is a square mod ?), with the parity of and as the only obstruction. Gauss alone gave eight different proofs, and the theorem became the seed of class field theory and the entire reciprocity program of modern number theory.
The Core Insight
Whether one prime is a square modulo another is not an isolated arithmetic accident — it is governed by a reciprocal relationship. The "exchange" of and in the Legendre symbol costs only a sign, and that sign is determined entirely by the residues of and modulo . Two supplementary laws handle the special cases and , and together with multiplicativity these three rules let you evaluate any Legendre symbol by repeated reduction, much like the Euclidean algorithm computes a GCD.
Formal Statement
Quadratic Residue and the Legendre Symbol
Let be an odd prime and . An integer with is a quadratic residue mod if there exists with ; otherwise it is a quadratic non-residue. The Legendre symbol is defined by
Here is the (odd prime) modulus, is the integer being tested, and the symbol takes values in .
Euler's Criterion
For an odd prime and ,
Multiplicativity of the Legendre Symbol
For an odd prime and integers ,
Law of Quadratic Reciprocity
Let and be distinct odd primes. Then
Equivalently,
so the two symbols agree unless , in which case they are opposite. The two supplementary laws are
Why It Holds / Derivation
:::proof[Eisenstein's Lattice-Point Proof of [4]] We sketch the classical proof via Gauss's Lemma and lattice-point counting, the cleanest elementary route.
Step 1 — Gauss's Lemma. Let be odd and . Consider the multiples , each reduced to its least positive residue mod . Let be the number of these residues exceeding . ThenEisenstein's lattice-point count: points of the rectangle split by the diagonal $py=qx$, here $p=7,\ q=5$.
<svg viewBox="0 0 420 320" xmlns="http://www.w3.org/2000/svg">
<rect width="420" height="320" fill="#0a0e17"/>
<!-- axes -->
<line x1="40" y1="280" x2="380" y2="280" stroke="#94a3b8" stroke-width="1.5"/>
<line x1="40" y1="280" x2="40" y2="40" stroke="#94a3b8" stroke-width="1.5"/>
<text x="360" y="300" fill="#e2e8f0" font-size="12">x (k)</text>
<text x="10" y="55" fill="#e2e8f0" font-size="12">y (j)</text>
<!-- rectangle [1,3] x [1,2] in math coords, scaled -->
<!-- map: x: 1..3 -> 90..330 ; y: 1..2 -> 240..120 -->
<rect x="90" y="120" width="240" height="120" fill="none" stroke="#94a3b8" stroke-dasharray="4 3"/>
<!-- diagonal line py=qx => 7y=5x => y=(5/7)x ; through origin -->
<line x1="40" y1="280" x2="380" y2="40" stroke="#d4a853" stroke-width="2"/>
<text x="300" y="70" fill="#d4a853" font-size="12">py = qx</text>
<!-- lattice points k=1,2,3 ; j=1,2 -->
<!-- below line: count -->
<circle cx="90" cy="240" r="4" fill="#e2e8f0"/>
<circle cx="210" cy="240" r="4" fill="#e2e8f0"/>
<circle cx="330" cy="240" r="4" fill="#e2e8f0"/>
<circle cx="90" cy="120" r="4" fill="#e2e8f0"/>
<circle cx="210" cy="120" r="4" fill="#e2e8f0"/>
<circle cx="330" cy="120" r="4" fill="#e2e8f0"/>
<text x="150" y="270" fill="#94a3b8" font-size="11">below: ∑⌊kq/p⌋</text>
<text x="150" y="105" fill="#94a3b8" font-size="11">above: ∑⌊jp/q⌋</text>
<text x="90" y="305" fill="#e2e8f0" font-size="11">total = ((p-1)/2)((q-1)/2) = 3·2 = 6</text>
</svg>
Carl Friedrich Gauss | 1777–1855
Gauss proved quadratic reciprocity at age 19 (April 1796) after a year of effort, calling it the theorema aureum — the golden theorem. He published the first complete proof in his 1801 masterwork Disquisitiones Arithmeticae, and over his lifetime found eight distinct proofs, driven by his quest to generalize the result to higher powers (cubic and biquadratic reciprocity). His introduction of congruence notation, his systematic theory of forms, and his Gauss sums created the language in which all later reciprocity laws are expressed. The pursuit of a "general reciprocity law" became the organizing problem of 19th- and 20th-century number theory, culminating in Artin reciprocity.
Building Intuition
Think of the Legendre symbol as a "yes/no question about the prime , asked in the world of arithmetic mod ." Quadratic reciprocity says this question has a mirror in the world mod , and the two answers are linked. The miracle is that there's any link at all: a priori, being a square mod and being a square mod live in totally different finite worlds.
A useful mental model: the symbol behaves like a homomorphism in its top argument (multiplicativity [3]), so it suffices to know its values on , on , and on odd primes — and reciprocity reduces an odd prime in the top to a smaller modulus in the bottom. This makes evaluation an algorithm: each application of [5] flips and shrinks the numbers, exactly like the Euclidean algorithm, terminating quickly. The deeper modern view: tells you how the prime splits in the field , and reciprocity is the statement that splitting is governed by a congruence condition on — the first instance of "primes split according to Frobenius classes."
Worked Examples
Is 30 a quadratic residue mod 53?
Given: Evaluate ; note is prime, . Step 1 — Factor and use multiplicativity [3]: , soSolvability of $x^2 \equiv 17 \pmod{101}$
Given: is prime; determine if a solution exists by computing . Step 1 — Apply reciprocity [5]: , so the sign is andA solution exists; in fact since ... (checking: ; a direct search gives , since — the symbol guarantees solvability without exhibiting the root).
Common Misconceptions
The Legendre symbol is NOT defined for composite lower entries — use the Jacobi symbol carefully. The Legendre symbol requires to be an odd prime. The generalized Jacobi symbol (defined for odd via multiplicativity over the prime factorization of ) also satisfies reciprocity and the supplementary laws — but a Jacobi value of does NOT guarantee that is a quadratic residue mod . For example , yet is a non-residue mod (it's a non-residue mod both and ). The Jacobi symbol speeds up computation but loses the QR interpretation for composite moduli. Reciprocity does NOT say the two symbols are always equal. A common error is to drop the sign factor. Take , , both . Then is odd, so [4] gives . Check: squares mod 7 are , so ; and a square, so . Indeed . The symbols differ precisely because both primes are — exactly the case naive "they're always equal" reasoning gets wrong.Connections
Quadratic reciprocity sits at the crossroads of several theories. It is the simplest case of Artin Reciprocity in class field theory, where the Legendre symbol becomes an Artin symbol describing how primes split in abelian extensions. Through Gauss Sums and Cyclotomic Fields, the value is encoded in the factorization of in and in where . The multiplicative structure relies on Cyclic Groups (the group being cyclic) and on Fermat's Little Theorem. Generalizations to higher powers — Cubic Reciprocity and Biquadratic Reciprocity — require working in and , foreshadowing Algebraic Number Theory.
Real-World Applications
- Primality testing — Solovay–Strassen test. A probabilistic primality test computes a Jacobi symbol and compares it to ; mismatches prove compositeness. This was historically important for cryptographic key generation.
- Cryptography — Goldwasser–Micali encryption. This semantically secure public-key scheme encodes bits as quadratic residues vs. pseudo-residues modulo a composite ; security rests on the quadratic residuosity problem (hard without the factorization).
- Computing modular square roots — Tonelli–Shanks. Before extracting a square root mod , one checks for solvability; this underlies point decompression on elliptic curves used in ECC and Bitcoin signatures.
- Integer factorization — quadratic sieve & number field sieve. These algorithms search for ; residue criteria determine which primes can appear in factor bases, dramatically pruning the search.
- Pseudorandom generation — Blum Blum Shub. This cryptographically secure generator iterates with , ; the choice (so is a non-residue, via [6]) guarantees unique principal square roots.
- Coding theory — quadratic residue codes. Cyclic codes (e.g. the binary Golay code, related QR codes over ) are built from the set of quadratic residues mod a prime, yielding excellent error-correcting properties.
Historical Development
- 1640s–1650s — Fermat observes which primes are sums of two squares (), implicitly studying and the residue of .
- 1744–1746 — Euler states empirical conjectures equivalent to quadratic reciprocity in correspondence and in Theoremata circa divisores numerorum, and proves Euler's criterion [2].
- 1785 — Legendre publishes a partial proof and introduces the Legendre symbol, formulating reciprocity in its modern symbolic form but with gaps (he assumed unproven results on primes in arithmetic progressions).
- April 8, 1796 — Gauss (age 19) completes the first rigorous proof, recording the date in his diary; he names it the theorema aureum.
- 1801 — Gauss publishes two complete proofs in Disquisitiones Arithmeticae, founding modern number theory and introducing congruence notation.
- 1808–1818 — Gauss discovers further proofs (sixth proof via Gauss sums), aiming at higher reciprocity laws.
- 1844–1850 — Eisenstein gives elegant lattice-point and Gauss-sum proofs (the one sketched above) and, with Jacobi, advances cubic/biquadratic reciprocity.
- 1880s — Hilbert, Kummer recast reciprocity via the Hilbert symbol and local-global product formulas, paving the way to class field theory.
- 1927 — Emil Artin proves Artin reciprocity, the sweeping generalization for abelian extensions that contains quadratic reciprocity as its most basic special case.
Subtleties & Limits
Quadratic reciprocity is completely solved, but its generalizations drive active research. The Langlands program seeks a vast non-abelian reciprocity law linking Galois representations to automorphic forms; quadratic reciprocity is the abelian, rank-one tip of this iceberg. For higher power residues, Artin's reciprocity governs abelian extensions, but explicit, computable reciprocity laws for general algebraic number fields (the "explicit reciprocity laws" of Wiles, Coleman, and others in -adic settings) remain technically intricate. Open computational questions persist too: the quadratic residuosity problem — distinguishing genuine residues from pseudo-residues mod without the factorization — is believed hard, but no proof of its hardness exists; if quantum factoring (Shor's algorithm) renders factoring easy, the cryptographic schemes built on it collapse. Finally, fine statistical questions about the distribution of quadratic residues (least non-residue size, related to GRH) connect to deep conjectures about -functions.