Quadratic Residues
Statement
Let be an odd prime. An integer with is called a quadratic residue (QR) mod if there exists with ; otherwise it is a quadratic non-residue (QNR). Exactly residues are QRs and are QNRs.
A classical characterisation (Euler's criterion): for ,
For the criterion gives a clean answer: is a QR mod if and only if .
Visualization
Quadratic residues mod 7 (squares of reduced mod 7):
| 1 | 1 |
| 2 | 4 |
| 3 | 2 |
| 4 | 2 |
| 5 | 4 |
| 6 | 1 |
QRs mod 7: . QNRs mod 7: .
Quadratic residues mod 13 (squares of reduced mod 13):
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | |
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | 4 | 9 | 3 | 12 | 10 | 10 | 12 | 3 | 9 | 4 | 1 |
QRs mod 13: . QNRs: .
Note: , so is a QR — confirmed above.
Proof Sketch
- The map on is 2-to-1 (since and for odd), so exactly elements are QRs.
- Every element of satisfies by Fermat's Little TheoremFermat's Little TheoremFor prime p, a^p is congruent to a mod pRead more →, so is a square root of , hence .
- The are exactly the kernel of (the -th power map), giving Euler's criterion.
- For : iff is even iff .
Connections
Quadratic residues are the language in which Quadratic ReciprocityQuadratic ReciprocityRelationship between solvability of quadratic congruences for two odd primesRead more → is stated: the Legendre symbol encodes whether is a QR mod . The count of QRs is governed by Euler's Totient FunctionEuler's Totient Functionφ(n) counts integers up to n coprime to n, and governs modular exponentiationRead more → through the index of the subgroup of squares in .
Lean4 Proof
/-- -1 is a square in ZMod p iff p % 4 ≠ 3.
Mathlib's `ZMod.exists_sq_eq_neg_one_iff` states this directly. -/
theorem neg_one_is_qr (p : ℕ) [Fact p.Prime] :
IsSquare (-1 : ZMod p) ↔ p % 4 ≠ 3 :=
ZMod.exists_sq_eq_neg_one_iff