Supriya Ghosh (Editor)

Jacobi symbol

Updated on
Edit
Like
Comment
Share on FacebookTweet on TwitterShare on LinkedInShare on Reddit

The Jacobi symbol is a generalization of the Legendre symbol. Introduced by Jacobi in 1837, it is of theoretical interest in modular arithmetic and other branches of number theory, but its main use is in computational number theory, especially primality testing and integer factorization; these in turn are important in cryptography.

Contents

Definition

For any integer a and any positive odd integer n, the Jacobi symbol (a/n) is defined as the product of the Legendre symbols corresponding to the prime factors of n:

( a n ) = ( a p 1 ) α 1 ( a p 2 ) α 2 ( a p k ) α k ,

where

n = p 1 α 1 p 2 α 2 p k α k

is the prime factorization of n.

The Legendre symbol (a/p) is defined for all integers a and all odd primes p by

( a p ) = { 0 if  a 0 ( mod p ) , 1 if  a 0 ( mod p )  and for some integer  x : a x 2 ( mod p ) , 1 if  a 0 ( mod p )  and there is no such  x .

Following the normal convention for the empty product, (a/1) = 1.

The Legendre and Jacobi symbols are indistinguishable exactly when the lower argument is an odd prime, in which case they have the same value.

Table of values

The following is a table of values of Jacobi symbol (k/n) with n ≤ 59, k ≤ 30, n odd.

Properties

The following facts, even the reciprocity laws, are straightforward deductions from the definition of the Jacobi symbol and the corresponding properties of the Legendre symbol.

The Jacobi symbol is defined only when the upper argument ("numerator") is an integer and the lower argument ("denominator") is a positive odd integer.

1. If n is (an odd) prime, then the Jacobi symbol (a/n) is equal to (and written the same as) the corresponding Legendre symbol. 2. If ab  (mod n), then (a/n) = (b/n). 3. ( a n ) = { 0 if  gcd ( a , n ) 1 , ± 1 if  gcd ( a , n ) = 1.

If either the top or bottom argument is fixed, the Jacobi symbol is a completely multiplicative function in the remaining argument:

4. ( a b n ) = ( a n ) ( b n ) , so  ( a 2 n ) = 1  or  0. 5. ( a m n ) = ( a m ) ( a n ) , so  ( a n 2 ) = 1  or  0.

The law of quadratic reciprocity: if m and n are odd positive coprime integers, then

6. ( m n ) ( n m ) = ( 1 ) m 1 2 n 1 2 = { 1 if  n 1 ( mod 4 )  or  m 1 ( mod 4 ) , 1 if  n m 3 ( mod 4 )

and its supplements

7. ( 1 n ) = ( 1 ) n 1 2 = { 1 if  n 1 ( mod 4 ) , 1 if  n 3 ( mod 4 ) , 8. ( 2 n ) = ( 1 ) n 2 1 8 = { 1 if  n 1 , 7 ( mod 8 ) , 1 if  n 3 , 5 ( mod 8 ) .

Like the Legendre symbol:

  • If (a/n) = −1 then a is a quadratic nonresidue modulo n'.
  • If a is a quadratic residue modulo n and gcd(a,n) = 1, then (a/n) = 1.
  • But, unlike the Legendre symbol:

    If (a/n) = 1 then a may or may not be a quadratic residue modulo n.

    This is because for a to be a quadratic residue modulo n, it has to be a quadratic residue modulo every prime factor of n. However, the Jacobi symbol equals one if, for example, a is a non-residue modulo exactly two of the prime factors of n.

    Although the Jacobi symbol cannot be uniformly interpreted in terms of squares and non-squares, it can be uniformly interpreted as the sign of a permutation by Zolotarev's lemma.

    The Jacobi symbol (a/n) is a Dirichlet character to the modulus n.

    Calculating the Jacobi symbol

    The above formulas lead to an efficient O(log a log b) algorithm for calculating the Jacobi symbol, analogous to the Euclidean algorithm for finding the gcd of two numbers. (This should not be surprising in light of rule 2).

    1. Reduce the "numerator" modulo the "denominator" using rule 2.
    2. Extract any factors of 2 from the "numerator" using rule 4 and evaluate them using rule 8.
    3. If the "numerator" is 1, rules 3 and 4 give a result of 1. If the "numerator" and "denominator" are not coprime, rule 3 gives a result of 0.
    4. Otherwise, the "numerator" and "denominator" are now odd positive coprime integers, so we can flip the symbol using rule 6, then return to step 1.

    Example of calculations

    The Legendre symbol (a/p) is only defined for odd primes p. It obeys the same rules as the Jacobi symbol (i.e., reciprocity and the supplementary formulas for (−1/p) and (2/p) and multiplicativity of the "numerator".)

    Problem: Given that 9907 is prime, calculate (1001/9907).

    Using the Legendre symbol

    ( 1001 9907 ) = ( 7 9907 ) ( 11 9907 ) ( 13 9907 ) . ( 7 9907 ) = ( 9907 7 ) = ( 2 7 ) = 1. ( 11 9907 ) = ( 9907 11 ) = ( 7 11 ) = ( 11 7 ) = ( 4 7 ) = 1. ( 13 9907 ) = ( 9907 13 ) = ( 1 13 ) = 1. ( 1001 9907 ) = 1.

    Using the Jacobi symbol

    ( 1001 9907 ) = ( 9907 1001 ) = ( 898 1001 ) = ( 2 1001 ) ( 449 1001 ) = ( 449 1001 ) = ( 1001 449 ) = ( 103 449 ) = ( 449 103 ) = ( 37 103 ) = ( 103 37 ) = ( 29 37 ) = ( 37 29 ) = ( 8 29 ) = ( 2 29 ) 3 = 1.

    The difference between the two calculations is that when the Legendre symbol is used the "numerator" has to be factored into prime powers before the symbol is flipped. This makes the calculation using the Legendre symbol significantly slower than the one using the Jacobi symbol, as there is no known polynomial-time algorithm for factoring integers. In fact, this is why Jacobi introduced the symbol.

    Primality testing

    There is another way the Jacobi and Legendre symbols differ. If the Euler criterion formula is used modulo a composite number, the result may or may not be the value of the Jacobi symbol, and in fact may not even be −1 or 1. For example,

    ( 19 45 ) = 1  and  19 45 1 2 1 ( mod 45 ) . ( 8 21 ) = 1  but  8 21 1 2 1 ( mod 21 ) . ( 5 21 ) = 1  but  5 21 1 2 16 ( mod 21 ) .

    So if it is unknown whether a number n is prime or composite, we can pick a random number a, calculate the Jacobi symbol (a/n) and compare it with Euler's formula; if they differ modulo n, then n is composite; if they have the same residue modulo n for many different values of a, then n is "probably prime".

    This is the basis for the probabilistic Solovay–Strassen primality test and refinements such as the Baillie-PSW primality test and the Miller–Rabin primality test.

    References

    Jacobi symbol Wikipedia