Definition:Legendre Symbol

The Legendre symbol is a function introduced by Adrien-Marie Legendre in Paris in 1798, during his partly successful attempt to prove the Law of Quadratic Reciprocity.

The function was later expanded into the Jacobi Symbol, the Kronecker Symbol, the Hilbert Symbol and the Artin Symbol.

Definition
Legendre defined the symbol by:


 * $$\left(\frac{a}{p}\right) = \pm 1\equiv a^{(p-1)/2}\pmod p$$.

for some $$a \in \mathbb Z_p$$

where



\left(\frac{a}{p}\right) = \begin{cases} \;\;\,0\mbox{ if } a \equiv 0 \pmod{p} \\+1\mbox{ if }a \not\equiv 0\pmod{p} \mbox{ and for some integer }x, x^2\equiv \;a \pmod{p} \\-1\mbox{ if there is no such } x. \end{cases}$$

for some $$a \in \mathbb Z_p$$ and prime $$p \ge 3$$

Applications
The Legendre Symbol can be used as a tool to finding whether a number is a Quadratic Residue (mod p) through the following conditions:


 * If $$\frac{a}{p} = 1$$, then $$a$$ is a Quadratic Residue mod $$p$$
 * If $$\frac{a}{p} = -1$$, then $$a$$ is a Quadratic Non-Residue mod $$p$$

Properties
There are a number of useful properties of the Legendre symbol which can be used to speed up calculations. They include:

\left(\frac{ab}{p}\right) = \left(\frac{a}{p}\right)\left(\frac{b}{p}\right) $$

\left(\frac{a}{p}\right) = \left(\frac{b}{p}\right) $$
 * If a ≡ b (mod p), then $$

\left(\frac{a^2}{p}\right) = 1 $$

\left(\frac{-1}{p}\right) = (-1)^{(p-1)/2} =\begin{cases} +1\mbox{ if }p \equiv 1\pmod{4} \\ -1\mbox{ if }p \equiv 3\pmod{4} \end{cases}$$

This is called the first supplement to the law of quadratic reciprocity.

\left(\frac{2}{p}\right) = (-1)^{(p^2-1)/8} =\begin{cases} +1\mbox{ if }p \equiv 1\mbox{ or }7 \pmod{8} \\ -1\mbox{ if }p \equiv 3\mbox{ or }5 \pmod{8} \end{cases}$$

This is called the second supplement to the law of quadratic reciprocity.

The general Law of Quadratic Reciprocity is

\left(\frac{q}{p}\right) = \left(\frac{p}{q}\right)(-1)^{(p-1)(q-1)/4}. $$
 * If p and q are odd primes then $$