Next Article in Journal
A Face Image Virtualization Mechanism for Privacy Intrusion Prevention in Healthcare Video Surveillance Systems
Previous Article in Journal
Possible Physical Basis of Mirror Symmetry Effect in Racemic Mixtures of Enantiomers: From Wallach’s Rule, Nonlinear Effects, B–Z DNA Transition, and Similar Phenomena to Mirror Symmetry Effects of Chiral Objects
Previous Article in Special Issue
On a Generalization of a Lucas’ Result and an Application to the 4-Pascal’s Triangle
 
 
Font Type:
Arial Georgia Verdana
Font Size:
Aa Aa Aa
Line Spacing:
Column Width:
Background:
Article

On the Number of Witnesses in the Miller–Rabin Primality Test

by
Shamil Talgatovich Ishmukhametov
*,
Bulat Gazinurovich Mubarakov
and
Ramilya Gakilevna Rubtsova
Institute of Computational Mathematics and Information Technology, Kazan Federal University, Kremlevskya St. 35, Kazan 420008, Russia
*
Author to whom correspondence should be addressed.
Symmetry 2020, 12(6), 890; https://doi.org/10.3390/sym12060890
Submission received: 24 February 2020 / Revised: 25 March 2020 / Accepted: 28 March 2020 / Published: 1 June 2020
(This article belongs to the Special Issue Number Theory and Symmetry)

Abstract

:
In this paper, we investigate the popular Miller–Rabin primality test and study its effectiveness. The ability of the test to determine prime integers is based on the difference of the number of primality witnesses for composite and prime integers. Let W ( n ) denote the set of all primality witnesses for odd n. By Rabin’s theorem, if n is prime, then each positive integer a < n is a primality witness for n. For composite n, the power of W ( n ) is less than or equal to φ ( n ) / 4 where φ ( n ) is Euler’s Totient function. We derive new exact formulas for the power of W ( n ) depending on the number of factors of tested integers. In addition, we study the average probability of errors in the Miller–Rabin test and show that it decreases when the length of tested integers increases. This allows us to reduce estimations for the probability of the Miller–Rabin test errors and increase its efficiency.

1. Introduction

The MillerRabin primality test is an algorithm that checks whether a given number is prime or composite. Its original version, due to Gary L. Miller, was deterministic and relied on the unproved extended Riemann Hypothesis [1]. Michael O. Rabin modified it to obtain a probabilistic algorithm [2].
Definition 1.
Let m be a positive integer represented as m = 2 s · u where u is odd. We introduce two auxiliary functions b i n ( m ) = s and o d d ( m ) = u .
Definition 2.
Let n be an odd natural, n > 9 . An integer a , 1 a < n , is called a primality witness for n if it is co-prime to n and one of the following conditions holds:
1 . a o d d ( n 1 ) 1 mod n , 2 . a o d d ( n 1 ) 2 i 1 mod n   f o r   s o m e   i , 0 i < b i n ( n 1 ) ,
(We replaced original Rabin’s definition of the compositeness witnesses by the opposite relation). For generality, we count 1 and n 1 as primality witnesses and call them trivial witnesses since they satisfy (1) for any n.
Let W ( n ) denote the set of all primality witnesses for n. The Rabin theorem [2] asserts that if number n is prime then each non-zero integer, a < n is a primality witness for n, and therefore, the number of all witnesses | W ( n ) | = n 1 . For composite n, it satisfies inequality | W ( n ) | φ ( n ) / 4 where φ ( n ) is Euler’s totient function. Since Rabin did not consider 1 as a witness, then he stated the strict inequality | W ( n ) | < φ ( n ) / 4 .
Later, Gary Miller [1] developed a primality test that takes any integer a , 1 < a < n , checks if a is not a factor of n (otherwise, n is trivially composite), and whether a is a primality witness for n, that is, lies in the set W ( n ) . If the answer is positive, then n is probable prime with probability exceeding 3 / 4 . If we need in a more exact result, we should repeat this procedure several times taking different numbers a < n .
The researchers refer to this algorithm as to the Miller and Rabin primality test. We abbreviate it to MR test.
Definition 3.
Parameters a which are used in Miller’s algorithm are called bases. They are chosen randomly from interval [ 1 ; n 1 ] . If, for a given odd integer, n relation (1) holds at a base a, we say, n passes the MR test at base a. Otherwise, we call a a compositeness witness for n and deduce that n is certainly composite.
The probability of error after k successful iterations becomes less than 1 / 4 k . The only type of error in the Rabin’ procedure is defining a composite integer as prime.
More details on the Miller–Rabin test can be found in Chapter 3 of text-book [3] by Crandall and Pomerance. We abbreviate Miller–Rabin test as MR test.
Definition 4.
Composite integers qualifying by MR test as probable prime at a base a are called strong pseudoprimes relative to base a. Composite integers being probably prime relative to all a from a set A of bases are called strong probable prime relative to set of bases A.
Investigation of pseudoprime integers has a long history in the Computational Number Theory. We outline main advantages in this direction in the next section.

