mersenneforum.org

mersenneforum.org (https://www.mersenneforum.org/index.php)
-   PARI/GP (https://www.mersenneforum.org/forumdisplay.php?f=155)
-   -   PARI's commands (https://www.mersenneforum.org/showthread.php?t=13636)

3.14159 2010-08-11 19:05

[QUOTE=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.)
[/QUOTE]

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))));[/code]

Now, it gives the expected returns. I saved that into the text file of all the defined functions.

CRGreathouse 2010-08-11 19:07

[QUOTE=science_man_88;224957]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[/QUOTE]

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=science_man_88;224957]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.[/QUOTE]

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 2010-08-11 19:08

[QUOTE=3.14159;224958]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))));[/code]

Now, it gives the expected returns. I saved that into the text file of all the defined functions.[/QUOTE]

Glad to hear it.

3.14159 2010-08-11 19:11

[QUOTE=CRGreathouse]Glad to hear it.
[/QUOTE]

Now, using that function, I can modify the code to include as many bases as I'd like for it to be pseudoprime to.

CRGreathouse 2010-08-11 19:13

[QUOTE=3.14159;224963]Now, using that function, I can modify the code to include as many bases as I'd like for it to be pseudoprime to.[/QUOTE]

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?

3.14159 2010-08-11 19:15

[QUOTE=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?
[/QUOTE]


*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(10[sup]6[/sup]) 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.)

CRGreathouse 2010-08-11 19:18

[QUOTE=3.14159;224967]*facepalm* isPRP is a strong pseudoprimality test.[/QUOTE]

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)[/code]
a probable primality test would be
[code]isPRP_correct(n,b)=Mod(b,n)^(n-1)==1[/code]
and a pseudoprime test would be
[code]isPSP(n,b)=isPRP_correct(n,b)&&!isprime(n)[/code]

3.14159 2010-08-11 19:20

[QUOTE=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
[/QUOTE]

[B]So you're calling me a liar? Prove that I am a liar. [/B]

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

CRGreathouse 2010-08-11 19:26

[QUOTE=3.14159;224967]*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(10[sup]6[/sup]) and uses a random base.[/QUOTE]

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=3.14159;224967]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.)[/QUOTE]

If you really want to be pedantic about it, Carmichael numbers don't always pass isWPRP -- they only pass it [TEX]\varphi(n)[/TEX] 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 2010-08-11 19:28

[QUOTE=3.14159;224969][B]So you're calling me a liar? Prove that I am a liar. [/B][/QUOTE]

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=3.14159;224969]I suggest that you refresh before reply, as I was in the middle of refining the post, and retract the nonsense accusation.[/QUOTE]

Please refine your posts before posting.

3.14159 2010-08-11 19:31

[QUOTE=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.
[/QUOTE]

[B]isSPRP[/B]? Isn't the meaning a bit self-evident there?

[QUOTE=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.[/QUOTE]

Done.


All times are UTC. The time now is 22:21.

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