Quadratic reciprocity relates whether an odd prime p is a square modulo another odd prime q to whether q is a square modulo p. In words: for distinct odd primes p,q, the two Legendre symbols (qp) and (pq) are equal unless both p≡q≡3(mod4), in which case they differ in sign. It applies to solving congruences x2≡a(modm). Conjectured by Euler and Legendre, first fully proved by Gauss (1796–1801), who called it the "golden theorem."
💡 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 p and q in the Legendre symbol costs only a sign, and that sign is determined entirely by the residues of p and q modulo 4. Two supplementary laws handle the special cases a=−1 and a=2, 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
DefinitionQuadratic Residue and the Legendre Symbol
Let p be an odd prime and a∈Z. An integer a with gcd(a,p)=1 is a quadratic residue mod p if there exists x with x2≡a(modp); otherwise it is a quadratic non-residue. The Legendre symbol is defined by
1
(pa)=⎩⎨⎧0+1−1if p∣a,if a is a QR mod p,if a is a non-QR mod p.
Derivation hint: This is a definition; the three-way split exhausts all residue classes since a is either divisible by p, or a nonzero square, or a nonzero non-square mod p. Here p is the (odd prime) modulus, a is the integer being tested, and the symbol takes values in {−1,0,+1}.
TheoremEuler's Criterion
For an odd prime p and gcd(a,p)=1,
2
(pa)≡a(p−1)/2(modp).
Derivation hint: The cyclic group (Z/pZ)× has order p−1; squares form the unique index-2 subgroup, exactly the kernel of a↦a(p−1)/2, whose values are ±1 since (a(p−1)/2)2=ap−1≡1 by Fermat.
TheoremMultiplicativity of the Legendre Symbol
For an odd prime p and integers a,b,
3
(pab)=(pa)(pb).
Derivation hint: Multiply Euler's criterion [2] for a and for b; a(p−1)/2b(p−1)/2=(ab)(p−1)/2 modulo p, and ±1 values determined mod p are determined exactly.
TheoremLaw of Quadratic Reciprocity
Let p and q be distinct odd primes. Then
4
(qp)(pq)=(−1)2p−1⋅2q−1.
Equivalently,
5
(pq)=(qp)⋅(−1)2p−1⋅2q−1,
so the two symbols agree unless p≡q≡3(mod4), in which case they are opposite. The two supplementary laws are
6
(p−1)=(−1)(p−1)/2={+1−1p≡1(mod4),p≡3(mod4),
7
(p2)=(−1)(p2−1)/8={+1−1p≡±1(mod8),p≡±3(mod8).
Derivation hint for [4]: the exponent 2p−1⋅2q−1 is odd iff both 2p−1 and 2q−1 are odd iff both p,q≡3(mod4). Hints for [6],[7]: [6] is Euler's criterion at a=−1; [7] follows from Gauss's lemma counting lattice points.
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 p be odd and gcd(a,p)=1. Consider the multiples a,2a,…,2p−1a, each reduced to its least positive residue mod p. Let μ be the number of these residues exceeding p/2. Then
8
(pa)=(−1)μ.
Derivation hint: Each reduced residue r with r>p/2 is replaced by p−r<p/2; the resulting set is exactly {1,…,(p−1)/2}, and the product introduces (−1)μ relative to a(p−1)/2⋅2p−1!; cancel the factorial and apply Euler's criterion [2].
Step 2 — Count via floor functions. For odd a, one shows μ≡∑k=1(p−1)/2⌊pka⌋(mod2), hence
9
(pa)=(−1)∑k=1(p−1)/2⌊ka/p⌋.
Derivation hint: Write ka=p⌊ka/p⌋+rk; summing over k and reducing mod 2 reorganizes the residue/non-residue counting from Step 1 into the floor sum.
Step 3 — Lattice points in a rectangle. Apply [9] with a=q and the symmetric expression with a=p. The sum ∑k=1(p−1)/2⌊kq/p⌋ counts lattice points (k,j) with 1≤k≤2p−1, 1≤j<kq/p, i.e. points below the line py=qx inside the rectangle R=[1,2p−1]×[1,2q−1]. The symmetric sum for p counts points above the line.
Step 4 — Add the counts. No lattice point lies on the line py=qx inside R (that would force p∣x, impossible). So the two sums together count all lattice points of R:
Derivation hint: Partition the 2p−1⋅2q−1 lattice points of the rectangle by whether they fall below or above the diagonal line, which has no interior lattice points.
Step 5 — Conclude. Multiplying the two instances of [9]:
(pq)(qp)=(−1)∑⌊kq/p⌋+∑⌊jp/q⌋=(−1)2p−1⋅2q−1,
which is exactly [4]. ■
Figure
Eisenstein's lattice-point count: points of the rectangle split by the diagonal py=qx, here p=7,q=5.
```svg
```
mathematician · 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
🧠 Intuition
Think of the Legendre symbol (pq) as a "yes/no question about the prime q, asked in the world of arithmetic mod p." Quadratic reciprocity says this question has a mirror in the world mod q, and the two answers are linked. The miracle is that there's any link at all: a priori, being a square mod p and being a square mod q 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 −1, on 2, 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: (pq) tells you how the prime psplits in the field Q(q∗), and reciprocity is the statement that splitting is governed by a congruence condition on p — the first instance of "primes split according to Frobenius classes."
Worked Examples
ExampleIs 30 a quadratic residue mod 53?
Given: Evaluate (5330); note 53 is prime, 53≡1(mod4).
Step 1 — Factor and use multiplicativity [3]:30=2⋅3⋅5, so
(5330)=(532)(533)(535).
Step 2 — The factor (532) via [7]:53≡5(mod8), and 5≡−3(mod8), so (532)=−1.
Step 3 — The factor (533) via reciprocity [5]: Since 53≡1(mod4), the sign is +, so (533)=(353)=(32). Now (32)=−1 (since 3≡3(mod8)). So (533)=−1.
Step 4 — The factor (535) via [5]: Both with 5≡1(mod4) → sign +, so =(553)=(53). Check 3 mod 5: squares mod 5 are {1,4}, so (53)=−1. Thus (535)=−1.
Step 5 — Combine:
(5330)=(−1)(−1)(−1)=−1.
(5330)=−1⇒30 is a non-residue mod 53.
ExampleSolvability of x2≡17(mod101)
Given:101 is prime; determine if a solution exists by computing (10117).
Step 1 — Apply reciprocity [5]:17≡1(mod4), so the sign is + and
(10117)=(17101).
Step 2 — Reduce the top mod 17:101=5⋅17+16, so 101≡16(mod17), giving (17101)=(1716).
Step 3 — Recognize a perfect square:16=42, hence (1716)=+1 automatically.
Step 4 — Conclude existence:
(10117)=+1.
A solution exists; in fact x≡±22(mod101) since 222=484=4⋅101+80... (checking: 484−4(101)=80=17; a direct search gives x≡±38, since 382=1444=14⋅101+30 — the symbol guarantees solvability without exhibiting the root).
x2≡17(mod101)is SOLVABLE, since (10117)=+1.
Common Misconceptions
⚠️ Common mistake
The Legendre symbol is NOT defined for composite lower entries — use the Jacobi symbol carefully. The Legendre symbol (pa) requires p to be an odd prime. The generalized Jacobi symbol(na) (defined for odd n>1 via multiplicativity over the prime factorization of n) also satisfies reciprocity and the supplementary laws — but a Jacobi value of +1 does NOT guarantee that a is a quadratic residue mod n. For example (152)=(32)(52)=(−1)(−1)=+1, yet 2 is a non-residue mod 15 (it's a non-residue mod both 3 and 5). The Jacobi symbol speeds up computation but loses the QR interpretation for composite moduli.
Counterexample
Reciprocity does NOT say the two symbols are always equal. A common error is to drop the sign factor. Take p=3, q=7, both ≡3(mod4). Then 2p−1⋅2q−1=1⋅3=3 is odd, so [4] gives (73)(37)=−1. Check: squares mod 7 are {1,2,4}, so (73)=−1; and 7≡1(mod3) a square, so (37)=(31)=+1. Indeed (−1)(+1)=−1. The symbols differ precisely because both primes are ≡3(mod4) — exactly the case naive "they're always equal" reasoning gets wrong.
Connections
connection
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 (pq) is encoded in the factorization of p in Q(ζq) and in Q(q∗) where q∗=(−1)(q−1)/2q. The multiplicative structure relies on Cyclic Groups (the group (Z/pZ)× being cyclic) and on Fermat's Little Theorem. Generalizations to higher powers — Cubic Reciprocity and Biquadratic Reciprocity — require working in Z[ω] and Z[i], foreshadowing Algebraic Number Theory.
Real-World Applications
🔬 Where this appears
Historical Development
⏳ History
- 1640s–1650s — Fermat observes which primes are sums of two squares (p≡1(mod4)), implicitly studying (p−1) and the residue of −1.
- 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
open-problem
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 p-adic settings) remain technically intricate. Open computational questions persist too: the quadratic residuosity problem — distinguishing genuine residues from pseudo-residues mod n=pq 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 L-functions.