In a previous post called Solving Quadratic Congruences, we discuss the solvability of the quadratic congruence
where is an odd prime and is relatively prime to . In this post, we continue to discuss the solvability of equation (1) from the view point of quadratic residues. In this subsequent post, we discuss specific algorithms that produce solutions to such equations.
____________________________________________________________________________
Definition
Let be an odd prime. Let be an integer that is not divisible by (equivalently relatively prime to ). Whenever equation (1) has solutions, we say that the number is a quadratic residue modulo . Otherwise, we say that the number is a quadratic nonresidue modulo . When the context is clear, the word quadratic is sometimes omitted.
The term quadratic residues is more convenient to use. Instead of saying the equation has a solution, we say the number is a quadratic residue for the modulus in question. The significance of the notion of quadratic residue extends beyond the convenience of having a shorter name. It and and the Legendre symbol lead to a large body of beautiful and deep results in number theory, the quadratic reciprocity theorem being one of them.
One property of the quadratic congruence equation (1) is that when equation (1) has solutions, it has exactly two solutions among the set (see Lemma 1 in the post Solving Quadratic Congruences). Thus among the integers in the set , of them are quadratic residues and the other half are quadratic nonresidues modulo .
For example, consider the modulus . Among the numbers in the set , the numbers are quadratic residues and the numbers are quadratic nonresidues. See the following two tables.
The above table shows the least residues of for . It shows that there can only be . Thus these are the quadratic residues. The table below shows the status of residue/nonresidue among the integers in .
____________________________________________________________________________
Legendre Symbol
The notion of quadratic residues is often expressed using the Legendre symbol, which is defined as follows:
The bottom number in the above notation is an odd prime. The top number is an integer that is not divisible by (equivalently relatively prime to ). Despite the appearance, the Legendre symbol is not the fraction of over . It follows from the definition that the symbol has the value of one if the equation has solutions. It has the value of negative one if the equation has no solutions.
For example, for and and for . To evaluate , consider the equation , which is equivalent to the equation . This last equation has no solutions. Thus .
The quadratic reciprocity law discussed below allows us to calculate by flipping . In certain cases, flipping the symbol keeps the same sign. In other cases, flipping introduces a negative sign (as in this example).
____________________________________________________________________________
Basic Properties
Euler’s Criterion is a formula that determines whether an integer is a quadratic residue modulo an odd prime. We have the following theorem. A proof of Euler’s Criterion is found in this post.
Theorem 1 (Euler’s Criterion)

Let be an odd prime number. Let be a positive integer that is not divisible by . Then the following property holds.
The following lemma shows a connection between the notion of quadratic residue and the notion of primitive roots.

Lemma 2
 The number is a quadratic residue modulo if and only if for some integer .
 Or equivalently, the number is a quadratic nonresidue modulo if and only if for some integer .

Let be an odd prime. Let be a primitive root modulo . Let be a positive integer that is not divisible by . Then we have the following equivalence.
Proof of Lemma 2
A primitive root exists since the modulus is prime (see Theorem 1 in the post Primitive roots of prime moduli). Furthermore, any integer that is not divisible by is congruent to a unique element of the set . Thus for the number in question, either or . We can conclude that the first bullet point in the lemma is equivalent to the second bullet point.
We prove the first bullet point. First we show the direction . Suppose . Clearly the equation has a solution since .
Now we show the direction . We prove the contrapositive. Suppose that . We wish to show that is a quadratic nonresidue modulo . Suppose not. Then for some . It follows that . Note that if , , which is not true. By Fermat’s little theorem, we have . We have the following derivation.
On the other hand, we can express as follows:
Note that the last congruence contradicts the fact that is a primitive root modulo since is the least exponent that such that . So cannot be a quadratic residue modulo . We have proved that if , then is a quadratic nonresidue modulo . Equivalently, if is a quadratic residue modulo , then . Thus the lemma is established.
We can also obtain an alternative proof by using Theorem 1 (Euler’s Criterion). We show of both bullet points.
First, of the first bullet point. Suppose . Then . Thus and is a quadratic residue modulo by Euler’s Criterion.
Now of the second bullet point. Suppose . Then . The last congruence because is a primitive root. Thus and is a quadratic nonresidue modulo by Euler’s Criterion.
Remark
Each number in the set is congruent to a power of the primitive root in question. Lemma 2 indicates that the even powers are the quadratic residues while the odd powers are the quadratic nonresidues. The following lemma is a corollary of Lemma 2.

Lemma 3
 If and are quadratic residues modulo , then is a quadratic residue modulo .
 If is a quadratic residue and is a quadratic nonresidue modulo , then is a quadratic nonresidue modulo .
 If and are quadratic nonresidues modulo , then is a quadratic residue modulo .

Let be an odd prime. Then we have the following.
Proof of Lemma 3
Let be a primitive root modulo . Then we express each residue or nonresidue as a power of and then multiply the two powers of by adding the exponents as in the following.
The first product above has an even exponent. Thus the product of two quadratic residues is a quadratic residue (the first bullet point). The second product above has an odd exponent. Thus the product of a quadratic residue and a quadratic nonresidue is a nonresidue (second bullet point). The third product above has an even exponent. Thus the product of two nonresidues is a residue.
One part of the following theorem is a corollary of Lemma 3.

Theorem 4
 If and , then .
 If , then .
 if and , then .

Let be an odd prime. Then we have the following results.
Proof of Theorem 4
The first and second bullets points are straightforward. We prove the third bullet point, which follows from Lemma 3. Given and , they would fall into one of the three cases of Lemma 3. Translating each case of Lemma 3 will give the correct statement in Legendre symbol.
____________________________________________________________________________
Quadratic Reciprocity
Quadratic reciprocity is a property that indicates how and are related when both and are odd prime. Even thought the statement of the theorem is easy to state and understand, it is an unexpected and profound result. Our goal here is quite simple – state the theorem and demonstrate how it can be used to simplify calculations. We have the following theorems.

Theorem 5 (Quadratic Reciprocity)

Let and be two distinct odd prime numbers. The following statement holds.

Theorem 6

Let and be two distinct odd prime numbers. The following statement holds.

Theorem 7

Let and be two distinct odd prime numbers. The following statement holds.
Theorems 4, 5, 6 and 7 are tools for evaluating Legendre symbols. We demonstrate with examples.
____________________________________________________________________________
Examples
Example 1
Is a quadratic residue modulo the prime ?
We evaluate the symbol . Note that . By Theorem 7, . It follows that is a quadratic residue modulo the prime . Furthermore, has solutions.
Example 2
Solve .
Note that is a prime while is not since . After applying Theorem 4, we have:
.
Now we can start using quadratic reciprocity.
The above derivation is the result of applying Theorems 4, 5 and 7. Of particular importance is the repeated applications of Theorem 5 (Quadratic Reciprocity) so that the numbers in the Legendre symbols are much smaller than the ones we start with.
As useful as it is, the theorem for quadratic reciprocity does not show us how to solve the equation . See Example 2 in the post Solving Quadratic Congruences to see how it can be solved.
____________________________________________________________________________
Revised December 9, 2015
Pingback: The Legendre symbol  Exploring Number Theory