# Quadratic reciprocity

In number theory, the

**law of quadratic reciprocity**is a theorem about modular arithmetic that gives conditions for the solvability of quadratic equations modulo prime numbers. Due to its subtlety, it has many formulations, but the most standard statement is:

This law, together with its [|supplements], allows the easy calculation of any Legendre symbol, making it possible to determine whether there is an integer solution for any quadratic equation of the form for an odd prime ; that is, to determine the "perfect squares" modulo. However, this is a non-constructive result: it gives no help at all for finding a

*specific*solution; for this, other methods are required. For example, in the case using Euler's criterion one can give an explicit formula for the "square roots" modulo of a quadratic residue, namely,

indeed,

Note that this formula only works if it is known in advance that is a quadratic residue, which can be checked using the law of quadratic reciprocity.

The quadratic reciprocity theorem was conjectured by Euler and Legendre and first proved by Gauss, who referred to it as the "fundamental theorem" in his

*Disquisitiones Arithmeticae*and his papers, writing

Privately, Gauss referred to it as the "golden theorem." He published six proofs for it, and two more were found in his posthumous papers. There are now over 240 published proofs. The shortest known proof is included [|below], together with short proofs of the law's supplements.

Generalizing the reciprocity law to higher powers has been a leading problem in mathematics, and has been crucial to the development of much of the machinery of modern algebra, number theory, and algebraic geometry, culminating in Artin reciprocity, class field theory, and the Langlands program.

## Motivating examples

Quadratic reciprocity arises from certain subtle factorization patterns involving perfect square numbers. In this section, we give examples which lead to the general case.### Factoring ''n''^{2} − 5

Consider the polynomial and its values for The prime factorizations of these values are given as follows:The prime factors dividing are, and every prime whose final digit is or ; no primes ending in or ever appear. Now, is a prime factor of some whenever, i.e. whenever i.e. whenever 5 is a quadratic residue modulo. This happens for and those primes with and note that the latter numbers and are precisely the quadratic residues modulo. Therefore, except for, we have that is a quadratic residue modulo iff is a quadratic residue modulo.

The law of quadratic reciprocity gives a similar characterization of prime divisors of for any prime

*q*, which leads to a characterization for any integer.

### Patterns among quadratic residues

Let*p*be an odd prime. A number modulo

*p*is a quadratic residue whenever it is congruent to a square ; otherwise it is a quadratic non-residue. Here we exclude zero as a special case. Then as a consequence of the fact that the multiplicative group of a finite field of order

*p*is cyclic of order

*p-1*, the following statements hold:

- There are an equal number of quadratic residues and non-residues; and
- The product of two quadratic residues is a residue, the product of a residue and a non-residue is a non-residue, and the product of two non-residues is a residue.

*not*hold if the modulus is not prime.

For example, there are only 2 quadratic residues in the multiplicative group modulo 15.

Moreover although 7 and 8 are quadratic non-residues, their product 7x8 = 11 is also a quadratic non-residue, in contrast to the prime case.

Quadratic residues are entries in the following table:

n | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 |

n^{2} | 1 | 4 | 9 | 16 | 25 | 36 | 49 | 64 | 81 | 100 | 121 | 144 | 169 | 196 | 225 | 256 | 289 | 324 | 361 | 400 | 441 | 484 | 529 | 576 | 625 |

mod 3 | 1 | 1 | 0 | 1 | 1 | 0 | 1 | 1 | 0 | 1 | 1 | 0 | 1 | 1 | 0 | 1 | 1 | 0 | 1 | 1 | 0 | 1 | 1 | 0 | 1 |

mod 5 | 1 | 4 | 4 | 1 | 0 | 1 | 4 | 4 | 1 | 0 | 1 | 4 | 4 | 1 | 0 | 1 | 4 | 4 | 1 | 0 | 1 | 4 | 4 | 1 | 0 |

mod 7 | 1 | 4 | 2 | 2 | 4 | 1 | 0 | 1 | 4 | 2 | 2 | 4 | 1 | 0 | 1 | 4 | 2 | 2 | 4 | 1 | 0 | 1 | 4 | 2 | 2 |

