Agrawal–Biswas primality test Created 2026-09-24 Updated 2026-11-05
The Agrawal–Biswas primality test tests a formal polynomial identity in :
For , the identity holds exactly when is a prime number. Testing a formal polynomial is stronger than evaluating it at residues.
The randomized algorithm first handles prime numbers at most thirteen, divisibility by them, and perfect powers. For remaining , choose a monic polynomial of polynomial degree , with independent uniform lower coefficients modulo . Compute the remainder of modulo using exponentiation by squaring. A nonzero remainder proves compositeness. The monic polynomial permits division even when the coefficient ring has zero divisors.
Every prime number passes. After preprocessing, a composite number is rejected with probability at least per trial, so independent trials give error at most . Keeping remainders below polynomial degree makes the computation polynomial time in the bit length of .[ref]
We give the Agrawal–Biswas primality test, which has one-sided error. Small inputs and perfect powers can first be recognized deterministically. For every remaining integer , put and choose a uniformly random monic polynomial
Using repeated squaring in the quotient ring , test the identity
This takes time polynomial in because every intermediate polynomial has degree below .
If is prime, the intermediate binomial coefficients are divisible by , so the identity always holds. Now suppose that is composite and is not a prime power. Choose a prime divisor and write with and . Over ,
because an intermediate coefficient equal to is nonzero modulo . Hence
is a nonzero polynomial of degree below over .
Reduction of random modulo is uniform among the monic degree- polynomials. The polynomial has at most distinct monic irreducible factors of degree . On the other hand, the number of monic irreducibles of degree obeys the standard lower bound
Whenever is one of these irreducibles but does not divide , the tested congruence fails. Thus one trial detects compositeness with probability at least
after the finitely many small are handled directly. Repeating times makes the probability of missing a composite less than , while a prime is never rejected. Therefore compositeness is in RP, and primality testing is in