Skip to content

Jacobi Symbol

The Legendre symbol

Motivation

The Legendre symbol

(ap) \left(\frac{a}{p}\right)

is defined only when the denominator is an odd prime. In many problems, however, one must work modulo an odd composite integer. The Jacobi symbol extends the notation of the Legendre symbol to this broader setting.

Let

n>1 n>1

be an odd integer with prime factorization

n=p1e1p2e2prer. n=p_1^{e_1}p_2^{e_2}\cdots p_r^{e_r}.

For any integer aa, the Jacobi symbol is defined by

(an)=(ap1)e1(ap2)e2(apr)er. \left(\frac{a}{n}\right) = \left(\frac{a}{p_1}\right)^{e_1} \left(\frac{a}{p_2}\right)^{e_2} \cdots \left(\frac{a}{p_r}\right)^{e_r}.

When nn is prime, the Jacobi symbol agrees with the Legendre symbol.

First Examples

Consider

(521). \left(\frac{5}{21}\right).

Since

21=37, 21=3\cdot7,

we have

(521)=(53)(57). \left(\frac{5}{21}\right) = \left(\frac{5}{3}\right) \left(\frac{5}{7}\right).

Now

52(mod3), 5\equiv2\pmod3,

and 22 is not a square modulo 33, so

(53)=1. \left(\frac{5}{3}\right)=-1.

Also

5≢1,2,4(mod7), 5\not\equiv 1,2,4\pmod7,

so

(57)=1. \left(\frac{5}{7}\right)=-1.

Therefore

(521)=(1)(1)=1. \left(\frac{5}{21}\right)=(-1)(-1)=1.

This does not necessarily mean that 55 is a square modulo 2121. Indeed, a Jacobi symbol equal to 11 is only a necessary condition for being a quadratic residue modulo a composite modulus, not a sufficient one.

Difference from the Legendre Symbol

For an odd prime pp, the value

(ap)=1 \left(\frac{a}{p}\right)=1

means that

x2a(modp) x^2\equiv a\pmod p

has a solution.

For composite nn, the value

(an)=1 \left(\frac{a}{n}\right)=1

does not guarantee that

x2a(modn) x^2\equiv a\pmod n

has a solution.

For example,

(215)=(23)(25)=(1)(1)=1. \left(\frac{2}{15}\right) = \left(\frac{2}{3}\right) \left(\frac{2}{5}\right) = (-1)(-1)=1.

But 22 is not a square modulo 1515. The squares modulo 1515 are

0,1,4,6,9,10. 0,1,4,6,9,10.

Thus the Jacobi symbol behaves like a residue character, but it does not fully solve quadratic congruences for composite moduli.

Basic Properties

The Jacobi symbol inherits many formal properties from the Legendre symbol.

First, it depends only on a(modn)a\pmod n:

ab(modn)(an)=(bn). a\equiv b\pmod n \quad\Longrightarrow\quad \left(\frac{a}{n}\right)=\left(\frac{b}{n}\right).

Second, it is multiplicative in the numerator:

(abn)=(an)(bn). \left(\frac{ab}{n}\right) = \left(\frac{a}{n}\right) \left(\frac{b}{n}\right).

Third, it is multiplicative in the denominator:

(amn)=(am)(an) \left(\frac{a}{mn}\right) = \left(\frac{a}{m}\right) \left(\frac{a}{n}\right)

for odd positive integers m,nm,n.

These properties make the Jacobi symbol computationally efficient.

Special Values

The special formulas for 1-1 and 22 remain valid for odd positive nn:

(1n)=(1)(n1)/2, \left(\frac{-1}{n}\right) = (-1)^{(n-1)/2},

and

(2n)=(1)(n21)/8. \left(\frac{2}{n}\right) = (-1)^{(n^2-1)/8}.

Thus

(1n)=1 \left(\frac{-1}{n}\right)=1

when

n1(mod4), n\equiv1\pmod4,

and equals 1-1 when

n3(mod4). n\equiv3\pmod4.

Similarly,

(2n)=1 \left(\frac{2}{n}\right)=1

when

n1,7(mod8), n\equiv1,7\pmod8,

and equals 1-1 when

n3,5(mod8). n\equiv3,5\pmod8.

Reciprocity Law

The Jacobi symbol satisfies the same formal reciprocity law as the Legendre symbol.

If mm and nn are odd positive coprime integers, then

(mn)(nm)=(1)m12n12. \left(\frac{m}{n}\right) \left(\frac{n}{m}\right) = (-1)^{\frac{m-1}{2}\frac{n-1}{2}}.

Equivalently,

(mn)=(nm) \left(\frac{m}{n}\right) = \left(\frac{n}{m}\right)

unless both mm and nn are congruent to 3(mod4)3\pmod4. In that exceptional case,

(mn)=(nm). \left(\frac{m}{n}\right) = -\left(\frac{n}{m}\right).

This law allows rapid computation without factoring the numerator.

Example of Computation

Compute

(10019907). \left(\frac{1001}{9907}\right).

Using reciprocity is far better than checking squares directly.

Reduce:

1001=71113. 1001=7\cdot11\cdot13.

Then

(10019907)=(79907)(119907)(139907). \left(\frac{1001}{9907}\right) = \left(\frac{7}{9907}\right) \left(\frac{11}{9907}\right) \left(\frac{13}{9907}\right).

Each symbol can be reduced by quadratic reciprocity and modular reduction. This process eventually reduces the computation to small symbols such as

(1q),(1q),(2q). \left(\frac{1}{q}\right),\qquad \left(\frac{-1}{q}\right),\qquad \left(\frac{2}{q}\right).

The Euclidean-algorithm-like nature of this process is one reason the Jacobi symbol is useful in computation.

Use in Primality Testing

The Jacobi symbol is central in probabilistic primality tests.

For an odd integer nn, Euler’s criterion suggests that if nn is prime, then

a(n1)/2(an)(modn) a^{(n-1)/2}\equiv \left(\frac{a}{n}\right)\pmod n

for all integers aa coprime to nn.

If this congruence fails for some aa, then nn is definitely composite.

This idea leads to the Solovay-Strassen primality test. The test does not prove primality in one step, but it efficiently detects many composite numbers.

Conceptual Role

The Jacobi symbol separates formal reciprocity from actual solvability of quadratic congruences. It preserves the algebraic laws of the Legendre symbol while allowing composite denominators.

This distinction is important. For prime moduli, quadratic residue theory is controlled by fields. For composite moduli, the arithmetic decomposes through prime powers, and a single symbol no longer captures all information.

The Jacobi symbol is therefore both a computational tool and a bridge from elementary congruence theory to deeper arithmetic characters.