Lecture 19: Gauss' Lemma; Quadratic Reciprocity

# Summary

In today's class we began by reviewing the criteria we saw for evaluating Legendre symbols last class period, particularly when the "numerator" was either -1 or 2. Afterwards we set to proving

(1)
\begin{align} \left(\frac{2}{p}\right) = \left\{\begin{array}{rl}1,&\mbox{ if }p \equiv 1,7 \mod{8}\\-1, & \mbox{ if } p \equiv 3,5 \mod{8}.\end{array}\right. \end{align}

This required Gauss' Lemma, which lets us determine whether a is a square based on residues of products ja, where j ranges over the "first half" of residues mod p. After this, we stated and applied the Quadratic Reciprocity Law.

# Review

Last class period we wrote down some rules for determining whether -1 or 2 is a square modulo a given odd prime p. Let's try to put these skills to the test.

#### Example: Determining whether -2 is a square

Let's try to determine whether -2 is a square modulo 467, 569, 821 and 383 (all these numbers are prime). For the first one, we notice that

(2)
\begin{align} \left(\frac{-2}{467}\right) = \left(\frac{-1}{467}\right)\left(\frac{2}{467}\right). \end{align}

Now to determine whether -1 is a square mod 467, we note that $467 \equiv 3 \mod{4}$. This means that -1 is not a square. On the other hand, to determine whether 2 is a square mod 467, we note that $467 \equiv 3 \mod{8}$. This means that 2 is also not a square mod 467. Hence we have

(3)
\begin{align} \left(\frac{-2}{467}\right) = \left(\frac{-1}{467}\right)\left(\frac{2}{467}\right) = (-1)(-1) = 1, \end{align}

and so we see that -2 is a square mod 467.

Similarly we have

(4)
\begin{split} \left\{\begin{array}{cc}569 \equiv 1 \mod{4}\\569 \equiv 1 \mod{8}\end{array}\right\} &\Longrightarrow \left(\frac{-2}{569}\right) = \left(\frac{-1}{569}\right)\left(\frac{2}{569}\right) = (1)(1) = 1\\ \left\{\begin{array}{cc}821 \equiv 1 \mod{4}\\821 \equiv 5 \mod{8}\end{array}\right\} &\Longrightarrow \left(\frac{-2}{821}\right) = \left(\frac{-1}{821}\right)\left(\frac{2}{821}\right) = (1)(-1) = -1\\ \left\{\begin{array}{cc}383 \equiv 3 \mod{4}\\383 \equiv 7 \mod{8}\end{array}\right\} &\Longrightarrow \left(\frac{-2}{383}\right) = \left(\frac{-1}{383}\right)\left(\frac{2}{383}\right) = (-1)(1) = -1.\\ \end{split}

$\square$

# Gauss' Lemma

Having practiced the rules we learned last time, let's prove the result concerning the Legendre symbol $\left(\frac{2}{p}\right)$. To do so, we'll need the following

Gauss' Lemma: For p an odd prime and $p \nmid a$, let

$\displaystyle n=\#\left\{1 \leq j \leq \frac{p-1}{2}: \begin{array}{cc}\mbox{ the least non-neg residue of }\\ja \mbox{ is greater than}\frac{p}{2}\end{array}\right\}.$

Then $\left(\frac{a}{p}\right) = (-1)^n$.

Before we prove this result, let's see it in practice.

#### Example: Is 5 a square mod 11?

Let's try to compute $\left(\fra{5}{11}\right)$. For this, we're told we need to compute $5j$ for values of j between 1 and $\frac{11-1}{2} = 5$. So let's do it:

(5)
\begin{split} 5\cdot 1 &\equiv 5 \mod{11}\\ 5\cdot 2 &\equiv 10 \mod{11}\\ 5\cdot 3 &\equiv 15 \equiv 4 \mod{11}\\ 5\cdot 4 &\equiv 20 \equiv 9 \mod{11}\\ 5\cdot 5 &\equiv 25 \equiv 4 \mod{11}. \end{split}

Notice that there are 2 residues on this list which are greater than $\frac{11}{2} = 5.5$, and so Gauss' Lemma says that

(6)
\begin{align} \left(\frac{5}{11}\right) = (-1)^2 = 1. \end{align}

$\square$

Proof of Gauss' Lemma: To start off, we'll split the least non-negative residues from the set

(7)
\begin{align} 1\cdot a, 2\cdot a, \cdots, \frac{p-1}{2} a \end{align}

into two groups: the set $r_1,\cdots, r_n$ will be the set of those residues that are greater than $\frac{p}{2}$, and the set $s_1,\cdots, s_m$ of residues which are less than $\frac{p}{2}$. Notice that none of these residues actually hit $\frac{p}{2}$ on the nose, since this number is not an integer. So really we have $\{r_1,\cdots, r_n\} \subseteq \{\frac{p+1}{2},\cdots,p-1\}$ and $\{s_1,\cdots, s_m\}\subseteq \{1,\cdots,\frac{p-1}{2}\}$.

Now we claim that the integers

(8)
\begin{align} p-r_1,p-r_2,\cdots,p-r_n,s_1,s_2,\cdots,s_m \end{align}

are the same modulo p as the integers

(9)
\begin{align} 1,2,3,\cdots,\frac{p-1}{2}. \end{align}

To see that this is true, notice that the integers from 8 are all between 1 and $\frac{p-1}{2}$ — the $s_j$ certainly live in this range, but since we have $\frac{p+1}{2}\leq r_i \leq p-1$ we also have $1 \leq p-r_i \leq \frac{p-1}{2}$. So to show that these collections are the same, we just need to show that the top collection has no repeats.

For this, we'll check three things:

1. there are no repeats of the form $p-r_i \equiv p-r_j \mod{p}$
2. there are no repeats of the form $s_i \equiv s_j \mod{p}$ and
3. there are no repeats of the form $p-r_i \equiv s_j \mod{p}$.

To check the first, let $k_i,k_j$ be given so that $r_i \equiv k_i \cdot a$ and $r_j \equiv k_j \cdot a$. Then we get

(10)
\begin{align} p-r_i \equiv p-r_j \Leftrightarrow -r_i \equiv -r_j \Leftrightarrow r_i \equiv r_j \Leftrightarrow k_i \cdot a \equiv k_j \cdot a \Leftrightarrow k_i \equiv k_j \mod{p}. \end{align}

Hence if $r_i$ and $r_j$ arose by multiplying a by distinct (mod p) numbers $k_i$ and $k_j$, then $p-r_i \not\equiv p-r_j \mod{p}$. This means we solved condition 1 above.

The proof that condition 2 works is the same as that for condition 1. For condition 3, suppose that $p-r_i \equiv s_j \mod{p}$. Then let's let $k_1$ be an integer between 1 and $\frac{p-1}{2}$ so that $r_i \equiv k_i\cdot a\mod{p}$, and let's let $k_j$ be an integer between 1 and $\frac{p-1}{2}$ so that $s_j \equiv k_j \cdot a \mod{p}$. Then we have

(11)
\begin{align} p-r_i \equiv s_j \Leftrightarrow -r_i \equiv s_j \Leftrightarrow -k_i \cdot a \equiv k_j \cdot a \Leftrightarrow -k_i \equiv k_j \mod{p}. \end{align}

This latter congruence, though, is impossible, since $-k_i$ has least non-negative residue between $\frac{p+1}{2}$ and $p-1$. So this means condition 3 is satisfied as well.

Now that we've established our claim that 8 and 9 are the same sets mod p, we'll compute $\left(\frac{p-1}{2}\right)!$. Now we know that this factorial is given by multiplying all the elements in together, which means that it's the same as multiplying all the elements in 8 together. Hence:

(12)
\begin{split} \left(\frac{p-1}{2}\right)! &\equiv 1\cdot 2 \cdot 3 \cdot \cdots \cdot \frac{p-1}{2}\\ &\equiv (p-r_1)\cdots(p-r_n)s_1\cdots s_m\\ &\equiv (-1)^n r_1\cdots r_n s_1 \cdots s_m\\ &\equiv (-1)^n \left(a \cdot (2a)\cdot (3a)\cdots \left((\frac{p-1}{2} a\right)\right)\\ &\equiv (-1)^n a^{\frac{p-1}{2}} \left(1\cdot 2\cdot 3 \cdots \frac{p-1}{2}\right)\\ &\equiv(-1)^n a^{\frac{p-1}{2}}\left(\frac{p-1}{2}\right)! \mod{p}. \end{split}

Now we can cancel the factorial on both sides of this equation (since this factorial is relatively prime to p, as it is the product of numbers all relatively prime to p). This leaves us with

(13)
\begin{align} 1 \equiv (-1)^n a^{\frac{p-1}{2}} \mod{p}. \end{align}

Moving the minus ones to the other side of the equation, and recalling Euler's Criterion, tells us that

(14)
\begin{align} (-1)^n \equiv a^{\frac{p-1}{2}} \equiv \left(\frac{a}{p}\right). \end{align}

$\square$

Corollary: For any odd prime p we have

$\displaystyle \left(\frac{2}{p}\right) = \left\{\begin{array}{rl}1,&\mbox{ if }p \equiv 1,7 \mod{8}\\-1, & \mbox{ if } p \equiv 3,5 \mod{8}.\end{array}\right.$

Proof: Gauss' Lemma tells us that to compute $\left(\frac{2}{p}\right)$, we need to count the j between 1 and $\frac{p-1}{2}$ for which $2j$ has least non-negative residue greater than $\frac{p}{2}$. But since our j lie in the range between 1 and $\frac{p-1}{2}$, this means that $2j$ lies in the range between 1 and $p-1$. In other words, we don't need to worry about "modding out" by any multiple of p to compute the least non-negative residue for $2j$: the product $2j$ is already the least non-negative residue mod p. Hence we can say that the least non-negative residue of $2j$ mod p is greater than $\frac{p}{2}$ precisely when

(15)
\begin{align} 2j > \frac{p}{2} \Leftrightarrow j > \frac{p}{4}. \end{align}

Since j is an integer and $\frac{p}{4}$ is not, we can rewrite this last inequality as

(16)
\begin{align} j\geq \left\lceil \frac{p}{4}\right\rceil \end{align}

The number of j between 1 and $\frac{p-1}{2}$ which satisfy this criteria is $\frac{p-1}{2}-\left\lceil \frac{p}{4}\right\rceil+1$. Hence we have

(17)
\begin{align} \left(\frac{2}{p}\right) = (-1)^{\frac{p-1}{2}-\left\lceil \frac{p}{4}\right\rceil+1}. \end{align}

All we need to do now is determine conditions on p that tells us when $\frac{p-1}{2}-\left\lceil \frac{p}{4}\right\rceil+1$ is even or odd. For this, we'll do some investigating mod 8.

Case I: Suppose that $p \equiv 1 \mod{8}$. This tells us that $p = 8k+1$ for some integer k. In this case we get

(18)
\begin{align} \frac{p-1}{2}-\left\lceil \frac{p}{4}\right\rceil+1 = \frac{8k+1-1}{2}-\left\lceil \frac{8k+1}{4}\right\rceil+1 = 4k - (2k+1) + 1 = 2k. \end{align}

Since this number is even, that means we have $\left(\frac{2}{p}\right) = (-1)^{2k} = 1$.

Case II: Suppose that $p \equiv 3 \mod{8}$. This tells us that $p = 8k+3$ for some integer k. In this case we get

(19)
\begin{align} \frac{p-1}{2}-\left\lceil \frac{p}{4}\right\rceil+1 = \frac{8k+3-1}{2}-\left\lceil \frac{8k+3}{4}\right\rceil+1 = 4k+1 - (2k+1) + 1 = 2k+1. \end{align}

Since this number is even, that means we have $\left(\frac{2}{p}\right) = (-1)^{2k+1} = -1$.

Case III: Suppose that $p \equiv 5 \mod{8}$. This tells us that $p = 8k+5$ for some integer k. In this case we get

(20)
\begin{align} \frac{p-1}{2}-\left\lceil \frac{p}{4}\right\rceil+1 = \frac{8k+5-1}{2}-\left\lceil \frac{8k+5}{4}\right\rceil+1 = 4k+2 - (2k+2) + 1 = 2k+1. \end{align}

Since this number is even, that means we have $\left(\frac{2}{p}\right) = (-1)^{2k+1} = -1$.

Case IV: Suppose that $p \equiv 7 \mod{8}$. This tells us that $p = 8k+7$ for some integer k. In this case we get

(21)
\begin{align} \frac{p-1}{2}-\left\lceil \frac{p}{4}\right\rceil+1 = \frac{8k+7-1}{2}-\left\lceil \frac{8k+7}{4}\right\rceil+1 = 4k+3 - (2k+2) + 1 = 2k+2. \end{align}

Since this number is even, that means we have $\left(\frac{2}{p}\right) = (-1)^{2k+2} = -1$.
$\square$

Recall that for an arbitrary integer $n = \pm 2^e p_1^{e_1}\cdots p_k^{e_k}$ and an odd prime p not dividing n, we have

(22)
\begin{align} \left(\frac{n}{p}\right) = \left(\frac{\pm 1}{p}\right)\left(\frac{2}{p}\right)^e\left(\frac{p_1}{p}^{e_1}\right)\cdots\left(\frac{p_k}{p}\right)^{e_k}. \end{align}

Now these first two terms we know how to compute, based on the residue class of p modulo 4 and 8 (respectively). But what about the rest? If q is an odd prime distinct from p, how do we compute the Legendre symbol $\left(\frac{q}{p}\right)$? Though this sounds like a much more daunting task than the Legendre symbols we computed for -1 and 2, it is in fact just as easily resolved.

Theorem (Quadratic Reciprocity): Suppose that p and q are distinct odd prime numbers. Then we have

$\displaystyle \left(\frac{p}{q}\right)\left(\frac{q}{p}\right) = (-1)^{\left(\frac{p-1}{2}\right)\left(\frac{q-1}{2}\right)} = \left\{\begin{array}{rl}1,&\mbox{ if }p \equiv 1 \mod{4} \mbox{ or } q \equiv 1 \mod{4}\\-1,&\mbox{ if }p \equiv q \equiv 3 \mod{4}.\end{array}\right.$

Notice that this theorem tells us that if either p or q is congruent to 1 modulo 4, then we have

(23)
\begin{align} \left(\frac{p}{q}\right) = \left(\frac{q}{p}\right), \end{align}

and that if both p and q are congruent to 3 modulo 4, then we have

(24)
\begin{align} \left(\frac{p}{q}\right) = -\left(\frac{q}{p}\right). \end{align}

#### Example: This might have seemed impossible yesterday…

Let's try to compute $\left(\frac{1061}{1721}\right)$. It will help to know that both of these are prime, and it turns out that we also know that $1061 \equiv 1 \mod{4}$. Quadratic reciprocity then tells us that

(25)
\begin{align} \left(\frac{1061}{1721}\right) = \left(\frac{1721}{1061}\right). \end{align}

Now since $1721 \equiv 660 \mod{1061}$, this means that we have

(26)
\begin{align} \left(\frac{1721}{1061}\right) = \left(\frac{660}{1061}\right). \end{align}

Now you might be tempted to use quadratic reciprocity to "flip" this Legendre symbol, but note that it isn't a prime number! That means we can't flip it, but instead need to factor 660 in the hopes of factoring the Legendre symbol into simpler terms. For this, we used the fact that $660 = 2^2\cdot 3 \cdot 5\cdot 11$, so that

(27)
\begin{align} \left(\frac{660}{1061}\right) = \left(\frac{2^2}{1061}\right)\left(\frac{3}{1061}\right)\left(\frac{5}{1061}\right)\left(\frac{11}{1061}\right). \end{align}

Now the first of these terms is clearly 1, since $2^2$ is "visibly" a square. For the other terms, we'll use quadratic reciprocity to flip them. For all these Legendre symbols, notice that the "denominator" is 1 modulo 4, meaning that we can flip the symbol without introducing a minus sign. Hence we have

(28)
\begin{align} \left(\frac{2^2}{1061}\right)\left(\frac{3}{1061}\right)\left(\frac{5}{1061}\right)\left(\frac{11}{1061}\right) = (1)\left(\frac{1061}{3}\right)\left(\frac{1061}{5}\right)\left(\frac{1061}{11}\right). \end{align}

Again, to compute these symbols we just reduct 1061 modulo 3, 5 and 11. It turns out that $1061 \equiv 2 \mod{3}$, $1061 \equiv 1 \mod{5}$, and that $1061 \equiv 5 \mod{11}$. We can substitute these values in to find

(29)
\begin{align} \left(\frac{1061}{3}\right)\left(\frac{1061}{5}\right)\left(\frac{1061}{11}\right) = \left(\frac{2}{3}\right)\left(\frac{1}{5}\right)\left(\frac{5}{11}\right). \end{align}

Now the first term must be -1 based on our rule for whether 2 is a square modulo an odd prime (in particular, $3 \equiv 3 \mod{8}$, meaning that 2 isn't a square mod 3). The second term is "visibly" 1 since $1 = 1^2$. The last term was computed earlier in class as 1. So all together, we get

(30)
\begin{align} \left(\frac{1061}{1721}\right) = \left(\frac{2}{3}\right)\left(\frac{1}{5}\right)\left(\frac{5}{11}\right) = (-1)(1)(1) = -1. \end{align}

$\square$