Mathematics, the way it is currently written, can be difficult to read. Sometimes it helps to see how people think about a topic or theorem before (or after, or during) the reading of a proper treatment or rigorous proof. The purpose of this post is to provide such a view regarding the proof of the famous law of quadratic reciprocity. There are many details missing, on purpose, and the hope is that it reads like a good story that’s both interesting, believable and easily verifiable.

Basically this “law” provides a fantastic theoretical tool used to tell us which numbers have square roots mod p. We will not get into the full extent of its power. Rather, the goal here is to (eventually) state it and to shine light on remarkable features of the proof. We start with -1.

When is -1 a square?

As example, $\sqrt{-1}$  makes sense mod 5, since

$2^2 = 4= -1 \mod 5$.

More generally, it turns out that for any odd prime p,

$x^2=-1 \mod p$  has a solution if an only if

$p=1 \mod 4$

The reason boils down to Euler’s Criterion (below). Let’s first warm up with Fermat’s Little Theorem (FLT), which states:

$x^{p-1}=1 \mod p \hbox{ if } x \ne 0$

FLT is true because $x, 2x, 3x, ...\ , (p-1)x$  are all different mod p, and so their product is $(p-1)!$

Canceling the factor $(p-1)!$ on both sides gives $x^{p-1}=1 \mod p$. The upshot is that the equation:

$x^{p-1} -1=0 \mod p$

has p-1 solutions (the maximum it could have, considering its degree).

Now, consider the similar equation:

$x^{\frac{p-1}{2}}=1 \mod p$.

$\hbox{If }x_0=y^2 \hbox{ (and } y\ne 0 \hbox{), then } x_0 \hbox{ is a solution, by FLT.}$

Since there are $\frac{p-1}{2}$ different (nonzero) squares mod p (prove it) and since the equation has at most $\frac{p-1}{2}$ solutions (believe it for now–think degree again, working modulo a prime), the solutions of the equation are exactly the squares. This is called Euler’s criterion and often written as:

${\bf \emph{x}}$ is a (nonzero) square mod p if and only if ${\bf \emph{x}^\frac{p-1}{2}=1}$

(By the way, if $x^\frac{p-1}{2}\ne 1$  then  $x^\frac{p-1}{2}=-1 \mod p$ — why?)

We can now understand when -1 can be a perfect square mod p. In general, $(-1)^m$ can only equal 1 if $m$ is even. Thus, $(-1)^\frac{p-1}{2}=1$  if and only if  $\frac{p-1}{2}$  is even; that is, $p=1 \mod 4.$

When does $\sqrt 2$ exist?

This is actually similar but certainly trickier. The answer, for an odd prime p is:

$x^2=2$ has a solution (mod p) if and only if $p=1,7 \mod 8$.

To see why, we first consider something analogous to Fermat’s Little Theorem. Consider:

$x, 2x, 3x, ...\ , \frac{p-1}{2} x \hbox{ mod p}$

Not only are they all different mod p, but much better–there’s exactly one of these multiples of $x$ from each pair:

${\bf \{1,-1\}, \{2,-2\}, \{3,-3\}, \cdots, \{ \frac{p-1}{2}, -\frac{p-1}{2} \}}$

This is not too hard to prove and it’s fun. It will be crucial to remember later during the “reciprocity part” of the post.  This next fact isn’t easy, and it’s amazing:

$x$ is a square if and only if the “negative option” is chosen an even number of times.

The number of times the negative option is chosen is important enough to give it a name, $n$  used for this purpose for the rest of this post. As an example, for p=11 we ask: is 9 a square? (of course it is, $3^2=9$, but just play along!) The multiples of 9 are: 9, 18, 27, 36 and 45. Respectively, they reduce (mod 11) to:

${\bf -2, -4}, 5, 3 \hbox{ and } 1.$

With two negative options, $n=2$, which is even, so 9 is a square mod 11.

The explanation is similar to that of FLT,

$(x)(2x)(3x) \cdots (\frac{p-1}{2} x)=(-1)^n(\frac{p-1}{2}) ! \mod p$

Working mod p, we cancel the $(\frac{p-1}{2})!$ from both sides to get:

$x^\frac{p-1}{2}=(-1)^n.$

Combine this with Euler’s Criterion and we can now determine which numbers are squares modulo our odd prime p:

Key Fact:

$x$ is a square mod p if and only if $n$ is even.

If $x=2$, then it is a fun, tractable exercise (class project to help students discover strong induction?) to determine which primes have $n$ even, namely, $p=1,7 \mod 8.$

This is part of the law—for any odd prime $p$, we know that 2 is a square mod p if and only if $p=1 \hbox{ or } 7 \hbox{ mod 8.}$

Context is everything

One of the really cool things about quadratic reciprocity is that one needs to keep changing perspectives and contexts to understand it. This makes it a great introduction to modern mathematics. Take for example the notion of parity, which means evenness or oddness of an integer. On the surface, 5 and -5 have the same parity. In the above discussion, we considered sets {1,-1}, {2,-2}, … viewed mod p. If p is an odd prime, then -2 really means p-2 which has the opposite parity of 2. Perhaps these sets should have been written {1,p-1}, {2, p-2}, … This awareness of multiple perspectives helps with what follows.

