Home › Number Theory › Lesson 8

The Law of Quadratic Reciprocity

Lesson 8 of 13

Key idea of this section

For distinct odd primes p, q:   (p/q)(q/p) = (−1)((p−1)/2)·((q−1)/2).

Statement and history

Reciprocity says that the question "is p a square modulo q?" and the question "is q a square modulo p?" have the same answer, unless both p and q are ≡ 3 (mod 4), in which case they have opposite answers. The law was conjectured by Euler and stated by Legendre, whose attempted proof was incomplete; Gauss gave the first complete proof in April 1796, shortly before his nineteenth birthday, and published it in the Disquisitiones (1801). He eventually gave eight proofs, and well over three hundred have since been published. We give Eisenstein's geometric proof (1844), built on Gauss's lemma.

Eisenstein's lemma

Lemma 8.1. Let p be an odd prime and a an odd integer with p ∤ a. Then

(a/p) = (−1)T,   T = ∑ₖ₌₁(p−1)/2 ⌊ka/p⌋.

Proof. Let h = (p − 1)/2 and write ka = p⌊ka/p⌋ + rₖ with 0 < rₖ < p. Let r′₁, …, r′λ be those rₖ below p/2 and s₁, …, sμ those above p/2. In the proof of Gauss's lemma we saw that the numbers r′ᵢ and p − sⱼ together are exactly 1, …, h. Summing the division equations and summing this list,

a ∑ₖ k = pT + ∑ r′ᵢ + ∑ sⱼ,      ∑ₖ k = ∑ r′ᵢ + μp − ∑ sⱼ.

Subtracting gives (a − 1)∑ₖ k = p(T − μ) + 2∑ sⱼ. Reducing modulo 2, with a and p odd, yields 0 ≡ T − μ (mod 2). So (−1)T = (−1)μ = (a/p) by Gauss's lemma. ∎

The proof of reciprocity

Theorem 8.2 (Quadratic reciprocity). If p and q are distinct odd primes, then (p/q)(q/p) = (−1)((p−1)/2)·((q−1)/2).

Proof. Consider the lattice points (x, y) with 1 ≤ x ≤ (p − 1)/2 and 1 ≤ y ≤ (q − 1)/2; there are ((p − 1)/2)((q − 1)/2) of them. None lies on the line qx = py, since that would require p | x. Those below the line (y < qx/p) number

∑ₓ₌₁(p−1)/2 ⌊qx/p⌋ = T(q, p),

because for each x the admissible y are 1, …, ⌊qx/p⌋ (and ⌊qx/p⌋ ≤ (q − 1)/2 since qx/p < q/2). Symmetrically, the points above the line number T(p, q) = ∑y ⌊py/q⌋. Hence T(q, p) + T(p, q) = ((p − 1)/2)((q − 1)/2), and Lemma 8.1 gives

(q/p)(p/q) = (−1)T(q,p) + T(p,q) = (−1)((p−1)/2)((q−1)/2). ∎

Computing with reciprocity

Together with multiplicativity and the two supplementary laws, reciprocity evaluates any Legendre symbol by repeated reduction, in the manner of the Euclidean algorithm. Worked example: is 219 a square modulo the prime 383? Here 219 = 3 · 73.

(3/383) = −(383/3) = −(2/3) = −(−1) = +1        (both ≡ 3 mod 4; 383 ≡ 2 mod 3)
(73/383) = (383/73) = (18/73) = (2/73)(9/73) = +1   (73 ≡ 1 mod 4 and 73 ≡ 1 mod 8)

So (219/383) = +1, and x² ≡ 219 (mod 383) is solvable. Euler's criterion confirms 219¹⁹¹ ≡ 1 (mod 383).

Reciprocity also answers the inverse question: for which primes p is a fixed a a residue? For example, for p > 3,

(3/p) = +1  ⟺  p ≡ ±1 (mod 12).

Indeed (3/p) = (p/3)(−1)(p−1)/2; (p/3) = +1 iff p ≡ 1 (mod 3), and the sign is +1 iff p ≡ 1 (mod 4); combining by CRT, (3/p) = +1 iff p ≡ 1 or 11 (mod 12). The answer depends only on p modulo 12, a phenomenon with no a priori explanation; class field theory explains it as the decomposition law of primes in the field ℚ(√3) ⊂ ℚ(e2πi/12).

The Jacobi symbol

To avoid factoring the top entry, Jacobi extended the symbol. For odd n = p₁p₂⋯pᵣ (primes with repetition) and any a, define (a/n) = ∏ (a/pᵢ). The Jacobi symbol is multiplicative in both arguments and satisfies the same three laws: for odd positive coprime m, n,

(m/n)(n/m) = (−1)((m−1)/2)((n−1)/2),  (−1/n) = (−1)(n−1)/2,  (2/n) = (−1)(n²−1)/8.

(Proof: each formula is multiplicative in the relevant variables, because (m − 1)/2 is additive modulo 2 under multiplication of odd numbers, and similarly for (n² − 1)/8 modulo 2.) It can therefore be computed in O(log² n) bit operations without any factorisation. One warning: (a/n) = +1 does not imply that a is a square modulo a composite n. For instance (2/15) = (2/3)(2/5) = (−1)(−1) = +1, but the squares of units modulo 15 are only 1 and 4. On the other hand (a/n) = −1 does prove that a is a non-residue.

An application: Pépin's test

For the Fermat number Fₙ = 22ⁿ + 1 (n ≥ 1), Fₙ is prime if and only if 3(Fₙ−1)/2 ≡ −1 (mod Fₙ). If Fₙ is prime then Fₙ ≡ 1 (mod 4) and Fₙ ≡ 2 (mod 3), so (3/Fₙ) = (Fₙ/3) = (2/3) = −1, and Euler's criterion gives the congruence. Conversely the congruence implies that 3 has order Fₙ − 1, a power of 2, modulo Fₙ, so Fₙ − 1 ≤ φ(Fₙ) and Fₙ is prime. For F₄ = 65537 one checks 3³²⁷⁶⁸ ≡ 65536 ≡ −1. Fermat numbers F₅ through F₃₂ are all known to be composite.

Exercise

  • (a)
    Compute (150/1009) (1009 is prime).
  • (b)
    Determine all primes p ≠ 2, 5 for which 5 is a quadratic residue.
  • (c)
    Compute the Jacobi symbol (1001/9907) without factoring 9907.
Show solution

Answers: (a) (150/1009) = (2/1009)(3/1009)(25/1009). Since 1009 ≡ 1 (mod 8), (2/1009) = 1; since 1009 ≡ 1 (mod 4), (3/1009) = (1009/3) = (1/3) = 1; and (25/1009) = 1. So (150/1009) = +1. (b) 5 ≡ 1 (mod 4), so (5/p) = (p/5), which is +1 iff p ≡ ±1 (mod 5). (c) 1001 ≡ 1 (mod 4), so (1001/9907) = (9907/1001) = (898/1001) = (2/1001)(449/1001). 1001 ≡ 1 (mod 8) gives (2/1001) = 1. Then (449/1001) = (1001/449) = (103/449) = (449/103) = (37/103) = (103/37) = (29/37) = (37/29) = (8/29) = (2/29)³ = (−1)³ = −1, using at each flip that one of the two entries is ≡ 1 (mod 4), and 29 ≡ 5 (mod 8). So (1001/9907) = −1. (In fact 9907 is prime, so 1001 is a non-residue.)

V.3.1