mod 11 | 1 | 4 | 9 | 5 | 3 | 3 | 5 | 9 | 4 | 1 | 0 | 1 | 4 | 9 | 5 | 3 | 3 | 5 | 9 | 4 | 1 | 0 | 1 | 4 | 9 |

mod 13 | 1 | 4 | 9 | 3 | 12 | 10 | 10 | 12 | 3 | 9 | 4 | 1 | 0 | 1 | 4 | 9 | 3 | 12 | 10 | 10 | 12 | 3 | 9 | 4 | 1 |

mod 17 | 1 | 4 | 9 | 16 | 8 | 2 | 15 | 13 | 13 | 15 | 2 | 8 | 16 | 9 | 4 | 1 | 0 | 1 | 4 | 9 | 16 | 8 | 2 | 15 | 13 |

mod 19 | 1 | 4 | 9 | 16 | 6 | 17 | 11 | 7 | 5 | 5 | 7 | 11 | 17 | 6 | 16 | 9 | 4 | 1 | 0 | 1 | 4 | 9 | 16 | 6 | 17 |

mod 23 | 1 | 4 | 9 | 16 | 2 | 13 | 3 | 18 | 12 | 8 | 6 | 6 | 8 | 12 | 18 | 3 | 13 | 2 | 16 | 9 | 4 | 1 | 0 | 1 | 4 |

mod 29 | 1 | 4 | 9 | 16 | 25 | 7 | 20 | 6 | 23 | 13 | 5 | 28 | 24 | 22 | 22 | 24 | 28 | 5 | 13 | 23 | 6 | 20 | 7 | 25 | 16 |

mod 31 | 1 | 4 | 9 | 16 | 25 | 5 | 18 | 2 | 19 | 7 | 28 | 20 | 14 | 10 | 8 | 8 | 10 | 14 | 20 | 28 | 7 | 19 | 2 | 18 | 5 |

mod 37 | 1 | 4 | 9 | 16 | 25 | 36 | 12 | 27 | 7 | 26 | 10 | 33 | 21 | 11 | 3 | 34 | 30 | 28 | 28 | 30 | 34 | 3 | 11 | 21 | 33 |

mod 41 | 1 | 4 | 9 | 16 | 25 | 36 | 8 | 23 | 40 | 18 | 39 | 21 | 5 | 32 | 20 | 10 | 2 | 37 | 33 | 31 | 31 | 33 | 37 | 2 | 10 |

mod 43 | 1 | 4 | 9 | 16 | 25 | 36 | 6 | 21 | 38 | 14 | 35 | 15 | 40 | 24 | 10 | 41 | 31 | 23 | 17 | 13 | 11 | 11 | 13 | 17 | 23 |

mod 47 | 1 | 4 | 9 | 16 | 25 | 36 | 2 | 17 | 34 | 6 | 27 | 3 | 28 | 8 | 37 | 21 | 7 | 42 | 32 | 24 | 18 | 14 | 12 | 12 | 14 |

This table is complete for odd primes less than 50. To check whether a number

*m*is a quadratic residue mod one of these primes

*p*, find

*a*≡

*m*and 0 ≤

*a*<

*p*. If

*a*is in row

*p*, then

*m*is a residue ; if

*a*is not in row

*p*of the table, then

*m*is a nonresidue.

The quadratic reciprocity law is the statement that certain patterns found in the table are true in general.

### ''q'' = ±1 and the first supplement

Trivially 1 is a quadratic residue for all primes. The question becomes more interesting for −1. Examining the table, we find −1 in rows 5, 13, 17, 29, 37, and 41 but not in rows 3, 7, 11, 19, 23, 31, 43 or 47. The former set of primes are all congruent to 1 modulo 4, and the latter are congruent to 3 modulo 4.### ''q'' = ±2 and the second supplement

Examining the table, we find 2 in rows 7, 17, 23, 31, 41, and 47, but not in rows 3, 5, 11, 13, 19, 29, 37, or 43. The former primes are all ≡ ±1, and the latter are all ≡ ±3. This leads to−2 is in rows 3, 11, 17, 19, 41, 43, but not in rows 5, 7, 13, 23, 29, 31, 37, or 47. The former are ≡ 1 or ≡ 3, and the latter are ≡ 5, 7.

