We didn't cover this in our MATH-470 course, but I was reading the source code for the GNU MP library and saw that mpz_probab_prime_p() uses Baillie-PSW[1] on top of Miller-Rabin when checking if n is a probable prime; so, I decided to learn more about it.
We've previously looked at the Miller-Rabin primality test which is a Fermat test, however, there exists strong pseudoprimes that pass Fermat tests against many bases; e.g. there exists a Carmichael number that is a strong pseudoprime to all prime bases less than 307[2]. The BPSW algorithm uses a Lucas probable prime test on top of a Fermat prime test. There are few overlapping pseudoprimes between the Lucas and Fermat tests, making BPSW less likely to fail.
If n is an odd prime, then the Jacobi is equivalent to the Legendre.
If a≡nb, then (na)=(nb)=(na±m⋅n).
(nab)=(na)(nb).
(na2)=(na)2.
(mna)=(ma)(nb).
(n2a)=(na)2.
(nm)(mn)=(−1)2m−1⋅2n−1.
(1n)=(n1)=1.
(n−1)=(−1)2n−1.
(n2)=(−1)8n2−1.
Properties common between the Jacobi and Legendre:
If (na)=−1 then a is a quadratic non-residue modulo n.
If a is a quadratic residue modulo n, and (a,n)=1, then (na)=1.
As we will find out later, factorization is problem that lies in NP∩coNP as such we conjecture that there is no efficient (classical polynomial-time) algorithm to compute a non-trivial number's factorization. As such, relying on the formal definition of the Jacobi is impractical to do when testing very large integers for primality. Utilizing the properties of the Jacobi, we can compute the Jacobi in O(logalogn) time, as opposed to at best sub-exponential time using factorization.
Arnault, François. “Constructing Carmichael Numbers Which Are Strong Pseudoprimes to Several Bases.” Journal of Symbolic Computation, vol. 20, no. 2, 1995, pp. 151–161., https://doi.org/10.1006/jsco.1995.1042. ↩︎