2. Some History Remarks

Fist attempts to find fast primality algorithms were based on Fermat’s Little Theorem asserting that for prime n and for any positive integer a, the following relation holds
a n a mod n
Indeed, many composite integers do not satisfy (2) and can be discarded after the first check. Composite n that satisfy (2) are called Fermat pseudoprimes relative to base a.
It is important to note that all strong pseudoprimes relative to a base a are also Fermat pseudoprimes relative to a.
We can decrease the number of false decisions by Fermat’s test by checking the relation (2) with several different a. However, this does not allow us to completely avoid false conclusions since so-called Carmichael numbers exist.
Integer n is called a Carmichael number if it satisfies (2) for all a. Carmichael numbers appear relatively rarely and the least Carmichael number is 561 = 3 · 7 · 11 . It is known that Carmichael numbers are exactly those integers which satisfy Korselt’s criterion:
Korselt Criterion (1899). A positive compositeinteger n is a Carmichael number if and only if n is square-free, and for all prime divisors p of n, it is true that p 1 | n 1 .
One of the interesting problems is to find for a given odd integer n the least witness. In 1994 Alford, Granville and Pomerance proved [4] that such witnesses exceed ( log n ) 1 / ( 3 log log log n ) for infinitely many n. We also show that there are finite sets of odd composites which do not have a reliable witness, namely a common witness for all of the numbers in the set.
MR test discards a Carmichael number n, if the base was chosen from [ 1 ; n 1 ] \ W ( n ) .
Let us fix a base a and let n a be a least composite integer that the MR Test accepts at the base a. Then, any odd n < n a for which a is a primality witness, is definitely prime. This means that when we know n a , we can definitely check any n < n a for primality using only one round of the MR procedure. The corresponding integer n a is small. But if we take a set A of several different bases a and find a least composite n A for which all a A are primality witness, this n A can be very large. Candidates for bases a can be any positive integers that are not squares. However, historically, candidates for special bases are chosen from the set of primes.
Let P k denote the set of the first k primes P k = { 2 , 3 , 5 , 7 , , p k } , and let ψ k be a least strong pseudoprime relative to P k for a k 1 . Function ψ k is well defined and is exponentially computable. Its computation began already 40 years ago.
First four values of ψ k have been found by C. Pomerance, J. Selfridge, and S.Waggstaff [5] in 1980.
A systematic calculation of ψ k for larger k has been initiated by J. Jaeschke [6] who elaborated basic algorithms helpful for searching for strong pseudoprimes of different forms. In 1993 Jaeschke calculated ψ k for 5 k 8 and proposed upper bounds for ψ k at 9 k 11 .
F. Arnault in papers [7,8] described another algorithm to search for Carmichael numbers and strong pseudoprimes integers.
Jaeschke’ hypothesis have been improved in 2001 by Z. Zang [9] who constructed a lesser 19-digits decimal integer Q 11 = 3825123056546413051 bounding above ψ 11 . Z.Zang conjectures that values ψ k for 9 k 11 are equal to each other and coincide with Q 11 .
In 2012 J. Jiang and Y. Deng [10] confirmed Zang’s Hypothesis by showing that Q 11 = ψ 9 = ψ 10 = ψ 11 .
The last record is reached by J. Sorenson and J. Webster [11] in 2016. They found ψ 12 and ψ 13 , where ψ 13 = 3317044064679887385961981 3 . 3 · 10 24 . So at the moment we can successfully determine prime integers less than 3 . 3 · 10 24 by only 13 rounds of the MR test. But this bound is much less than integers used in Cryptography. For example, DSS algorithm uses prime integers of length 256 bits (≈80 decimal digits).
Another branch of investigations in connected with the problem of distribution of Fermat pseudoprimes and strong pseudoprimes. Let F ( n ) denote set
F ( n ) = { a mod n : a n 1 1 mod n } .
Clearly, F ( n ) W ( n ) .
In 1985 P. Erdos and C. Pomerance [12] studied an asymptotic behavior of average function
A ( x ) = 1 x n x | F ( n ) |
where sum is counted over odd integers. They showed using complex number-theoretical calculations that A ( x ) is a growing function bounded below by x 15 / 23 .
Our average function A v g ( x ) looks close to A ( x ) but we show that for almost all composite n W ( n ) consists of only two elements 1 and n 1 and function A v g ( x ) tends to zero with x tending to infinity.
Average number of errors in the MR test was also studied in 1993 by I. Damgard, P. Landrock and C Pomerance. In paper [13] they studied an average probability of the false decision by the MR test in the following procedure:
Fix k > 0 and t > 0 and choose randomly k-bit odd integer n. Check it with t rounds of MR test with randomly chosen bases from [ 1 ; n 1 ] . If n was discarded during the procedure (that is, found a W ( n ) ), take another n. Continue until n was found passed t rounds. Let p k , t be the probability that the procedure returns a composite integer.
The authors found explicit upper bounds for various k and t. In particular they proved that p k , 1 k 2 4 2 k for k 2 . Their results show that the probability of false decisions of the MR test depends on the length of tested numbers and it decreases if the length of the numbers increases.

