![]() |
[QUOTE=CRGreathouse;222444]Did you have something particular in mind?
You could get a small speedup by installing (possibly as a second OS rather than replacing your primary) some form of Linux, installing gp2c, running the script through gp2c, and hand-editing the C code to type-specialize, as well as to replace general functions with custom specific functions. But for this problem, most of the time is just spent proving primality, so there's no a whole lot to be done.[/QUOTE] is .5*c+/- n in there maybe we can find a way to speed it up with that info. |
[QUOTE=science_man_88;222446]is .5*c+/- n in there maybe we can find a way to speed it up with that info.[/QUOTE]
As always, I'm open to ideas. |
[QUOTE=CRGreathouse;222447]As always, I'm open to ideas.[/QUOTE]
i can't even get my original idea to work right lol: [CODE]forstep(c=2,100,[2],for(n=1,.5*c,if(isprime(.5*c+n) && isprime(.5*c-n),print(c))))[/CODE] gives a isprime error of not integer value in arithmetic function. |
[QUOTE]i can't even get my original idea to work right lol:[/QUOTE]
My original idea of the prime test let all the pseudoprimes pass. I somehow construed the Fermat test so that 11 is now occasionally marked off as a composite. Well, a * b = 11. a =?; b = ? Ideas: a = 5.5, b = 2. Resolved: Set base to 2. |
t=0;forstep(n=2,400000,[2],forprime(p=2,n/2,t+=isprime(n-p);if(t>0,break())))
this is a alteration of your quick code and performs to 400,000 in (94 ms I think is what i got) the other code took 1907 for a one time test if I looked up my stats properly. so that's about 2000% as fast. the limitation is the precomputed primes here though. I love this i tested repeatedly at 100,000 and 1,000,000 and the 100,000 always got 93-94 ms the 1000000 went as low as 891 and never to 940 so in the linear to sub-linear range(I say this because 94 overwhelmed 93 in the 100,000 test) and technically if we get around the precomputed prime thing in under about 1900% the time it takes now we can still have it faster than the other one. |
[QUOTE=3.14159;222455]My original idea of the prime test let all the pseudoprimes pass.
I somehow construed the Fermat test so that 11 is now occasionally marked off as a composite. Well, a * b = 11. a =?; b = ? Ideas: a = 5.5, b = 2. Resolved: Set base to 2.[/QUOTE] maybe you should get a test mode where they can pick the base and how far to test up. or maybe put a for loop around it to test one base at a time up to the given limit. |
[QUOTE]maybe you should get a test mode where they can pick the base and how far to test up.[/QUOTE]
This would only be useful for the Miller-Rabin test, as the Fermat test is weak to Carmichael numbers, which satisfy the test in every base except those that are its factors or multiples/powers of its factors. |
Also: If 6n+1, 12n+1, and 18n+1 are prime, (6n+1)(12n+1)(18n+1) = Carmichael number.
My best guess: (6n+1)(12n+1) = 72n^2 + 6n + 12n + 1 = 72n^2 + 18n + 1 (18n+1)(72n^2 + 18n + 1) = 1296n^3 + 72n^2 + 324n^2 + 18n + 18n + 1 That = 1296n^3 + 396n^2 + 36n + 1 Code!: [code]for(n=10^3,3*10^3,(1296n^3 + 396n^2 + 36n + 1),if(numdiv(1296n^3 + 396n^2 + 36n + 1) == 8,print(n))[/code] Refined to: [code]b(n) = { for(n=10^3,3*10^3,(1296n^3 + 396n^2 + 36n + 1, if(numdiv(1296n^3 + 396n^2 + 36n + 1) == 8,print(n))) ); }[/code] I need a bit of assistance here.. [code](13:20) gp > b(n) = { for(n = 10^3, 3*10^3,(1296*n^3 + 396*n^2 + 36*n + 1, if(numdiv(1296*n^3 + 396*n^2 + 36*n + 1) == 8, print(n))); }[/code] [code]*** syntax error, unexpected ')', expecting KPARROW or ',': ...*n^2+36*n+1)==8,print(n)));[/code] |
[CODE]b(n)=for(n=10^3,3*10^3,if(numdiv(1296*n^3+396*n^2+36*n+1)==8,print(n)));[/CODE] I got this to do nothing but no syntax errors lol
|
[QUOTE]I got this to do nothing but no syntax errors lol[/QUOTE]
That's something of an improvement. Keep working at it until PARI recognizes the command and obeys it. |
[QUOTE=science_man_88;222456]t=0;forstep(n=2,400000,[2],forprime(p=2,n/2,t+=isprime(n-p);if(t>0,break())))
this is a alteration of your quick code and performs to 400,000 in (94 ms I think is what i got) the other code took 1907 for a one time test if I looked up my stats properly. so that's about 2000% as fast.[/QUOTE] This code shows that there is some Goldbach partition for some even number up to 400000, not that every even number up to 400000 has a Goldbach partition. It's faster by doing far less. |
| All times are UTC. The time now is 04:47. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2021, Jelsoft Enterprises Ltd.