← back to Number Theory

Quadratic Residues

Jim Hefferon · Elementary Number Theory · Ch. 6

A quadratic residue mod p is a nonzero number that is a perfect square mod p. Exactly half the nonzero residues are squares. The Legendre symbol encodes which are which, and quadratic reciprocity reveals a deep symmetry between different primes.

Squares mod p

For a prime p, the nonzero residues mod p split evenly: (p-1)/2 are quadratic residues (squares), and (p-1)/2 are non-residues. This is because squaring is two-to-one: a^2 ≡ (-a)^2 (mod p).

Quadratic residues mod 13 (squares highlighted) 1 2 3 4 5 6 7 8 9 10 11 12 QR mod 13: 1, 3, 4, 9, 10, 12 (6 of 12)
Scheme

Legendre symbol and Euler's criterion

The Legendre symbol (a/p) equals 1 if a is a QR mod p, -1 if not, and 0 if p divides a. Euler's criterion computes it: (a/p) ≡ a^((p-1)/2) (mod p). This is a fast test for whether a number is a square mod p.

Scheme

Quadratic reciprocity (statement)

For distinct odd primes p and q: (p/q)(q/p) = (-1)^((p-1)/2 * (q-1)/2). In words: p is a square mod q and q is a square mod p, unless both are 3 mod 4, in which case exactly one is. This is the "golden theorem" that wpGauss proved eight different ways.

Scheme