mersenneforum.org  

Go Back   mersenneforum.org > Great Internet Mersenne Prime Search > Software

Reply
 
Thread Tools
Old 2019-07-15, 19:37   #1
neomacdev
 
Apr 2019

2×11 Posts
Default Question about Sage's is_pseudoprime() function (Baillie-PSW)

Hi,

The is_pseudoprime() function in Sage apparently uses the Baillie-PSW probabilistic primality test. (I've read a lot about primality tests, etc, in the last 6-8 months, but haven't paid much attention to the probabilistic tests.) I've noticed that this is_pseudoprime() function sometimes returns very fast even for LARGE (million+ digit) numbers. However, sometimes it seems to never return.

For example, I wanted to test / sieve a bunch of numbers that are around three-quarters of a million digits long using a probabilistic primality test. And sometimes the is_pseudoprime() function returns basically immediately, but for other input numbers I've let it run for 6 or 8 hours and it never returns. I don't know if this is a problem in Sage, where it is hanging. Or if this Baillie-PSW probabilistic primality test algorithm itself is actually taking 6+ hours to run on a 0.75+ million digit number.

Can anyone shed any light on this for me?

One example of a number I am trying to do a probabilistic primality test on, where Sage's is_pseudoprime() didn't return after 6+ hours of running.

#-----------------------------------------------------------------------------------------------------------------------

import datetime

n = 6 * Integer(2618163402417*2^1290001-1) * Integer(4547148564885*2^1290000-1) + 1

print "# of digits in n: ", len(str(n))
print "begin Baillie–PSW primality test at", str(datetime.datetime.now())

if n.is_pseudoprime() == false:
print "composite"
else:
print "maybe prime"

print "end Baillie–PSW primality test at", str(datetime.datetime.now())
print "done"

#-----------------------------------------------------------------------------------------------------------------------
neomacdev is offline   Reply With Quote
Old 2019-07-15, 20:42   #2
paulunderwood
 
paulunderwood's Avatar
 
Sep 2002
Database er0rr

3,739 Posts
Default

Does Sage use FFT multiplication? It is a must for such large numbers. Note that BPSW is 1+3 or 1+2 "selfridges" depending on the implementation, where 1 selfridge is the time taken to do a PRP test.
paulunderwood is online now   Reply With Quote
Old 2019-07-15, 21:05   #3
neomacdev
 
Apr 2019

2×11 Posts
Default

Quote:
Originally Posted by paulunderwood View Post
Does Sage use FFT multiplication? It is a must for such large numbers. Note that BPSW is 1+3 or 1+2 "selfridges" depending on the implementation, where 1 selfridge is the time taken to do a PRP test.
Sage certainly has fast multiplication routines. Although I don't know if those routines are being used for the multiplications done as part of the is_pseudoprime() function (Baillie-PSW test).
neomacdev is offline   Reply With Quote
Old 2019-07-15, 23:22   #4
paulunderwood
 
paulunderwood's Avatar
 
Sep 2002
Database er0rr

3,739 Posts
Default

At 0.75M+ digits use a 1 selfridge PRP test using PFGW and for added peace of mind use its "-tc" (combined tests) to test Fermat+Lucas. It will be much quicker than Sage.

I can only think Sage is either not using FFT or its FFT is much slower than Woltman's. (GWNUM is used in PFGW.)

Sage most likely does some trial division in its is_pseudpirme test. Hence the quick return for some numbers.

Last fiddled with by paulunderwood on 2019-07-15 at 23:24
paulunderwood is online now   Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Program for Sage enzocreti enzocreti 18 2018-12-06 05:34
A useful function. JM Montolio A Miscellaneous Math 28 2018-03-08 14:29
phi function rula Homework Help 3 2017-01-18 01:41
Elliptic-curve L-function question fivemack Math 0 2010-08-22 14:52
Baillie-PSW Primality Test flouran Math 0 2009-05-16 18:27

All times are UTC. The time now is 23:26.


Fri Jul 16 23:26:19 UTC 2021 up 49 days, 21:13, 1 user, load averages: 1.15, 1.42, 1.57

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.