fbpx
Wikipedia

Jacobi symbol

The Jacobi symbol is a generalization of the Legendre symbol. Introduced by Jacobi in 1837,[1] 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.

k
n
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16
1 1
3 0 1 −1
5 0 1 −1 −1 1
7 0 1 1 −1 1 −1 −1
9 0 1 1 0 1 1 0 1 1
11 0 1 −1 1 1 1 −1 −1 −1 1 −1
13 0 1 −1 1 1 −1 −1 −1 −1 1 1 −1 1
15 0 1 1 0 1 0 0 −1 1 0 0 −1 0 −1 −1
17 0 1 1 −1 1 −1 −1 −1 1 1 −1 −1 −1 1 −1 1 1

Jacobi symbol (k/n) for various k (along top) and n (along left side). Only 0 ≤ k < n are shown, since due to rule (2) below any other k can be reduced modulo n. Quadratic residues are highlighted in yellow — note that no entry with a Jacobi symbol of −1 is a quadratic residue, and if k is a quadratic residue modulo a coprime n, then (k/n) = 1, but not all entries with a Jacobi symbol of 1 (see the n = 9 and n = 15 rows) are quadratic residues. Notice also that when either n or k is a square, all values are nonnegative.

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:

 

where

 

is the prime factorization of n.

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

 

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

When the lower argument is an odd prime, the Jacobi symbol is equal to the Legendre symbol.

Table of values

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

k
n
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1
3 1 −1 0 1 −1 0 1 −1 0 1 −1 0 1 −1 0 1 −1 0 1 −1 0 1 −1 0 1 −1 0 1 −1 0
5 1 −1 −1 1 0 1 −1 −1 1 0 1 −1 −1 1 0 1 −1 −1 1 0 1 −1 −1 1 0 1 −1 −1 1 0
7 1 1 −1 1 −1 −1 0 1 1 −1 1 −1 −1 0 1 1 −1 1 −1 −1 0 1 1 −1 1 −1 −1 0 1 1
9 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0
11 1 −1 1 1 1 −1 −1 −1 1 −1 0 1 −1 1 1 1 −1 −1 −1 1 −1 0 1 −1 1 1 1 −1 −1 −1
13 1 −1 1 1 −1 −1 −1 −1 1 1 −1 1 0 1 −1 1 1 −1 −1 −1 −1 1 1 −1 1 0 1 −1 1 1
15 1 1 0 1 0 0 −1 1 0 0 −1 0 −1 −1 0 1 1 0 1 0 0 −1 1 0 0 −1 0 −1 −1 0
17 1 1 −1 1 −1 −1 −1 1 1 −1 −1 −1 1 −1 1 1 0 1 1 −1 1 −1 −1 −1 1 1 −1 −1 −1 1
19 1 −1 −1 1 1 1 1 −1 1 −1 1 −1 −1 −1 −1 1 1 −1 0 1 −1 −1 1 1 1 1 −1 1 −1 1
21 1 −1 0 1 1 0 0 −1 0 −1 −1 0 −1 0 0 1 1 0 −1 1 0 1 −1 0 1 1 0 0 −1 0
23 1 1 1 1 −1 1 −1 1 1 −1 −1 1 1 −1 −1 1 −1 1 −1 −1 −1 −1 0 1 1 1 1 −1 1 −1
25 1 1 1 1 0 1 1 1 1 0 1 1 1 1 0 1 1 1 1 0 1 1 1 1 0 1 1 1 1 0
27 1 −1 0 1 −1 0 1 −1 0 1 −1 0 1 −1 0 1 −1 0 1 −1 0 1 −1 0 1 −1 0 1 −1 0
29 1 −1 −1 1 1 1 1 −1 1 −1 −1 −1 1 −1 −1 1 −1 −1 −1 1 −1 1 1 1 1 −1 −1 1 0 1
31 1 1 −1 1 1 −1 1 1 1 1 −1 −1 −1 1 −1 1 −1 1 1 1 −1 −1 −1 −1 1 −1 −1 1 −1 −1
33 1 1 0 1 −1 0 −1 1 0 −1 0 0 −1 −1 0 1 1 0 −1 −1 0 0 −1 0 1 −1 0 −1 1 0
35 1 −1 1 1 0 −1 0 −1 1 0 1 1 1 0 0 1 1 −1 −1 0 0 −1 −1 −1 0 −1 1 0 1 0
37 1 −1 1 1 −1 −1 1 −1 1 1 1 1 −1 −1 −1 1 −1 −1 −1 −1 1 −1 −1 −1 1 1 1 1 −1 1
39 1 1 0 1 1 0 −1 1 0 1 1 0 0 −1 0 1 −1 0 −1 1 0 1 −1 0 1 0 0 −1 −1 0
41 1 1 −1 1 1 −1 −1 1 1 1 −1 −1 −1 −1 −1 1 −1 1 −1 1 1 −1 1 −1 1 −1 −1 −1 −1 −1
43 1 −1 −1 1 −1 1 −1 −1 1 1 1 −1 1 1 1 1 1 −1 −1 −1 1 −1 1 1 1 −1 −1 −1 −1 −1
45 1 −1 0 1 0 0 −1 −1 0 0 1 0 −1 1 0 1 −1 0 1 0 0 −1 −1 0 0 1 0 −1 1 0
47 1 1 1 1 −1 1 1 1 1 −1 −1 1 −1 1 −1 1 1 1 −1 −1 1 −1 −1 1 1 −1 1 1 −1 −1
49 1 1 1 1 1 1 0 1 1 1 1 1 1 0 1 1 1 1 1 1 0 1 1 1 1 1 1 0 1 1
51 1 −1 0 1 1 0 −1 −1 0 −1 1 0 1 1 0 1 0 0 1 1 0 −1 1 0 1 −1 0 −1 1 0
53 1 −1 −1 1 −1 1 1 −1 1 1 1 −1 1 −1 1 1 1 −1 −1 −1 −1 −1 −1 1 1 −1 −1 1 1 −1
55 1 1 −1 1 0 −1 1 1 1 0 0 −1 1 1 0 1 1 1 −1 0 −1 0 −1 −1 0 1 −1 1 −1 0
57 1 1 0 1 −1 0 1 1 0 −1 −1 0 −1 1 0 1 −1 0 0 −1 0 −1 −1 0 1 −1 0 1 1 0
59 1 −1 1 1 1 −1 1 −1 1 −1 −1 1 −1 −1 1 1 1 −1 1 1 1 1 −1 −1 1 1 1 1 1 −1

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.[2]

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  
3.  

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

