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).

For an odd prime , an integer coprime to is a quadratic residue (QR) if the congruence has a solution, and a quadratic nonresidue (QNR) otherwise. The Legendre symbol packages this dichotomy into a completely multiplicative function valued in , transforming questions about square roots mod into algebra over the finite field . This matters because solvability of is the simplest nontrivial local condition in number theory — the seed from which class field theory and the Langlands program grow. The surprising fact, which Gauss called the theorema aureum ("golden theorem"), is quadratic reciprocity: whether is a square mod is governed by whether is a square mod , even though these two questions concern entirely different finite fields, with a correction term depending only on .

The Core Insight

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

Quadratic Residue

Let be an odd prime and with . Then is a quadratic residue modulo if there exists with

1
and a quadratic nonresidue otherwise. The set of residue classes that are QRs is denoted .
⟳This is a definition; the existence of is equivalent to lying in the image of the squaring map on .

Legendre Symbol

For an odd prime and integer , the Legendre symbol is

2
⟳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.

Counting and Multiplicativity

Among the nonzero residues mod , exactly are QRs and are QNRs. The Legendre symbol is completely multiplicative:

3
⟳The squaring map on the cyclic group has kernel of order , so ; multiplicativity follows because is a group homomorphism into .

Euler's Criterion

For odd prime and ,

4
⟳ by Fermat, so ; the value is iff lies in the unique index-2 subgroup of QRs, which is exactly the set of solutions to .

Quadratic Reciprocity

For distinct odd primes ,

5
with the two supplementary laws
6
⟳ 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

Euler's Criterion

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.

Quadratic Reciprocity via Gauss's Lemma (sketch)

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
7
⟳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
8
⟳ 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
9
⟳Total interior lattice points equal and the diagonal hits none, so the two triangular counts sum to the total.
Step 4 — Conclude. Therefore
10
⟳Multiply the two Gauss-lemma expressions and substitute equation [9].

which is equation [5].

Carl Friedrich Gauss | 1777–1855

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.

The squaring map on $(\mathbb{Z}/11\mathbb{Z})^\times$ folds the unit circle onto the QRs

Squaring mod 11: residues 1..10 → QRs {1,3,4,5,9} domain (Z/11Z)* image = QR 1 10 5 6 4 7 2 9 1 3 5 9,4 each ±x pair (e.g. 5,6=−5) collapses to one square — the map is 2-to-1

Worked Examples

Is 30 a quadratic residue mod 53?

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: .

Find a square root of 7 mod 23 using Euler's criterion

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

  1. Solovay–Strassen primality test: uses the Jacobi symbol and Euler's criterion to probabilistically certify primality — historically central to RSA key generation.
  2. Tonelli–Shanks square-root extraction: computing square roots mod underpins decompression of elliptic-curve points (from to ) in protocols like ECDSA and EdDSA.
  3. Goldwasser–Micali cryptosystem: the first probabilistic public-key scheme, whose semantic security rests on the quadratic residuosity problem — distinguishing QRs from QNRs mod a composite without its factorization.
  4. Rabin cryptosystem: encryption is squaring mod ; decryption requires square roots mod and combined by CRT, with security provably equivalent to factoring.
  5. Paillier and Cocks identity-based encryption: Cocks's IBE scheme manipulates Jacobi symbols of ciphertext components.
  6. Quadratic-residue (QR) error-correcting codes: a class of cyclic codes (including the binary Golay code as a special case) whose defining set is the QRs mod a prime.
  7. Pseudorandom generators: the Blum–Blum–Shub generator iterates , with output bits secured by quadratic residuosity.

Historical Development

  • 1640s — Fermat states results on which primes are sums of two squares, implicitly governed by .
  • 1750s — Euler conjectures the reciprocity relation in the language of which primes divide values of quadratic forms, and proves Euler's criterion.
  • 1785 — Legendre states the law of quadratic reciprocity and introduces the symbol notation, but his proofs assume the existence of primes in arithmetic progressions (then unproven), leaving gaps.
  • 1796 — Gauss, aged 18, gives the first rigorous and complete proof (his "first proof," by induction).
  • 1801 — Publication of Disquisitiones Arithmeticae, presenting the theorema aureum with multiple proofs and the full theory of forms.
  • 1808–1832 — Gauss develops further proofs, including those via Gauss sums and biquadratic reciprocity over .
  • 1844–1850 — Eisenstein gives elegant lattice-point and trigonometric proofs; Eisenstein and Jacobi establish cubic and quartic reciprocity.
  • 1882 — Kronecker and Weber extend the symbol (Kronecker symbol) and frame reciprocity within cyclotomic theory.
  • 1927 — Emil Artin proves the Artin reciprocity law, subsuming quadratic reciprocity as the simplest abelian case and crowning class field theory.

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

Before this

Where this leads