Legendre symbol (a/p) for variousa (along top) andp (along left side).
a
p
0
1
2
3
4
5
6
7
8
9
10
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 othera can be reduced modulop.Quadratic residues are highlighted in yellow, and correspond precisely to the values 0 and 1.
Let be an oddprime number. An integer is aquadratic residue modulo if it iscongruent to aperfect square modulo and is a quadratic nonresidue modulo otherwise. TheLegendre symbol is a function of and defined as
Legendre's original definition was by means of the explicit formula
ByEuler'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 convenientnotation that recorded quadratic residuosity ofa mod p. For the sake of comparison,Gauss used the notationaRp,aNp according to whethera is a residue or a non-residue modulop. For typographical convenience, the Legendre symbol is sometimes written as (a | p) or (a/p). For fixedp, the sequence isperiodic with periodp and is sometimes called theLegendre sequence. Each row in the following table exhibits periodicity, just as described.
There are a number of useful properties of the Legendre symbol which, together with the law ofquadratic reciprocity, can be used to compute it efficiently.
Given a generator, if, then is a quadratic residue if and only if is even. This shows that half of the elements in are quadratic residues.
If then the fact that
gives us that is a square root of the quadratic residue.
The Legendre symbol is periodic in its first (or top) argument: ifa ≡b (modp), then
In particular, the product of two numbers that are both quadratic residues or quadratic non-residues modulop is a residue, whereas the product of a residue with a non-residue is a non-residue. A special case is the Legendre symbol of a square:
When viewed as a function ofa, the Legendre symbol is the unique quadratic (or order 2)Dirichlet character modulop.
The first supplement to the law of quadratic reciprocity:
The second supplement to the law of quadratic reciprocity:
Special formulas for the Legendre symbol for small values ofa:
For an odd primep ≠ 3,
For an odd primep ≠ 5,
TheFibonacci numbers 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, ... are defined by the recurrenceF1 =F2 = 1,Fn+1 =Fn +Fn−1. Ifp is a prime number then
Sums of the form, typically taken over all integers in the range for some function, are a special case ofcharacter sums. They are of interest in the distribution ofquadratic residues modulo a prime number.
TheJacobi symbol is a generalization of the Legendre symbol that allows for a composite second (bottom) argumentn, althoughn must still be odd and positive inotrud. This generalization provides an efficient way to compute all Legendre symbols without performing factorization along the way.
A further extension is theKronecker symbol, in which the bottom argument may be any integer.
The above properties, including the law of quadratic reciprocity, can be used to evaluate any Legendre symbol. For example:
Or using a more efficient computation:
The articleJacobi symbol has more examples of Legendre symbol manipulation.
Since no efficientfactorization algorithm is known, but efficientmodular exponentiation algorithms are, in general it is more efficient to use Legendre's original definition, e.g.
usingrepeated squaring modulo 331, reducing every value using the modulus after every operation to avoid computation with large integers.
^Ribenboim, p. 64; Lemmermeyer, ex. 2.25–2.28, pp. 73–74.
^Gauss, "Summierung gewisser Reihen von besonderer Art" (1811), reprinted inUntersuchungen ... pp. 463–495
^Gauss, "Neue Beweise und Erweiterungen des Fundamentalsatzes in der Lehre von den quadratischen Resten" (1818) reprinted inUntersuchungen ... pp. 501–505
Gauss, Carl Friedrich (1965),Untersuchungen über höhere Arithmetik (Disquisitiones Arithmeticae & other papers on number theory), translated by Maser, H. (Second ed.), New York: Chelsea,ISBN0-8284-0191-8