### ''q'' = ±3

3 is in rows 11, 13, 23, 37, and 47, but not in rows 5, 7, 17, 19, 29, 31, 41, or 43. The former are ≡ ±1 and the latter are all ≡ ±5.−3 is in rows 7, 13, 19, 31, 37, and 43 but not in rows 5, 11, 17, 23, 29, 41, or 47. The former are ≡ 1 and the latter ≡ 2.

Since the only residue is 1, we see that −3 is a quadratic residue modulo every prime which is a residue modulo 3.

### ''q'' = ±5

5 is in rows 11, 19, 29, 31, and 41 but not in rows 3, 7, 13, 17, 23, 37, 43, or 47. The former are ≡ ±1 and the latter are ≡ ±2.Since the only residues are ±1, we see that 5 is a quadratic residue modulo every prime which is a residue modulo 5.

−5 is in rows 3, 7, 23, 29, 41, 43, and 47 but not in rows 11, 13, 17, 19, 31, or 37. The former are ≡ 1, 3, 7, 9 and the latter are ≡ 11, 13, 17, 19.

### Higher ''q''

The observations about −3 and 5 continue to hold: −7 is a residue modulo*p*if and only if

*p*is a residue modulo 7, −11 is a residue modulo

*p*if and only if

*p*is a residue modulo 11, 13 is a residue if and only if

*p*is a residue modulo 13, etc. The more complicated-looking rules for the quadratic characters of 3 and −5, which depend upon congruences modulo 12 and 20 respectively, are simply the ones for −3 and 5 working with the first supplement.

The generalization of the rules for −3 and 5 is Gauss's statement of quadratic reciprocity.

### Legendre's version

Another way to organize the data is to see which primes are residues mod which other primes, as illustrated in the following table. The entry in row*p*column

*q*is

**R**if

*q*is a quadratic residue ; if it is a nonresidue the entry is

**N**.

If the row, or the column, or both, are ≡ 1 the entry is blue or green; if both row and column are ≡ 3, it is yellow or orange.

The blue and green entries are symmetric around the diagonal: The entry for row

*p*, column

*q*is

**R**if and only if the entry at row

*q*, column

*p*, is

**R**.

The yellow and orange ones, on the other hand, are antisymmetric: The entry for row

*p*, column

*q*is

**R**if and only if the entry at row

*q*, column

*p*, is

**N**.

The reciprocity law states that these patterns hold for all

*p*and

*q*.

R | q is a residue | q ≡ 1 or p ≡ 1 |

N | q is a nonresidue | q ≡ 1 or p ≡ 1 |

R | q is a residue | both q ≡ 3 and p ≡ 3 |

N | q is a nonresidue | both q ≡ 3 and p ≡ 3 |

## Statement of the theorem

**Quadratic Reciprocity.**If then the congruence is solvable if and only if is solvable. If then the congruence is solvable if and only if is solvable.

**Quadratic Reciprocity.**Define. Then the congruence is solvable if and only if is solvable.

**Quadratic Reciprocity.**If

*p*or

*q*are congruent to 1 modulo 4, then: is solvable if and only if is solvable. If

*p*and

*q*are congruent to 3 modulo 4, then: is solvable if and only if is not solvable.

The last is immediately equivalent to the modern form stated in the introduction above. It is a simple exercise to prove that Legendre's and Gauss's statements are equivalent – it requires no more than the first supplement and the facts about multiplying residues and nonresidues.

## Proof

The following proof, from The American Mathematical Monthly, is apparently the shortest one known.Let

where and is the Legendre symbol. Note that for an odd and any

In particular, substituting and a nonresidue, we get, and setting, we get ; and by similar reasoning,

Furthermore,

and, recalling that

Therefore, for odd we have

Since, by induction for odd

Therefore, by Euler's criterion, for an odd prime,

Now, the cyclic shifts of a given -tuple are distinct unless all are equal, since the period of its repeated single-position cyclic shift divides, and so is or 1. When they are distinct, their total contribution to the sum defining is, which is divisible by. Therefore, modulo ,