3. Counting Number of Witnesses

In this section we deduce exact formulas for the number of primality witnesses for different types of composite integers.
We begin our investigation with a little proposition improving Rabin’s estimate.
Theorem 1.
If a W ( n ) , then n a W ( n ) .
Proof. 
Let k = o r d n ( a ) . If k is odd, then a o d d ( n 1 ) mod n = 1 , and ( n a ) o d d ( n 1 ) 1 mod n , therefore, n a is also a witness.
If k is even, then a k / 2 1 mod n . If k / 2 is even, then ( n a ) k / 2 a k / 2 1 mod n , and ( n a ) is a witness.
Finally, if k / 2 is odd, then ( n a ) k / 2 a k / 2 1 mod n . Since k / 2 | o d d ( n 1 ) , then a o d d ( n 1 ) 1 mod n , and ( n a ) again is a witness.
This completes the proof. □
Corollary 1.
(The Improved Rabin Theorem). Let n be a natural, and A be an arbitrary set of bases less than n, co-prime to n, such that for any a A , n a is not in A. If all bases a A are primality witnesses of n, then n is probable prime with probability of error less than or equal to 1 / 16 k .
Indeed, when we found a primality witness a for integer n, we get two primality witnesses for n, namely, a and n a . So, this reduces the probability of error by a factor of 4 2 = 16 .
Let N w ( n ) = | W ( n ) | be the power of number of primality witnesses W ( n ) . As mentioned earlier, for prime n N w ( n ) = n 1 , and for composite n N w φ ( n ) / 4 .
Below we estimate function N w ( n ) more exactly. First we formulate a theorem restricting possible witnesses for a composite n.
Theorem 2.
Let n = u · v for co-prime factors u and v (possibly, composite), and a W ( n ) . Then,
1 . o r d u ( a ) | G C D ( φ ( u ) , ( u φ ( u ) ) v 1 ) , 2 . o r d v ( a ) | G C D ( φ ( v ) , ( v φ ( v ) ) u 1 ) , 3 . b i n ( o r d u ( a ) ) = b i n ( o r d v ( b ) ) .
Proof. 
  • Since a is a primality witness for n then a n 1 1 mod n and a n 1 1 mod u . Besides, n 1 = u v 1 = φ ( u ) v + ( u φ ( u ) ) v 1 , so
    1 a n 1 a φ ( u ) v + ( u φ ( u ) ) v 1 a ( u φ ( u ) ) v 1 mod u ,
    since a φ ( u ) 1 mod u by Euler’s Theorem.
  • By symmetry.
  • If o r d u ( a ) is odd, then a o d d ( n 1 ) 1 mod n (otherwise, a satisfies the second clause of the MRT, and o r d u ( a ) should be even). Then a o d d ( n 1 ) 1 mod v and o r d v ( a ) is odd.
