mersenneforum.org  

Go Back   mersenneforum.org > Great Internet Mersenne Prime Search > Math

Reply
 
Thread Tools
Old 2004-03-09, 14:20   #1
HiddenWarrior
 
HiddenWarrior's Avatar
 
Jun 2003
Russia, Novosibirsk

2·107 Posts
Default Good way to minimize factoring algoritm twice?

Ok, 2^p-1 has divider q of form q=2kp+1. Let's remember the thread: http://www.mersenneforum.org/showthread.php?t=1804 (see about explanation of p periodicity). So, we first find LowT and HighT. I'll show Visual Basic code to explain it (easy to rewrite on other langs):

Dim LowT as long
Dim HighT as long
For LowT = 1 To 4
If (2 * LowT * P + 1) Mod 8 = 1 Then Exit For
Next
For HighT = 1 To 4
If (2 * HighT * P + 1) Mod 8 = 7 Then Exit For
Next

If we'll test this code for different P's we'll find that LowT and HighT is 1,3 or 4. To say more! One of this numbers is always 4 and the other one is 1 or 3!!!

Now we can modify our q: q=8*p*iteration+2*p*lowt+1 (or q=8*p*iteration+2*p*hight+1). Futher: 2^p-1=q1*q2 (if is not prime). We can check again and we'll find that q1 or q2 always contains LowT or HighT with the value 4!!! Therefore we can check only dividers that contain 4 (the value of LowT or HighT) inside them.

Result: we can check only for dividers of form q=8*p*iteration+8*p+1=8*p*(iteration+1)+1=8*p*I+1 (where I begins its run from 1).

Some samples:
2^11-1=23*89 (23 it is I=1 and LowT=1, 89 it is I=1 HighT=4!!!)
2^23-1=47*178481 (47 it is I=1 and LowT=1, 178481 it is I=969 HighT=4!!!)
2^29-1=233*1103*2089 (233 it is I=1 and HighT=4!!!, 1103 it is I=5 LowT=3, 2089 it is I=9 HighT=4!!!)
and so on...

Last fiddled with by HiddenWarrior on 2004-03-09 at 14:26
HiddenWarrior is offline   Reply With Quote
Old 2004-03-09, 23:01   #2
dsouza123
 
dsouza123's Avatar
 
Sep 2002

2×331 Posts
Default

That is equivalent to:
given q = 2kp+1 only when 2k is a multiple of 8 is it a potential factor of 2^p -1
so with k = 1,2,3,,5,6,7,,9,10,11 a factor wont be found.

k must be a multiple of 4, or when (k mod 4) = 0 and k >= 4

8, 2*4, 2^3, 4*2, 8*1
16, 2*8, 2^4, 4*4, 8*2
24, 2*12, 2^3*3, 4*6, 8*3
32, 2*16, 2^5, 4*8, 8*4
40, 2*20, 2^3*5, 4*10, 8*5
48, 2*24, 2^4*3, 4*12, 8*6
56, 2*28, 2^3*7, 4*14, 8*7
64, 2*32, 2^6, 4*16, 8*8
72, 2*36, 2^3*3^2, 4*20, 8*9

that implies the formula should be q=8kp+1 and only when (q mod 8) = 1
is it a potential factor.

Is the q=2kp+1 imprecise ? Allowing many values that can't be a factor.
Is the test of (q mod 8) = 1 or = 7 not correct should it be only (q mod 8) = 1 ?
dsouza123 is offline   Reply With Quote
Old 2004-03-09, 23:47   #3
Maybeso
 
Maybeso's Avatar
 
Aug 2002
Portland, OR USA

2·137 Posts
Default

Quote:
Originally Posted by dsouza123
That is equivalent to:
given q = 2kp+1 only when 2k is a multiple of 8 is it a potential factor of 2^p -1
so with k = 1,2,3,,5,6,7,,9,10,11 a factor wont be found.
No, he is saying that when k is one of those numbers, the 2k for the other factor will be a multiple of 8. Because the product, Mp, must be == 7 mod 8.

Notice that for 2^11 -1, it is the higher factor, 89, that has 8| 2k. What this means is, if we restrict our search to 8kp+1, we can't stop at the square root - not that we are trial factoring anywhere near that now.

So, HiddenWarrior - because we are not doing a complete search, not even to the square root - we can only check the smaller of any factor pairs. If we skip any 7 mod 8 factors, we will be skipping the entire pair. Knowing that the other factor is 8kp+1 does us no good if we never look at it. And we wouldn't want to. It is easier to check every possible factor up to 100 bits, rather than checking 1/8th of all factors up to 20 million bits.

