3 | 0 | 1 | −1 | |||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|
5 | 0 | 1 | −1 | −1 | 1 | |||||||
7 | 0 | 1 | 1 | −1 | 1 | −1 | −1 | |||||
11 | 0 | 1 | −1 | 1 | 1 | 1 | −1 | −1 | −1 | 1 | −1 | |
Only 0 ≤ a < p are shown, since due to the first property below any other a can be reduced modulo p. Quadratic residues are highlighted in yellow, and correspond precisely to the values 0 and 1. |
In number theory, the Legendre symbol is a multiplicative function with values 1, −1, 0 that is a quadratic character modulo of an odd prime number p: its value at a (nonzero) quadratic residue mod p is 1 and at a non-quadratic residue (non-residue) is −1. Its value at zero is 0.
The Legendre symbol was introduced by Adrien-Marie Legendre in 1798[1] in the course of his attempts at proving the law of quadratic reciprocity. Generalizations of the symbol include the Jacobi symbol and Dirichlet characters of higher order. The notational convenience of the Legendre symbol inspired introduction of several other "symbols" used in algebraic number theory, such as the Hilbert symbol and the Artin symbol.
Let
p
a
p
p
p
a
p
\left( | a |
p |
\right)=\begin{cases} 1&ifaisaquadraticresiduemodulopanda\not\equiv0\pmodp,\\ -1&ifaisaquadraticnonresiduemodulop,\\ 0&ifa\equiv0\pmodp. \end{cases}
Legendre's original definition was by means of the explicit formula
\left( | a |
p |
\right)\equiv
| ||||
a |
\pmodp and \left(
a | |
p |
\right)\in\{-1,0,1\}.
By Euler's criterion, which had been discovered earlier and was known to Legendre, these two definitions are equivalent.[2] Thus Legendre's contribution lay in introducing a convenient notation that recorded quadratic residuosity of a mod p. For the sake of comparison, Gauss used the notation aRp, aNp according to whether a is a residue or a non-residue modulo p. For typographical convenience, the Legendre symbol is sometimes written as (a | p) or (a/p). For fixed p, the sequence
\left(\tfrac{0}{p}\right),\left(\tfrac{1}{p}\right),\left(\tfrac{2}{p}\right),\ldots
The following is a table of values of Legendre symbol
\left( | a |
p |
\right)
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 | 26 | 27 | 28 | 29 | 30 | ||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
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 | −1 | 0 | 1 | −1 | 0 | |
5 | 1 | −1 | −1 | 1 | 0 | 1 | −1 | −1 | 1 | 0 | 1 | −1 | −1 | 1 | 0 | 1 | −1 | −1 | 1 | 0 | 1 | −1 | −1 | 1 | 0 | 1 | −1 | −1 | 1 | 0 | |
7 | 1 | 1 | −1 | 1 | −1 | −1 | 0 | 1 | 1 | −1 | 1 | −1 | −1 | 0 | 1 | 1 | −1 | 1 | −1 | −1 | 0 | 1 | 1 | −1 | 1 | −1 | −1 | 0 | 1 | 1 | |
11 | 1 | −1 | 1 | 1 | 1 | −1 | −1 | −1 | 1 | −1 | 0 | 1 | −1 | 1 | 1 | 1 | −1 | −1 | −1 | 1 | −1 | 0 | 1 | −1 | 1 | 1 | 1 | −1 | −1 | −1 | |
13 | 1 | −1 | 1 | 1 | −1 | −1 | −1 | −1 | 1 | 1 | −1 | 1 | 0 | 1 | −1 | 1 | 1 | −1 | −1 | −1 | −1 | 1 | 1 | −1 | 1 | 0 | 1 | −1 | 1 | 1 | |
17 | 1 | 1 | −1 | 1 | −1 | −1 | −1 | 1 | 1 | −1 | −1 | −1 | 1 | −1 | 1 | 1 | 0 | 1 | 1 | −1 | 1 | −1 | −1 | −1 | 1 | 1 | −1 | −1 | −1 | 1 | |
19 | 1 | −1 | −1 | 1 | 1 | 1 | 1 | −1 | 1 | −1 | 1 | −1 | −1 | −1 | −1 | 1 | 1 | −1 | 0 | 1 | −1 | −1 | 1 | 1 | 1 | 1 | −1 | 1 | −1 | 1 | |
23 | 1 | 1 | 1 | 1 | −1 | 1 | −1 | 1 | 1 | −1 | −1 | 1 | 1 | −1 | −1 | 1 | −1 | 1 | −1 | −1 | −1 | −1 | 0 | 1 | 1 | 1 | 1 | −1 | 1 | −1 | |
29 | 1 | −1 | −1 | 1 | 1 | 1 | 1 | −1 | 1 | −1 | −1 | −1 | 1 | −1 | −1 | 1 | −1 | −1 | −1 | 1 | −1 | 1 | 1 | 1 | 1 | −1 | −1 | 1 | 0 | 1 | |
31 | 1 | 1 | −1 | 1 | 1 | −1 | 1 | 1 | 1 | 1 | −1 | −1 | −1 | 1 | −1 | 1 | −1 | 1 | 1 | 1 | −1 | −1 | −1 | −1 | 1 | −1 | −1 | 1 | −1 | −1 | |
37 | 1 | −1 | 1 | 1 | −1 | −1 | 1 | −1 | 1 | 1 | 1 | 1 | −1 | −1 | −1 | 1 | −1 | −1 | −1 | −1 | 1 | −1 | −1 | −1 | 1 | 1 | 1 | 1 | −1 | 1 | |
41 | 1 | 1 | −1 | 1 | 1 | −1 | −1 | 1 | 1 | 1 | −1 | −1 | −1 | −1 | −1 | 1 | −1 | 1 | −1 | 1 | 1 | −1 | 1 | −1 | 1 | −1 | −1 | −1 | −1 | −1 | |
43 | 1 | −1 | −1 | 1 | −1 | 1 | −1 | −1 | 1 | 1 | 1 | −1 | 1 | 1 | 1 | 1 | 1 | −1 | −1 | −1 | 1 | −1 | 1 | 1 | 1 | −1 | −1 | −1 | −1 | −1 | |
47 | 1 | 1 | 1 | 1 | −1 | 1 | 1 | 1 | 1 | −1 | −1 | 1 | −1 | 1 | −1 | 1 | 1 | 1 | −1 | −1 | 1 | −1 | −1 | 1 | 1 | −1 | 1 | 1 | −1 | −1 | |
53 | 1 | −1 | −1 | 1 | −1 | 1 | 1 | −1 | 1 | 1 | 1 | −1 | 1 | −1 | 1 | 1 | 1 | −1 | −1 | −1 | −1 | −1 | −1 | 1 | 1 | −1 | −1 | 1 | 1 | −1 | |
59 | 1 | −1 | 1 | 1 | 1 | −1 | 1 | −1 | 1 | −1 | −1 | 1 | −1 | −1 | 1 | 1 | 1 | −1 | 1 | 1 | 1 | 1 | −1 | −1 | 1 | 1 | 1 | 1 | 1 | −1 | |
61 | 1 | −1 | 1 | 1 | 1 | −1 | −1 | −1 | 1 | −1 | −1 | 1 | 1 | 1 | 1 | 1 | −1 | −1 | 1 | 1 | −1 | 1 | −1 | −1 | 1 | −1 | 1 | −1 | −1 | −1 | |
67 | 1 | −1 | −1 | 1 | −1 | 1 | −1 | −1 | 1 | 1 | −1 | −1 | −1 | 1 | 1 | 1 | 1 | −1 | 1 | −1 | 1 | 1 | 1 | 1 | 1 | 1 | −1 | −1 | 1 | −1 | |
71 | 1 | 1 | 1 | 1 | 1 | 1 | −1 | 1 | 1 | 1 | −1 | 1 | −1 | −1 | 1 | 1 | −1 | 1 | 1 | 1 | −1 | −1 | −1 | 1 | 1 | −1 | 1 | −1 | 1 | 1 | |
73 | 1 | 1 | 1 | 1 | −1 | 1 | −1 | 1 | 1 | −1 | −1 | 1 | −1 | −1 | −1 | 1 | −1 | 1 | 1 | −1 | −1 | −1 | 1 | 1 | 1 | −1 | 1 | −1 | −1 | −1 | |
79 | 1 | 1 | −1 | 1 | 1 | −1 | −1 | 1 | 1 | 1 | 1 | −1 | 1 | −1 | −1 | 1 | −1 | 1 | 1 | 1 | 1 | 1 | 1 | −1 | 1 | 1 | −1 | −1 | −1 | −1 | |
83 | 1 | −1 | 1 | 1 | −1 | −1 | 1 | −1 | 1 | 1 | 1 | 1 | −1 | −1 | −1 | 1 | 1 | −1 | −1 | −1 | 1 | −1 | 1 | −1 | 1 | 1 | 1 | 1 | 1 | 1 | |
89 | 1 | 1 | −1 | 1 | 1 | −1 | −1 | 1 | 1 | 1 | 1 | −1 | −1 | −1 | −1 | 1 | 1 | 1 | −1 | 1 | 1 | 1 | −1 | −1 | 1 | −1 | −1 | −1 | −1 | −1 | |
97 | 1 | 1 | 1 | 1 | −1 | 1 | −1 | 1 | 1 | −1 | 1 | 1 | −1 | −1 | −1 | 1 | −1 | 1 | −1 | −1 | −1 | 1 | −1 | 1 | 1 | −1 | 1 | −1 | −1 | −1 | |
101 | 1 | −1 | −1 | 1 | 1 | 1 | −1 | −1 | 1 | −1 | −1 | −1 | 1 | 1 | −1 | 1 | 1 | −1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | −1 | −1 | −1 | −1 | 1 | |
103 | 1 | 1 | −1 | 1 | −1 | −1 | 1 | 1 | 1 | −1 | −1 | −1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | −1 | −1 | −1 | 1 | −1 | 1 | 1 | −1 | 1 | 1 | 1 | |
107 | 1 | −1 | 1 | 1 | −1 | −1 | −1 | −1 | 1 | 1 | 1 | 1 | 1 | 1 | −1 | 1 | −1 | −1 | 1 | −1 | −1 | −1 | 1 | −1 | 1 | −1 | 1 | −1 | 1 | 1 | |
109 | 1 | −1 | 1 | 1 | 1 | −1 | 1 | −1 | 1 | −1 | −1 | 1 | −1 | −1 | 1 | 1 | −1 | −1 | −1 | 1 | 1 | 1 | −1 | −1 | 1 | 1 | 1 | 1 | 1 | −1 | |
113 | 1 | 1 | −1 | 1 | −1 | −1 | 1 | 1 | 1 | −1 | 1 | −1 | 1 | 1 | 1 | 1 | −1 | 1 | −1 | −1 | −1 | 1 | −1 | −1 | 1 | 1 | −1 | 1 | −1 | 1 | |
127 | 1 | 1 | −1 | 1 | −1 | −1 | −1 | 1 | 1 | −1 | 1 | −1 | 1 | −1 | 1 | 1 | 1 | 1 | 1 | −1 | 1 | 1 | −1 | −1 | 1 | 1 | −1 | −1 | −1 | 1 |
There are a number of useful properties of the Legendre symbol which, together with the law of quadratic reciprocity, can be used to compute it efficiently.
g\in
* | |
F | |
p |
x=gr
x
r
* | |
F | |
p |
p\equiv3mod4
p+1 | |
4 |
+
p+1 | |
4 |
=
p+1 | |
2 |
=
(p-1)+2 | |
2 |
=
p-1 | |
2 |
+1
a=x(p+1)/4
x
\left( | a |
p |
\right)=\left(
b | |
p |
\right).
\left( | ab |
p |
\right)=\left(
a | \right)\left( | |
p |
b | |
p |
\right).
\left( | x2 |
p |
\right)=\begin{cases}1&ifp\nmidx\ 0&ifp\midx.\end{cases}
\left( | a |
p |
\right)
\left( | -1 |
p |
\right)=
| ||||
(-1) |
= \begin{cases} 1&ifp\equiv1\pmod{4}\\ -1&ifp\equiv3\pmod{4}.\end{cases}
\left( | 2 |
p |
\right)=(-1)\tfrac{p2-1}{8}= \begin{cases} 1&ifp\equiv1or7\pmod{8}\\ -1&ifp\equiv3or5\pmod{8}. \end{cases}
\left( | a |
p |
\right)
\left( | 3 |
p |
\right)=
| ||||||
(-1) |
= \begin{cases} 1&ifp\equiv1or11\pmod{12}\\ -1&ifp\equiv5or7\pmod{12}. \end{cases}
\left( | 5 |
p |
\right)
| ||||||
=(-1) |
= \begin{cases} 1&ifp\equiv1or4\pmod5\\ -1&ifp\equiv2or3\pmod5. \end{cases}
F | |||||
|
\equiv0\pmodp, Fp\equiv\left(
p | |
5 |
\right)\pmodp.
For example,
\begin{align} \left(\tfrac{2}{5}\right)&=-1,&F3&=2,&F2&=1,\ \left(\tfrac{3}{5}\right)&=-1,&F4&=3,&F3&=2,\ \left(\tfrac{5}{5}\right)&=0,&F5&=5,&&\ \left(\tfrac{7}{5}\right)&=-1,&F8&=21,&F7&=13,\ \left(\tfrac{11}{5}\right)&=1,&F10&=55,&F11&=89. \end{align}
Let p and q be distinct odd primes. Using the Legendre symbol, the quadratic reciprocity law can be stated concisely:
\left( | q | \right)\left( |
p |
p | |
q |
\right)=(-1)\tfrac{p-1{2} ⋅ \tfrac{q-1}{2}}.
Many proofs of quadratic reciprocity are based on Euler's criterion
\left( | a |
p |
\right)\equiva\tfrac{p-1{2}}\pmodp.
In addition, several alternative expressions for the Legendre symbol were devised in order to produce various proofs of the quadratic reciprocity law.
p-1 | |
\sum | |
k=0 |
ak2 | ||
\zeta | =\left( |
a | |
p |
p-1 | |
\right)\sum | |
k=0 |
k2 | |
\zeta |
, \zeta=
| ||||
e |
in his fourth[4] and sixth[5] proofs of quadratic reciprocity.
\left( | p |
q |
\right)
| ||||
=sgn\left(\prod | ||||
i=1 |
| |||||
\prod | \left( | ||||
k=1 |
k | - | |
p |
i | |
q |
\right)\right).
Reversing the roles of p and q, he obtains the relation between and .
\left( | q |
p |
\right)
| ||||
=\prod | ||||
n=1 |
| |||||
|
.
Using certain elliptic functions instead of the sine function, Eisenstein was able to prove cubic and quartic reciprocity as well.
The above properties, including the law of quadratic reciprocity, can be used to evaluate any Legendre symbol. For example:
\begin{align} \left(
12345 | |
331 |
\right)&=\left(
3 | |
331 |
\right)\left(
5 | |
331 |
\right)\left(
823 | |
331 |
\right)\\ &=\left(
3 | |
331 |
\right)\left(
5 | |
331 |
\right)\left(
161 | |
331 |
\right)\\ &=\left(
3 | |
331 |
\right)\left(
5 | |
331 |
\right)\left(
7 | |
331 |
\right)\left(
23 | |
331 |
\right)\\ &=(-1)\left(
331 | |
3 |
\right)\left(
331 | |
5 |
\right)(-1)\left(
331 | |
7 |
\right)(-1)\left(
331 | |
23 |
\right)\\ &=-\left(
1 | |
3 |
\right)\left(
1 | |
5 |
\right)\left(
2 | |
7 |
\right)\left(
9 | |
23 |
\right)\\ &=-\left(
1 | |
3 |
\right)\left(
1 | |
5 |
\right)\left(
2 | |
7 |
\right)\left(
32 | |
23 |
\right)\\ &=-(1)(1)(1)(1)\\ &=-1. \end{align}
Or using a more efficient computation:
\left(
12345 | |
331 |
\right)=\left(
98 | |
331 |
\right)=\left(
2 ⋅ 72 | |
331 |
\right)=\left(
2 | |
331 |
\right)=(-1)\tfrac{3312-1}{8}=-1.
Since no efficient factorization algorithm is known, but efficient modular exponentiation algorithms are, in general it is more efficient to use Legendre's original definition, e.g.
\begin{align} \left( | 98 |
331 |
\right)&\equiv
| ||||
98 |
&\pmod{331}\\ &\equiv98165&\pmod{331}\\ &\equiv98 ⋅ (982)82&\pmod{331}\\ &\equiv98 ⋅ 582&\pmod{331}\\ &\equiv98 ⋅ 2541&\pmod{331}\\ &\equiv133 ⋅ 2540&\pmod{331}\\ &\equiv133 ⋅ 29420&\pmod{331}\\ &\equiv133 ⋅ 4510&\pmod{331}\\ &\equiv133 ⋅ 395&\pmod{331}\\ &\equiv222 ⋅ 394&\pmod{331}\\ &\equiv222 ⋅ 1972&\pmod{331}\\ &\equiv222 ⋅ 82&\pmod{331}\\ &\equiv-1&\pmod{331} \end{align}
using repeated squaring modulo 331, reducing every value using the modulus after every operation to avoid computation with large integers.