Legendre Symbol

DOWNLOAD Mathematica Notebook

The Legendre symbol is a number theoretic function (a/p) which is defined to be equal to +/-1 depending on whether a is a quadratic residue modulo p. The definition is sometimes generalized to have value 0 if p|a,

 (a/p)=(a|p)={0   if p|a; 1   if a is a quadratic residue modulo p; -1   if a is a quadratic nonresidue modulo p.
(1)

If p is an odd prime, then the Jacobi symbol reduces to the Legendre symbol. The Legendre symbol is implemented in the Wolfram Language via the Jacobi symbol, JacobiSymbol[a, p].

The Legendre symbol obeys the identity

 ((ab)/p)=(a/p)(b/p).
(2)

Particular identities include

((-1)/p)=(-1)^((p-1)/2)
(3)
(2/p)=(-1)^((p^2-1)/8)
(4)
((-3)/p)={1 if p=1 (mod 6); -1 if p=5 (mod 6)
(5)
(5/p)={1 if p=1,9 (mod 10); -1 if p=3,7 (mod 10)
(6)

(Nagell 1951, p. 144), as well as the general

 (q/p)=(p/q)(-1)^([(p-1)/2][(q-1)/2])
(7)

when p and q are both odd primes.

In general,

 (a/p)=a^((p-1)/2) (mod p)
(8)

if p is an odd prime.

Wolfram Web Resources

Mathematica »

The #1 tool for creating Demonstrations and anything technical.

Wolfram|Alpha »

Explore anything with the first computational knowledge engine.

Wolfram Demonstrations Project »

Explore thousands of free applications across science, mathematics, engineering, technology, business, art, finance, social sciences, and more.

Computerbasedmath.org »

Join the initiative for modernizing math education.

Online Integral Calculator »

Solve integrals with Wolfram|Alpha.

Step-by-step Solutions »

Walk through homework problems step-by-step from beginning to end. Hints help you try the next step on your own.

Wolfram Problem Generator »

Unlimited random practice problems and answers with built-in Step-by-step solutions. Practice online or make a printable study sheet.

Wolfram Education Portal »

Collection of teaching and learning tools built by Wolfram education experts: dynamic textbook, lesson plans, widgets, interactive Demonstrations, and more.

Wolfram Language »

Knowledge-based programming for everyone.