Although, .... you may have something here ...
Once we get beyond 64 bits, it might be worth it to check 8kp+1 up to 127 bits.
Hmm, how often is the smallest factor == 1 mod 8, and how often 7 mod 8?
Does it make sense to check either of these subsets to a higher bit level?
Maybeso is offline   Reply With Quote
Old 2004-03-10, 01:25   #4
Maybeso
 
Maybeso's Avatar
 
Aug 2002
Portland, OR USA

2×137 Posts
Default

Quote:
Originally Posted by Maybeso
Although, .... you may have something here ...
Once we get beyond 64 bits, it might be worth it to check 8kp+1 up to 127 bits.
Hmm, how often is the smallest factor == 1 mod 8, and how often 7 mod 8?
Does it make sense to check either of these subsets to a higher bit level?
I checked http://www.mersenneforum.org/lmh/factor.zip - the factors LMH has found for p > 79M. The ratio is:
41.13% == 1 (mod 8)
58.87% == 7 (mod 8)

So is this enough of a difference to justify a separate search to a higher bit level?
Maybeso is offline   Reply With Quote
Old 2004-03-10, 12:21   #5
HiddenWarrior
 
HiddenWarrior's Avatar
 
Jun 2003
Russia, Novosibirsk

21410 Posts
Default

Quote:
Originally Posted by Maybeso
Notice that for 2^11 -1, it is the higher factor, 89, that has 8| 2k. What this means is, if we restrict our search to 8kp+1, we can't stop at the square root - not that we are trial factoring anywhere near that now.
Yes, in this case we have to do factoring to [(2^p-1)/2] to find this factor. We'll move twice faster but will miss factors that has form of 8*p*i+2*p+1 (7 mod 8). Maybe it's some reasons to implemet it on higher bits like from 70bit level.

Quote:
Originally Posted by Maybeso
Hmm, how often is the smallest factor == 1 mod 8, and how often 7 mod 8?
I can calculate this rate for all know factors from 0M..500M today...
HiddenWarrior is offline   Reply With Quote
Old 2004-03-10, 12:40   #6
nfortino
 
nfortino's Avatar
 
Nov 2003

3·5·11 Posts
Default

Quote:
Originally Posted by HiddenWarrior
Yes, in this case we have to do factoring to [(2^p-1)/2] to find this factor. We'll move twice faster but will miss factors that has form of 8*p*i+2*p+1 (7 mod 8). Maybe it's some reasons to implemet it on higher bits like from 70bit level.



I can calculate this rate for all know factors from 0M..500M today...
Be very careful using LMH>79.3M data. We know not all factors are found, and it is conceivable more 1 mod 8 factors are missed than 7 mod 8 factors.
nfortino is offline   Reply With Quote
Old 2004-03-10, 12:54   #7
HiddenWarrior
 
HiddenWarrior's Avatar
 
Jun 2003
Russia, Novosibirsk

D616 Posts
Default

Ok! I'll do report for two ranges 0M..79.3M and 79.3M and 500M then
HiddenWarrior is offline   Reply With Quote
Old 2004-03-10, 13:39   #8
HiddenWarrior
 
HiddenWarrior's Avatar
 
Jun 2003
Russia, Novosibirsk

110101102 Posts
Default

It is 44.x% for (1 mod 8) and 55.y% for (7 mod 8)
But we get 1 mod 8 only by q1=8*p*i+1 and 7 mod 8 we get by q2=2p+1 mod 8 and q3=6*p+1 mod 8. I think it is faster to check only q1 dividers than both q2 and q3 and this percentage doesn't realy show the right situation...

Last fiddled with by HiddenWarrior on 2004-03-10 at 13:49
HiddenWarrior is offline   Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Minimize |n-2^x*3^y| over the integer a1call Information & Answers 93 2016-09-10 17:34
Good air-cooler good enough for overclocked i7-5820K RienS Hardware 17 2014-11-18 22:58
A mobile Tesla coil - is it good for factoring? for wiping debt? LaurV Lounge 3 2013-01-28 09:08
Minimize maximum error Joshua2 Homework Help 10 2011-03-15 13:19
any good GNFS factoring programs? ixfd64 Factoring 1 2004-04-27 09:41

All times are UTC. The time now is 17:43.


Fri Jul 16 17:43:59 UTC 2021 up 49 days, 15:31, 1 user, load averages: 1.34, 1.45, 1.48

Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.

This forum has received and complied with 0 (zero) government requests for information.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation.
A copy of the license is included in the FAQ.