mersenneforum.org  

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

Reply
 
Thread Tools
Old 2010-08-11, 19:05   #265
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

69016 Posts
Default

Quote:
Originally Posted by CRGreathouse
If you fix that, does it work? If so, great. If not, please post the modified code, seeing that both modbmpsp and modbm needed to be changed. (Edit: all the code, if you can -- p, modbm*, isPRP, and whatever else you're calling.)
Here is the code snippet:
Code:
 modbm2(x,n,m)=for(n=x,n,if(isprime(n*p(m)^2+1)&isprime(2*(n*p(m^2)+1)-1)&isPRP((n*p(m)^2+1)*(2*(n*p(m)^2+1)-1)b=2),print((n*p(m)^2+1)*(2*(n*p(m)^2+1)-1))));
Now, it gives the expected returns. I saved that into the text file of all the defined functions.

Last fiddled with by 3.14159 on 2010-08-11 at 19:06
3.14159 is offline   Reply With Quote
Old 2010-08-11, 19:07   #266
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

175B16 Posts
Default

Quote:
Originally Posted by science_man_88 View Post
look to get a value out of a function and used by other functions if the first code returns nothing it is assumed to return 0
Pretty much. Internally there are actually different values: the integer 0 (gen_0), positive and negative floating-point 0s at every precision level, and in this case a special value called gnil. When a function returns gnil the GUI knows to display nothing (and not increment the % number), but if a value is needed gnil is treated the same as gen_0.

Quote:
Originally Posted by science_man_88 View Post
so the value you are test as the first part of if (isprp() or what ever that part is is returning 0 since its variables are used later with no initial value they are assumed 0 and so mod by 0 error occurs. so to solve it the value outside of 0 of the other function so that other functions can use it.
That's not quite enough to cause the error, since it's the first part of a Mod() call -- we would be raising 0 to some power, which isn't division by zero unless the exponent is negative. And even that would give "impossible inverse mod X" rather than division by 0. But it was clearly a mistake, and getting one mistake out of the way may let us more clearly see what's actually wrong.

Of course the process of fixing that mistake may correct the other, who knows?
CRGreathouse is offline   Reply With Quote
Old 2010-08-11, 19:08   #267
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

597910 Posts
Default

Quote:
Originally Posted by 3.14159 View Post
Here is the code snippet:
Code:
 modbm2(x,n,m)=for(n=x,n,if(isprime(n*p(m)^2+1)&isprime(2*(n*p(m^2)+1)-1)&isPRP((n*p(m)^2+1)*(2*(n*p(m)^2+1)-1)b=2),print((n*p(m)^2+1)*(2*(n*p(m)^2+1)-1))));
Now, it gives the expected returns. I saved that into the text file of all the defined functions.
Glad to hear it.
CRGreathouse is offline   Reply With Quote
Old 2010-08-11, 19:11   #268
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

24·3·5·7 Posts
Default

Quote:
Originally Posted by CRGreathouse
Glad to hear it.
Now, using that function, I can modify the code to include as many bases as I'd like for it to be pseudoprime to.
3.14159 is offline   Reply With Quote
Old 2010-08-11, 19:13   #269
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3×1,993 Posts
Default

Quote:
Originally Posted by 3.14159 View Post
Now, using that function, I can modify the code to include as many bases as I'd like for it to be pseudoprime to.
I don't know what the goal of that or any of your functions are (well, other than isPRP which I presume checks if the input is a probable-prime. Wait, doesn't yours actually check if it's a strong probable prime instead?
CRGreathouse is offline   Reply With Quote
Old 2010-08-11, 19:15   #270
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 what the goal of that or any of your functions are (well, other than isPRP which I presume checks if the input is a probable-prime. Wait, doesn't yours actually check if it's a strong probable prime instead?

*facepalm* isPRP is a strong pseudoprimality test and uses base 2. isWPRP is a Fermat test. isSPRP is a strong pseudoprimality test that performs trial factoring to nextprime(106) and uses a random base.

Carmichael numbers only pass isWPRP, not the other two, unless the Carmichael number happens to be a strong pseudoprime number to base 2. (Ex: 15841 is a Carmichael number and is a 2-SPRP.)

Last fiddled with by 3.14159 on 2010-08-11 at 19:18
3.14159 is offline   Reply With Quote
Old 2010-08-11, 19:18   #271
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3×1,993 Posts
Default

Quote:
Originally Posted by 3.14159 View Post
*facepalm* isPRP is a strong pseudoprimality test.
I checked the code. The deceptively-named isPRP tests whether the input is a b-strong probable prime. A strong pseudoprimality test would be
Code:
isSPSP(n,b)=isPRP(n,b)&!isprime(n)
a probable primality test would be
Code:
isPRP_correct(n,b)=Mod(b,n)^(n-1)==1
and a pseudoprime test would be
Code:
isPSP(n,b)=isPRP_correct(n,b)&&!isprime(n)
CRGreathouse is offline   Reply With Quote
Old 2010-08-11, 19:20   #272
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

168010 Posts
Default

Quote:
Originally Posted by CRGreathouse
I checked the code. The deceptively-named isPRP tests whether the input is a b-strong probable prime. A strong pseudoprimality test would be
So you're calling me a liar? Prove that I am a liar.

I suggest that you refresh before reply, as I was in the middle of refining the post, and retract the nonsense accusation.

Last fiddled with by 3.14159 on 2010-08-11 at 19:26
3.14159 is offline   Reply With Quote
Old 2010-08-11, 19:26   #273
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

135338 Posts
Default

Quote:
Originally Posted by 3.14159 View Post
*facepalm* isPRP is a strong pseudoprimality test and uses base 2. isWPRP is a Fermat test. isSPRP is a strong pseudoprimality test that performs trial factoring to nextprime(106) and uses a random base.
Your function names bother me. The strong test doesn't have S in its name, etc. But at least document what they do in addhelp commands in your file so that when you share them people know that they do what they say, not what they're named.

Quote:
Originally Posted by 3.14159 View Post
Carmichael numbers only pass isWPRP, not the other two, unless the Carmichael number happens to be a strong pseudoprime number to base 2. (Ex: 15841 is a Carmichael number and is a 2-SPRP.)
If you really want to be pedantic about it, Carmichael numbers don't always pass isWPRP -- they only pass it \varphi(n) times, so 320 out of 560 times for 561. They can have lots of bad bases for the strong test, too -- but never more than a quarter. 8911 is a good example of a Carmichael number with lots of bad bases.
CRGreathouse is offline   Reply With Quote
Old 2010-08-11, 19:28   #274
CRGreathouse
 
CRGreathouse's Avatar
 
Aug 2006

3×1,993 Posts
Default

Quote:
Originally Posted by 3.14159 View Post
So you're calling me a liar? Prove that I am a liar.
I said that your functions were named deceptively. That statement stands.

I did not call you a liar, though I'd be happy to if you can point out an example of yourself lying.

Quote:
Originally Posted by 3.14159 View Post
I suggest that you refresh before reply, as I was in the middle of refining the post, and retract the nonsense accusation.
Please refine your posts before posting.
CRGreathouse is offline   Reply With Quote
Old 2010-08-11, 19:31   #275
3.14159
 
3.14159's Avatar
 
May 2010
Prime hunting commission.

24·3·5·7 Posts
Default

Quote:
Originally Posted by CRGreathouse
Your function names bother me. The strong test doesn't have S in its name, etc. But at least document what they do in addhelp commands in your file so that when you share them people know that they do what they say, not what they're named.
isSPRP? Isn't the meaning a bit self-evident there?

Quote:
Originally Posted by CRGreathouse
But at least document what they do in addhelp commands in your file so that when you share them people know that they do what they say, not what they're named.
Done.

Last fiddled with by 3.14159 on 2010-08-11 at 19:33
3.14159 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 06:55.


Fri Aug 6 06:55:36 UTC 2021 up 14 days, 1:24, 1 user, load averages: 2.41, 2.61, 2.70

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.