Quadratic reciprocity (Gauss's theorema aureum)
Anchor (Master): Gauss 1801 *Disquisitiones Arithmeticae* arts. 125-152 (originator: the first complete proof of quadratic reciprocity by induction, called the theorema aureum); Gauss 1808 *Theorematis arithmetici demonstratio nova* (Göttingen) (Gauss's third proof via the lemma and absolute-residue counting); Gauss 1818 *Theorematis fundamentalis in doctrina de residuis quadraticis demonstrationes et amplificationes novae* (Werke II, 47-64) (Gauss's fourth, fifth, sixth proofs — including the Gauss-sum proof); Eisenstein 1845 *J. reine angew. Math.* 28, 246-248 (Eisenstein's geometric lattice-point counting proof — the canonical modern textbook proof); Eisenstein 1844 *J. reine angew. Math.* 27, 289-310 (cubic and biquadratic reciprocity in $\mathbb{Z}[\zeta_3]$ and $\mathbb{Z}[i]$); Dirichlet 1854 (Gauss-sum proof using cyclotomic fields, expanded in Dedekind's edition of Dirichlet's *Vorlesungen* 1894); Hilbert 1897 *Jahresber. DMV* 4, 175-546 (Hilbert symbol and the product formula $\prod_v (a, b)_v = 1$); Hilbert 1900 ICM Paris (the 9th problem on general reciprocity); Takagi 1920 *J. Coll. Sci. Tokyo* 41, 1-133 (class field theory for abelian extensions of number fields); Artin 1927 *Hamb. Abh.* 5, 353-363 (Artin reciprocity, the modern formulation); Furtwängler 1909 *Math. Ann.* 67, 1-31 (Eisenstein reciprocity for the $\ell$-th power residue symbol); Lemmermeyer 2000 *Reciprocity Laws: From Euler to Eisenstein* (Springer Monographs in Mathematics) (catalogue of 300+ independent proofs); Ireland-Rosen 1990 *A Classical Introduction to Modern Number Theory* §§5-6; Serre 1973 *A Course in Arithmetic* (Springer GTM 7) Ch. I §3
Intuition Beginner
The law of quadratic reciprocity is a single equation that connects two completely separate-looking questions. Pick two distinct odd primes and . The first question: is a square modulo ? The second question: is a square modulo ? On the face of it these questions have nothing to do with each other — one is arithmetic inside the field , the other is arithmetic inside the field . Gauss discovered in 1796 that the answers are linked by a clean rule depending only on the residues of and modulo .
The rule. If at least one of is congruent to modulo , then is a square modulo if and only if is a square modulo . If both and are congruent to modulo , then is a square modulo if and only if is not a square modulo . So the two answers agree when the primes are well-behaved at the residue , and they flip when both primes are stubborn at the residue .
Worked example. Is a square modulo ? We have , both , so the answers flip. Is a square modulo ? Reduce , and is a square. So is a square modulo . By the flip, is not a square modulo . Cross-check by listing the squares modulo : the squares of are , so the squares modulo are , and is not on the list. The reciprocity rule got the right answer.
The compact form. Use the Legendre symbol from the previous unit. The law of quadratic reciprocity says, for distinct odd primes , $$ \left(\frac{p}{q}\right) \left(\frac{q}{p}\right) ;=; (-1)^{\frac{p - 1}{2} \cdot \frac{q - 1}{2}}. $$ The right-hand side is unless both and are , in which case it is . So in the good case and in the flip case.
Why does this matter? Two reasons. First, it converts an existence question modulo into a related question modulo , so we can flip back and forth between the two primes, reducing the larger argument each time. Combined with the multiplicative property of the Legendre symbol and the two supplementary laws for and , the reciprocity law gives a complete algorithm for computing any Legendre symbol in time roughly steps — far faster than searching for square roots. Second, it is the foundational example of a reciprocity law, a kind of relation that underlies all modern number theory: cubic reciprocity, biquadratic reciprocity, Artin reciprocity, and the Langlands programme all descend from this single elementary observation.
Gauss called the law the theorema aureum — the golden theorem — and produced eight independent proofs of it over his lifetime. By 2026 more than three hundred independent proofs are known, catalogued in Lemmermeyer's Reciprocity Laws. The multiplicity of proofs is itself a signal: the law sits at a deep junction of arithmetic, geometry, and analysis, and each new viewpoint produces a new proof.
Visual Beginner
The reciprocity exponent has a clean geometric reading. It is the number of integer points inside a rectangle with sides and . The picture shows the rectangle for and .
The picture captures Eisenstein's geometric proof of the reciprocity law: the rectangle has interior lattice points, the diagonal of slope passes through no lattice point (since ), and the count of lattice points in the lower triangle controls via Gauss's lemma while the count in the upper triangle controls . Adding the two counts modulo recovers the reciprocity exponent.
Worked example Beginner
Compute the Legendre symbol using the law of quadratic reciprocity.
Step 1. Both and are odd primes. Reduce modulo : , and . Since at least one (in fact both) of the primes is , the reciprocity flip exponent is even, so .
Step 2. Reduce the larger argument modulo the smaller prime : , so . This gives .
Step 3. Factor and apply multiplicativity: , using that on the cube.
Step 4. Compute via the second supplementary law . Here , odd, so . Alternatively use , and the supplementary law gives for .
Step 5. Compute using reciprocity again. Both and are odd primes; , so the flip exponent is even and . Reduce , so . Apply the second supplementary law: , so .
Step 6. Combine: . Therefore , and is a quadratic residue modulo .
Cross-check by enumeration is feasible because is small. The squares modulo are the squares of , reducing modulo . A direct search finds , so , confirming that is a square modulo .
The reciprocity computation extends to much larger primes where direct enumeration would be infeasible. The whole computation took six steps, none harder than a small modular reduction. The general algorithm uses reciprocity to halve the larger argument at each step, much like the Euclidean algorithm — and the total number of reduction steps for computing is .
Check your understanding Beginner
Formal definition Intermediate+
We restate the reciprocity-law setup precisely, building on the Legendre-symbol framework from 21.01.06.
Definition (reciprocity exponent). For distinct odd primes , the reciprocity exponent is $$ \varepsilon(p, q) ;=; \frac{p - 1}{2} \cdot \frac{q - 1}{2} \pmod 2. $$ It equals unless both and are , in which case it equals .
Definition (Jacobi symbol; Jacobi 1837). For an odd positive integer with prime factorisation and an integer coprime to , the Jacobi symbol is the completely multiplicative extension of the Legendre symbol: $$ \left(\frac{a}{n}\right) ;=; \prod_{i = 1}^k \left(\frac{a}{p_i}\right)^{e_i}. $$ For the Jacobi symbol is defined to equal . The Jacobi symbol satisfies in and in . It takes values in , with exactly when .
Definition (Frobenius element at a quadratic extension). For with the signed prime and an odd prime unramified in , the Frobenius element is if splits in and if remains inert in . The Artin map sends , and the splitting behaviour of in records the value of the Legendre symbol .
The Jacobi symbol does not detect quadratic residuosity for composite modulus: does not imply is a square modulo . For instance , but is not a square modulo (the squares modulo are ). The right statement is that is a square modulo iff for every odd prime and additional conditions hold for the prime (Hensel-style).
Counterexamples to common slips
"Quadratic reciprocity computes for arbitrary ." False: reciprocity in its Gauss form computes for distinct odd primes . To compute a general Legendre symbol with composite, one must combine multiplicativity in — using the supplementary laws for and and reciprocity for the odd-prime factors of — and recurse. The Jacobi-symbol extension makes the recursion work without factoring at each step, which is the operational advantage.
"The reciprocity exponent depends on the values of and themselves." Partially false: the exponent depends only on the residues of and modulo , not on and as integers. Specifically iff ; otherwise . This is why the reciprocity law is sometimes formulated as: unless both primes are .
"The Jacobi symbol implies is a non-residue modulo ." True in this direction (since if were a square modulo it would be a square modulo every prime divisor , forcing for all , hence ). The converse fails: does not imply is a square modulo when is composite, by the example above.
Key theorem with proof Intermediate+
The signature theorem of this unit is Gauss's quadratic reciprocity law itself. We give the modern textbook proof via Eisenstein's lattice-point counting argument, which is the canonical route in every standard reference (Hardy-Wright Ch. VI, Ireland-Rosen §5.3, Serre Ch. I §3).
Theorem (quadratic reciprocity; Gauss 1801). For distinct odd primes , $$ \left(\frac{p}{q}\right) \left(\frac{q}{p}\right) ;=; (-1)^{\frac{p - 1}{2} \cdot \frac{q - 1}{2}}. $$ Equivalently, unless , in which case .
Proof (Eisenstein 1845 lattice-point counting). Set and for brevity. We compute the product by counting integer points in the rectangle .
Step 1 — Gauss's lemma applied to . From 21.01.06 Exercise 6 (Gauss's lemma), where counts the elements of whose least positive residue modulo exceeds . Equivalently, write for each ; the residue exceeds iff after adjustment by an element of the "absolute residue" representative is negative. A standard counting identity (Gauss 1808, restated in Ireland-Rosen Lemma 5.3.1) gives
$$
\mu(q, p) ;\equiv; \sum_{j = 1}^{P} \lfloor j q / p \rfloor \pmod 2.
$$
The same identity applied to gives .
Step 2 — Two-way counting of . The rectangle contains integer points. We split by the diagonal line — the line from the origin to the opposite corner of (extended). This diagonal passes through no integer point of except possibly the corner, but the corner is not on the line (since for ). Moreover the line misses every interior lattice point because if for integers with , then , and since we have , impossible for .
So every lattice point of lies strictly above or strictly below the diagonal. The number of lattice points strictly below the diagonal (i.e., with , equivalently ) is $$ N_{\text{below}} ;=; \sum_{x = 1}^{P} #{y : 1 \leq y \leq Q, ; p y < q x} ;=; \sum_{x = 1}^{P} \min(Q, \lfloor q x / p \rfloor). $$ For we have , so , and the is unneeded: $$ N_{\text{below}} ;=; \sum_{x = 1}^{P} \lfloor q x / p \rfloor ;\equiv; \mu(q, p) \pmod 2. $$
Symmetrically, the number of lattice points strictly above the diagonal is $$ N_{\text{above}} ;=; \sum_{y = 1}^{Q} \lfloor p y / q \rfloor ;\equiv; \mu(p, q) \pmod 2. $$
Step 3 — Add. , the total point count of . Reducing modulo : $$ \mu(q, p) + \mu(p, q) ;\equiv; P Q ;=; \frac{p - 1}{2} \cdot \frac{q - 1}{2} \pmod 2. $$
Step 4 — Combine via Gauss's lemma. By Gauss's lemma, $$ \left(\frac{p}{q}\right) \left(\frac{q}{p}\right) ;=; (-1)^{\mu(p, q)} (-1)^{\mu(q, p)} ;=; (-1)^{\mu(p, q) + \mu(q, p)} ;=; (-1)^{\frac{p - 1}{2} \cdot \frac{q - 1}{2}}. $$ This is the law of quadratic reciprocity.
Bridge. Quadratic reciprocity is the foundational example of a reciprocity law — a relation that ties the splitting behaviour of a prime in an extension (or equivalently, the value of a residue symbol at ) to a congruence condition on modulo the conductor of the extension. The central insight is that the quadratic-residuosity question depends only on the residue class of modulo , with the dependence given by the Legendre symbol and the supplementary laws — the analogue for the quadratic extension of the statement of class field theory. The bridge is to the broader framework of 21.02.05 class field theory and Artin reciprocity, where the Artin map identifies the abelianised Galois group with a generalised ideal class group, and the Frobenius at records the splitting of in .
The Hilbert symbol formulation (Hilbert 1897) gives the cleanest packaging: the Hilbert symbol at each place of detects local solvability of , and the global product formula is logically equivalent to quadratic reciprocity together with the two supplementary laws. Putting these together, the elementary law that is a square modulo exactly when is a square modulo (up to the parity correction for ) is the simplest manifestation of a structural principle that generalises through cubic and biquadratic reciprocity in cyclotomic integer rings (Eisenstein 1844), Eisenstein reciprocity for -th powers (Furtwängler 1909), Artin reciprocity for abelian extensions (Artin 1927), and the Langlands programme for non-abelian extensions.
Exercises Intermediate+
Lean formalization Intermediate+
Mathlib provides the canonical scaffolding for quadratic reciprocity and its supplementary laws, with the proofs going through Gauss sums (the algebraic-number-theory route).
-- Operative imports: Mathlib.NumberTheory.LegendreSymbol.QuadraticReciprocity,
-- Mathlib.NumberTheory.LegendreSymbol.GaussSum,
-- Mathlib.NumberTheory.LegendreSymbol.JacobiSymbol
#check @ZMod.quadraticReciprocity
-- (p/q) * (q/p) = (-1)^((p - 1)/2 * (q - 1)/2), the main reciprocity law.
#check @ZMod.quadraticReciprocity_one_mod_four
-- Specialised statement for the p ≡ 1 (mod 4) case (no flip).
#check @ZMod.quadraticReciprocity_three_mod_four_three_mod_four
-- Specialised statement for the p ≡ q ≡ 3 (mod 4) case (flip).
#check @ZMod.legendreSym_two
-- (2/p) = (-1)^((p^2 - 1)/8), the second supplementary law.
#check @ZMod.legendreSym_neg_one
-- (-1/p) = (-1)^((p - 1)/2), the first supplementary law.
#check @ZMod.jacobiSym
-- The Jacobi symbol (a/n) for n odd positive.
#check @ZMod.jacobiSym_quadraticReciprocity
-- (m/n) * (n/m) = (-1)^((m - 1)/2 * (n - 1)/2) for m, n odd coprime positive.
#check @gaussSum_sq
-- The evaluation tau(chi_p)^2 = (-1)^((p - 1)/2) * p of the quadratic Gauss sum.The Mathlib formalisation is comprehensive at the level of the reciprocity statement, both supplementary laws, the Jacobi-symbol generalisation with its own reciprocity law, and the underlying Gauss-sum machinery. What Mathlib has not yet packaged: a constructive Eisenstein lattice-point counting proof (Mathlib's proof uses Gauss sums and is non-constructive in style); the explicit binary Jacobi-symbol algorithm with constructive output; the Hilbert-symbol product formula as a packaged reciprocity result; cubic and biquadratic reciprocity in and ; the Artin reciprocity map for the quadratic extension with the Frobenius identification . These are the formalisation gaps documented in the unit metadata Mathlib gap analysis.
Advanced results Master
Theorem 1 (quadratic reciprocity; Gauss 1801, theorema aureum). For distinct odd primes , $$ \left(\frac{p}{q}\right) \left(\frac{q}{p}\right) ;=; (-1)^{\frac{p - 1}{2} \cdot \frac{q - 1}{2}}. $$ Equivalently unless , in which case [Gauss 1801]. Proved above as the Key Theorem via Eisenstein's lattice-point counting. Gauss called the law the theorema aureum — "the golden theorem" — and announced his first complete proof in his mathematical diary entry of 19 April 1796 ("Per inductionem inveni 24 Mart. 1796"). The 1801 Disquisitiones proof is Gauss's first; he produced seven more proofs over his lifetime [Gauss 1808] [Gauss 1818], collected in Werke II 1863.
Theorem 2 (first supplementary law). For an odd prime, , i.e., iff [Gauss 1801]. Proved in 21.01.06 Exercise 5 via Euler's criterion. The first supplementary law characterises the primes for which is a square modulo , which is also the characterisation of primes representable as (Fermat 1640, Euler 1755).
Theorem 3 (second supplementary law). For an odd prime, , i.e., iff and iff [Gauss 1801]. Proved in 21.01.06 Exercise 7 via Gauss's lemma applied to . The second supplementary law together with the first and quadratic reciprocity gives a complete algorithm for computing for any and any odd prime .
Theorem 4 (Jacobi-symbol reciprocity; Jacobi 1837). For odd coprime positive integers, $$ \left(\frac{m}{n}\right) \left(\frac{n}{m}\right) ;=; (-1)^{\frac{m - 1}{2} \cdot \frac{n - 1}{2}}, $$ together with the Jacobi-symbol supplementary laws and [Lemmermeyer 2000]. Proved above as Exercises 4 and 5 via the multiplicativity identity and its analogue. The Jacobi-symbol formulation is the operative form for the binary Jacobi-symbol algorithm: compute in time by alternating reduction and reciprocity flip without factoring .
Theorem 5 (Hilbert reciprocity; Hilbert 1897). For , the Hilbert symbol at each place of (finite primes and the archimedean place ) records whether the quadratic form has a non-zero solution in . The product formula holds: $$ \prod_v (a, b)_v ;=; 1, $$ with all but finitely many factors equal to [Hilbert 1897]. For both squarefree positive integers coprime to a prime , the Hilbert symbol at the finite place reduces to a Legendre-symbol expression — specifically, for units, where is the reduction modulo . The product formula encodes quadratic reciprocity in adelic form: the matching of signs at the two finite primes and the archimedean place gives precisely . Hilbert's Zahlbericht developed this in §§64-90, and Hilbert's 9th problem (1900 ICM Paris) [Hilbert 1900] asked for the most general reciprocity law in any algebraic number field — the question answered by Takagi 1920 and Artin 1927.
Theorem 6 (Eisenstein reciprocity for -th power residues; Eisenstein 1850 / Furtwängler 1909). Let be an odd prime and . For coprime to and a rational integer coprime to , the -th power residue symbol (the group of -th roots of unity) satisfies $$ \left(\frac{\alpha}{a}\right)\ell ;=; \left(\frac{a}{\alpha}\right)\ell $$ provided is primary ( rational mod ) [Furtwängler 1909]. Eisenstein stated this in 1850 Crelle 39 for extending his 1844 cubic reciprocity, and Furtwängler 1909 Math. Ann. 67 proved the full -th-power form. Eisenstein reciprocity is the natural generalisation of Gauss's quadratic reciprocity from to cyclotomic integer rings , and was the bridge between the elementary reciprocity laws and the general class-field-theoretic reciprocity of Takagi 1920 and Artin 1927.
Theorem 7 (Artin reciprocity; Artin 1927). For a finite abelian extension of number fields with modulus , the Artin map $$ \mathrm{Art}{L/K} : I_K(\mathfrak{m}) / N{L/K}(I_L(\mathfrak{m})) P_{L/K}(\mathfrak{m}) ;\xrightarrow{\sim}; \mathrm{Gal}(L/K) $$ is an isomorphism, sending an unramified prime of to its Frobenius element [Artin 1927]. Specialised to the quadratic extension where is the signed prime, the Artin map sends an odd prime to the Frobenius , whose image in is . The Artin map's compatibility with the conductor recovers quadratic reciprocity: the value of depends only on the residue class of modulo . Takagi 1920 J. Coll. Sci. Tokyo 41 had proved existence of the abelian-extension classification; Artin 1927 Hamb. Abh. 5 added the explicit Frobenius-isomorphism formulation. The non-abelian generalisation is the Langlands programme.
Theorem 8 (Stickelberger's theorem; Stickelberger 1890). In the cyclotomic field , the prime ideal factorisation of the Gauss sum is controlled by the Stickelberger element $$ \theta ;=; \sum_{a = 1}^{p - 1} \left{\frac{a}{p}\right} \sigma_a^{-1} \in \mathbb{Q}[\mathrm{Gal}(\mathbb{Q}(\zeta_p)/\mathbb{Q})], $$ where is the fractional part of and is the Galois automorphism . The Stickelberger ideal annihilates the ideal class group of . Stickelberger 1890 Math. Ann. 37 generalises the Gauss-sum proof of quadratic reciprocity to a much broader class-field-theoretic framework, and is the foundation for Iwasawa theory (Iwasawa 1959).
Synthesis. Quadratic reciprocity is the foundational structural theorem of elementary number theory and the prototype of every subsequent reciprocity law. The central insight is exactly that the quadratic-residuosity question depends only on the residue class of modulo the conductor of the quadratic extension — the Legendre symbol is the Artin map evaluated at . The bridge is to the broader framework of 21.02.05 class field theory, where the Artin map identifies the abelianised Galois group with a generalised ideal class group, and to the Hilbert-symbol formulation of 21.03.04 adelic reciprocity, where the global product formula packages quadratic reciprocity and the two supplementary laws into a single adelic statement. Putting these together, the elementary law is the rational-prime manifestation of a structural principle that generalises through Eisenstein reciprocity for -th powers (Eisenstein 1850, Furtwängler 1909), Artin reciprocity for abelian extensions (Takagi 1920, Artin 1927), and the Langlands programme for non-abelian extensions (Langlands 1967, Wiles-Taylor 1995).
The historical arc from Euler 1744 to Artin 1927 is the canonical example of how an elementary observation grows into a structural principle. Euler 1744 Comm. Acad. Petrop. 14 conjectured special cases of quadratic reciprocity disguised as theorems about divisors of binary quadratic forms ; Legendre 1798 Essai sur la théorie des nombres gave the modern symbol-form statement with an incomplete proof depending on the unproven Dirichlet theorem on primes in arithmetic progressions; Gauss 1801 articles 125-152 gave the first complete proof, by induction on the larger prime, and then produced seven more proofs [Gauss 1808] [Gauss 1818] over the next two decades. Jacobi 1837 extended to the Jacobi symbol with the algorithmic consequence of efficient computation; Eisenstein 1844 added cubic and biquadratic reciprocity in the cyclotomic rings; Eisenstein 1845 [Eisenstein 1845] gave the lattice-point-counting proof that became the canonical textbook proof. Dirichlet 1854 / Dedekind 1894 gave the Gauss-sum proof via cyclotomic fields. Hilbert 1897 generalised to the Hilbert symbol and the product formula, with the 9th Hilbert problem (1900) asking for the most general reciprocity. Furtwängler 1909 proved Eisenstein reciprocity for -th powers; Takagi 1920 and Artin 1927 completed the classical reciprocity programme via class field theory for abelian extensions.
The applied legacy is the cryptographic infrastructure built on the efficient computability of the Legendre and Jacobi symbols. The binary Jacobi-symbol algorithm computes in time using reciprocity steps — the algorithm underlying every primality-testing pre-check (Solovay-Strassen 1977, Adleman-Pomerance-Rumely 1983), every cryptographic library's Legendre-symbol computation (OpenSSL, libgmp, Crypto++), and the Tonelli-Shanks modular-square-root algorithm essential for elliptic-curve point decompression in ECDSA, EdDSA, BLS12-381. The Goldwasser-Micali probabilistic encryption scheme (1982) founded the modern provable-security paradigm with the first semantically-secure public-key encryption from the quadratic-residuosity assumption. The pattern recurs in the quadratic sieve of Pomerance 1985, the second-fastest classical integer-factorisation algorithm with sub-exponential complexity, which uses smooth values of and the multiplicative structure of the Legendre symbol to build a non-degenerate congruence of squares from which factors .
Full proof set Master
Proposition 1 (quadratic reciprocity, Eisenstein lattice-point proof). For distinct odd primes , .
Proof. Reprised from the Key Theorem with sharpened notation. Set , . We compute by counting lattice points in the rectangle .
By Gauss's lemma (Proposition 4 of 21.01.06) and the parity identity (proved as Exercise 7 above),
$$
\left(\frac{q}{p}\right) ;=; (-1)^{\mu(q, p)} ;=; (-1)^{\sum_j \lfloor j q / p \rfloor}.
$$
Symmetrically .
The diagonal from the origin passes through no interior lattice point of : if were such a point with , then , and forces , impossible for .
So every lattice point of lies strictly above or strictly below the diagonal. The number of lattice points strictly below is $$ N_{\text{below}} ;=; \sum_{x = 1}^P #{y : 1 \leq y, ; p y < q x} ;=; \sum_{x = 1}^P \lfloor q x / p \rfloor, $$ using that for (since ). Symmetrically , and .
Reducing modulo : $$ \sum_{x = 1}^P \lfloor q x / p \rfloor + \sum_{y = 1}^Q \lfloor p y / q \rfloor ;\equiv; P Q \pmod 2, $$ so by Gauss's lemma, $$ \left(\frac{p}{q}\right) \left(\frac{q}{p}\right) ;=; (-1)^{\sum_y \lfloor p y / q \rfloor + \sum_x \lfloor q x / p \rfloor} ;=; (-1)^{P Q} ;=; (-1)^{\frac{p - 1}{2} \cdot \frac{q - 1}{2}}. $$
Proposition 2 (Jacobi-symbol reciprocity). For odd coprime positive integers, .
Proof. See Exercise 4 above. Factor and , expand the Jacobi symbols multiplicatively, apply quadratic reciprocity to each pair , and use the identity to recognise the exponent as .
Proposition 3 (Jacobi-symbol supplementary laws). For odd positive integer, and .
Proof. See Exercise 5 above. Multiplicative expansion in the prime factorisation , the Legendre-symbol supplementary laws for each , and the multiplicativity-mod- identities and .
Proposition 4 (correctness of the binary Jacobi-symbol algorithm). The Jacobi symbol for positive odd coprime can be computed in bit operations by the following recursive algorithm:
function jacobi(a, n):
a = a mod n
if a == 0: return 0 if n != 1 else 1
result = 1
while a != 0:
while a is even:
a = a / 2
if n mod 8 in {3, 5}: result = -result
swap a, n
if a mod 4 == 3 and n mod 4 == 3: result = -result
a = a mod n
return result if n == 1 else 0Proof. Correctness follows from three operations: (i) the modular-reduction step since the Jacobi symbol depends only on modulo ; (ii) the even-factor extraction by multiplicativity, with depending on ; (iii) the reciprocity flip adjusted by the parity correction when both . The complexity is bit operations because each modular reduction halves the operand size by a factor of on average (analogous to the Euclidean algorithm), and there are such reductions, each costing bit operations.
Proposition 5 (quadratic reciprocity, Gauss-sum proof). Same statement as Proposition 1, via the Gauss-sum identity .
Proof. See Exercise 8 above. Work in modulo a prime ideal above . The Frobenius at acts on the Gauss sum as , while the algebraic identity combined with Euler's criterion gives . Cancel (unit modulo ) and use via the first supplementary law to recover QR.
Proposition 6 (quadratic reciprocity, Hilbert-symbol product-formula proof). Same statement as Proposition 1, via the Hilbert-symbol product formula .
Proof sketch. Apply the product formula at , for distinct odd primes . The Hilbert symbol takes the value at every place except at (and at in general; for odd primes, when and when — the -adic local symbol carries the supplementary-law sign).
At : since (so represents positive numbers).
At : where is a -adic unit, by the Hilbert-symbol-to-Legendre-symbol identity.
At : symmetrically.
At : via local computation in .
The product formula gives , hence QR.
Proposition 7 (decision procedure for quadratic residuosity modulo prime powers). For an odd prime, , and coprime to : is a quadratic residue modulo iff is a quadratic residue modulo .
Proof. Direction : if then .
Direction : by Hensel's lemma. Suppose with . We lift inductively: given , write and seek with . Expanding, $$ x_k^2 ;=; x_{k - 1}^2 + 2 p^{k - 1} t x_{k - 1} + p^{2(k - 1)} t^2 ;\equiv; a + p^{k - 1}(c + 2 t x_{k - 1}) \pmod{p^k}. $$ Solve : since is odd and (which follows from by induction), the coefficient is a unit modulo , so has a unique solution. Hence the lift exists, and induction completes the proof.
The case is more delicate: is a square modulo for iff .
Connections Master
Quadratic residues and the Legendre symbol
21.01.06. Just shipped. The Legendre-symbol framework of21.01.06supplies every operative tool used in this unit: the definition , Euler's criterion , multiplicativity , the two supplementary laws and , and Gauss's lemma . The reciprocity law of the present unit combines these with the lattice-point parity identity to compute in terms of , and the algorithmic combination computes any in bit operations.Primitive roots and structure of
21.01.05. Shipped. The cyclicity of proved in21.01.05supplies the existence of a primitive root modulo , which underlies Euler's criterion and the Gauss-sum proof of reciprocity: the quadratic character is the unique non-identity homomorphism , and the Gauss sum records the character's image in the cyclotomic field .Fermat-Euler-Wilson theorems
21.01.04. Shipped. The reciprocity law inherits Fermat's little theorem via Euler's criterion (the Gauss-sum proof uses the Frobenius modulo in the cyclotomic ring , which is the cyclotomic-field analogue of Fermat). The first supplementary law iff characterises the primes representable as sums of two squares (Fermat 1640, Euler 1755), one of the canonical applications of21.01.04and one of the foundational consequences of the reciprocity-law programme.Dedekind domains and unique factorisation of ideals
21.02.03. Pending. The Gauss-sum proof of reciprocity lives in the cyclotomic ring , a Dedekind domain whose ideal factorisation theory packages the Stickelberger ideal and the Frobenius-element machinery. Eisenstein's cubic and biquadratic reciprocity (1844) live in the cyclotomic rings and , both Euclidean domains and the simplest examples of Dedekind extensions of . The bridge to21.02.03is the move from prime-number reciprocity to prime-ideal reciprocity, which is the foundational step of algebraic number theory.Class field theory and Artin reciprocity
21.02.05. Pending. The structural generalisation of quadratic reciprocity: every finite abelian extension of number fields corresponds bijectively to a generalised ideal class group of , via the Artin map . Specialised to , Artin reciprocity recovers Gauss's quadratic reciprocity. The Langlands programme is the non-abelian generalisation, conjecturally identifying Galois representations of with automorphic representations of reductive groups.Cubic and biquadratic reciprocity in cyclotomic integers
21.02.06. Pending. Eisenstein 1844 proved cubic reciprocity in (the Eisenstein integers) and biquadratic reciprocity in (the Gaussian integers). These are the first higher-reciprocity results, generalising Gauss's quadratic reciprocity from to cyclotomic integer rings , and were the bridge to Eisenstein reciprocity for -th powers (Furtwängler 1909) and the general reciprocity laws of class field theory.Galois groups and field automorphisms
01.02.04. Shipped. The Galois group is cyclic of order , and the quadratic character corresponds via Galois theory to the unique quadratic subfield . The Frobenius element at a prime unramified in this extension equals — the explicit form of Artin reciprocity for the simplest abelian extension of beyond the rationals themselves.Cyclotomic extensions and roots of unity
01.02.05. Shipped. The cyclotomic field — the splitting field of over — contains the Gauss sum , which lives in the quadratic subfield . The Gauss-sum proof of quadratic reciprocity (Exercise 8 above) is intrinsically a cyclotomic-field calculation: the Frobenius modulo acts on as , and tracking this action on the Gauss sum recovers reciprocity.Dirichlet -functions and primes in arithmetic progressions
21.03.02. Pending. The Legendre symbol extends to the quadratic Dirichlet character , and the Dirichlet -function has functional equation and Euler product. Dirichlet 1837 proved for non-principal to deduce the infinitude of primes in arithmetic progressions; the quadratic Dirichlet -functions are the simplest non-principal twists of and the prototype for the entire Dirichlet -function theory. The Riemann hypothesis for — the Generalised Riemann Hypothesis in the quadratic case — controls the error term in the prime-counting function for primes in arithmetic progression .Hilbert symbol and adelic reciprocity
21.03.04. Pending. Hilbert 1897 packaged quadratic reciprocity and the two supplementary laws into the single adelic statement , where is the Hilbert symbol at each place of . The Hilbert-symbol formulation generalises directly to number fields and is the foundation for the adelic / idelic class field theory of Chevalley 1933, Tate 1950, and the Langlands programme.
Historical & philosophical context Master
Euler 1744 Comm. Acad. Petrop. 14, 151-181 is the originator of quadratic reciprocity in the disguised form of theorems about divisors of binary quadratic forms . Euler observed empirically that the set of prime divisors of depends only on the residue class of the prime modulo — a statement equivalent to quadratic reciprocity once translated through the Legendre-symbol formalism (not available to Euler). Continued in Euler 1783 Opera Postuma I, 64-84, which contains the cleanest formulation Euler attained.
Legendre 1798 Essai sur la théorie des nombres introduced the symbol that bears his name and gave the modern formulation of the reciprocity law: for distinct odd primes , . Legendre's proof is incomplete: it depends on the unproven assumption that for every residue class coprime to , there exist infinitely many primes — a statement equivalent to Dirichlet's theorem on primes in arithmetic progressions, not proved until Dirichlet 1837 via the analytic non-vanishing for non-principal Dirichlet characters. So Legendre had the right statement but no complete proof.
Gauss 1801 Disquisitiones Arithmeticae arts. 125-152 [Gauss 1801] gave the first complete proof. Gauss had discovered the law independently in April 1796 (mathematical diary entry of 19 April 1796: "Per inductionem inveni 24 Mart. 1796") as a -year-old, and called it the theorema aureum — "the golden theorem" — or the fundamental theorem of arithmetic in his later writings. The 1801 Disquisitiones proof is by induction on the larger prime, with eight separate cases by the parities of modulo and the various splittings; article 131 is the central inductive step. Gauss produced seven more proofs over the next two decades [Gauss 1808] [Gauss 1818], six of which appeared in Werke II 1863. Gauss's stated intent in proving the law eight times was to find the conceptually right proof — and the multiplicity of methods is itself a signal that the law sits at a deep junction of arithmetic, geometry, and analysis. Today more than independent proofs are known, catalogued in Lemmermeyer 2000 Reciprocity Laws [Lemmermeyer 2000]; Lemmermeyer's web-maintained running count now exceeds proofs.
Eisenstein 1844 J. reine angew. Math. 27 proved cubic reciprocity in the cyclotomic ring of Eisenstein integers, with the companion paper Crelle 28 giving biquadratic reciprocity in . These are the first higher-reciprocity results, generalising Gauss's quadratic reciprocity from to cyclotomic integer rings . Eisenstein 1845 J. reine angew. Math. 28, 246-248 [Eisenstein 1845] then gave the geometric lattice-point proof of quadratic reciprocity: count integer points strictly under the line of slope inside the rectangle in two ways. This is the canonical proof reproduced in every modern textbook (Hardy-Wright Ch. VI, Ireland-Rosen §5.3, Serre Ch. I §3) and the proof we present as the Key Theorem above.
Dirichlet 1854 / Dedekind 1894 gave the Gauss-sum proof of reciprocity using the evaluation of the quadratic Gauss sum in the cyclotomic field . The sign determination is Gauss's 1805 result (after four years of attempts, recorded as the diary entry of 30 August 1805: "Endlich entdeckt — Heureka! num = " — a different Eureka moment, but the Gauss-sum sign came in 1805). Dedekind's supplements to Dirichlet's Vorlesungen introduce the modern abelian-group framework of characters, prefiguring the entire -function programme.
Jacobi 1837 J. reine angew. Math. 30, 166-182 extended the Legendre symbol to the Jacobi symbol for odd positive composite, by multiplicativity in the prime-power decomposition. The Jacobi symbol satisfies the same reciprocity law for odd coprime positive, and the same two supplementary laws. The algorithmic consequence is the binary Jacobi-symbol algorithm: compute in time by alternating reduction and reciprocity flip, without factoring . This is the algorithm used in every modern cryptographic library.
Hilbert 1897 Jahresber. DMV 4, 175-546 [Hilbert 1897] — the Zahlbericht, Hilbert's encyclopaedic report on algebraic number theory commissioned by the DMV in 1893 — developed the Hilbert symbol at each place of a number field and the product formula . The Hilbert symbol at a finite prime detects whether has non-zero solutions over the local field ; quadratic reciprocity becomes the Euler-factor matching of the product formula. Hilbert's 9th problem (1900 ICM Paris) [Hilbert 1900] asks for the most general reciprocity law in any algebraic number field — the question answered by Takagi 1920 and Artin 1927.
Furtwängler 1909 Math. Ann. 67, 1-31 [Furtwängler 1909] proved the Eisenstein reciprocity law for the -th power residue symbol in for an odd prime, generalising Eisenstein's 1850 statement to all . A precursor to the general reciprocity laws of class field theory.
Takagi 1920 J. Coll. Sci. Tokyo 41, 1-133 [Takagi 1920] proved class field theory for relatively abelian extensions of number fields: every finite abelian extension corresponds bijectively to a generalised ideal class group of , with the conductor-discriminant formula expressing the abelian -function as a product of Hecke -functions. Specialised to and quadratic , Takagi's theorem reduces to quadratic reciprocity. Artin 1927 Hamb. Abh. 5, 353-363 [Artin 1927] added the explicit Frobenius-isomorphism formulation — the Artin reciprocity law — identifying the Artin map as the canonical isomorphism. The non-abelian generalisation is the Langlands programme: Artin reciprocity equals abelian Langlands; the Langlands functoriality conjectures (Langlands 1967 letter to Weil; Langlands 1970 Yale Lectures) extend to all reductive groups via -functions of automorphic representations.
The applied legacy: the binary Jacobi-symbol algorithm computes Legendre symbols efficiently and underlies the Solovay-Strassen primality test (1977), the Tonelli-Shanks modular-square-root algorithm essential for elliptic-curve point decompression, and the Goldwasser-Micali 1982 first semantically-secure encryption scheme. The quadratic sieve of Pomerance 1985 — the second-fastest classical integer-factorisation algorithm, with sub-exponential complexity — uses the multiplicative structure of the Legendre symbol to build a non-degenerate congruence of squares from which factors . The same quadratic-residue framework Gauss developed in 1801 underlies every modern cryptographic protocol involving modular square roots.
Bibliography Master
@book{Gauss1801,
author = {Gauss, Carl Friedrich},
title = {Disquisitiones Arithmeticae},
publisher = {Gerhard Fleischer},
address = {Leipzig},
year = {1801},
note = {Articles 125-152 contain the first complete proof of quadratic reciprocity (Gauss's first proof, by induction on the larger prime), completed April 1796 according to Gauss's mathematical diary. Article 151 calls the law the theorema aureum. English translation by Arthur A. Clarke, Yale University Press, 1965/1986.}
}
@article{Gauss1808,
author = {Gauss, Carl Friedrich},
title = {Theorematis arithmetici demonstratio nova},
journal = {Commentationes Societatis Regiae Scientiarum Gottingensis},
year = {1808},
note = {Gauss's third proof of quadratic reciprocity, via Gauss's lemma and absolute-residue counting. Reprinted in Werke II (1863), 1-8. Founded the lemma-and-counting tradition continued by Eisenstein.}
}
@article{Gauss1818,
author = {Gauss, Carl Friedrich},
title = {Theorematis fundamentalis in doctrina de residuis quadraticis demonstrationes et amplificationes novae},
journal = {Commentationes Societatis Regiae Scientiarum Gottingensis},
year = {1818},
note = {Gauss's fourth, fifth, and sixth proofs: the Gauss-sum proof via cyclotomic periods (foundational for the entire theory of Gauss sums); the cyclotomic-polynomial proof; the higher-reciprocity-style proof using $p$-th roots of unity. Werke II (1863), 47-64.}
}
@article{Eisenstein1845,
author = {Eisenstein, Gotthold},
title = {Geometrischer Beweis des Fundamentaltheorems f{\"u}r die quadratischen Reste},
journal = {Journal f{\"u}r die reine und angewandte Mathematik},
volume = {28},
pages = {246--248},
year = {1845},
note = {The lattice-point-counting proof of quadratic reciprocity. Canonical modern textbook proof: count integer points under the line of slope $q/p$ inside the rectangle $[1, (p-1)/2] \times [1, (q-1)/2]$ in two ways.}
}
@article{Eisenstein1844,
author = {Eisenstein, Gotthold},
title = {Beweis des Reciprocit{\"a}tssatzes f{\"u}r die cubischen Reste in der Theorie der aus den dritten Wurzeln der Einheit zusammengesetzten complexen Zahlen},
journal = {Journal f{\"u}r die reine und angewandte Mathematik},
volume = {27},
pages = {289--310},
year = {1844},
note = {Cubic reciprocity in the cyclotomic ring $\mathbb{Z}[\zeta_3]$ of Eisenstein integers. Companion paper Crelle 28 (1844), 53-67 gives biquadratic reciprocity in $\mathbb{Z}[i]$. The first higher-reciprocity results.}
}
@book{DirichletDedekind1894,
author = {Dirichlet, Peter Gustav Lejeune and Dedekind, Richard},
title = {Vorlesungen {\"u}ber Zahlentheorie},
edition = {4},
publisher = {Vieweg},
address = {Braunschweig},
year = {1894},
note = {Sections 52-58 give Dirichlet's Gauss-sum proof of quadratic reciprocity using the evaluation $\tau(\chi_p)^2 = (-1)^{(p-1)/2} p$ of the quadratic Gauss sum. Dedekind's supplements introduce the modern abelian-group framework of characters.}
}
@article{Hilbert1897,
author = {Hilbert, David},
title = {Die Theorie der algebraischen Zahlk{\"o}rper},
journal = {Jahresbericht der Deutschen Mathematiker-Vereinigung},
volume = {4},
pages = {175--546},
year = {1897},
note = {The Zahlbericht — Hilbert's encyclopaedic report on algebraic number theory. Develops the Hilbert symbol $(a, b)_v$ at each place of a number field and the product formula $\prod_v (a, b)_v = 1$. Quadratic reciprocity becomes Euler-factor matching of the product formula.}
}
@misc{Hilbert1900,
author = {Hilbert, David},
title = {Mathematische Probleme},
howpublished = {Address before the International Congress of Mathematicians, Paris, 8 August 1900. G{\"o}ttinger Nachrichten 1900, 253-297; English translation Bulletin AMS 8 (1902), 437-479},
year = {1900},
note = {The 9th problem: proof of the most general reciprocity law in an arbitrary number field. Motivated class field theory; answered by Takagi 1920 and Artin 1927 for abelian extensions.}
}
@article{Takagi1920,
author = {Takagi, Teiji},
title = {{\"U}ber eine Theorie des relativ-Abelschen Zahlk{\"o}rpers},
journal = {Journal of the College of Science, Tokyo},
volume = {41},
pages = {1--133},
year = {1920},
note = {Class field theory for relatively abelian extensions of number fields. Every finite abelian extension corresponds bijectively to a generalised ideal class group via the Artin map. Specialised to $K = \mathbb{Q}$ and quadratic $L$, reduces to quadratic reciprocity.}
}
@article{Artin1927,
author = {Artin, Emil},
title = {Beweis des allgemeinen Reziprozit{\"a}tsgesetzes},
journal = {Abhandlungen aus dem Mathematischen Seminar der Universit{\"a}t Hamburg},
volume = {5},
pages = {353--363},
year = {1927},
note = {Artin reciprocity. The Artin map induces an isomorphism from generalised ideal classes to the Galois group, sending a prime $\mathfrak{p}$ to its Frobenius element. The modern formulation of all reciprocity laws for abelian extensions.}
}
@article{Furtwangler1909,
author = {Furtw{\"a}ngler, Philipp},
title = {Allgemeiner Existenzbeweis f{\"u}r den Klassenk{\"o}rper eines beliebigen algebraischen Zahlk{\"o}rpers},
journal = {Mathematische Annalen},
volume = {67},
pages = {1--31},
year = {1909},
note = {Proof of the Eisenstein reciprocity law for the $\ell$-th power residue symbol in $\mathbb{Z}[\zeta_\ell]$ for $\ell$ odd prime. Precursor to general class-field-theoretic reciprocity.}
}
@book{Lemmermeyer2000,
author = {Lemmermeyer, Franz},
title = {Reciprocity Laws: From Euler to Eisenstein},
series = {Springer Monographs in Mathematics},
publisher = {Springer},
address = {Berlin},
year = {2000},
note = {The definitive modern monograph on quadratic reciprocity and its higher generalisations. Catalogues more than $300$ independent proofs of QR (web-maintained count now exceeds $345$). Chapters 1-9 develop the historical proof tradition from Euler 1744 through Gauss's eight proofs to Eisenstein's lattice-point proof.}
}
@book{IrelandRosen1990,
author = {Ireland, Kenneth and Rosen, Michael},
title = {A Classical Introduction to Modern Number Theory},
edition = {2},
series = {Graduate Texts in Mathematics},
volume = {84},
publisher = {Springer},
year = {1990},
note = {Chapter 5 §§5.2-5.3 develops quadratic reciprocity with a careful proof via Gauss's lemma and Eisenstein's lattice-point counting, plus the Jacobi-symbol generalisation. Chapter 6 develops the Gauss-sum proof. Chapter 11 develops cubic and biquadratic reciprocity.}
}
@book{Apostol1976,
author = {Apostol, Tom M.},
title = {Introduction to Analytic Number Theory},
series = {Undergraduate Texts in Mathematics},
publisher = {Springer},
year = {1976},
note = {Sections 9.6-9.7 give the statement of QR, the Gauss-sum derivation, the Jacobi-symbol algorithm, and the application to deciding quadratic residuosity for arbitrary moduli.}
}
@book{Serre1973,
author = {Serre, Jean-Pierre},
title = {A Course in Arithmetic},
series = {Graduate Texts in Mathematics},
volume = {7},
publisher = {Springer},
year = {1973},
note = {Chapter I §3 gives Serre's clean adelic-style proof of quadratic reciprocity via the Hilbert symbol and the product formula. The shortest rigorous modern treatment.}
}
@book{NivenZuckermanMontgomery1991,
author = {Niven, Ivan and Zuckerman, Herbert S. and Montgomery, Hugh L.},
title = {An Introduction to the Theory of Numbers},
edition = {5},
publisher = {Wiley},
year = {1991},
note = {Sections 3.2-3.3 develop quadratic reciprocity at the undergraduate level with worked examples. Standard undergraduate textbook.}
}
@book{HardyWright2008,
author = {Hardy, G. H. and Wright, E. M.},
title = {An Introduction to the Theory of Numbers},
edition = {6},
publisher = {Oxford University Press},
year = {2008},
note = {Revised by D. R. Heath-Brown and J. H. Silverman. Chapters V-VII develop quadratic residues and the Legendre symbol with two proofs of quadratic reciprocity: Gauss's lemma + Eisenstein lattice-point counting (Ch. VI §6.13) and the Gauss-sum proof (Ch. VII).}
}
@book{Cox2013,
author = {Cox, David A.},
title = {Primes of the form $x^2 + n y^2$: Fermat, class field theory, and complex multiplication},
edition = {2},
publisher = {Wiley},
year = {2013},
note = {The canonical modern textbook on the consequences of quadratic reciprocity for Fermat-style primes-of-the-form problems, with the originator chain Fermat-Euler-Lagrange-Legendre-Gauss developed from primary sources.}
}
@book{Burton2010,
author = {Burton, David M.},
title = {Elementary Number Theory},
edition = {7},
publisher = {McGraw-Hill},
year = {2010},
note = {Chapter 9 §9.3 develops quadratic reciprocity at the undergraduate Beginner-tier level with worked examples for small primes and a step-by-step computation of the Legendre symbol using the reciprocity flip.}
}