So

and are congruent to, and thus to each other, modulo – but they both are numbers of the form, so they are equal, which is the law of quadratic reciprocity.

### Proofs of the supplements

The value of the Legendre symbol of follows directly from Euler's criterion:by Euler's criterion, but both sides of this congruence are numbers of the form, so they must be equal.

Whether is a quadratic residue can be concluded if we know the number of solutions of the equation with which can be solved by standard methods. Namely, all its solutions where can be grouped into octuplets of the form, and what is left are four solutions of the form and possibly four additional solutions where and, which exist precisely if is a quadratic residue. That is, is a quadratic residue precisely if the number of solutions of this equation is divisible by. And this equation can be solved in just the same way here as over the rational numbers: substitute, where we demand that , then the original equation transforms into

Here can have any value that does not make the denominator zero - for which there are possibilities - and also does not make zero, which excludes one more option,. Thus there are

possibilities for, and so together with the two excluded solutions there are overall solutions of the original equation. Therefore, is a residue modulo if and only if divides. This is a reformulation of the condition stated above.

## History and alternative statements

The theorem was formulated in many ways before its modern form: Euler and Legendre did not have Gauss's congruence notation, nor did Gauss have the Legendre symbol.In this article

*p*and

*q*always refer to distinct positive odd primes, and

*x*and

*y*to unspecified integers.

### Fermat

Fermat proved a number of theorems about expressing a prime by a quadratic form:He did not state the law of quadratic reciprocity, although the cases −1, ±2, and ±3 are easy deductions from these and other of his theorems.

He also claimed to have a proof that if the prime number

*p*ends with 7, and the prime number

*q*ends in 3, and

*p*≡

*q*≡ 3, then

Euler conjectured, and Lagrange proved, that

Proving these and other statements of Fermat was one of the things that led mathematicians to the reciprocity theorem.

### Euler

Translated into modern notation, Euler stated that for distinct odd primes*p*and

*q*:

- If
*q*≡ 1 then*q*is a quadratic residue if and only if there exists some integer*b*such that*p*≡*b*^{2}. - If
*q*≡ 3 then*q*is a quadratic residue if and only if there exists some integer*b*which is odd and not divisible by*q*such that*p*≡ ±*b*^{2}.

He could not prove it, but he did prove the second supplement.

### Legendre and his symbol

Fermat proved that if*p*is a prime number and

*a*is an integer,

Thus if

*p*does not divide

*a*, using the non-obvious fact that the residues modulo

*p*form a field and therefore in particular the multiplicative group is cyclic, hence there can be at most two solutions to a quadratic equation:

Legendre lets

*a*and

*A*represent positive primes ≡ 1 and

*b*and

*B*positive primes ≡ 3, and sets out a table of eight theorems that together are equivalent to quadratic reciprocity:

Theorem | When | it follows that |

I | ||

II | ||

III | ||

IV | ||

V | ||

VI | ||

VII | ||

VIII |

He says that since expressions of the form

will come up so often he will abbreviate them as:

This is now known as the Legendre symbol, and an equivalent definition is used today: for all integers

*a*and all odd primes

*p*

#### Legendre's version of quadratic reciprocity

He notes that these can be combined:A number of proofs, especially those based on Gauss's Lemma, explicitly calculate this formula.

#### The supplementary laws using Legendre symbols

Legendre's attempt to prove reciprocity is based on a theorem of his:**Example.**Theorem I is handled by letting

*a*≡ 1 and

*b*≡ 3 be primes and assuming that and, contrary the theorem, that Then has a solution, and taking congruences leads to a contradiction.

This technique doesn't work for Theorem VIII. Let

*b*≡

*B*≡ 3, and assume

Then if there is another prime

*p*≡ 1 such that

the solvability of leads to a contradiction. But Legendre was unable to prove there has to be such a prime

*p*; he was later able to show that all that is required is:

but he couldn't prove that either. Hilbert symbol discusses how techniques based on the existence of solutions to can be made to work.

### Gauss