The reciprocity part

The last part of the law of quadratic reciprocity concerns two odd primes p and q. It connects the answers to the two questions:

1. Is q a square mod p?
2. Is p a square mod q?

So, should we work mod p or mod q? We’ll lean towards mod p but really we’ll use neither!

Any positive integer $a$ can be decomposed as a “big part” plus a “remainder” with respect to division by p. That is:

$a=p \big [ \frac{a}{p} \big ]+r$

where [x] denotes the floor of x and $0\le r\le p-1 .$

So far we’ve been focusing on the “remainder” and ignoring the “big part.” We’ll do this decomposition for our usual set of numbers, namely  $a, 2a, 3a, \cdots , (\frac{p-1}{2})a .$

This time, we’ll add them, grouping the “big parts” together and “remainders” after.

As an illustrative example, we take $p=11, a=7 .$

We’ll take out a common factor of 7 on the left hand side, and a factor of 11 from the “big parts” on the right hand side. Thus:

${\bf 7(1+2+3+4+5)=}$

${\bf 11\big( [\frac{7}{11}]+[\frac{14}{11}]+[\frac{21}{11}]+[\frac{28}{11}]+[\frac{35}{11}] \big) +(7+}3+{\bf 10+6+}2{\bf)}$

From this simple example equation, one can see the main point (keep reading to see how). Even though this is an equation of integers, we can draw on our experience working mod p and recognize $n=3$ in the sense that 3 of the remainders had the “negative option.” Indeed, imagining mod 11, we know that 7 is not a square and we identify  $7=-4, 10=-1 \hbox{ and } 6=-5.$

Yet, crucially, our example equation isn’t mod 11—it’s an equation of integers. Let’s reduce it mod 2, where multiplication by an odd number has no effect (so we ignore the factor of 7 on the left and the factor of 11 on part of the right). Thus, viewed mod 2:

${\bf (1+2+3+4+5)}=$

$\big( [\frac{7}{11}]+[\frac{14}{11}]+[\frac{21}{11}]+[\frac{28}{11}]+[\frac{35}{11}] \big) +{\bf (7+3+10+6+2)}$

Now focus on the remainder part: (7+3+10+6+2). Compare its parity with what we’d have if we never needed the negative option, ie. (4+3+1+5+2). The difference is evidently $n \hbox{ mod 2}$ — one parity change for each negative option.

But the left hand side must be (a permuted version of) (4+3+1+5+2). Thus:

$0=[\frac{7}{11}]+[\frac{14}{11}]+[\frac{21}{11}]+[\frac{28}{11}]+[\frac{35}{11}]+{\bf \emph{n}}$

or, since we’re working mod 2:

$n=[\frac{7}{11}]+[\frac{14}{11}]+[\frac{21}{11}]+[\frac{28}{11}]+[\frac{35}{11}]$

In other words, the parity of the sum of the quotients is the same as the parity of  $n$,  which (by what we called “Key Fact”) tells us if $a$ is a square! So, 7 is not a square mod 11, because $n=3$ which is odd—but equivalently—because the sum of quotients

$[\frac{7}{11}]+[\frac{14}{11}]+[\frac{21}{11}]+[\frac{28}{11}]+[\frac{35}{11}]=0+1+1+2+3$

is also odd.

This will always work provided p is an odd prime and $a$ is an odd positive integer.

Therefore, a fundamental property about remainders has been wonderfully transformed into one regarding quotients. This is extremely interesting in its own right, and is also the main point. Now to state the theorem and clarify what’s left to show.

Theorem: For odd primes p and q, the two questions

1. Is q a square mod p?
2. Is p a square mod q?

have the same answer if and only if $\frac{p-1}{2} \frac{q-1}{2}$ is even.

We have seen how the answer to question 1 is controlled by the parity of:

$[\frac{q}{p}]+[\frac{2q}{p}]+\cdots +[\frac{((p-1)/2)q}{p}]$

Since both are odd primes, we can reverse the roles of p and q and the answer to question 2 is controlled by the parity of

$[\frac{p}{q}]+[\frac{2p}{q}]+\cdots +[\frac{((q-1)/2)p}{q}]$

All that remains is to show that the sum of these two expressions has the same parity as

$\frac{p-1}{2} \frac{q-1}{2}.$

But more is true: they are exactly equal. While remarkable, this equality is tractable and it may be possible (with hints!) to set this up as a class project, perhaps in a pre-calculus class after a discussion of inverse functions. But that’s a subject for another post.

We finish here by merely illustrating the equality on our example p=11, q=7. One sum of quotients we have already calculated as 0+1+1+2+3=7, the other is

$[\frac{11}{7}]+[\frac{22}{7}] +[\frac{33}{7}]=8.$

Also for this example $\frac{p-1}{2} \frac{q-1}{2}=(5)(3)=15.$

Perfect.