7 The reciprocity law
7.1 The statement
In the previous section the prime \(p\) was fixed, and we are asking “which \(a\) are quadratic residues mod \(p\)”? But we can also do something else: we can fix an integer \(a,\) and ask “for which (odd) primes \(p \nmid a\) is \(a\) a quadratic residue mod \(p\)?” For instance, with \(a = 5,\) we see the following:
Residue: \(\{11, 19, 29, 31, 41, 59, 61, 71, \dots\}\)
Non-residue: \(\{3, 7, 13, 17, 23, 37, 43, 47, \dots\}\)
Notice the last digits! Amazingly, the answer seems to depend only on \(p\) mod 5 – which is strange, since the question is about \(5 \bmod p,\) not \(p \bmod 5,\) and these are totally different things.
If you try other values of \(a,\) the answer doesn’t always depend on \(p \bmod a,\) but it’s not far off – it suffices to know \(p \bmod 4a.\) This is the first hint at the following beautiful and important theorem:
If \(p, q\) are two distinct odd primes, then \[\left(\frac{p}{q}\right) \cdot \left(\frac{q}{p}\right) = (-1)^{\tfrac{(p-1)}{2} \cdot \tfrac{(q-1)}{2}} = \begin{cases} \phantom{-}1 & \text{if at least one of $p, q$ is $1 \bmod 4$} \\ -1 & \text{if both are $3 \bmod 4$}. \end{cases}\]
Along with Gauss’ law there are two related theorems (the “supplements to quadratic reciprocity”) – one for \(a = -1\) (which we have already proved as Proposition 6.6 above), and another for \(a = 2\) (which will be Theorem 7.6 below). These say that for any odd prime \(p\) we have \[\left(\frac{-1}{p}\right) = (-1)^{\tfrac{(p-1)}{2}} = \begin{cases} \phantom{-}1 & \text{if $p = 1 \bmod 4$}\\ -1 & \text{if $p = 3 \bmod 4$} \end{cases}\] and \[\left(\frac{2}{p}\right) = (-1)^{\tfrac{(p^2-1)}{8}} = \begin{cases} \phantom{-}1 & \text{if $p = \pm 1 \bmod 8$}\\ -1 & \text{if $p =\pm 3 \bmod 8$}. \end{cases}\]
The quadratic reciprocity law has many different proofs; Gauss himself published six different proofs in his lifetime, and hundreds more have been found since. However, none of them are particularly easy – whichever why you approach it, you have to do some genuine work. We’ll give a proof shortly, which is quite close to one of Gauss’ original arguments. First, we note that this does explain the observations above:
Let \(a \in \mathbb{Z}\) be non-zero, and \(p,\) \(q\) odd primes, not dividing \(a,\) such that \(p = q \bmod 4|a|.\) Then \(\left(\frac{a}{p}\right) = \left(\frac{a}{q}\right).\)
Proof. Considering the prime factorisation of \(|a|\) and using the multiplicativity of the Legendre symbol, we may suppose that we are in one of three cases: \(a = -1,\) \(a = 2,\) or \(a\) is an odd prime. The first two cases are OK by the two supplementary laws, so we suppose we are in the third case.
Since \(p = q \bmod 4|a|,\) either \(p = q = 1 \bmod 4\) or \(p = q = 3 \bmod 4.\) If \(p = q = 1 \bmod 4,\) or if \(a = 1 \bmod 4,\) then we have \[\left(\frac{a}{p}\right) = \left(\frac{p}{a}\right) = \left(\frac{q}{a}\right) = \left(\frac{a}{q}\right).\] If \(a, p, q\) are all \(3 \bmod 4,\) then we have similarly \[\left(\frac{a}{p}\right) = -\left(\frac{p}{a}\right) = -\left(\frac{q}{a}\right) = \left(\frac{a}{q}\right).\]
7.2 Gauss’ Lemma
Let \(p\) be an odd prime, and let \(L \subset U_p\) be the set given by the residue classes of the integers \(\{1, \dots, \tfrac{p-1}{2}\}.\) Then \(\left(\frac{a}{p}\right) = (-1)^s,\) where \(s\) is the number of \(x \in L\) such that \(a x \notin L.\)
Take \(p = 13\) and \(a = 11\); then we reduce 11, 22, 33, 44, 55, 66 modulo 13 to \(-2,\) \(-4,\) \(-6,\) \(5,\) \(3,\) \(1.\) As expected by the proof of the Proposition, these are, up to sign, the integers between 1 and 6; and the minus sign appears exactly 3 times, so \(\left(\frac{11}{13}\right) = (-1)^3 = -1.\)
On the other hand, if \(p = 13\) and \(a = 10,\) we reduce 10, 20, 30, 40, 50, 60 to \(-3,-6,4,\) \(1,-2,-5,\) with 4 minus signs, so \(\left(\frac{10}{13}\right) = (-1)^4 = 1.\) Indeed, we check that \(6^2 = 36 = 10 \bmod 13.\)
Proof. Let us compute \(\prod_{x \in L} a x.\)
On the one hand, we can pull out all the factors of \(L\) and get \[\prod_{x \in L} a x = a^{(\#L)} \cdot \prod_{x \in L} x = a^{(p-1)/2} \left(\tfrac{p-1}{2}\right)!.\]
On the other hand, for \(x \in U_p,\) exactly one of \(x\) and \(-x\) is in \(L\); let’s write \(\lambda(x) = x\) if \(x \in L,\) and \(\lambda(x) = -x\) otherwise, and \(\epsilon(x) = x / \lambda(x) \in \{\pm 1\}.\) So we can write \[\begin{aligned} \prod_{x \in L} a x &= \prod_{x \in L} \epsilon(ax) \lambda(ax) \\ &= \left(\prod_{x \in L} \epsilon(ax)\right) \cdot \left(\prod_{x \in L} \lambda(ax)\right)\\ &= \left(-1\right)^s \cdot \left(\prod_{x \in L} \lambda(ax)\right),\\ \end{aligned}\] since the first product has \(s\) terms \(-1\) and all the rest \(+1.\)
We claim \(x \mapsto \lambda(ax)\) is a bijection \(L \to L,\) so the second product is just a re-ordering of the product \(\prod_{x \in L} x = \left(\tfrac{p-1}{2}\right)!.\) It suffices to show the map is injective, since \(L\) is finite. If \(\lambda(ax) = \lambda(ay)\) for some \(x, y \in L,\) then \(ax = \pm ay.\) Since \(a\) is a unit, this implies \(x = \pm y,\) and since \(x, y \in L,\) this forces \(x = y,\) as required.
So we have \(\prod_{x \in L} a x = (-1)^s \left(\tfrac{p-1}{2}\right)!.\) Comparing this with the previous formula for the same product, we have \[a^{(p-1)/2} \left(\tfrac{p-1}{2}\right)! = (-1)^s \left(\tfrac{p-1}{2}\right)!\] and cancelling the (nonzero) common factor \(\left(\tfrac{p-1}{2}\right)!\) gives the lemma.
The quantity \(\left(\tfrac{p-1}{2}\right)! \bmod p,\) which appears in the above proof, turns out to be a very interesting quantity! Can you show that \[\left(\left(\tfrac{p-1}{2}\right)!\right)^2 \bmod p = \begin{cases} \phantom{-}1 & \text{if $p = 1 \bmod 4$} \\ -1 & \text{if $p = 3 \bmod 4$?}\end{cases}\]
[Notice that this gives a direct proof that \(-1\) is a square mod \(p\) if \(p = 1 \bmod 4.\) On the other hand, if \(p = 3 \bmod 4,\) then we must have either \(\left(\tfrac{p-1}{2}\right)! = 1\) or \(\left(\tfrac{p-1}{2}\right)! = -1.\) Can you spot any pattern governing which case occurs? (\(\circledast\))
For \(p\) an odd prime, we have \[\left(\frac{2}{p}\right) = (-1)^{(p^2 - 1) / 8} = \begin{cases} 1 & \text{if $p = \pm 1 \bmod 8$}\\ -1 & \text{if $p = \pm 3 \bmod 8$}.\end{cases}\]
Proof. Clearly, for an integer \(a \in \{1, \dots, \tfrac{p-1}{2}\},\) we have \(2a \in L\) if \(1 \leqslant a \leqslant\tfrac{p-1}{4},\) and \(2a \notin L\) if \(\tfrac{p-1}{4} < a \leqslant\tfrac{p-1}{2}\}.\) So \(\left(\frac{2}{p}\right)\) is \((-1)^s,\) where \(s = \#\{ a : \tfrac{p-1}{4} < a \leqslant\tfrac{p-1}{2}\}.\)
Now we consider cases:
\(p = 8q + 1\): then \(s = \#\{ a : 2q < a \leqslant 4q \} = 2q\) even
\(p = 8q + 3\): then \(s = \#\{ a : 2q + \tfrac{1}{2} < a \leqslant 4q + 1 \} = 2q + 1\) odd
\(p = 8q + 5\): then \(s = \#\{ a : 2q + 1 < a \leqslant 4q + 2 \} = 2q + 1\) odd
\(p = 8q + 7\): then \(s = \#\{ a : 2q + \tfrac{3}{2} < a \leqslant 4q + 3\} = 2q + 2\) even.
7.3 Eisenstein’s lemma and the final proof
To complete the proof of Quadratic Reciprocity we need one more lemma.
For \(a\) odd, let \[t = \sum_{i = 1}^{(p-1)/2} \lfloor \tfrac{ia}{p} \rfloor,\] where \(\lfloor x\rfloor\) denotes, as usual, the greatest integer \(\leqslant x.\) Then \(\left(\frac{a}{p}\right) = (-1)^t.\)
Proof. It suffices to show that \(t = s\bmod 2,\) where \(s\) is as in Gauss’ lemma. For each \(i,\) we write \[i a = p \cdot \lfloor \tfrac{ia}{p} \rfloor + r_i\] where \(r_i\) is the unique integer in \(\{1, \dots, p-1\}\) congruent to \(ia \bmod p.\) Adding these equations together, and reducing mod 2 (remembering that \(a\) and \(p\) are odd), we obtain \[(1 + \dots + \tfrac{p-1}{2}) = t + \sum r_i.\]
As in the proof of Gauss’ lemma, for each \(\ell \in L,\) exactly one of \(\ell\) or \(p - \ell\) occurs among the \(r_i.\) Moreover, the number of times that \(p - \ell\) occurs is \(s.\) Since \(p - \ell = 1 + \ell \bmod 2,\) we have \(\sum r_i = s + (1+ \dots + \tfrac{p-1}{2}).\) Plugging this into the above, we deduce that \[(1 + \dots + \tfrac{p-1}{2}) = t + s + (1 + \dots + \tfrac{p-1}{2}) \bmod 2,\] so \(t = -s = s \bmod 2.\)
Proof of Quadratic Reciprocity. We’re going to do this by “counting lattice points”. Consider the rectangle \(R\) in the \((x, y)\) plane with vertices at \((0, 0),\) \((p/2, 0),\) \((p/2, q/2)\) and \((0, q/2).\) The diagonal \(y = \tfrac{q}{p}\) x divides this into two triangles.
We want to count the pairs \((x, y) \in \mathbb{Z}^2\) which lie in the interior of \(R.\) Evidently there are exactly \(\tfrac{p-1}{2} \cdot \tfrac{q-1}{2}\) of these in total; and none of them lie exactly on the diagonal (since \(p\) and \(q\) are distinct primes).
On the other hand, how many lie below the diagonal? For each \(i = 1, \dots, \tfrac{p-1}{2},\) the number of points below the diagonal in the “vertical column” with \(x = i\) is exactly \(\lfloor \tfrac{iq}{p}\rfloor.\) Thus the total number is the quantity \(t\) from the last lemma; so \((-1)^t = \left(\frac{q}{p}\right).\)
Reversing the roles of \(p\) and \(q,\) the number of lattice points above the diagonal, \(t',\) satisfies \((-1)^{t'} = \left(\frac{p}{q}\right).\) Since every point must lie above or below the diagonal, \(t + t' = \tfrac{(p-1)}{2} \cdot \tfrac{(q-1)}{2},\) and hence \[\left(\frac{q}{p}\right) \cdot \left(\frac{p}{q}\right) = (-1)^{t + t'} = (-1)^{\tfrac{(p-1)}{2} \cdot \tfrac{(q-1)}{2}}.\] which proves the theorem.