4.  
5.  

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

6.  

and its supplements

7.  ,

and  

8.  

Combining properties 4 and 8 gives:

9.  

Like the Legendre symbol:

  • If (a/n) = −1 then a is a quadratic nonresidue modulo n.

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)[3] 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 even "numerator" using rule 9.
  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.

Implementation in Lua

function jacobi(n, k) assert(k > 0 and k % 2 == 1) n = n % k t = 1 while n ~= 0 do while n % 2 == 0 do n = n / 2 r = k % 8 if r == 3 or r == 5 then t = -t end end n, k = k, n if n % 4 == 3 and k % 4 == 3 then t = -t end n = n % k end if k == 1 then return t else return 0 end end 

Implementation in C++

// a/n is represented as (a,n) int jacobi(int a, int n) {  assert(n > 0 && n%2 == 1);  //step 1  a = a % n;  int t = 1;  int r;  //step 3  while (a != 0) {  //step 2  while (a % 2 == 0) {  a /= 2;  r = n % 8;  if (r == 3 || r == 5) {  t = -t;  }  }  //step 4  r = n;  n = a;  a = r;  if (a % 4 == 3 && n % 4 == 3) {  t = -t;  }  a = a % n;  }  if (n == 1) {  return t;  }  else {  return 0;  } } 

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

 

Using the Jacobi symbol

 

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.[4] In fact, this is why Jacobi introduced the symbol.

Primality testing

There is another way the Jacobi and Legendre symbols differ. If the Euler's 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,

 

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.

As an indirect use, it is possible to use it as an error detection routine during the execution of the Lucas–Lehmer primality test which, even on modern computer hardware, can take weeks to complete when processing Mersenne numbers over   (the largest known Mersenne prime as of December 2018). In nominal cases, the Jacobi symbol:

 

This also holds for the final residue   and hence can be used as a verification of probable validity. However, if an error occurs in the hardware, there is a 50% chance that the result will become 0 or 1 instead, and won't change with subsequent terms of   (unless another error occurs and changes it back to -1).

See also

Notes

  1. ^ Jacobi, C. G. J. (1837). "Über die Kreisteilung und ihre Anwendung auf die Zahlentheorie". Bericht Ak. Wiss. Berlin: 127–136.
  2. ^ Ireland & Rosen pp. 56–57 or Lemmermeyer p. 10
  3. ^ Cohen, pp. 29–31
  4. ^ The number field sieve, the fastest known algorithm, requires
     
    operations to factor n. See Cohen, p. 495

