主題
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 素性檢驗, 素性檢驗, 偽素數, 強偽素數

使用 探索

參考文獻

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.

在 上引用

Rabin-Miller 強偽素數檢驗

請引用本文

Weisstein, Eric W. "Rabin-Miller 強偽素數檢驗。" 來自 Web 資源。 https://mathworld.tw/Rabin-MillerStrongPseudoprimeTest.html

學科分類