Skip to content

Quadratic Residues

Definition. For pp prime and p∤ap \nmid a, aa is a quadratic residue (QR) mod pp if x2≡a(modp)x^2 \equiv a \pmod p is solvable, and a non-residue otherwise.

For odd pp, exactly half of the nonzero residue classes are QRs: the map x↦x2x \mapsto x^2 on (Z/pZ)×(\mathbb{Z}/p\mathbb{Z})^\times is two-to-one (xx and −x-x), so its image has (p−1)/2(p-1)/2 elements. Example mod 7: squares are 1,4,2,2,4,11, 4, 2, 2, 4, 1; QRs are {1,2,4}\{1, 2, 4\}.

a(p−1)/2≡{1a is a QR−1a is a non-residue(modp).a^{(p-1)/2} \equiv \begin{cases} 1 & a \text{ is a QR} \\ -1 & a \text{ is a non-residue}\end{cases} \pmod p.

Proof sketch. With gg a primitive root, a=gka = g^k; then a(p−1)/2=gk(p−1)/2≡1a^{(p-1)/2} = g^{k(p-1)/2} \equiv 1 iff (p−1)∣k(p−1)/2(p-1) \mid k(p-1)/2, i.e. kk even iff aa is a QR. If aa is a non-residue (kk odd), a(p−1)/2a^{(p-1)/2} squares to 1 but is not 1, hence is −1-1 (only two square roots of 1 mod pp). ■\blacksquare

(ap)={1a QR mod p−1a non-residue0p∣a\left(\frac{a}{p}\right) = \begin{cases} 1 & a \text{ QR mod } p \\ -1 & a \text{ non-residue} \\ 0 & p \mid a \end{cases}

Euler’s criterion becomes (ap)≡a(p−1)/2(modp)\left(\frac{a}{p}\right) \equiv a^{(p-1)/2} \pmod p; a fast evaluation method.

Properties.

  • Multiplicativity: (abp)=(ap)(bp)\left(\frac{ab}{p}\right) = \left(\frac{a}{p}\right)\left(\frac{b}{p}\right).
  • (−1p)=(−1)(p−1)/2\left(\frac{-1}{p}\right) = (-1)^{(p-1)/2}: −1-1 is a QR exactly for p≡1(mod4)p \equiv 1 \pmod 4.
  • (2p)=(−1)(p2−1)/8\left(\frac{2}{p}\right) = (-1)^{(p^2-1)/8}: 2 is a QR exactly for p≡±1(mod8)p \equiv \pm 1 \pmod 8.
  • Quadratic reciprocity (Gauss): for odd primes p≠qp \neq q, (pq)(qp)=(−1)p−12q−12\left(\frac{p}{q}\right)\left(\frac{q}{p}\right) = (-1)^{\frac{p-1}{2}\frac{q-1}{2}}; the deep theorem that lets you evaluate any Legendre symbol by repeated reduction.

Worked example. Is 5 a QR mod 23? 23≡3(mod5)23 \equiv 3 \pmod 5. Reciprocity: (523)=(235)\left(\frac{5}{23}\right) = \left(\frac{23}{5}\right) (sign =(−1)11⋅2=+1= (-1)^{11 \cdot 2} = +1), and 23≡3(mod5)23 \equiv 3 \pmod 5: (35)=−1\left(\frac{3}{5}\right) = -1 (squares mod 5 are 1, 4). So 5 is a non-residue mod 23. Check by Euler: 511≡−1(mod23)5^{11} \equiv -1 \pmod{23}.

8.4 Counting Solutions of x2≡ax^2 \equiv a

Section titled “8.4 Counting Solutions of x2≡ax^2 \equiv ax2≡a”

For odd pp and p∤ap \nmid a:

  • aa QR: exactly two solutions, xx and p−xp - x (found by Tonelli’s algorithm or trial).
  • aa non-residue: zero solutions.

The equation x2≡a(modpk)x^2 \equiv a \pmod{p^k} behaves differently: solutions lift uniquely from mod pp when pp is odd. For x2≡a(mod2k)x^2 \equiv a \pmod{2^k} the 2-adic analysis is more delicate; a favourite distinction-level question.

Problem 1. Determine (713)\left(\frac{7}{13}\right) and, if 7 is a QR, solve x2≡7x^2 \equiv 7.

Euler: 76(mod13)7^6 \pmod{13}: 72=49≡107^2 = 49 \equiv 10, 74≡100≡97^4 \equiv 100 \equiv 9, 76≡9⋅10=90≡12≡−17^6 \equiv 9 \cdot 10 = 90 \equiv 12 \equiv -1. So 7 is a non-residue: no solutions.

Problem 2. Show x2≡−1(modp)x^2 \equiv -1 \pmod p is solvable iff p=2p = 2 or p≡1(mod4)p \equiv 1 \pmod 4. Euler: (−1)(p−1)/2=1(-1)^{(p-1)/2} = 1 iff p≡1(mod4)p \equiv 1 \pmod 4.

  • Euler’s criterion works only for odd prime pp.
  • (ap)=1\left(\frac{a}{p}\right) = 1 gives two solutions, not one: remember ±x\pm x.
  • Reciprocity sign bookkeeping: the exponent is p−12⋅q−12\frac{p-1}{2}\cdot\frac{q-1}{2}; an odd product flips the symbol, an even one does not.
  • Composite moduli need the Jacobi symbol (a/n)(a/n), which is multiplicative but does not decide solvability when nn is composite: (an)=1\left(\frac{a}{n}\right) = 1 does not imply x2≡ax^2 \equiv a is solvable.

Mod 11, the QRs are {1,3,4,5,9}\{1, 3, 4, 5, 9\}; exactly (11−1)/2=5(11-1)/2 = 5 classes. Verify by squaring 1,…,101, \ldots, 10 and note the symmetry xx and 11−x11 - x share a square.

(ap)≡a(p−1)/2(modp)\left(\frac{a}{p}\right) \equiv a^{(p-1)/2} \pmod p

Euler’s criterion doubles as a computation recipe: exponentiate and read the sign. For p=23p = 23, a=5a = 5: 511≡−1(mod23)5^{11} \equiv -1 \pmod{23}, so 5 is a non-residue and x2≡5x^2 \equiv 5 has no solution. Pair this with reciprocity for a two-mark derivation.

(ap)≡a(p−1)/2(modp)\left(\frac{a}{p}\right) \equiv a^{(p-1)/2} \pmod p

Euler’s criterion doubles as a computation recipe: exponentiate and read the sign. For p=23p = 23, a=5a = 5: 511≡−1(mod23)5^{11} \equiv -1 \pmod{23}, so 5 is a non-residue and x2≡5x^2 \equiv 5 has no solution. Pair this with reciprocity for a two-mark derivation. Euler’s criterion also solves xx: when a(p+1)/4≡±xa^{(p+1)/4} \equiv \pm x for p≡3(mod4)p \equiv 3 \pmod 4, squaring recovers aa; the two solutions are negatives of each other.

Mod 11 the QRs are {1,3,4,5,9}\{1, 3, 4, 5, 9\} and mod 13 they are {1,3,4,9,10,12}\{1, 3, 4, 9, 10, 12\}; five and six classes respectively, each exactly half of the nonzero residues as Euler’s criterion predicts.