mersenneforum.org  

Go Back   mersenneforum.org > New To GIMPS? Start Here! > Information & Answers

Reply
 
Thread Tools
Old 2016-05-12, 21:57   #12
danaj
 
"Dana Jacobsen"
Feb 2011
Bangkok, TH

22·227 Posts
Default

PFGW's nextprime is not at all optimal (with 3.7.10 at least). It does a shallow small factor check followed by WraithX's GMP BPSW test. It's significantly slower than Pari or Perl/ntheory, when for large inputs (4000+ digits) it could be much faster if it did a sieve followed by its PRP tests, with the BPSW test reserved for anything passing the PRP test.

Of course for the trivial sizes you're showing (sub-40 digits) you're measuring completely wrong. next_prime for 40 digit inputs should be taking less than a millisecond.

For next prime of 10^2000:

22s Perl/ntheory
128s Pari/GP 2.8.0 (55e7256a)
231s PFGW 3.7.10.64bit

Once you get into the 2k-10k range and larger, the fastest strategy I know is to use a sieve (Perl/ntheory or newpgen or whatever) followed by PFGW on each candidate (so it runs the fast PRP test), followed by a better test on the result (Pari/GP, Perl/ntheory, etc.). There isn't any really convenient one-stop solution right now.

There's another thread that was discussing this, and if I had a good gwnum standalone base-2 M-R test I could easily add it to my code. A standalone Fermat would work also -- the one in PFGW exists but doesn't look easy to take out.

Last fiddled with by danaj on 2016-05-12 at 22:01 Reason: best -> fastest
danaj is offline   Reply With Quote
Old 2016-05-12, 22:32   #13
PawnProver44
 
PawnProver44's Avatar
 
"NOT A TROLL"
Mar 2016
California

C516 Posts
Post

I do not think any of those programs can handle nextprime(x) for x around 200k digits, and I think no text editor would support at least 500k lines of next, but if any please let me know of a few editors I can use for something like this:

nextprime(input.txt); (random 200k digit number)

Result = inputprime.out (decimal expansion of nextprime(x))
PawnProver44 is offline   Reply With Quote
Old 2016-05-12, 23:06   #14
danaj
 
"Dana Jacobsen"
Feb 2011
Bangkok, TH

22×227 Posts
Default

It depends what you mean by "cannot handle." All three tools ought to work. I've used mine for 100k inputs before, but the time taken can be extreme. I don't see why Pari/GP would have any issues with large inputs other than the time taken.

vim and emacs will both handle 500k character lines without a problem. Older versions of vi work but get slow for such long lines. You can also just generate 500k random digits with a program and have it output to your file.

You could also just do something like:
Code:
perl -Mntheory=:all -E 'prime_set_config(use_primeinc=>1); say random_ndigit_prime(1000);'
which will do basically what you're suggesting. It turns on the fast-but-bad-distribution PRIMEINC method for random primes, then asks for a random prime of however many digits. Which means it chooses a random number of that many digits, then runs next_prime on it. But at 100k digits, gwnum is *much* faster than GMP, so doing things the long way around is going to save a lot of time.

I would think that doing next_prime of simple expressions would be more palatable than completely random PRPs. It sounds like there are already issues with submitting giant numbers like these. Wouldn't next_prime(10^100000+10^12345) or something be different enough and yet still easily describable?
danaj is offline   Reply With Quote
Old 2016-05-12, 23:18   #15
a1call
 
a1call's Avatar
 
"Rashid Naimi"
Oct 2015
Remote to Here/There

1000000011112 Posts
Default

Quote:
Originally Posted by danaj View Post
I would think that doing next_prime of simple expressions would be more palatable than completely random PRPs. It sounds like there are already issues with submitting giant numbers like these. Wouldn't next_prime(10^100000+10^12345) or something be different enough and yet still easily describable?
That's a good point. There are limitations to web "form submission" by design. The best that can be done to submit a large decimal expansion with a form is to use loss-less compressed files. However there is always other means of file transfer other than form submission (which is not really designed for the purpose). FTP link in an email should work (at least in theory).

Last fiddled with by a1call on 2016-05-12 at 23:21
a1call is offline   Reply With Quote
Old 2016-05-15, 18:29   #16
PawnProver44
 
PawnProver44's Avatar
 
"NOT A TROLL"
Mar 2016
California

197 Posts
Post

Quote:
Originally Posted by danaj View Post

Once you get into the 2k-10k range and larger, the fastest strategy I know is to use a sieve (Perl/ntheory or newpgen or whatever) followed by PFGW on each candidate (so it runs the fast PRP test), followed by a better test on the result (Pari/GP, Perl/ntheory, etc.). There isn't any really convenient one-stop solution right now.

