mersenneforum.org  

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

Reply
 
Thread Tools
Old 2010-08-17, 15:43   #606
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

24·3·5·7 Posts
Cool Idea:

I defined the function em2 to return b-values that are divisible by a user-specified number.

I thought of a new function that gets rid of the b-values divisible by any prime in a range of primes. simply save these to a file, remove every duplicate, remove the b-values from the range that happen to be divisible by p, and test the remainder. It's already defined.

To make it somewhat better: I'm going to need a further command that prints the numbers that are not in the set of em2 for any of the primes specified. The primelimit is set to 2147483648, so it's going to be somewhat useful.
Excellent idea, amirite?

Last fiddled with by 3.14159 on 2010-08-17 at 15:46
3.14159 is offline   Reply With Quote
Old 2010-08-17, 15:51   #607
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

24×3×5×7 Posts
Default

The code snippet I scribbled on paper for the next command:

nonmem(a,x,m,b) = {
for(n=a,x,
if(n=!mem(a,x,m,b), print(n))
);
}

(Please tell whether or not there are any errors there.)

For mem:
mem(a,x,m,b) = {
forprime(p=a,x,
print(em2(p,m!,b))
);
}

(Where b = 10b).

Last fiddled with by 3.14159 on 2010-08-17 at 15:53
3.14159 is offline   Reply With Quote
Old 2010-08-17, 15:56   #608
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3·1,993 Posts
Default

Quote:
Originally Posted by 3.14159 View Post
Need to proofread more often, there.
I'm sure I scanned that portion of the code at least two or three times, but it wasn't clear that there was anything wrong. (The other parts where I thought the problem was I looked at a dozen times at least... although that did help me optimize those parts.)

In any case that project is running now. It's about 100 times faster than my old version at these sizes, and should be about 1000 times faster as the numbers grow large. I'm still actively looking to optimize the program -- I'm hoping for at least a 20% improvement, maybe a 50% improvement if I missed something big. But compared to the improvements I already have that's peanuts.
CRGreathouse is offline   Reply With Quote
Old 2010-08-17, 15:58   #609
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

24·3·5·7 Posts
Default

Quote:
Originally Posted by CRGreathouse
I'm sure I scanned that portion of the code at least two or three times, but it wasn't clear that there was anything wrong. (The other parts where I thought the problem was I looked at a dozen times at least... although that did help me optimize those parts.)
Mistakes can sometimes be right under your nose, and you probably won't notice them until the most random of times.

Quote:
Originally Posted by CRGreathouse
In any case that project is running now. It's about 100 times faster than my old version at these sizes, and should be about 1000 times faster as the numbers grow large. I'm still actively looking to optimize the program -- I'm hoping for at least a 20% improvement, maybe a 50% improvement if I missed something big. But compared to the improvements I already have that's peanuts.
10000% improvement? Excellent.

Last fiddled with by 3.14159 on 2010-08-17 at 15:59
3.14159 is offline   Reply With Quote
Old 2010-08-17, 16:00   #610
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3×1,993 Posts
Default

Quote:
Originally Posted by 3.14159 View Post
I defined the function em2 to return b-values that are divisible by a user-specified number.

I thought of a new function that gets rid of the b-values divisible by any prime in a range of primes. simply save these to a file, remove every duplicate, remove the b-values from the range that happen to be divisible by p, and test the remainder. It's already defined.

To make it somewhat better: I'm going to need a further command that prints the numbers that are not in the set of em2 for any of the primes specified. The primelimit is set to 2147483648, so it's going to be somewhat useful.
Just make a vector with a member for every number in the range you're considering, and set the value to 314159 if you find a prime that divides the number. Then take all the values that aren't 314159 and test them to see if they're prime.
CRGreathouse is offline   Reply With Quote
Old 2010-08-17, 16:01   #611
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

175B16 Posts
Talking

Quote:
Originally Posted by 3.14159 View Post
10000% improvement? Excellent.
Yes, I did more work last night than in the month of calculation I put in earlier.
CRGreathouse is offline   Reply With Quote
Old 2010-08-17, 16:03   #612
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

24×3×5×7 Posts
Default

Quote:
Originally Posted by CRGreathouse
Just make a vector with a member for every number in the range you're considering, and set the value to 314159 if you find a prime that divides the number. Then take all the values that aren't 314159 and test them to see if they're prime.
A vector with the smallest k * n! + 1 that's divided by p, for a range of p?

Also: Anything regarding the code snippets I thought up a few minutes ago?

Last fiddled with by 3.14159 on 2010-08-17 at 16:05
3.14159 is offline   Reply With Quote
Old 2010-08-17, 16:10   #613
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3×1,993 Posts
Default

Quote:
Originally Posted by 3.14159 View Post
A vector with the smallest k * n! + 1 that's divided by p, for a range of p?
A vector v where v[1] represents k = 1, v[2] represents k = 2, etc. Mark off entries when you know they're bad, and test only the unmarked entries.

Quote:
Originally Posted by 3.14159 View Post
Also: Anything regarding the code snippets I thought up a few minutes ago?
I don't know exactly how em2 works so I can't say much. But try my idea, it works much better. Printing is bad, don't do it if you can avoid it.
CRGreathouse is offline   Reply With Quote
Old 2010-08-17, 16:13   #614
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

24×3×5×7 Posts
Default

Quote:
Originally Posted by CRGreathouse
I don't know exactly how em2 works so I can't say much. But try my idea, it works much better. Printing is bad, don't do it if you can avoid it.
em2 removes all the k-values divisible by a user-specified number.

Last fiddled with by 3.14159 on 2010-08-17 at 16:13
3.14159 is offline   Reply With Quote
Old 2010-08-17, 16:16   #615
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

69016 Posts
Default

Quote:
Originally Posted by CRGreathouse
A vector v where v[1] represents k = 1, v[2] represents k = 2, etc. Mark off entries when you know they're bad, and test only the unmarked entries.
A vector of the integers?
3.14159 is offline   Reply With Quote
Old 2010-08-17, 16:19   #616
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

175B16 Posts
Default

Quote:
Originally Posted by 3.14159 View Post
em2 removes all the k-values divisible by a user-specified number.
I read that in your post. It doesn't tell me enough that I can comment on code using it.

Quote:
Originally Posted by 3.14159 View Post
A vector of the integers?
Not really important here. The best of all the easy solutions in Pari is to use a VECSMALL, which is created by vectorsmall just like a VEC is created by vector.
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:02.


Fri Aug 6 23:02:34 UTC 2021 up 14 days, 17:31, 1 user, load averages: 3.38, 3.93, 3.95

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.