If b i n ( o r d u ( a ) ) = i for 0 < i < b i n ( n 1 ) , then a is a witness by second clause of the MRT, so a o d d ( n 1 ) 2 i 1 1 mod n , a o d d ( n 1 ) 2 i 1 1 mod v , and a o d d ( n 1 ) 2 i 1 mod v , so o r d v ( a ) = o d d ( n 1 ) 2 i and b i n ( o r d v ( a ) ) is equal to i.
The theorem is proved. □
Example 1.
Let n = 15 · 19 = 285 , and a W ( n ) . By Theorem 2:
1 . o r d u ( a ) | G C D ( φ ( u ) , ( u φ ( u ) ) v 1 ) = G C D ( 8 , 132 ) = 4 , 2 . o r d v ( a ) | G C D ( φ ( v ) , ( v φ ( v ) ) u 1 ) = G C D ( 18 , 14 ) = 2 , 3 . b i n ( o r d u ( a ) ) = b i n ( o r d v ( b ) ) .
So, possible a satisfies ( o r d u ( a ) , o r d v ( a ) ) = ( 1 , 1 ) , or, ( o r d u ( a ) , o r d v ( a ) ) = ( 2 , 2 ) , so n = 285 has only trivial witnesses 1 and n 1 .
Theorem 3.
Let n = p k be a degree of prime p, then N w ( n ) = p 1 .
Proof. 
Let a be a witness for n = p k , then o r d a ( n ) | G C D ( φ ( n ) , n 1 ) = G C D ( p k 1 ( p 1 ) , p k 1 ) = p 1 .
Besides, any a satisfying a p 1 mod n = 1 is a witness of n. Indeed, let a p 1 mod n = 1 . Then, m = o r d n ( a ) is a factor of n 1 = p k 1 . Let n 1 = 2 s · t for odd t, therefore, m = 2 s 1 · t 1 , where s 1 s and t 1 is a factor of t.
If s 1 = 0 , then a t 1 mod n = 1 , a t mod n = 1 and a is a witness by the first clause of the MRT. Otherwise, let 0 r s 1 be such that a t 1 2 r 1 mod n . Then a t 2 r 1 mod n and a is a witness by the second clause of the MRT. This completes the proof. □
We call integer n semiprime if it is a product of two distinct primes n = p q , p < q . Semiprimes are close to primes, and we prove below that they have a maximal number of primality witnesses among composite numbers.
Theorem 4.
Number of witnesses of semiprime n = p q is equal to
N w ( p q ) = ( o d d ( d ) ) 2 · ( 4 b i n ( d ) + 2 ) / 3 ,
where d = G C D ( p 1 , q 1 ) .
We begin with example of application of this formula.
Example 2.
Let n = 11 · 31 = 341 . Then d = G C D ( p 1 , q 1 ) = 10 = 5 · 2 1 , o d d ( d ) = 5 , s = b i n ( d ) = 1 . By the theorem,
N w ( 31 ) = 5 2 · ( 4 + 2 ) / 3 = 50 .
Proof. 
Let d = G C D ( p 1 , q 1 ) . Applying Theorem 2 to n = p q we obtain
1 . o r d p ( a ) | d , o r d q ( a ) | d , 2 . b i n ( o r d u ( a ) ) = b i n ( o r d v ( b ) ) .
We distribute all n-witnesses a into s + 1 classes W i , 0 i s , where class W i consists of a with b i n ( o r d p ( a ) ) = b i n ( o r d q ( a ) ) = i .
Class W 0 contains such a that both o r d p ( a ) and o r d q ( a ) are odd. Let a W 0 , and ( i , j ) = ( o r d p ( a ) , o r d q ( a ) ) . Numbers i and j are factors of u = o d d ( d ) by the choice of a. Conversely, each integer a < n satisfying o r d p ( a ) | u , o r d q ( a ) | u , is a witness of n and lies in W 0 .
Let fix a pair ( i , j ) , i | d , j | d . By Euler’s theorem, in Z p there are exactly φ ( i ) elements of multiplicative order i, and in Z q there are φ ( j ) elements of multiplicative order j, so, there exist exactly φ ( i ) · φ ( j ) pairs ( x , y ) , 0 < x < p , 0 < y < q , such that ( o r d p ( x ) , o r d q ( y ) ) = ( i , j ) . But for each such pair ( x , y ) there exists a unique a < n with ( a mod p , a mod q ) = ( x , y ) , so there is a injective correspondence between witnesses a of n with odd orders o r d p ( a ) , o r d q ( a ) , and pairs ( x , y ) with x | u , y | u . Therefore, the power of W 0 is equal to
| W 0 | = x | u , y | u φ ( x ) · φ ( y ) = x | u φ ( x ) y | u φ ( y ) = u 2 ,
since by a known theorem of Euler for any natural m v | m φ ( v ) = m .
The next class W 1 has the same power u 2 since is consists of witnesses a with b i n ( o r d p ( a ) ) = b i n ( o r d q ( a ) ) = 1 , and
| W 1 | = x | d , y | d φ ( 2 x ) · φ ( 2 y ) = u 2 ,
since φ ( 2 z ) = φ ( z ) for odd z.
The power of class W i is equal to
x | d , y | d φ ( 2 i x ) · φ ( 2 i y ) = 4 i 1 u 2 .
Therefore, the number of all witnesses N w ( n ) = u 2 ( 1 + 1 + 4 + + 4 s 1 ) = u 2 · ( 4 s + 2 ) / 3 . This completes the proof. □
Corollary 2.
(Rabin’s theorem for semiprimes). The number of witnesses of n = p q , p q , is less or equal to φ ( n ) / 4 .
Proof. 
If p = q , then N w ( n ) = p 1 by Theorem 3, and φ ( n ) / 4 = p ( p 1 ) / 4 , so N w ( n ) < φ ( n ) / 4 at p 5 .
Let p < q . Ratio N w ( n ) / n reaches its maximum when G C D ( p 1 ; q 1 ) = p 1 , q = 2 p 1 , and b i n ( p 1 ) = 1 . Indeed, o d d ( n ) is diminishing in two times when b i n ( p 1 ) is added by 1, and the whole expression in (4) becomes less. Then, m a x o d d ( d ) = ( p 1 ) / 2 , so
m a x N w ( p q ) = N w ( p ( 2 p 1 ) ) = ( p 1 ) 2 2 = φ ( n ) 4 .
Example 3.
Let n = 7 · 13 = 91 . N w ( 91 ) = 3 2 · 2 = 18 = φ ( 91 ) / 4 .
Now we study function N w ( n ) at products of k distinct primes. The general result for such products is formulated below:
Theorem 5.
Let n = p 1 · p 2 · p k be the product of k distinct primes. Then
N w ( n ) = u 1 · u 2 · · u k · 1 + 2 k s 1 2 k 1 , w h e r e
s = m i n { b i n ( d 1 ) , b i n ( d 2 ) , , b i n ( d k ) } , d i = G C D p i 1 ; j i p j 1 ,
u i = o d d ( d i ) .
Let us begin with an example n = 7 · 13 · 31 = 2821 . The corresponding restrictions are listed below:
1 . o r d p ( a ) | d 1 = G C D ( p 1 ; q r 1 ) = 6 , u 1 = 3 , 2 . o r d q ( a ) | d 2 = G C D ( q 1 ; p r 1 ) = 12 , u 2 = 3 , 3 . o r d r ( a ) | d 3 = G C D ( r 1 ; p q 1 ) = 30 , u 3 = 15 , 4 . b i n ( o r d p ( a ) ) = b i n ( o r d q ( b ) ) = b i n ( o r d r ( b ) ) .
Since s = m i n { b i n ( d 1 ) , b i n ( d 2 ) , b i n ( d 3 ) } = m i n { 1 , 2 , 1 } = 1 , we obtain
N w ( 2821 ) = 3 · 3 · 15 1 + 2 3 1 2 3 1 = 270
(compare with φ ( n ) / 4 = 6 · 12 · 30 / 4 = 540 ).
Proof. 
Let u i = o d d ( d i ) and k-tuple ( x 1 , x 2 , , x k ) contains components x i | u i , 1 i k . There are φ ( x 1 ) · · φ ( x k ) witnesses of n with o r d p i ( a ) = x i for 1 i k . So,
| W 0 | = ( x 1 , x 2 , , x k ) , x i | u i φ ( x 1 ) · · φ ( x k ) =
= x | u 1 φ ( x ) · x | u 2 φ ( x ) x | u k φ ( x ) = u 1 · u 2 · · u k .
As in the previous theorem, the power of class W 1 is equal to power of W 0 = u 1 · u 2 · · u k , while the power of the each further class W i + 1 is equal to the power of the previous one multiplied by φ ( 2 k ) = 2 k 1 since each additive φ ( 2 i x 1 ) · · φ ( 2 i x k ) in the previous class corresponds to additive φ ( 2 i + 1 x 1 ) · · φ ( 2 i + 1 x k ) and their ratio r i is
r i = φ ( 2 i + 1 x 1 ) · · φ ( 2 i + 1 x k ) φ ( 2 i x 1 ) · · φ ( 2 i x k ) = 2 k .
The proof is complete. □

