Quadratic residues: why exactly half the nonzero elements mod p are squares
The squaring map x -> x^2 is 2-to-1, which forces exactly (p-1)/2 quadratic residues. We develop the Legendre symbol, Euler's criterion, the law of quadratic reciprocity, and the Tonelli-Shanks algorithm for extracting square roots modulo a prime.
Modulo , the squares of the nonzero elements are , , , , , . The set of values is – exactly half of . This is no coincidence. In this article we explain why, modulo any odd prime, precisely half of the nonzero residues are squares, and we develop the theory that grows from this observation.
1 Definition of quadratic residues
2 Why exactly half: the squaring map is 2-to-1
3 The Legendre symbol
4 Euler's criterion: an efficient test
5 The law of quadratic reciprocity: the most surprising theorem
6 The Tonelli–Shanks algorithm
Once we know that is a quadratic residue modulo , we may want to find an actual square root.
7 Takeaway
Exactly of the nonzero residues modulo are quadratic residues (because is a 2-to-1 map).
The Legendre symbol encodes quadratic residuosity as and is completely multiplicative.
Euler's criterion provides an test.
The law of quadratic reciprocity is a remarkable link between the arithmetic of two different primes.
The Tonelli–Shanks algorithm efficiently extracts square roots modulo .
In the next article, we discover another face of the Euclidean algorithm – continued fractions and the theory of best rational approximations.
Mathematics "between the lines" — exploring the intuition textbooks leave out, written in LaTeX on Folio.