![]() |
![]() |
#1 |
Mar 2011
Germany
1418 Posts |
![]()
Hi,
a friend of mine suggested two new variants of the Lucas Lehmer scheme. In both cases there is no subtraction of 2, just the squaring. I tested both variants for smaller primes up to 10000 (no false positives) and all Mersenne primes up to 44497 (all positive tests). So here is my question: Can one prove that the following algorithm is a prime test for Mersenne numbers? If not, maybe it could be used as a probable prime test. It should be faster than the usual Lucas Lehmer test. Here is the algorithm (with two different initial and final conditions): Code:
LucasLehmer(p) {s = a M = 2^p - 1 repeat p times : s = s*s mod M if s = a^2 return PRIME else return COMPOSITE} variant 1: a = 3 variant 2: a = 5 Pari GP code: LL1(p)={m=2^p-1;s=3;for(i=1,p,s=lift(Mod(s,m)^2));print(s==9)} LL2(p)={m=2^p-1;s=5;for(i=1,p,s=lift(Mod(s,m)^2));print(s==25)} |
![]() |
![]() |
![]() |
#2 |
Basketry That Evening!
"Bunslow the Bold"
Jun 2011
40<A<43 -89<O<-88
1C3516 Posts |
![]()
I'm not sure it is faster. Subtracting two is an easy thing to do, while this test has two more squares. Removing p-2 minus-2 operations may or may not make up for two extra squares, and even if it does, the gains are barely noticeable at best.
|
![]() |
![]() |
![]() |
#3 |
"Nancy"
Aug 2002
Alexandria
2,467 Posts |
![]()
Let N = 2^p-1. You compute 3^(2^p) == 3^(N+1) (mod N). This is essentially just a Fermat test. It may correctly determine primality for all Mersenne numbers, but I'm not aware of a proof. The Lucas-Lehmer does provably determine primality for Mersenne numbers, and the subtraction of 2 each iteration is insignificant for computational cost.
|
![]() |
![]() |
![]() |
#4 | |
Mar 2011
Germany
6116 Posts |
![]() Quote:
Thanks for pointing this out. Edit: I did not see it because in the suggestions there were even more variants: real LL tests with different initial values... (Shame on me) Last fiddled with by MrRepunit on 2012-05-09 at 23:21 |
|
![]() |
![]() |
![]() |
#5 | |
"Forget I exist"
Jul 2009
Dartmouth NS
845010 Posts |
![]() Quote:
Last fiddled with by science_man_88 on 2012-05-09 at 23:43 |
|
![]() |
![]() |
![]() |
#6 |
Mar 2011
Germany
97 Posts |
![]()
Right, I forgot to mention that. But it is trivial: s mod (2^3-1) is smaller than 9 (or 25), so 2^p-1 must be larger than 9 (or 25).
|
![]() |
![]() |
![]() |
#7 | |
"Forget I exist"
Jul 2009
Dartmouth NS
2×52×132 Posts |
![]() Quote:
Last fiddled with by science_man_88 on 2012-05-10 at 00:27 |
|
![]() |
![]() |
![]() |
#8 | |
Mar 2011
Germany
9710 Posts |
![]() Quote:
![]() |
|
![]() |
![]() |
![]() |
#9 |
"Forget I exist"
Jul 2009
Dartmouth NS
100001000000102 Posts |
![]() |
![]() |
![]() |
![]() |
#10 |
Romulan Interpreter
"name field"
Jun 2011
Thailand
24·643 Posts |
![]()
The idea is not new, it was many times discussed before. If you do not start with 3, but with some value dependent of each p, you can prove that this test is equivalent to a LL test, functional and computational. For example you start with
One direction is easy to prove, with Fermat, if As I said, the idea is not new, I "rediscovered" it myself some time ago, and post it to the forum, wondering if it is faster then LL test. As it turned out from discussions, it is not, the only improvement is related to subtracting 2, which is computationally insignificant. Further search turned out that other people had different forms of this idea before, more or less provable being LL equivalent, but at the end all it takes is to see that when Mp is prime there is the big ZERO at some iteration in the LL test, which is unique (the terms after are all +/-2), and when Mp is composite, there is no zero, the residues go in a loop after a while. Last fiddled with by LaurV on 2012-05-10 at 04:05 |
![]() |
![]() |
![]() |
Thread Tools | |
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Modifying the Lucas Lehmer Primality Test into a fast test of nothing | Trilo | Miscellaneous Math | 25 | 2018-03-11 23:20 |
Question About Lucas-Lehmer Test (JAVA) | jmanes92 | Programming | 9 | 2013-02-22 22:19 |
Faster Lucas-Lehmer test using integer arithmetic? | __HRB__ | Software | 188 | 2010-08-09 11:13 |
Lucas Lehmer test question? | BMgf | Programming | 23 | 2003-12-09 08:52 |
about Lucas-Lehmer test and Prime 95 | Annunaki | Math | 22 | 2003-08-05 21:52 |