The law of quadratic reciprocity is a well known number theoretic theorem that gives conditions for the solvability of quadratic equations modulo prime numbers.
Example: Are there solutions to the congruence $x^2 + 4x \equiv 10 \pmod{7}$?
Theorem:
Let $p$ and $q$ be distinct odd primes. Then the law of quadratic reciprocity can be broken into three parts:
$$\left( \frac{-1}{p} \right) =
\begin{cases}
1 &p \equiv 1 \pmod{4} \\
-1 &p \equiv 3 \pmod{4}
\end{cases}$$
$$\left( \frac{2}{p} \right) =
\begin{cases}
1 &p \equiv 1 \rm\ or\ 7 \pmod{8} \\
-1 &p \equiv 3 \rm\ or\ 5 \pmod{8}
\end{cases}$$
$$\left( \frac{q}{p} \right) =
\begin{cases}
\left( \frac{p}{q} \right) &p \equiv 1 \pmod{4} \text{ or } q \equiv 1 \pmod{4} \\
-\left( \frac{p}{q} \right) &p \equiv 3 \pmod{4} \text{ and } q \equiv 3 \pmod{4}
\end{cases}$$
We will focus on the proof for the 3rd more general case for the purposes of this article.
The main use for the law of quadratic reciprocity is to compute Legendre symbols.
Definition:
The Legendre symbol of $a$ modulo $p$ is
$$\left( \frac{a}{p} \right) =
\begin{cases}
1 &\text{if a is a quadratic residue modulo p} \\
-1 &\text{if a is a nonresidue modulo p}
\end{cases}$$
In essence, the Legendre symbol denotes whether a solution exists to the equation $x^2 \equiv a \pmod{p}$.
Example:
$$\left( \frac{55}{179} \right) = \left( \frac{5}{179} \right) \cdot \left( \frac{11}{79} \right) = \left( \frac{179}{5} \right) \cdot -\left( \frac{179}{11} \right) = -\left( \frac{4}{5} \right) \cdot \left( \frac{3}{11} \right) \\ = -\left( \frac{3}{11} \right) = \left( \frac{11}{3} \right) = \left( \frac{2}{3} \right) = -1.$$
As you can see, the law of quadratic reciprocity allowed us to determine that $55$ is not square modulo $79$. At this point, one might be inclined to ask how to find the solutions given the result that a number is a quadratic residue. The answer to this problem is a separate matter (see Quadratic residues) and will not be discussed here.
There are actually many different proofs for quadratic reciprocity. We outline two of them below.
Eisenstein's proof uses a criterion of Gauss that we will prove before discussing his argument.
Theorem:
Let $p$ be and odd prime, let $a$ be an integer that is not divisible by $p$, and let $\mu(a, p) = $ the number of integers in the list $a, 2a, ..., Pa$ that become negative when the integers in the list are reduced modulo $p$ into the interval from $-P$ to $P$. Then
$$\left( \frac{a}{p}\right) = (-1)^{\mu(a, p)}.$$
Before starting the proof of Gauss's Criterion, we first introduce a lemma that describes what happens when we reduce $a, 2a, 3a, ..., Pa$ modulo p.
Lemma:
When the numbers $a, 2a , 3a , ... , Pa$ are reduced modulo p into the range from $-P$ to $P$, the reduced values are $\pm1, ..., \pm P$ in some order, with each number appearing once with either a plus sign or a minus sign.
We will not prove this lemma here, but hope it comes as a good exercise to the reader.
Proof of Gauss:
We start by taking the list of numbers $a, 2a, ..., Pa$ and multiplying them. The product equals
$$a \cdot 2a \cdot\cdot\cdot Pa = a^P(1 \cdot 2 \cdot\cdot\cdot P) = a^P \cdot P!. \tag{*}$$
On the other hand, the Lemma above tells us that
$$a \cdot 2a \cdot\cdot\cdot Pa \equiv (\pm1)(\pm2)\cdot\cdot\cdot(\pm P) \pmod{p},$$
where the number of minus signs is $\mu(a, p)$ by definition. So
$$\begin{align*}
a \cdot 2a \cdot\cdot\cdot Pa &\equiv (-1)^{\mu(a, p)} \cdot 1 \cdot 2 \cdot\cdot\cdot P \pmod{P} \\
&\equiv (-1)^{\mu(a, p)} \cdot P! \pmod{P}. \tag{**}
\end{align*}$$
Comparing the formula $(*)$ to the congruence $(**)$, we see that
$$a^P \cdot P! \equiv (-1)^{\mu(a, p)} \cdot P!.$$
The number $P!$ is not divisible by $p$, so we may cancel it from both sides of the congruence to get
$$a^P \equiv (-1)^{\mu(a, p)} \pmod{p}.$$
Finally, we observe that Euler's Criterion says that
$$a^P \equiv \left( \frac{a}{p} \right) \pmod{p},$$
(remember that $P = \frac{p-1}{2}$), so
$$\left( \frac{a}{p} \right) \equiv (-1)^{\mu(a, p)} \pmod{p}.$$
This says that $\left( \frac{a}{p} \right) - (-1)^{\mu(a, p)}$ is divisible by $p$. But the quantity $\left( \frac{a}{p} \right) - (-1)^{\mu(a, p)}$ equals either $-2, 0, \rm or, 2$, while $p \geq 3$, so we conclude that $\left( \frac{a}{p} \right) - (-1)^{\mu(a, p)} = 0. \square$
Rest of the proof coming soon.
Before we get to the second proof of quadratic reciprocity, we are going to need to learn a little bit about algebraic permutations. A permutation of a set $S$ is defined as a bijection from $S$ to itself. That is, it is a function from $S$ to $S$ that is both injective (one-to-one) and surjective (onto). For example, $f: \{1, 2, 3, 4\} \to \{1, 2, 3, 4\}$ is a permutaion given by $$f(n) = \begin{cases} n+1 & n < 4 \\ 1 & n = 4 \end{cases}$$ It can be visualized as such:
Notice the cycle decomposition and $sgn()$ value accompanying the figure above.Try composing some permutations yourself below:
Now with some basic knowledge of permutations, we are ready to tackle the proof that Dr. Matt Baker outlines in his blog here.
Definition:
Let $\tau_a$ be the permutation of $\{1, 2, ..., p-1\}$ given by multiplying by $a$ modulo $p$ where $a$ is an integer not divisible by the odd prime $p$. Then Zolotarev's Lemma states
$$ \left( \frac{a}{p} \right) = \left[ \frac{a}{p} \right]$$
where $\left[ \frac{a}{p} \right] = sgn(\tau_a)$.
Proof:
Let $g$ be a primitive root modulo $p$ and let $k=\rm ind_g(a)$. As a set, $\{1, 2, ..., p-1\} = \{g^0, g^1, ..., g^{p-2}\}$ modulo $p$. This means multiplying by $a$ is equivalent to adding $k$ modulo $p-1$ on $\{0, 1, ..., p-2\}$. Therefore
$$sgn(\tau_a) = ((-1)^{\frac{p-1}{(k, p-1)} - 1})^{(k, p-1)} = (-1)^{p-1-(k, p-1)} = (-1)^{(k, p-1)} \text{ since (p-1) is even.}$$
But,
$$ (k, p-1) \text{ is } \begin{cases}
\text{odd} &\text{if k is odd} \\
\text{even} &\text{if k is even}
\end{cases}$$
and therefore,
$$sgn(\tau_a) = (-1)^k = \left( \frac{a}{p} \right). \square$$
Now that we understand Zolotarev's Lemma, we can discuss the proof proposed by Matt Baker.
First, we need to define some permutaions in the form of playing card arrangements. Let $m$ and $n$ be odd relatively prime positive integers. We have a stack of $mn$ playing cards numbered $0$ through $mn-1$ and you want to deal them onto the table in an $m \times n$ rectangular array. Consider the following three ways of doing this:
Row Deal
($\rho$): Deal the cards into rows, going left to right and top to bottom.
This bonus section discusses Jacobi symbols, a generalization of Legendre symbols. Evaluating Legendre symbols is useful, but for large numbers, it is not feasible to factor the numerator and split into multiple Legendre symbols. This is where the Generalized Law of Quadratic Reciprocity comes in.
Theorem:
Let $a$ and $b$ be odd positive integers. Then the generalized law of quadratic reciprocity can be broken into three parts:
$$\left( \frac{-1}{b} \right) =
\begin{cases}
1 &b \equiv 1 \pmod{4} \\
-1 &b \equiv 3 \pmod{4}
\end{cases}$$
$$\left( \frac{2}{b} \right) =
\begin{cases}
1 &b \equiv 1 \rm\ or\ 7 \pmod{8} \\
-1 &b \equiv 3 \rm\ or\ 5 \pmod{8}
\end{cases}$$
$$\left( \frac{a}{b} \right) =
\begin{cases}
\left( \frac{b}{a} \right) &a \equiv 1 \pmod{4} \text{ or } b \equiv 1 \pmod{4} \\
-\left( \frac{b}{a} \right) &a \equiv 3 \pmod{4} \text{ and } b \equiv 3 \pmod{4}
\end{cases}$$
As you may have noticed, this statement is extremely similar to the Law of Quadratic Reciprocity discussed above. In fact, the argument for Zolotarev's Lemma above generalizes to give quadratic reciprocity for the Jacobi symbol
Example:
$$\left( \frac{55}{179} \right) = -\left( \frac{179}{55} \right) = -\left( \frac{14}{55} \right) = -\left( \frac{2}{55} \right) \cdot \left( \frac{7}{55} \right) = \left( \frac{55}{7} \right) = \left( \frac{6}{7} \right) \\ = \left( \frac{2}{7} \right) \cdot \left( \frac{3}{7} \right) = -\left( \frac{7}{3} \right) = -\left( \frac{1}{3} \right) = -1.$$
As you can see, we were able to evaluate the same Legendre as the beginning of the article without factoring $55$.