4. Frequency Function

In this part we introduce a notion of frequency function that characterizes the probability to find at one attempt a primality witness for a given integer n.
Let define frequency function F r ( n ) as follows
F r ( n ) = N w ( n ) φ ( n ) .
According to Rabin’s theorem, F r ( n ) = 1 for prime n, and F r ( n ) 1 / 4 for composite n. We study distribution of values F r ( n ) for semiprime integers n = p q , p < q .
1. We begin our research with case q 1 = k ( p 1 ) for k 2 . Numbers of this type appear frequently among strong pseudoprimes. Let rewrite p and q in form p = 2 s u + 1 , q = 2 s k u + 1 , where u is odd, s 1 , and consider different s:
Case 1.
s = 1 , u = o d d ( d ) = ( p 1 ) / 2 , N w ( p q ) = 2 u 2 = ( p 1 ) 2 / 2 ,
F r ( n ) = ( p 1 ) 2 / 2 ( p 1 ) ( q 1 ) = 2 u 2 2 u · 2 k u = 1 2 k .
Function F r ( n ) reaches its maximum 1 / 4 at k = 2 : ( p , q ) = ( 2 u + 1 , 4 u + 1 ) . Since, both p and q are prime then u 0 mod 3 , so ( p , q ) = ( 6 t + 1 , 12 t + 1 ) , t 1 . Such pairs form a sequence
( 7 , 13 ) , ( 19 , 37 ) , ( 31 , 61 ) , ( 37 , 73 ) , .
Case 2.
s = 2 , u = o d d ( d ) = ( p 1 ) / 4 , N w ( p q ) = 6 u 2 , and
F r ( n ) = 6 u 2 ( p 1 ) ( q 1 ) = 6 u 2 4 u · 4 k u = 3 8 k .
Maximum of F r ( n ) is now 3 / 16 = 0.1875 at k = 2 .
Case 3.
s 1 , At arbitrary s we have
F r ( n ) = ( 1 + ( 4 s 1 ) / 3 ) u 2 ( p 1 ) ( q 1 ) = ( 1 + ( 4 s 1 ) / 3 ) u 2 2 s u · 2 s k u = 1 3 k u 2 · 2 2 s 1 + 1 3 k .
Thus, function F r ( n ) at semiprimes n = p q , q 1 = k ( p 1 ) , is located in the interval
1 3 k < F r ( n ) 1 2 k , k 2 .
2. Now, we turn to a common case n = p q :
p = 1 + k 1 u , q = 1 + k 2 u , G C D ( k 1 , k 2 ) = 1 , u = t 2 s , t o d d .
For such n
N w ( n ) = t 2 ( 4 s + 2 ) / 3 , φ ( n ) = k 1 k 2 t 2 4 s , F r ( n ) = 4 s + 2 3 k 1 k 2 · 4 s .
So,
1 3 k 1 k 2 < F r ( n ) 1 2 k 1 k 2
Conclusion. Function F r ( n ) at semiprimes n = p q depends mostly on values k 1 and k 2 in representation p = k 1 u + 1 , q = k 2 u + 1 . F r ( n ) takes maximal values close to 1 / 4 only at small k 1 and k 2 . This completely corresponds to experimental data. Among values ψ k the most expected are pseudoprimes of form u = ( u + 1 ) ( 2 u + 1 ) with minimal values k 1 = 1 and k 2 = 2 .
An important question connecting with efficiency of MRT is the average frequency of witnesses for composite numbers. As earlier, we study this problem for semiprime integers.
Let fix any prime p and a board B. We count average frequency of integers p q , q > p , p q B . For convenience, we assume that B = p ( p + ( p 1 ) k ) for a positive k Z .
For simplicity we explain all deductions at example p = 11 . Every prime q has d = G C D ( p 1 , q 1 ) equal either 2, or 10.
Let d = 10 . Corresponding q lie in the set { 21 , 31 , 41 , 51 , 61 , 71 , 81 , 91 , 101 , , 10 k + 11 } , where 10 k + 11 = B / p . Each third integer in the sequence is a multiple of 3, some others are multiples of 7, 11 etc. Since q should be prime we need to remove them from the sequence. The rest consists of integers
Q B = { 31 , 41 , 61 , 71 , 101 , 113 } .
We assume that primes q Q B are distributed uniformly in the interval [ 1 , B / p ] . Then the average frequency can be estimated as
A v g ( F r ( n ) ) 1 k 1 4 + 1 6 + + 1 2 k = 1 2 k 1 + 1 2 + 1 3 + + 1 k
(we remind that F r ( p ( i ( p 1 ) + p ) = 1 / 2 ( i + 1 ) ).
The expression in the last brackets is a partial sum of the Harmonic Series. Its value is
i = 1 k 1 i < i = 1 k + 1 1 i = ln k + γ + ε n ,
where γ = 0 . 5772 . . . is the Euler—Mascheroni constant and lim k ε n = 0 . Constant γ and additive ε n can be ignored so
A v g ( F r ( n ) ) < ln k 2 k
Since ( p 1 ) k + 1 = B / p , then k > B / p 2 1 and ln k < ln B , so
A v g ( F r ( n ) ) < ln B 2 ( B p 2 ) · p 2
Let us move now to primes q of type d = G C D ( p 1 , q 1 ) = 2 . They lie in the sequence
q { 13 , 15 , 17 , 19 , 23 , , 25 , 27 , 29 , , 2 m + 1 }
where 2 m + 1 = B / p , q = 2 i + 1 , G C D ( i , 5 ) = 1 . When we remove composite integers, the rest contains at least half members.
Integers n = p q with G C D ( p 1 , q 1 ) = 2 have only trivial witnesses 1 and n 1 so their frequency function takes values
F r ( n ) = 2 ( p 1 ) ( q 1 ) .
Assuming that such n are distributed uniformly in the interval [ p 2 ; B ] we estimate the average frequency by expression
A v g ( F r ) 2 p k m 1 ( p 1 ) ( 2 k + 1 ) / 2 m + 1 p 2 <
4 ( 2 m + 1 p ) ( p 1 ) · 1 2 · i = ( p + 1 ) / 2 m 1 i < 2 ( 2 m + 1 p ) ( p 1 ) · ln m
Substituting in the last expression 2 m + 1 = B / p we get
A v g ( F r ) < 2 p ln B ( B p 2 ) ( p 1 )
Expressions (7) and (8) give upper bounds for two types of integers n = p q . In the second case the estimation is lesser so average estimation for the united class of all n = p q B , p < q , can be set by the upper bound of (7). This assertion does not depend on a special p = 11 so we can state the following theorem.
Theorem 6.
Let p be a prime and B satisfy B > p 2 . Then the average frequency of witnesses in the class of semiprimes n = p q B , q > p , has an upper bound
A v g ( F r ( n ) ) < p 2 ln B 2 ( B p 2 )
Note than limit of the average function is 0 as B . This explains the phenomenon that the number of false conclusions in the Miller–Rabin test decreases when length of tested integers increases.

5. Numbers with Maximal Frequency of Witnesses

In this section we study composite n with maximal frequency F r ( n ) = 1 / 4 . Let n = p 1 p 2 p k be the product of k different primes.
We begin with case k = 2 . As we see from the previous section, integers n = p q have maximal frequency only in case when q = 2 p 1 . Such pairs appear comparatively often, and their quantity is diminishing together with their size.
Table 1 contains number of semiprimes with maximal frequency in intervals [ ( i 1 ) · 10 5 ; i · 10 5 ; ] , 1 i < 10 .
Case k = 3 is more interesting. In order function F r ( p q r ) reached its maximum = 0 . 25 , we need satisfaction of four requirements:
1 . G C D ( p 1 ; q r 1 ) = p 1 , 2 . G C D ( q 1 ; p r 1 ) = q 1 , 3 . G C D ( r 1 ; p q 1 ) = r 1 . 4 . b i n ( p 1 ) = b i n ( q 1 ) = b i n ( r 1 ) = 1 .
Such triples exist, and an example of it was already given in Rabin’s paper [2] n = 487 · 1531 · 2683 = 2000436751 . Rabin himself estimated F r ( n ) as 0 . 2493 , but the difference is due to the fact that he did not include 1 in the list of witnesses.
Such triples appear much more seldom and have a form
n = ( 2 k 1 + 1 ) u · ( 2 k 2 + 1 ) u · ( 2 k 3 + 1 ) u f o r u N .
We arranged the search of such triples at a computer and found 160 such integers not exceeding 2 · 10 14 . The least triple we found is
n = 19 · 199 · 271 = 1024651 .
The largest found triple has a form n = ( u + 1 ) ( 3 u + 1 ) ( 5 u + 1 ) at u = 24102 :
n = 24103 · 72307 · 120511 = 21002 84533 02331 .
Let us study the form u , 3 u , 5 u and find restrictions on u in order to n = ( u + 1 ) ( 3 u + 1 ) ( 5 u + 1 ) satisfies first 3 conditions of (9). The first requirement is satisfied automatically. The second and third requirement are listed below:
( 3 u + 1 ) 1 | ( u + 1 ) ( 5 u + 1 ) 1 u 0 mod 3 .
( 5 u + 1 ) 1 | ( u + 1 ) ( 3 u + 1 ) 1 3 u + 4 0 mod 5 ,
so u = 6 + 15 t for t 1 . If we add requirements p q r 3 mod 4 we obtain
15 t + 7 3 mod 4 t 1 mod 4 , u = 6 + 15 ( 1 + 4 t 1 ) = 21 + 60 t 1 .
Let now consider products of k primes where k 4 . The maximum of frequency of such products is 1 / 2 k 1 , since it is reached when for any i k ( p i 1 ) / 2 is odd, and ( p i 1 ) | ( p j i 1 ) . Then,
F r ( p ) = 2 · i = 1 k p i 1 2 = φ ( n ) 2 k 1 .
A quick search of tuples n = p q r t below 10 12 gave 70 examples of them. The least 4-tuple was
n = 19 · 31 · 127 · 547 = 40917241 ,
while the largest was
n = 19 · 127 · 14071 · 29347 = 99 64281 70081 .
Some computational results on distribution of strong semiprime integers can be found in [14].

6. Conclusions

In this section we will summarize the main results of the paper.
  • We found exact formulas for the number of witnesses for composite n with different number of factors.
  • We introduced the frequency function F r ( n ) characterizing the probability to find at one attempt a primality witness for a given n and found exact bounds for distribution of this function for semiprime integers n.
  • Like as Damgard, Landrock, and Pomerance in [13], we studied an average values of F r ( n ) at intervals [ 1 ; x ] for semiprime integers n = p q , n x , with fixed p and showed that it bounded above by p 2 log x / 2 ( x p 2 ) .
    Since such integers have maximal values of F ( n ) among all composites, this opens a way in future investigations to find exact upper bounds for average values of frequency function among all k-bit odd integers for any k.
  • Finally, we described possible forms of composites with maximal values of frequency function for products of k distinct primes at k 2 and using computer calculations found their examples and their quantity at initial intervals of set of all naturals.

Author Contributions

S.T.I. gave impetus to the research and proved Theorems 1 and 2. B.G.M. proved other theorems and propositions, and R.G.R. developed software for testing results. All authors have read and agreed to the published version of the manuscript.

Funding

This research was funded by RFBR grant 18-47-16005. This investigation was supported by the grant of Scientific and Educational Mathematical Center of the Volga Federal District, agreement No. 075-02-2020-1478.

Conflicts of Interest

The authors declare no conflict of interest.

References

  1. Miller Gary, L. Riemann’s Hypothesis and Tests for Primality. J. Comput. Syst. Sci. 1976, 13, 300–317. [Google Scholar] [CrossRef] [Green Version]
  2. Rabin, M. Probabilistic algorithm for testing primality. J. Number Theory 1980, 12, 128–138. [Google Scholar] [CrossRef] [Green Version]
  3. Crandall, R.; Pomerance, C. The Prime Numbers: A Computational Perspertive, 2nd ed.; Springer: Berlin, Germany, 2005; 604p. [Google Scholar]
  4. Alford, W.R.; Granville, A.; Pomerance, C. On the difficulty of finding reliable witnesses. In Algorithmic Number Theory; First Internat. Symp., ANTS-I; Lecture Notes in Computer Science; Springer: Berlin/Heidelberg, Germany, 1994; p. 116. [Google Scholar]
  5. Pomerance, C.; Selfridge, J.L.; Wagstaff, S.S., Jr. The pseudoprimes to 25 · 109. Math. Comput. 1980, 35, 1003–1026. [Google Scholar]
  6. Jaeschke, G. On Strong Pseudoprimes to Several Bases. Math. Comput. 1993, 61, 915–926. [Google Scholar] [CrossRef]
  7. Arnault, F. Rabin-Miller primality test: composite numbers which pass it. J. Symb. Comput. 1995, 64, 355–361. [Google Scholar] [CrossRef]
  8. Arnault, F. Constructing Carmichael numbers which are strong pseudoprimes to several bases. J. Symb. Comput. 1995, 20, 151–161. [Google Scholar] [CrossRef] [Green Version]
  9. Zhang, Z. Finding strong pseudoprimes to several bases. Math. Comput. 2001, 70, 863–872. [Google Scholar] [CrossRef] [Green Version]
  10. Jiang, J.; Deng, Y. Strong pseudoprimes to the first 9 prime bases. arXiv 2012, arXiv:1207.0063v1. [Google Scholar]
  11. Sorenson, J.; Webster, J. Strong pseudoprimes to twelve prime bases. arXiv 2015, arXiv:1509.00864v1. [Google Scholar] [CrossRef] [Green Version]
  12. Erdos, P.; Pomerance, C. On the number of false witnesses for a composite number. Math. Comput. 1986, 46, 259–279. [Google Scholar] [CrossRef] [Green Version]
  13. Damgard, I.; Landrock, P.; Pomerance, C. Average case error estimates for the strong probable prime test. Math. Comput. 1993, 61, 177194. [Google Scholar] [CrossRef] [Green Version]
  14. Ishmukhametov, S.; Mubarakov, B. On practical aspects of the Miller–Rabin primality test. Lobachevskii J. Math. 2013, 34, 304–312. [Google Scholar] [CrossRef]
Table 1. Distribution of semiprimes with maximal frequency below 10 6 .
Table 1. Distribution of semiprimes with maximal frequency below 10 6 .
12345678910
670494448412424386393358370343

Share and Cite

MDPI and ACS Style

Ishmukhametov, S.T.; Mubarakov, B.G.; Rubtsova, R.G. On the Number of Witnesses in the Miller–Rabin Primality Test. Symmetry 2020, 12, 890. https://doi.org/10.3390/sym12060890

AMA Style

Ishmukhametov ST, Mubarakov BG, Rubtsova RG. On the Number of Witnesses in the Miller–Rabin Primality Test. Symmetry. 2020; 12(6):890. https://doi.org/10.3390/sym12060890

Chicago/Turabian Style

Ishmukhametov, Shamil Talgatovich, Bulat Gazinurovich Mubarakov, and Ramilya Gakilevna Rubtsova. 2020. "On the Number of Witnesses in the Miller–Rabin Primality Test" Symmetry 12, no. 6: 890. https://doi.org/10.3390/sym12060890

Note that from the first issue of 2016, this journal uses article numbers instead of page numbers. See further details here.

Article Metrics

Back to TopTop