主题
Search

Rabin-Miller 强伪素数检验


一种素性检验,它提供了一种有效的概率算法,用于确定给定数字是否为素数。它基于强伪素数的性质。

该算法的步骤如下。给定一个奇数整数 n,令 n=2^rs+1,其中 s奇数。然后选择一个随机整数 a,其中 1<=a<=n-1。如果 a^s=1 (mod n) 或对于某个 0<=j<=r-1a^(2^js)=-1 (mod n),则 n 通过测试。一个素数将对所有 a 通过测试。

该测试非常快速,并且需要不超过 (1+o(1))lgn 次乘法运算(模 n),其中 lg 是以 2 为底的对数。不幸的是,一个通过测试的数字不一定是素数。Monier (1980) 和 Rabin (1980) 已经证明,对于最多 1/4 的可能基数 a合数会通过测试。如果对一个合数执行 N 次独立的测试,那么它通过每次测试的概率为 1/4^N 或更小。

然而,如果预先知道通过特定测试集的最小合数,那么该测试集就构成了对所有较小数的素性证明。使用前 k 个素数进行多次 Rabin-Miller 测试时,通过测试的最小奇数序列(对于 k=1, 2, ...)由 2047, 1373653, 25326001, 3215031751, 2152302898747, 3474749660383, 341550071728321, 341550071728321, ... 给出 (OEIS A014233; Jaeschke 1993)。因此,使用前 7 个素数(使用 8 个素数没有改进)的多次 Rabin 测试对于高达 3.4×10^(14) 的每个数字都是有效的。

Wolfram 语言在基数 2 和 3 中结合 Lucas 伪素数测试实现了多次 Rabin-Miller 测试,作为函数使用的素性检验PrimeQ[n]。截至 1997 年,已知此过程仅对所有 n<10^(16) 是正确的,但没有已知的反例,如果存在任何反例,预计它们出现的概率极小(即,远小于计算机执行测试时发生硬件错误的概率)。


另请参阅

Baillie-PSW 素性检验, Lucas-Lehmer 检验, Miller 素性检验, 素性检验, 伪素数, 强伪素数

使用 Wolfram|Alpha 探索

参考文献

Arnault, F. "Rabin-Miller Primality Test: Composite Numbers Which Pass It." Math. Comput. 64, 355-361, 1995.Crandall, R. and Pomerance, C. 素数. New York: Springer-Verlag, 2001.Damgård, I.; Landrock, P.; and Pomerance, C. "Average Case Error Estimates for the Strong Probably Prime Test." Math. Comput. 61, 177-194, 1993.Jaeschke, G. "On Strong Pseudoprimes to Several Bases." Math. Comput. 61, 915-926, 1993.Miller, G. "Riemann's Hypothesis and Tests for Primality." J. Comp. Syst. Sci. 13, 300-317, 1976.Monier, L. "Evaluation and Comparison of Two Efficient Probabilistic Primality Testing Algorithms." Theor. Comput. Sci. 12, 97-108, 1980.Pomerance, C.; Selfridge, J. L.; and Wagstaff, S. S. Jr. "The Pseudoprimes to 25·10^9." Math. Comput. 35, 1003-1026, 1980. http://mpqs.free.fr/ThePseudoprimesTo25e9.pdf.Rabin, M. O. "Probabilistic Algorithm for Testing Primality." J. Number Th. 12, 128-138, 1980.Sloane, N. J. A. Sequence A014233 in "The On-Line Encyclopedia of Integer Sequences."Wagon, S. "Primality Testing." Math. Intell. 8, No. 3, 58-61, 1986.Wagon, S. Mathematica in Action. New York: W. H. Freeman, pp. 15-17, 1991.

在 Wolfram|Alpha 上引用

Rabin-Miller 强伪素数检验

请引用本文

Weisstein, Eric W. "Rabin-Miller 强伪素数检验。" 来自 MathWorld--Wolfram Web 资源。 https://mathworld.net.cn/Rabin-MillerStrongPseudoprimeTest.html

学科分类