For an odd integer , write with odd. Choose a base uniformly from . It passes the Miller–Rabin test whenA nontrivial greatest common divisor of or failure certifies compositeness. Exponentiation by squaring computes ; at most further squarings test the other possibilities.
Every prime number passes: arithmetic modulo a prime number is a field, whose only square roots of one are and . The squaring chain ends at one by the Fermat little theorem; its first one is either the initial value or follows minus one.
For an odd composite number, at most one quarter of bases in the stated range pass. Thus independently sampled bases give false probable-prime probability at most , for each fixed composite input. A passing composite is a strong pseudoprime to that base.[ref]
A strong liar for an odd composite integer is a base for which the Miller-Rabin primality test reports a pass. Write with odd. A base is a strong liar whenThe base “lies” because these conditions hold for every allowed nonzero base when is prime, but can also hold for a composite.
For , base 2 is a strong liar because and divides . For every odd composite, strong liars occupy at most a quarter of the standard base sampling space; independently sampling bases bounds all-pass error by . A fixed handpicked list needs a separate guarantee for the intended input range.[ref]
Probabilistic Algorithm for Testing Primality by Michael O. Rabin. §§1–2, strong-pseudoprime condition and quarter bound
A deterministic Miller-Rabin primality test chooses bases justified to distinguish every composite in a specified input range, instead of sampling bases for a probabilistic guarantee. For each base, write with odd , test , and square successively according to the Miller-Rabin primality test. A failing base certifies compositeness; passing a fixed list certifies primality only under the proven range theorem for that list. For machine integers such as , established finite-range base sets permit deterministic implementations. The exact bases, bound, treatment of small primes and modular-arithmetic overflow are part of the algorithm's contract.
Articles by others on the same topic
There are currently no matching articles.