• a is a quadratic residue mod m if . Otherwise, a is a quadratic nonresidue.
• Quadratic Reciprocity relates the solvability of the congruence to the solvability of the congruence , where p and q are distinct odd primes.
• If p is an odd prime, there are equal numbers of quadratic residues and quadratic nonresidues among .
• If p is an odd prime, , and , the Legendre symbol is defined by

• Legendre symbols provide a computational tool for determining whether a quadratic congruence has a solution.
• Euler's theorem says that if p is an odd prime, , and , then

Gauss considered the proofs he gave of quadratic reciprocity one of his crowning achievements; in fact, he gave 6 distinct proofs during his lifetime. Reciprocity is a deep result: Proofs eluded both Euler and Legendre.

The reciprocity law is simple to state. For p and q odd primes, it relates solutions to the two congruences

(Note how p and q switch places: This explains why it's called a reciprocity law.) The law of quadratic reciprocity says:

The congruences are either both solvable or both unsolvable, unless both primes are congruent to 3 mod 4. In that case, one is solvable while the other is not.

Gauss first gave a proof of this when he was 19!

Gauss's masterwork, the Disquisitiones Arithmeticae, was published in 1801 when Gauss was 24. It changed the course of number theory, collecting scattered results into a unified theory.

Definition. Let , . a is a quadratic residue mod m if the following equation has a solution:

Otherwise, a is a quadratic nonresidue mod m.

Example. 8 is a quadratic residue mod 17, since

However, 8 is a quadratic nonresidue mod 11, because has no solutions.

As the table shows, 1, 3, 4, 5, and 9 are quadratic residues mod 11. (0 is not considered a quadratic residue, since .) But 8 is a quadratic nonresidue mod 11.

Notice the symmetry in the nonzero elements of the table. Do you see why this is happening?

Lemma. Let p be an odd prime. The congruence

has:

(a) Only the solution if .

(b) Exactly 0 or 2 solutions if .

Proof. solves . Conversely, if , then , so , and hence .

Suppose . To show there are 0 or 2 solutions, suppose there is at least one solution b. Then , so . I claim that b and are distinct.

If not, then , so . p is an odd prime, so . Therefore, , , , and finally --- contradicting . Hence, .

Now I have two distinct solutions; since a quadratic equation mod p has at most two solutions (Prove it!), there are exactly two.

Example. has 5 and 12 as solutions, and .

But note that the result is false if : has exactly one solution ( ).

Example. Take .

Thus, 1, 2, 4 are quadratic residues mod 7. Notice that there are equal numbers of residues and nonresidues.

Corollary. Let p be an odd prime. There are quadratic residues and quadratic nonresidues mod p in .

Proof. k and have the same square mod p. That is, 1 and have the same square, 2 and have the same square, ..., and and have the same square.

Thus, the number of different squares is --- these squares are the quadratic residues, and the other numbers in are quadratic nonresidues.

The fact observed in the first sentence of the proof explains the symmetries in the table of squares mod 11 and mod 7 that I gave above.

Definition. Let p be an odd prime, and let . The Legendre symbol is defined by

Note that is disallowed (since ) even though has a solution.

Example. . , since . Likewise, , since .

Note that 5 is congruent to 1 mod 4; as predicted by reciprocity, both of the following the congruences have solutions:

You might wonder about the case where , or the case where the modulus is composite. For , there are only two quadratic congruences:

These have the solutions and --- nothing much is going on.

If the modulus has prime factorization , then relative primality implies that it's enough to solve the congruences for each i. It turns out that solving such a congruence reduces to determining whether a is a quadratic residue mod . Therefore, there is little harm in concentrating on the case of a single prime.

Example. can be reduced to the simultaneous congruences

These can be rewritten as

The first equation has solutions or . The second equation has the single solution . So I have two cases.

If and , the Chinese Remainder Theorem gives .

If and , the Chinese Remainder Theorem gives .

Thus, I have two solutions mod 35 to the original quadratic congruence.

Here are some tools for computing Legendre symbols.

Theorem. (Euler) Let p be an odd prime, , . Then

Proof. There are two cases. Suppose that . Then there is a number b such that . So

If , then \contra. So , and little Fermat implies that . So

The other possibility is . In this case, consider the set . I claim that these integers occur in pairs s, t, such that .

First, if , then s is invertible mod p. So I can write , and the pair s, , multiplies to a.

Moreover, s and are distinct. If not, , or , which contradicts .

Since the integers divide up into pairs, each multiplying to a, and since there are pairs, I have

By Wilson's theorem,

Example. Suppose and . Then

Hence, , and should have a solution. Indeed,

Lemma. If , then .

Proof. If , then if and only if . Thus, one of these equations is solvable or not solvable if and only if the same is true for the other --- which means .

Note that I can use this result to apply Euler's formula to for by simply replacing a with such that .

Lemma. Let p be an odd prime, , . Then

Proof. By Euler,

Therefore,

The two sides of this equation are . Since p is an odd prime, the two sides can't differ by 2. Hence, they must be equal as integers:

Corollary. Let p be an odd prime, , . Then

You can use the results above to compute for specific values of a and arbitrary p.

Lemma.

Proof. By Euler's formula,

Using Gauss's lemma, which I'll prove shortly, you can also show that

Note that the exponent on the right is actually an integer: Since , . And is divisible by 8, because one of k, , must be even.

Example. , because . Thus, has solutions. And in fact,

Likewise, , because . Hence, has no solutions.

Finally,

Therefore, has solutions. works, for instance.