References

  • Cohen, Henri (1993). A Course in Computational Algebraic Number Theory. Berlin: Springer. ISBN 3-540-55640-0.
  • Ireland, Kenneth; Rosen, Michael (1990). A Classical Introduction to Modern Number Theory (Second edition). New York: Springer. ISBN 0-387-97329-X.
  • Lemmermeyer, Franz (2000). Reciprocity Laws: from Euler to Eisenstein. Berlin: Springer. ISBN 3-540-66957-4.
  • Shallit, Jeffrey (December 1990). "On the Worst Case of Three Algorithms for Computing the Jacobi Symbol". Journal of Symbolic Computation. 10 (6): 593–61. doi:10.1016/S0747-7171(08)80160-5. Computer science technical report PCS-TR89-140.
  • Vallée, Brigitte; Lemée, Charly (October 1998). Average-case analyses of three algorithms for computing the Jacobi symbol (Technical report). CiteSeerX 10.1.1.32.3425.
  • Eikenberry, Shawna Meyer; Sorenson, Jonathan P. (October 1998). "Efficient Algorithms for Computing the Jacobi Symbol" (PDF). Journal of Symbolic Computation. 26 (4): 509–523. CiteSeerX 10.1.1.44.2423. doi:10.1006/jsco.1998.0226.

External links

  • Calculate Jacobi symbol shows the steps of the calculation.