Gauss first proves the supplementary laws. He sets the basis for induction by proving the theorem for ±3 and ±5. Noting that it is easier to state for −3 and +5 than it is for +3 or −5, he states the general theorem in the form:Introducing the notation

*a*R

*b*to mean

*a*is a quadratic residue , and letting

*a*,

*a*′, etc. represent positive primes ≡ 1 and

*b*,

*b*′, etc. positive primes ≡ 3, he breaks it out into the same 8 cases as Legendre:

Case | If | Then |

1) | ±a R a′ | ±a′ R a |

2) | ±a N a′ | ±a′ N a |

3) | +a R b− a N b | ±b R a |

4) | +a N b− a R b | ±b N a |

5) | ±b R a | +a R b− a N b |

6) | ±b N a | +a N b− a R b |

7) | +b R b′− b N b′ | −b′ N b+ b′ R b |

8) | −b N b′+ b R b′ | +b′ R b− b′ N b |

In the next Article he generalizes this to what are basically the rules for the Jacobi symbol. Letting

*A*,

*A*′, etc. represent any positive numbers ≡ 1 and

*B*,

*B*′, etc. positive numbers ≡ 3 :

Case | If | Then |

9) | ±a R A | ±A R a |

10) | ±b R A | +A R b− A N b |

11) | +a R B | ±B R a |

12) | −a R B | ±B N a |

13) | +b R B | −B N b+ N R b |

14) | −b R B | +B R b− B N b |

All of these cases take the form "if a prime is a residue, then the composite is a residue or nonresidue, depending on the congruences - 8).

Gauss needed, and was able to prove, a lemma similar to the one Legendre needed:

The proof of quadratic reciprocity uses complete induction.

These can be combined:

A number of proofs of the theorem, especially those based on Gauss sums derive this formula. or the splitting of primes in algebraic number fields,

### Other statements

Note that the statements in this section are equivalent to quadratic reciprocity: if, for example, Euler's version is assumed, the Legendre-Gauss version can be deduced from it, and vice versa.This can be proven using Gauss's lemma.

Gauss's fourth proof consists of proving this theorem and then restricting it to two primes. He then gives an example: Let

*a*= 3,

*b*= 5,

*c*= 7, and

*d*= 11. Three of these, 3, 7, and 11 ≡ 3, so

*m*≡ 3. 5×7×11 R 3; 3×7×11 R 5; 3×5×11 R 7; and 3×5×7 N 11, so there are an odd number of nonresidues.

### Jacobi symbol

The Jacobi symbol is a generalization of the Legendre symbol; the main difference is that the bottom number has to be positive and odd, but does not have to be prime. If it is prime, the two symbols agree. It obeys the same rules of manipulation as the Legendre symbol. In particularand if both numbers are positive and odd :

However, if the Jacobi symbol is 1 but the denominator is not a prime, it does not necessarily follow that the numerator is a quadratic residue of the denominator. Gauss's cases 9) - 14) above can be expressed in terms of Jacobi symbols:

and since

*p*is prime the left hand side is a Legendre symbol, and we know whether

*M*is a residue modulo

*p*or not.

The formulas listed in the preceding section are true for Jacobi symbols as long as the symbols are defined. Euler's formula may be written

**Example.**

2 is a residue modulo the primes 7, 23 and 31:

But 2 is not a quadratic residue modulo 5, so it can't be one modulo 15. This is related to the problem Legendre had: if then

*a*is a non-residue modulo every prime in the arithmetic progression

*m*+ 4

*a*,

*m*+ 8

*a*,..., if there

*are*any primes in this series, but that wasn't proved until decades after Legendre.

Eisenstein's formula requires relative primality conditions

### Hilbert symbol

The quadratic reciprocity law can be formulated in terms of the Hilbert symbol where*a*and

*b*are any two nonzero rational numbers and

*v*runs over all the non-trivial absolute values of the rationals. The Hilbert symbol is 1 or −1. It is defined to be 1 if and only if the equation has a solution in the completion of the rationals at

*v*other than. The Hilbert reciprocity law states that, for fixed

*a*and

*b*and varying

*v*, is 1 for all but finitely many

*v*and the product of over all

