![]() |
|
|
#1 |
|
"Matthew Anderson"
Dec 2010
Oregon, USA
11·109 Posts |
in the Maple isprime() command, they use 100#, that is the product of the first 100 primes, as a precheck. Then
they come back and use 1000#. Just for our edification, 100# is calculated, by me, in Maple, as Code:
4711930799906184953162487834760260422020574773409675520188634839616415335845034221205289256705544681972439104097777157991804380284218315038719444943990492579030720635990538452312528339864352999310398481791730017201031090 Regards, Matt MODERATOR NOTE: Please put [code] tags around long numbers. Last fiddled with by Dr Sardonicus on 2022-02-15 at 16:33 |
|
|
|
|
|
#2 |
|
Sep 2002
Database er0rr
10010010011012 Posts |
According to https://www.maplesoft.com/support/he...x?path=isprime (sic) is a probablistic test. I wonder if it is like Pari/GP's 1+2 Selfridges BPSW variation, called ispseudoprime()?
Last fiddled with by paulunderwood on 2022-02-15 at 16:07 |
|
|
|
|
|
#3 | |
|
Sep 2002
Database er0rr
111158 Posts |
Quote:
|
|
|
|
|
|
|
#4 | |
|
Feb 2017
Nowhere
13×17×29 Posts |
Quote:
BTW the product of the primes up to 541 (the first hundred primes) has 220 decimal digits. Generally, the product of the primes up to p has roughly p/log(10) decimal digits, where log() is the natural log. Meaningless curiosity: 541 is the 100th prime, and its index, 100, is one of the square summands in the expression of 541 as the sum of two squares, 541 = 100 + 441. Stop the presses!
|
|
|
|
|
|
|
#5 | |
|
Feb 2017
Nowhere
13×17×29 Posts |
Quote:
No, the real and complex numbers are definitely not forgotten. In algebraic number theory, the valuations, be they Archimedean or not, are all called "primes." The Archimedean valuations are called "infinite primes." See "Ostrowki's Theorem" and "product formula." |
|
|
|
|
|
|
#6 | ||
|
"Robert Gerbicz"
Oct 2005
Hungary
3×547 Posts |
Quote:
Likely they are doing some trial divisions also, and in that case this is a single Baillie–PSW primality test (https://en.wikipedia.org/wiki/Bailli...primality_test), and there is no known counter-example. Quote:
https://www.maplesoft.com/support/he....aspx?path=GMP https://www.wolfram.com/legal/third-...enses/gmp.html so for big numbers you won't get a faster test using these costly softwares. |
||
|
|
|
|
|
#7 | |
|
"Curtis"
Feb 2005
Riverside, CA
2×2,927 Posts |
Quote:
Lists of small primes are exactly this problem- they can be reproduced nearly instantly, so there is no point in publishing lists of them. If you want such lists, by all means collect them at home- but the files take up server space while providing use to exactly nobody (because anyone can generate them themselves rather than trusting someone else's code and / or virus-free-ness). Last fiddled with by VBCurtis on 2022-02-15 at 19:23 |
|
|
|
|
|
|
#8 | |
|
Sep 2002
Database er0rr
5·937 Posts |
Quote:
I find GMP's documentation of BPSW very confusing and I am trying to find its source code to see the implementation. Perhaps n-rounds of Miller-Rabin followed by the (2.X Selfridges) BPSW variant of mine: Mod(Mod(2*x),x^2-P*x+1)^((n+1)/2) ==2*kronecker(2*(P+2),n) with kronecker(P^2-4,n)==-1, P minimal, checked to 2^64 would be better than what GMP has done -- or even just a simple Lucas chain with Q=1. I suppose a few extra milliseconds is no big deal when you are trying to eliminate pseudoprimes. Last fiddled with by paulunderwood on 2022-02-15 at 22:41 |
|
|
|
|
|
|
#9 |
|
"Robert Gerbicz"
Oct 2005
Hungary
3·547 Posts |
For Mathematica:
"PrimeQ first tests for divisibility using small primes, then uses the Miller–Rabin strong pseudoprime test base 2 and base 3, and then uses a Lucas test." ref. https://reference.wolfram.com/langua...tion.html#6849 |
|
|
|
|
|
#10 |
|
"Matthew Anderson"
Dec 2010
Oregon, USA
11·109 Posts |
Thank you everybody for all the interest and inputs.
For those who are interested, get a load of this. Here is internal code for Maple's isprime() command. I use showstat(). Code:
> showstat(isprime);
%;
isprime := proc(n)
local btor, nr, p, r;
1 if not type(n,'integer') then
2 if type(n,('complex')('numeric')) then
3 error "argument must be an integer"
else
4 return 'isprime(n)'
end if
end if;
5 if n < 2 then
6 return false
elif member(n,isprime:-special_primes) then
7 return true
elif igcd(2305567963945518424753102147331756070,n) <> 1 then
8 return false
elif n < 10201 then
9 return true
elif igcd(8496969489233418110532339909187349965926062586648932736611545426342203893270769390909069477309509137509786917118668028861499333825097682386722983737962963066757674131126736578936440788157186969893730633113066478620448624949257324022627395437363639038752608166758661255956834630697220447512298848222228550062683786342519960225996301315945644470064720696621750477244528915927867113,n) <> 1 then
10 return false
elif n < 1018081 then
11 return true
else
12 r := gmp_isprime(n);
13 if not r or n <= 5000000000 then
14 return r
end if;
15 nr := igcd(408410100000,n-1);
16 nr := igcd(nr^5,n-1);
17 r := iquo(n-1,nr);
18 btor := modp(('power')(2,r),n);
19 if cyclotest(n,btor,2,r) = false or irem(nr,3) = 0 and cyclotest(n,btor,3,r) = false or irem(nr,5) = 0 and cyclotest(n,btor,5,r) = false or irem(nr,7) = 0 and cyclotest(n,btor,7,r) = false then
20 return false
end if;
21 if isqrt(n)^2 = n then
22 return false
end if;
23 for p from 3 while numtheory:-jacobi(p^2-4,n) <> -1 do
24 NULL
end do;
25 return evalb(TraceModQF(p,n+1,n) = [2, p])
end if
end proc
Now show isprime(n) in action. > isprime(7); true > isprime(8); false If you have read this far, then you get a grade of A+. Here is a summary of what isprime() does. 1. check for positive integer 2. If the number is less than 100, compare to a list. 3. check for divisors less than 100. (this uses the product of prime numbers less than 100 and integer greatest common divisor command (igcd) 4. check for divisors between 101 and 1,000. (again a hard coded, large, minimal, 1000-smooth number, and igcd().) oops, I know I stated this differently in a previous post, but I'm pretty sure I got it right this time. 5. More that one probable prime test. These separate tests probably don't overlap. It has been shown that if there are any counterexamples, that is, cases when the isprime function fails, they are > 10^100. You can take my word on that. There are academic papers where people have tested isprime(n) to some limit. They probably tested specially chosen n values, looking for a failure. If a number is found that causes isprime to fail, the software team at Maple will probably change their code, if only to patch the specific values that might, someday, be found. The GMP library is apparently used by Maple. Last fiddled with by MattcAnderson on 2022-02-16 at 08:35 Reason: give thanks to all, mention GMP library ( was C++), refined isprime() step 4 |
|
|
|
|
|
#11 |
|
Sep 2002
Database er0rr
5·937 Posts |
Thanks for that Matt. So it seems:
What I'd like to see is n*1+m*2 Selfridges, although the chance of failing any of the above implementations is highly remote. Last fiddled with by paulunderwood on 2022-02-16 at 08:46 |
|
|
|
![]() |
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Number of LLR tests completed so far? | ellipse | Twin Prime Search | 30 | 2021-03-18 10:19 |
| Twin Prime tests | mathPuzzles | Math | 10 | 2017-06-24 08:41 |
| Largest number of LL tests before matching residues achieved? | sdbardwick | Lounge | 1 | 2015-02-03 15:03 |
| Which hardware should I run my primorial prime tests on? | jasong | Hardware | 3 | 2006-11-23 05:17 |
| failing all prime tests, can any body help this nooby | madbullet | Hardware | 5 | 2005-06-12 03:10 |