Home › Number Theory › Lesson 7

Quadratic Residues and the Legendre Symbol

Lesson 7 of 13

Key idea of this section

For an odd prime p and p ∤ a:   (a/p) ≡ a(p−1)/2 (mod p)   (Euler's criterion).

Definitions

Let p be an odd prime. An integer a with p ∤ a is a quadratic residue modulo p if x² ≡ a (mod p) is solvable, and a quadratic non-residue otherwise. The Legendre symbol is

(a/p) = +1 if a is a quadratic residue mod p,  −1 if a is a non-residue,  0 if p | a.

Since x ↦ x² is two-to-one on 𝔽ₚ× (x and −x have the same square, and x² = y² forces x = ±y), exactly half of the p − 1 units are residues: there are (p − 1)/2 residues and (p − 1)/2 non-residues. Modulo 11 the residues are 1, 3, 4, 5, 9 (the squares of 1, …, 5). In terms of a primitive root g, the residues are exactly the even powers of g.

Theorem 7.1 (Euler's criterion). For p ∤ a, (a/p) ≡ a(p−1)/2 (mod p). Consequently (ab/p) = (a/p)(b/p).

Proof. Write a = gᵏ for a primitive root g. Then a is a residue iff k is even. Now g(p−1)/2 is a square root of 1 different from 1, so it equals −1 (Theorem 3.3), and a(p−1)/2 = (g(p−1)/2)ᵏ = (−1)ᵏ. Multiplicativity follows because both sides of Euler's criterion are multiplicative, and two numbers in {±1} congruent modulo p > 2 are equal. ∎

Thus the Legendre symbol a ↦ (a/p) is a homomorphism 𝔽ₚ× → {±1}, the unique non-trivial character of order 2 of the cyclic group 𝔽ₚ×. Taking a = −1 recovers the result of Lesson 4:

(−1/p) = (−1)(p−1)/2 = +1 if p ≡ 1 (mod 4),  −1 if p ≡ 3 (mod 4).

Gauss's lemma

Euler's criterion decides individual cases but does not reveal how (a/p) depends on p. Gauss's lemma converts the symbol into a counting problem.

Theorem 7.2 (Gauss's lemma). Let p be an odd prime, p ∤ a, and let μ be the number of the integers a, 2a, …, ((p − 1)/2)a whose least positive residue modulo p exceeds p/2. Then (a/p) = (−1)μ.

Proof. Let h = (p − 1)/2. Reduce each ka (1 ≤ k ≤ h) to the representative of its class in (−p/2, p/2), writing ka ≡ εₖ mₖ with εₖ = ±1 and 1 ≤ mₖ ≤ h; exactly μ of the signs εₖ are −1. The mₖ are distinct: if mⱼ = mₖ then ja ≡ ±ka, so j ≡ ±k (mod p), forcing j = k because 2 ≤ j + k ≤ p − 1. Hence {m₁, …, mₕ} = {1, …, h}, and multiplying all h congruences,

aʰ · h! ≡ (−1)μ · h!   (mod p).

Since h! is a unit modulo p it can be cancelled, leaving aʰ ≡ (−1)μ, and Euler's criterion gives (a/p) = (−1)μ. ∎

Worked example: (5/13). The multiples 5, 10, 15, 20, 25, 30 reduce to 5, 10, 2, 7, 12, 4 modulo 13. Those exceeding 6.5 are 10, 7, 12, so μ = 3 and (5/13) = −1. Check: 5² ≡ −1, so 5⁶ ≡ −1 (mod 13), as Euler's criterion predicts.

The second supplementary law

Theorem 7.3. For an odd prime p,

(2/p) = (−1)(p²−1)/8 = +1 if p ≡ ±1 (mod 8),  −1 if p ≡ ±3 (mod 8).

Proof. Apply Gauss's lemma with a = 2. The numbers 2, 4, …, p − 1 are already reduced, and μ counts those in (p/2, p): μ = h − ⌊p/4⌋ with h = (p − 1)/2. Checking the four classes p = 8m + 1, 8m + 3, 8m + 5, 8m + 7 gives μ = 2m, 2m + 1, 2m + 1, 2m + 2, so μ is even exactly when p ≡ ±1 (mod 8). The same four cases show that (p² − 1)/8 has the same parity as μ. ∎

As an application, if q = 2p + 1 with p and q prime and p ≡ 3 (mod 4), then q ≡ 7 (mod 8), so 2 is a residue modulo q and 2p = 2(q−1)/2 ≡ 1 (mod q). So q divides the Mersenne number 2ᵖ − 1. Euler found this way that 23 | 2¹¹ − 1 = 2047 = 23 · 89 and 47 | 2²³ − 1.

Exercise

  • (a)
    List the quadratic residues modulo 13 and check that there are six.
  • (b)
    Use Gauss's lemma to compute (3/11).
  • (c)
    Show that 2 is a primitive root modulo every prime q = 4p + 1 with p an odd prime. (Hint: the order of 2 divides 4p.)
Show solution

Answers: (a) Squares of 1, …, 6 modulo 13: 1, 4, 9, 3, 12, 10. So the residues are 1, 3, 4, 9, 10, 12. (b) The multiples 3, 6, 9, 12, 15 reduce to 3, 6, 9, 1, 4 modulo 11; those above 5.5 are 6 and 9, so μ = 2 and (3/11) = +1. Indeed 5² = 25 ≡ 3. (c) q = 4p + 1 with p odd gives q ≡ 5 (mod 8), so (2/q) = −1 and 22p ≡ −1 (mod q); therefore the order of 2 divides 4p but not 2p, so it is 4 or 4p. It is not 4, since 2⁴ − 1 = 15 is not divisible by q ≥ 13. So the order is 4p = q − 1.

V.3.1