*v*is 1.

The proof of Hilbert reciprocity reduces to checking a few special cases, and the non-trivial cases turn out to be equivalent to the main law and the two supplementary laws of quadratic reciprocity for the Legendre symbol. There is no kind of reciprocity in the Hilbert reciprocity law; its name simply indicates the historical source of the result in quadratic reciprocity. Unlike quadratic reciprocity, which requires sign conditions and a special treatment of the prime 2, the Hilbert reciprocity law treats all absolute values of the rationals on an equal footing. Therefore, it is a more natural way of expressing quadratic reciprocity with a view towards generalization: the Hilbert reciprocity law extends with very few changes to all global fields and this extension can rightly be considered a generalization of quadratic reciprocity to all global fields.

## Connection with cyclotomic fields

The early proofs of quadratic reciprocity are relatively unilluminating. The situation changed when Gauss used Gauss sums to show that quadratic fields are subfields of cyclotomic fields, and implicitly deduced quadratic reciprocity from a reciprocity theorem for cyclotomic fields. His proof was cast in modern form by later algebraic number theorists. This proof served as a template for class field theory, which can be viewed as a vast generalization of quadratic reciprocity.Robert Langlands formulated the Langlands program, which gives a conjectural vast generalization of class field theory. He wrote:

## Other rings

There are also quadratic reciprocity laws in rings other than the integers.### Gaussian integers

In his second monograph on quartic reciprocity Gauss stated quadratic reciprocity for the ring of Gaussian integers, saying that it is a corollary of the biquadratic law in but did not provide a proof of either theorem. Dirichlet showed that the law in can be deduced from the law for without using biquadratic reciprocity.For an odd Gaussian prime and a Gaussian integer relatively prime to define the quadratic character for by:

Let be distinct Gaussian primes where

*a*and

*c*are odd and

*b*and

*d*are even. Then

### Eisenstein integers

Consider the following third root of unity:The ring of Eisenstein integers is For an Eisenstein prime and an Eisenstein integer with define the quadratic character for by the formula

Let λ =

*a*+

*bω*and μ =

*c*+

*dω*be distinct Eisenstein primes where

*a*and

*c*are not divisible by 3 and

*b*and

*d*are divisible by 3. Eisenstein proved

### Imaginary quadratic fields

The above laws are special cases of more general laws that hold for the ring of integers in any imaginary quadratic number field. Let*k*be an imaginary quadratic number field with ring of integers For a prime ideal with odd norm and define the quadratic character for as

for an arbitrary ideal factored into prime ideals define

and for define

Let i.e. is an integral basis for For with odd norm define integers

*a*,

*b*,

*c*,

*d*by the equations,

and a function

If

*m*=

*Nμ*and

*n*=

*Nν*are both odd, Herglotz proved

Also, if

Then

### Polynomials over a finite field

Let*F*be a finite field with

*q*=

*p*elements, where

^{n}*p*is an odd prime number and

*n*is positive, and let

*F*be the ring of polynomials in one variable with coefficients in

*F*. If and

*f*is irreducible, monic, and has positive degree, define the quadratic character for

*F*in the usual manner:

If is a product of monic irreducibles let

Dedekind proved that if are monic and have positive degrees,

## Higher powers

The attempt to generalize quadratic reciprocity for powers higher than the second was one of the main goals that led 19th century mathematicians, including Carl Friedrich Gauss, Peter Gustav Lejeune Dirichlet, Carl Gustav Jakob Jacobi, Gotthold Eisenstein, Richard Dedekind, Ernst Kummer, and David Hilbert to the study of general algebraic number fields and their rings of integers; specifically Kummer invented ideals in order to state and prove higher reciprocity laws.The ninth in the list of 23 unsolved problems which David Hilbert proposed to the Congress of Mathematicians in 1900 asked for the

"Proof of the most general reciprocity law or an arbitrary number field". In 1923 Emil Artin, building upon work by Philipp Furtwängler, Teiji Takagi, Helmut Hasse and others, discovered a general theorem for which all known reciprocity laws are special cases; he proved it in 1927.

The links below provide more detailed discussions of these theorems.