mersenneforum.org  

Go Back   mersenneforum.org > Math Stuff > Computer Science & Computational Number Theory > PARI/GP

Reply
 
Thread Tools
Old 2010-08-29, 20:25   #1112
science_man_88
 
science_man_88's Avatar
 
"Forget I exist"
Jul 2009
Dumbassville

203008 Posts
Default

Quote:
Originally Posted by CRGreathouse View Post
Instead of testing if n+1 is a prime, I loop through the primes, choosing n = p-1 so that n+1 is prime. Because I'm using Pari's precalculated list instead of testing numbers, the search is much faster. (This occurs even if I have to generate the whole list myself -- sieving is much faster than testing.)
my brain must have been switched off before lol.
science_man_88 is offline   Reply With Quote
Old 2010-08-29, 20:37   #1113
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

24×3×5×7 Posts
Default

Quote:
Originally Posted by CRGreathouse
Instead of testing if n+1 is a prime, I loop through the primes, choosing n = p-1 so that n+1 is prime. Because I'm using Pari's precalculated list instead of testing numbers, the search is much faster. (This occurs even if I have to generate the whole list myself -- sieving is much faster than testing.)
This renders you unable to test for larger numbers.
3.14159 is offline   Reply With Quote
Old 2010-08-29, 20:37   #1114
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3·1,993 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
outside of the fact that if you want them in order it's unlikely with my alteration wouldn't it be faster to say
Code:
n=p-1;a^2=p-1;b^4=p-1
to check 3 at once ? though this would take 3 times the memory I think.
That wouldn't work. First, you can't assign to a^2 (in C terminology, it's an rvalue not an lvalue; in assembly terms (though not strictly relevant here!), it's not memory-mapped). Second, you can't fix more than one member -- once you pick one, you fix the values for all of them.

Last fiddled with by CRGreathouse on 2010-08-29 at 20:39
CRGreathouse is offline   Reply With Quote
Old 2010-08-29, 20:38   #1115
kar_bon
 
kar_bon's Avatar
 
Mar 2006
Germany

22·727 Posts
Default

Quote:
Originally Posted by CRGreathouse View Post
That wouldn't work.
Yep, he's discovered! ... and deleted!
kar_bon is offline   Reply With Quote
Old 2010-08-29, 20:41   #1116
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

24×3×5×7 Posts
Default

Code:
1546750398064958524633425292455441988676752527730835687139862311217981986247572619886186890734016949799686352443760408934653066300968034776190705901570570913201114184380563243205276690363368824249952639567750758594330067937015662345505149388718977581056000000000000000000000000000000000000000000000001
76, 151, 301 digits, new record for Number, square, and fourth.

Last fiddled with by 3.14159 on 2010-08-29 at 20:43
3.14159 is offline   Reply With Quote
Old 2010-08-29, 20:44   #1117
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

10111010110112 Posts
Default

Quote:
Originally Posted by 3.14159 View Post
This renders you unable to test for larger numbers.
As long as you're working below 4e9 or 1e10 or so (depending on your platform), it's *far* more efficient to use forprime.

Further, for any number for which it is viable to generate all members up to, it's most efficient to sieve in some form. You could be talking about running overnight vs. taking a week. Of course this would take custom code!

I happen to have this: prototype code that lets me loop over primes up to primelimit^2 rather than primelimit. I'm not going to release it at this time: it's buggy near the endpoints and I need to fix that, plus it requires a dynamic installation of Pari so doesn't work for people who only have the Windows binary.
CRGreathouse is offline   Reply With Quote
Old 2010-08-29, 22:01   #1118
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

168010 Posts
Default

Quote:
Originally Posted by CRGreathouse
Further, for any number for which it is viable to generate all members up to, it's most efficient to sieve in some form. You could be talking about running overnight vs. taking a week. Of course this would take custom code!
Or a download of an already existing implementation of the sieve.
3.14159 is offline   Reply With Quote
Old 2010-08-29, 22:14   #1119
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

24·3·5·7 Posts
Default

Well, one may already exist in form of a sieve for Generalized Fermat numbers. All that is required is sieving for n^2 + 1 and n^4 + 1

Last fiddled with by 3.14159 on 2010-08-29 at 22:14
3.14159 is offline   Reply With Quote
Old 2010-08-29, 22:15   #1120
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3·1,993 Posts
Default

Quote:
Originally Posted by 3.14159 View Post
Or a download of an already existing implementation of the sieve.
Do you know of any good out-of-memory sieves?
CRGreathouse is offline   Reply With Quote
Old 2010-08-29, 22:27   #1121
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

24·3·5·7 Posts
Default

Quote:
Originally Posted by CRGreathouse
Do you know of any good out-of-memory sieves?
Well, I have a program that sieves for Generalized Fermats. You could sieve for n^2 + 1 and n^4 + 1 and take whatever elements both files have in common.
3.14159 is offline   Reply With Quote
Old 2010-08-29, 22:35   #1122
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3×1,993 Posts
Default

Quote:
Originally Posted by 3.14159 View Post
Well, I have a program that sieves for Generalized Fermats. You could sieve for n^2 + 1 and n^4 + 1 and take whatever elements both files have in common.
In a pinch, I suppose that works. You just test the remainder for primality of n+1, I suppose?
CRGreathouse is offline   Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Why do I sometimes see all the <> formatting commands when I quote or edit? cheesehead Forum Feedback 3 2013-05-25 12:56
Passing commands to PARI on Windows James Heinrich Software 2 2012-05-13 19:19
Ubiquity commands Mini-Geek Aliquot Sequences 1 2009-09-22 19:33
64-bit Pari? CRGreathouse Software 2 2009-03-13 04:22
Are these commands correct? jasong Linux 2 2007-10-18 23:40

All times are UTC. The time now is 23:13.


Fri Aug 6 23:13:09 UTC 2021 up 14 days, 17:42, 1 user, load averages: 4.62, 4.30, 4.09

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.