Section 12.4 Strong Pseudoprimes
Since composite numbers can pass Miller's test too, nomenclature can get frustrating if we don't organize. So we come up with another name.Definition 12.4.1.
We call a composite number
Theorem 12.4.2.
If
Proof.
As per our convention, let \(n\) be composite and odd, but it passes the base two test:
Since \(n\) is odd, we can cancel \(2\) in the congruence, and get
Rewrite this as \(2^{n-1}-1=nk\) for some integer \(k\text{.}\)
Since \(2^{n-1}-1\) is odd, then so is \(k\) necessarily. Now comes some final manipulation to prepare to apply Miller's test to \(2^n-1\text{:}\)
Now use the preceding equation as the exponent in Miller's test and a clever reduction:
Since \([(2^n-1)-1]/2=2^{n-1}-1\) is odd, the number passes Miller's test.
All that remains is to show \(2^n-1\) is composite if \(n\) is composite; this is a fairly straightforward extension of Lemma 12.1.2 (see Exercise 12.7.7).
Corollary 12.4.3.
If
Proof.
All we need is that \((\pm 1)^2=1\text{.}\)
Corollary 12.4.4.
There are infinitely many strong pseudoprimes (and hence pseudoprimes) base 2.
Proof.
Take your favorite pseudoprime, and keep subtracting one from two to the power of the previous (strong) pseudoprime.
Example 12.4.5.
For instance, we now know that
xxxxxxxxxx
n=2^341-1
print(mod(2,n)^((n-1)/2))
print((n-1)/2)
Theorem 12.4.6.
If
Algorithm 12.4.7. Miller-Rabin (probabilistic) primality test.
Run Miller's test for
xxxxxxxxxx
(1./4)^100
xxxxxxxxxx
p=next_probable_prime(randrange(2^1024))
q=next_probable_prime(randrange(2^1024))
n=p*q
pretty_print(html(p))
pretty_print(html(q))
pretty_print(html(n))
xxxxxxxxxx
p=next_probable_prime(randrange(2^1024))
%time is_prime(p)
Sage note 12.4.8. Reminder about timing.
Don't forget, you could use %time is_prime(p)
to time this operation in a worksheet or Sage command line.