jacobi, symbol, generalization, legendre, symbol, introduced, jacobi, 1837, theoretical, interest, modular, arithmetic, other, branches, number, theory, main, computational, number, theory, especially, primality, testing, integer, factorization, these, turn, i. The Jacobi symbol is a generalization of the Legendre symbol Introduced by Jacobi in 1837 1 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 kn 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 161 13 0 1 15 0 1 1 1 17 0 1 1 1 1 1 19 0 1 1 0 1 1 0 1 111 0 1 1 1 1 1 1 1 1 1 113 0 1 1 1 1 1 1 1 1 1 1 1 115 0 1 1 0 1 0 0 1 1 0 0 1 0 1 117 0 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1Jacobi symbol k n for various k along top and n along left side Only 0 k lt n are shown since due to rule 2 below any other k can be reduced modulo n Quadratic residues are highlighted in yellow note that no entry with a Jacobi symbol of 1 is a quadratic residue and if k is a quadratic residue modulo a coprime n then k n 1 but not all entries with a Jacobi symbol of 1 see the n 9 and n 15 rows are quadratic residues Notice also that when either n or k is a square all values are nonnegative Contents 1 Definition 2 Table of values 3 Properties 4 Calculating the Jacobi symbol 4 1 Implementation in Lua 4 2 Implementation in C 5 Example of calculations 5 1 Using the Legendre symbol 5 2 Using the Jacobi symbol 6 Primality testing 7 See also 8 Notes 9 References 10 External linksDefinition EditFor 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 a 1 a p 2 a 2 a p k a k displaystyle left frac a n right left frac a p 1 right alpha 1 left frac a p 2 right alpha 2 cdots left frac a p k right alpha k where n p 1 a 1 p 2 a 2 p k a k displaystyle n p 1 alpha 1 p 2 alpha 2 cdots p k alpha 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 displaystyle left frac a p right left begin array rl 0 amp text if a equiv 0 pmod p 1 amp text if a not equiv 0 pmod p text and for some integer x colon a equiv x 2 pmod p 1 amp text if a not equiv 0 pmod p text and there is no such x end array right Following the normal convention for the empty product a 1 1 When the lower argument is an odd prime the Jacobi symbol is equal to the Legendre symbol Table of values EditThe following is a table of values of Jacobi symbol k n with n 59 k 30 n odd kn 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 301 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 13 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 05 1 1 1 1 0 1 1 1 1 0 1 1 1 1 0 1 1 1 1 0 1 1 1 1 0 1 1 1 1 07 1 1 1 1 1 1 0 1 1 1 1 1 1 0 1 1 1 1 1 1 0 1 1 1 1 1 1 0 1 19 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 011 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 113 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 115 1 1 0 1 0 0 1 1 0 0 1 0 1 1 0 1 1 0 1 0 0 1 1 0 0 1 0 1 1 017 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 1 1 119 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 1 1 1 1 121 1 1 0 1 1 0 0 1 0 1 1 0 1 0 0 1 1 0 1 1 0 1 1 0 1 1 0 0 1 023 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 1 1 1 1 1 1 125 1 1 1 1 0 1 1 1 1 0 1 1 1 1 0 1 1 1 1 0 1 1 1 1 0 1 1 1 1 027 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 029 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 0 131 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 133 1 1 0 1 1 0 1 1 0 1 0 0 1 1 0 1 1 0 1 1 0 0 1 0 1 1 0 1 1 035 1 1 1 1 0 1 0 1 1 0 1 1 1 0 0 1 1 1 1 0 0 1 1 1 0 1 1 0 1 037 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 139 1 1 0 1 1 0 1 1 0 1 1 0 0 1 0 1 1 0 1 1 0 1 1 0 1 0 0 1 1 041 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 143 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 145 1 1 0 1 0 0 1 1 0 0 1 0 1 1 0 1 1 0 1 0 0 1 1 0 0 1 0 1 1 047 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 149 1 1 1 1 1 1 0 1 1 1 1 1 1 0 1 1 1 1 1 1 0 1 1 1 1 1 1 0 1 151 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 0 0 1 1 0 1 1 0 1 1 0 1 1 053 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 155 1 1 1 1 0 1 1 1 1 0 0 1 1 1 0 1 1 1 1 0 1 0 1 1 0 1 1 1 1 057 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 1 1 0 0 1 0 1 1 0 1 1 0 1 1 059 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1Properties EditThe following facts even the reciprocity laws are straightforward deductions from the definition of the Jacobi symbol and the corresponding properties of the Legendre symbol 2 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 a b mod n then a n b n a m n n displaystyle left frac a n right left frac b n right left frac a pm m cdot n n right 3 a n 0 if gcd a n 1 1 if gcd a n 1 displaystyle left frac a n right begin cases 0 amp text if gcd a n neq 1 pm 1 amp text if gcd a n 1 end cases 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 a n 2 1 or 0 displaystyle left frac ab n right left frac a n right left frac b n right quad text so left frac a 2 n right left frac a n right 2 1 text or 0 5 a m n a m a n so a n 2 a n 2 1 or 0 displaystyle left frac a mn right left frac a m right left frac a n right quad text so left frac a n 2 right left frac a n right 2 1 text 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 displaystyle left frac m n right left frac n m right 1 tfrac m 1 2 cdot tfrac n 1 2 begin cases 1 amp text if n equiv 1 pmod 4 text or m equiv 1 pmod 4 1 amp text if n equiv m equiv 3 pmod 4 end cases and its supplements 7 1 n 1 n 1 2 1 if n 1 mod 4 1 if n 3 mod 4 displaystyle left frac 1 n right 1 tfrac n 1 2 begin cases 1 amp text if n equiv 1 pmod 4 1 amp text if n equiv 3 pmod 4 end cases and 1 n n 1 1 displaystyle left frac 1 n right left frac n 1 right 1 8 2 n 1 n 2 1 8 1 if n 1 7 mod 8 1 if n 3 5 mod 8 displaystyle left frac 2 n right 1 tfrac n 2 1 8 begin cases 1 amp text if n equiv 1 7 pmod 8 1 amp text if n equiv 3 5 pmod 8 end cases Combining properties 4 and 8 gives 9 2 a n 2 n a n a n if n 1 7 mod 8 a n if n 3 5 mod 8 displaystyle left frac 2a n right left frac 2 n right left frac a n right begin cases left frac a n right amp text if n equiv 1 7 pmod 8 left frac a n right amp text if n equiv 3 5 pmod 8 end cases 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 EditThe above formulas lead to an efficient O log a log b 3 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 Reduce the numerator modulo the denominator using rule 2 Extract any even numerator using rule 9 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 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 Implementation in Lua Edit function jacobi n k assert k gt 0 and k 2 1 n n k t 1 while n 0 do while n 2 0 do n n 2 r k 8 if r 3 or r 5 then t t end end n k k n if n 4 3 and k 4 3 then t t end n n k end if k 1 then return t else return 0 end end Implementation in C Edit a n is represented as a n int jacobi int a int n assert n gt 0 amp amp n 2 1 step 1 a a n int t 1 int r step 3 while a 0 step 2 while a 2 0 a 2 r n 8 if r 3 r 5 t t step 4 r n n a a r if a 4 3 amp amp n 4 3 t t a a n if n 1 return t else return 0 Example of calculations EditThe 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 Edit 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 displaystyle begin aligned left frac 1001 9907 right amp left frac 7 9907 right left frac 11 9907 right left frac 13 9907 right left frac 7 9907 right amp left frac 9907 7 right left frac 2 7 right 1 left frac 11 9907 right amp left frac 9907 11 right left frac 7 11 right left frac 11 7 right left frac 4 7 right 1 left frac 13 9907 right amp left frac 9907 13 right left frac 1 13 right 1 left frac 1001 9907 right amp 1 end aligned Using the Jacobi symbol Edit 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 displaystyle begin aligned left frac 1001 9907 right amp left frac 9907 1001 right left frac 898 1001 right left frac 2 1001 right left frac 449 1001 right left frac 449 1001 right amp left frac 1001 449 right left frac 103 449 right left frac 449 103 right left frac 37 103 right left frac 103 37 right amp left frac 29 37 right left frac 37 29 right left frac 8 29 right left frac 2 29 right 3 1 end aligned 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 4 In fact this is why Jacobi introduced the symbol Primality testing EditThere is another way the Jacobi and Legendre symbols differ If the Euler s 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 displaystyle begin aligned left frac 19 45 right amp 1 amp amp text and amp 19 frac 45 1 2 amp equiv 1 pmod 45 left frac 8 21 right amp 1 amp amp text but amp 8 frac 21 1 2 amp equiv 1 pmod 21 left frac 5 21 right amp 1 amp amp text but amp 5 frac 21 1 2 amp equiv 16 pmod 21 end aligned 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 As an indirect use it is possible to use it as an error detection routine during the execution of the Lucas Lehmer primality test which even on modern computer hardware can take weeks to complete when processing Mersenne numbers over 2 82 589 933 1 displaystyle begin aligned 2 82 589 933 1 end aligned the largest known Mersenne prime as of December 2018 In nominal cases the Jacobi symbol s i 2 M p 1 i 0 displaystyle begin aligned left frac s i 2 M p right amp 1 amp i neq 0 end aligned This also holds for the final residue s p 2 displaystyle begin aligned s p 2 end aligned and hence can be used as a verification of probable validity However if an error occurs in the hardware there is a 50 chance that the result will become 0 or 1 instead and won t change with subsequent terms of s displaystyle begin aligned s end aligned unless another error occurs and changes it back to 1 See also EditKronecker symbol a generalization of the Jacobi symbol to all integers Power residue symbol a generalization of the Jacobi symbol to higher powers residues Notes Edit Jacobi C G J 1837 Uber die Kreisteilung und ihre Anwendung auf die Zahlentheorie Bericht Ak Wiss Berlin 127 136 Ireland amp Rosen pp 56 57 or Lemmermeyer p 10 Cohen pp 29 31 The number field sieve the fastest known algorithm requires O e ln N 1 3 ln ln N 2 3 C o 1 displaystyle O left e ln N frac 1 3 ln ln N frac 2 3 big C o 1 big right operations to factor n See Cohen p 495References EditCohen Henri 1993 A Course in Computational Algebraic Number Theory Berlin Springer ISBN 3 540 55640 0 Ireland Kenneth Rosen Michael 1990 A Classical Introduction to Modern Number Theory Second edition New York Springer ISBN 0 387 97329 X Lemmermeyer Franz 2000 Reciprocity Laws from Euler to Eisenstein Berlin Springer ISBN 3 540 66957 4 Shallit Jeffrey December 1990 On the Worst Case of Three Algorithms for Computing the Jacobi Symbol Journal of Symbolic Computation 10 6 593 61 doi 10 1016 S0747 7171 08 80160 5 Computer science technical report PCS TR89 140 Vallee Brigitte Lemee Charly October 1998 Average case analyses of three algorithms for computing the Jacobi symbol Technical report CiteSeerX 10 1 1 32 3425 Eikenberry Shawna Meyer Sorenson Jonathan P October 1998 Efficient Algorithms for Computing the Jacobi Symbol PDF Journal of Symbolic Computation 26 4 509 523 CiteSeerX 10 1 1 44 2423 doi 10 1006 jsco 1998 0226 External links EditCalculate Jacobi symbol shows the steps of the calculation Retrieved from https en wikipedia org w index php title Jacobi symbol amp oldid 1139817367, wikipedia, wiki, book, books, library,

article

, read, download, free, free download, mp3, video, mp4, 3gp, jpg, jpeg, gif, png, picture, music, song, movie, book, game, games.