Quadratic Residues and the Legendre Symbol
One-line: A quadratic residue mod is a nonzero square in , and the Legendre symbol encodes whether is such a square. Key result: Euler's criterion gives , and quadratic reciprocity relates to . Applies in: elementary and algebraic number theory, primality testing, cryptography, the theory of -functions. Who/when: Euler (1750s), Legendre (1798), Gauss (first proof of reciprocity, 1796/1801).
The nonzero residues mod form a cyclic group of even order . The squaring map is a 2-to-1 homomorphism, so exactly half the residues are squares. The Legendre symbol is precisely the unique nontrivial homomorphism — the quadratic character — and every deep theorem about residues (Euler's criterion, Gauss's lemma, reciprocity) is a statement about this character. Reciprocity itself is the assertion that a character mod , restricted to the prime , secretly carries the same arithmetic information as a character mod restricted to — a primordial instance of the duality at the heart of reciprocity laws.
Formal Statement
Let be an odd prime and with . Then is a quadratic residue modulo if there exists with
and a quadratic nonresidue otherwise. The set of residue classes that are QRs is denoted . Derivation hint: This is a definition; the existence of is equivalent to lying in the image of the squaring map on .
For an odd prime and integer , the Legendre symbol is
Derivation hint: The trichotomy partitions into the zero class and the two fibers of the squaring map on the unit group. Here is the prime "modulus" and the "numerator"; the symbol depends only on . Symbols: = greatest common divisor; = multiplicative group of units; = field with elements.
Among the nonzero residues mod , exactly are QRs and are QNRs. The Legendre symbol is completely multiplicative:
Derivation hint: The squaring map on the cyclic group has kernel of order , so ; multiplicativity follows because is a group homomorphism into .
For odd prime and ,
Derivation hint: by Fermat, so ; the value is iff lies in the unique index-2 subgroup of QRs, which is exactly the set of solutions to .
For distinct odd primes ,
with the two supplementary laws
Derivation hint: follows directly from Euler's criterion; and the main law follow from Gauss's lemma by counting lattice points, or from Gauss sums in .
Why It Holds / Derivation
Let be a primitive root mod , so is cyclic of order .
Step 1. Write . Then is a QR iff for some , i.e. iff is even, since the squares are exactly the elements of even index.
Step 2. Compute . By Lagrange, has exact order , so has order , meaning .
Step 3. Therefore . This equals iff is even (QR) and iff is odd (QNR), matching equation [2]. Since and are distinct mod (as is odd), the congruence determines the symbol exactly.
∎Step 1 — Gauss's Lemma. Fix coprime to and let . Reduce each () into the symmetric range and let be the number of negative reductions. Then
Derivation hint: The absolute values of the reductions are a permutation of , so multiplying gives ; cancel and apply Euler's criterion.
Step 2 — Counting for . The number counts lattice points under a line. Set
Derivation hint: counts integer multiples of below ; summing these "wraps" controls the parity when is odd. so .
Step 3 — Lattice-point symmetry (Eisenstein). The lattice points strictly inside the rectangle are split by the diagonal (no lattice point lies on it since ). Counting below the diagonal gives and above gives , hence
Derivation hint: Total interior lattice points equal and the diagonal hits none, so the two triangular counts sum to the total.
Step 4 — Conclude. Therefore
Derivation hint: Multiply the two Gauss-lemma expressions and substitute equation [9]. which is equation [5].
∎Gauss discovered quadratic reciprocity at age 18 (1795) and gave the first complete proof in 1796, publishing it in the Disquisitiones Arithmeticae (1801). He prized the result so highly that he returned to it throughout his life, ultimately producing eight distinct proofs using induction, Gauss's lemma, Gauss sums, cyclotomy, and the theory of forms. His search for higher reciprocity laws (cubic, biquadratic) forced him to invent the Gaussian integers and launched algebraic number theory. The Legendre symbol's name honors Legendre, but its deepest structural theorem is irreducibly Gaussian.
Building Intuition
Think of as a clock with hours arranged in a circle, where "multiply by " rotates you one hour. Squaring doubles your hour-position, so you can only land on even hours — and those even hours are exactly the QRs. The Legendre symbol asks: "is your hour even or odd?" That parity question is preserved under multiplication (even+even=even, odd+odd=even), which is why the symbol is multiplicative. Reciprocity is more startling. There's no obvious reason that the parity of 's position in 's clock should relate to the parity of 's position in 's clock — they are different clocks. Gauss's lattice-point proof reveals the hidden link: both parities are counting lattice points in the same rectangle, just split by its diagonal. The correction is simply "are both primes ?" — if so the symbols flip, otherwise they agree.
Worked Examples
Given: (prime, ), .
Step 1 — Factor and use multiplicativity [3]: , so
Step 2 — : Since , the supplementary law [6] gives .
Step 3 — : Both , , so the correction ; reciprocity [5] gives (since is a QNR mod 3).
Step 4 — : so no sign flip: . Squares mod 5 are , so is a QNR: .
Step 5 — Combine: .
Given: , .
Step 1 — Confirm is a QR via [4]: Compute . Successively: , , , so . Wait — that yields , so would be a nonresidue. Recheck: ; . Indeed , so no square root exists. Replace target by .
Step 2 — Test : , so by [6]: a root exists.
Step 3 — Extract root (Tonelli for ): when , a root of a QR is . Here , so .
Step 4 — Verify: , so . ✓
Common Misconceptions
The Legendre symbol is not a fraction. is a multiplicative symbol, not division; but it is NOT "two thirds" of anything.
" tells you the square root." It only certifies existence, not a value. Extracting the root (the Tonelli–Shanks algorithm) is a separate, harder task — though still polynomial time.
Multiplicativity is in the numerator only. as Legendre symbols (the right side isn't even defined for composite ); the analogous denominator multiplicativity belongs to the Jacobi Symbol, whose value does not imply is a QR.
Jacobi symbol does not mean quadratic residue. Take and . The Jacobi symbol factors as
Yet is not a square mod : the squares mod are , and is absent. The two 's cancel in the Jacobi symbol, masking that is a nonresidue modulo both prime factors. This is exactly why Solovay–Strassen primality testing must use the Jacobi symbol but interprets failure carefully.
Connections
The Legendre symbol is the quadratic case of a vast hierarchy. Replacing the prime modulus by a composite gives the Jacobi Symbol (still multiplicative, computable without factoring); extending to all of and beyond gives the Hilbert Symbol and the Power Residue Symbol. Euler's criterion realizes the symbol as the unique quadratic Dirichlet Character mod , linking residues to L-functions and Dirichlet Series via for the Kronecker symbol . Quadratic reciprocity is the abelian, degree-2 shadow of Class Field Theory and ultimately the Artin Reciprocity Law; Gauss's sum-based proof connects it to Cyclotomic Fields and Gauss Sums. The count of QRs and the distribution of feed directly into Character Sums and the Pólya–Vinogradov Inequality.
Real-World Applications
Historical Development
Subtleties & Limits
Least quadratic nonresidue. Let be the smallest positive QNR mod . Vinogradov conjectured for every . Under the Generalized Riemann Hypothesis, Ankeny proved ; unconditionally the best bound (Burgess) is roughly — far from the conjecture. The truth is believed to be , but this remains open.
Distribution and pseudorandomness. Whether the sequence behaves like a random sequence is captured by character-sum bounds; the Pólya–Vinogradov inequality gives , and improving the factor (the Pólya–Vinogradov / Burgess problem) is a deep open question tied to GRH.
Higher reciprocity and Langlands. Quadratic reciprocity generalizes to Artin reciprocity for abelian extensions; the nonabelian reciprocity laws sought by the Langlands program remain largely conjectural, making the Legendre symbol the fully understood tip of a vast iceberg.
See Also
Jacobi Symbol · Quadratic Reciprocity · Gauss Sums · Dirichlet Character · Tonelli–Shanks Algorithm · Class Field Theory · Cyclotomic Fields · Hilbert Symbol · Character Sums and the Pólya–Vinogradov Inequality