Lucas–Lehmer–Riesel test
In mathematics, the Lucas–Lehmer–Riesel test is a primality test for numbers of the form N = k ⋅ 2n − 1, with k < 2n. The test was developed by Hans Riesel and it is based on the Lucas–Lehmer primality test. It is the fastest deterministic algorithm known for numbers of that form. For numbers of the form N = k ⋅ 2n + 1 (Proth numbers), either application of Proth's theorem (a Las Vegas algorithm) or one of the deterministic proofs described in Brillhart-Lehmer-Selfridge 1975[1] are used.
The algorithm
The algorithm is very similar to the Lucas–Lehmer test, but with a variable starting point depending on the value of k.
Define a sequence ui for all i > 0 by:
Then N is prime if and only if it divides un−2.
Finding the starting value
The starting value u0 is determined as follows.
- If k = 1: if n is odd, then we can take u0 = 4. If n ≡ 3 (mod 4), then we can take u0 = 3. Note that if n is prime, these are Mersenne numbers.
- If k = 3: if n ≡ 0 or 3 (mod 4), then u0 = 5778.
- If k ≡ 1 or 5 (mod 6): if 3 does not divide N, then we take . See below for how to calculate this using a Lucas(4,1) sequence.
- Otherwise, we are in the case where k is a multiple of 3, and it is more difficult to select the right value of u0.
An alternative method for finding the starting value u0 is given in Rödseth 1994.[2] The selection method is much easier than that used by Riesel for the 3 divides k case. First find a P value that satisfies the following equalities of Jacobi symbols:
- .
In practice, only a few P values need be checked before one is found (5, 8, 9, or 11 work in about 85% of trials).
To find the starting value u0 from the P value we can use a Lucas(P,1) sequence, as shown in [2] as well as page 124 of.[3] The latter explains that when 3 ∤ k, P=4 may be used, hence the earlier search is not necessary. The starting value u0 is then equal to the modular Lucas sequence Vk(P,1) mod N. This process takes very little time compared to the main test.
How the test works
The Lucas–Lehmer–Riesel test is a particular case of group-order primality testing; we demonstrate that some number is prime by showing that some group has the order that it would have were that number prime, and we do this by finding an element of that group of precisely the right order.
For Lucas-style tests on a number N, we work in the multiplicative group of a quadratic extension of the integers modulo N; if N is prime, the order of this multiplicative group is N2 − 1, it has a subgroup of order N + 1, and we try to find a generator for that subgroup.
We start off by trying to find a non-iterative expression for the . Following the model of the Lucas–Lehmer test, put , and by induction we have .
So we can consider ourselves as looking at the 2ith term of the sequence . If a satisfies a quadratic equation, this is a Lucas sequence, and has an expression of the form . Really, we're looking at the k ⋅ 2ith term of a different sequence, but since decimations (take every kth term starting with the zeroth) of a Lucas sequence are themselves Lucas sequences, we can deal with the factor k by picking a different starting point.
LLR software
LLR is a program that can run the LLR tests. The program was developed by Jean Penné. Vincent Penné has modified the program so that it can obtain tests via the Internet. The software is both used by individual prime searchers and some distributed computing projects including Riesel Sieve and PrimeGrid.
See also
References
- Brillhart, John; Lehmer, Derrick Henry; Selfridge, John (April 1975). "New Primality Criteria and Factorizations of 2^m ± 1". Mathematics of Computation. 29 (130): 620–647. doi:10.1090/S0025-5718-1975-0384673-1.
- Rödseth, Öystein J. (1994). "A note on primality tests for N=h·2^n−1" (PDF). BIT Numerical Mathematics. 34 (3): 451–454. doi:10.1007/BF01935653. Archived from the original (PDF) on March 6, 2016.
- Riesel, Hans (1994). Prime Numbers and Computer Methods for Factorization. Progress in Mathematics. 126 (2nd ed.). Birkhäuser. pp. 107–121. ISBN 0-8176-3743-5.
- Riesel, Hans (1969). "Lucasian Criteria for the Primality of N = h·2n − 1". Mathematics of Computation. American Mathematical Society. 23 (108): 869–875. doi:10.2307/2004975. JSTOR 2004975.
External links
- Download Jean Penné's LLR
- Math::Prime::Util::GMP - Part of Perl's ntheory module, this has basic implementations of LLR and Proth form testing, as well as some BLS75 proof methods.