There's another thread that was discussing this, and if I had a good gwnum standalone base-2 M-R test I could easily add it to my code. A standalone Fermat would work also -- the one in PFGW exists but doesn't look easy to take out.
Is there some program I can use to generate large random numbers (500k+digits), then input them in wordpad for text editing and input into pfgw: -f -i input.txt, but how can I do this using Pari/Gp or ntheory to do that? For pfgw using a 2.16 Gz processor, I get timing greater than a decade for: nextprime(200k digit number) which is "extreme".

The problem with prp testing each candidate is the command line will freeze due to several lines of digits. Ntheory should not take more than two weeks for this using the same processor is my guess? Thanks. Seems complicated to me.
PawnProver44 is offline   Reply With Quote
Old 2016-05-15, 18:58   #17
danaj
 
"Dana Jacobsen"
Feb 2011
Bangkok, TH

22×227 Posts
Default

Pari/GP easily generates large random numbers. E.g.
Code:
echo 'random(10^1000)' | gp -f -q > /tmp/input.txt
There are plenty of other ways. I have a suspicion your next point will be what to do with the number you get (sieving or PFGW). At some point you really need to learn to read the man pages and figure out how to run things yourself.
danaj is offline   Reply With Quote
Old 2016-05-15, 19:03   #18
paulunderwood
 
paulunderwood's Avatar
 
Sep 2002
Database er0rr

2×32×11×19 Posts
Default

Something like the following might work:

Code:
 c=0;for(k=1,10000,n=random(10^500000);forprime(p=2,1000000,if(n%p==0,break(2)));c=c+1;write("pf500000.txt",n));print(c" numbers added")
Bear in mind that the file might be large, if you up the "k"!

Last fiddled with by paulunderwood on 2016-05-15 at 19:05
paulunderwood is offline   Reply With Quote
Old 2016-05-15, 19:14   #19
PawnProver44
 
PawnProver44's Avatar
 
"NOT A TROLL"
Mar 2016
California

197 Posts
Post

Set nextprime(2^620000) in pfgw a month ago and it is still working on it . For perl n/theory, I still get over a month (unless I am extremely lucky) using the same processor.

I am currently unsure if Pari/GP or perl/ntheory do sieves before prp testing remaining candidates for next_prime(n).

Last fiddled with by PawnProver44 on 2016-05-15 at 19:16
PawnProver44 is offline   Reply With Quote
Old 2016-05-15, 19:20   #20
paulunderwood
 
paulunderwood's Avatar
 
Sep 2002
Database er0rr

2×32×11×19 Posts
Default

This is better code for random primes. (The previous code I gave only produce one candidate )

Code:
 c=0;for(k=1,100,n=random(10^500000);factored=0;forprime(p=2,1000000,if(n%p==0,factored=1;break));if(factored==0,c=c+1;write("pf500000.txt",n)));print(c" numbers added")
5 numbers added
If you go down this line, use PFGW's "-f" switch.

Last fiddled with by paulunderwood on 2016-05-15 at 19:24
paulunderwood is offline   Reply With Quote
Old 2016-05-15, 19:24   #21
PawnProver44
 
PawnProver44's Avatar
 
"NOT A TROLL"
Mar 2016
California

197 Posts
Post

Quote:
Originally Posted by paulunderwood View Post
This is better code for random primes. (The previous code I gave only produce one candidate )

Code:
 c=0;for(k=1,100,n=random(10^500000);factored=0;forprime(p=2,1000000,if(n%p==0,factored=1;break));if(factored==0,c=c+1;write("pf500000.txt",n)));print(c" numbers added")
5 numbers added
for perl/ntheory my guess? That code just restarted my computer for some reason?
PawnProver44 is offline   Reply With Quote
Old 2016-05-15, 19:28   #22
paulunderwood
 
paulunderwood's Avatar
 
Sep 2002
Database er0rr

2×32×11×19 Posts
Default

Quote:
Originally Posted by PawnProver44 View Post
for perl/ntheory my guess? That code just restarted my computer for some reason?
I don't why that pari/gp should do that. Heat? Lack of memory? Watch out for the file size of "pf500000.txt"!

Last fiddled with by paulunderwood on 2016-05-15 at 19:32
paulunderwood is offline   Reply With Quote
Reply

Thread Tools


Similar Threads
Thread Thread Starter Forum Replies Last Post
Near- and quasi-repunit PRPs Batalov And now for something completely different 10 2019-09-12 13:31
OEIS - 2^n-5 - LLT-like algorithm for finding PRPs T.Rex Miscellaneous Math 13 2015-09-01 13:09
PRPs not prime schickel FactorDB 1 2015-08-03 02:50
Proven PRPs? Random Poster FactorDB 0 2012-07-24 10:53
PRPs that are composites gd_barnes Conjectures 'R Us 57 2011-09-12 12:31

All times are UTC. The time now is 14:39.


Mon Aug 2 14:39:34 UTC 2021 up 10 days, 9:08, 0 users, load averages: 3.90, 4.24, 3.96

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.