Quadratic Residues
Let . We say is a quadratic residue if there exists some such that . We shall focus on the case when is prime.
Let be a prime. From now assume . The case is easy anyway. Let be a generator of . Any can be written as for some .
Say is even. Write . Then , so is a quadratic residue. Exactly half of is even (since is odd), hence at least half of the elements of are quadratic residues.
Suppose we have . Then as well, and since (since ) every quadratic residue has at least two square roots (actually we know from before there can be at most two), thus at most half the elements of are quadratic residues. (Otherwise there are more square roots than elements!)
Thus exactly half of are quadratic residues, and they are the even powers of .
Given , consider the effect of exponentiating by . If is odd, say , we get
The square of is , so is or . But has order ( is a generator) thus we must have .
If is even, say , then .
Thus one way to tell if is a quadratic residue is to compute : if the result is , then is a quadratic residue, otherwise the result is and is a quadratic nonresidue.
Example: In , if is even (so ), then is a quadratic residue, otherwise is a quadratic nonresidue.
The Legendre Symbol
This fact (sometimes called Euler's Criterion) is so useful that we define the Legendre symbol for odd primes and integers by The symbol can also be written as .
Thus:
-
if is a quadratic residue of
-
if is a quadratic nonresidue of
-
if modulo
It is not hard to see that for any integer and for any coprime to
Gauss' Lemma
There is a less obvious way to compute the Legendre symbol. This method allows us to easily evaluate , among other things. Before stating the method formally, we demonstrate it with an example.
Let , and . There are nonzero elements . Consider the first half and multiply them all by to get . As integers, let us count the number of them that are greater than (that is, or higher).
Note: even though there is no way to define inequalities modulo , we can view elements of as integers in and look at sizes there, though it is not yet clear why we want to do this.
and are the only ones in the set that are greater than , so there are exactly of them. Then Gauss' Lemma states that if we take this and raise to this power, then we have , that is:
Theorem: Let be an odd prime, be an integer coprime to . Consider the set and view each member is an integer in . Let be the number of members in this set that are greater than . Then
Proof: Let be the members of the set less than , and be the members greater than . Then . Consider the sequence
Each of these are distinct: clearly and whenever (since is invertible), and if , then let . Then , which is a contradiction since Hence they must be precisely the numbers in some order, thus Dividing both sides by completes the proof.
For example, let be an odd prime and take . Consider the sequence . Note these are positive least residues. Now for some integer and . By considering each case we see that the number of elements greater than is even when and odd when . We can restate this as follows.
Theorem: Let be an odd prime.
Proof: See the last paragraph, and note that is even when and odd otherwise. Similarly for .
Example: By Gauss' Lemma, if and otherwise (). Combining this with the above result for we have if and otherwise ().