primes -- enhancement request

89 views
Skip to first unread message

Peter Luschny

unread,
Mar 12, 2019, 7:25:12 AM3/12/19
to sage-support
ValueError: Cannot compute primes beyond 436273290

I think SageMath should do better.

Cheers, Peter


/opt/sagemath-8.4/local/lib/python2.7/site-packages/sage/rings/fast_arith.pyx in sage.rings.fast_arith.prime_range (build/cythonized/sage/rings/fast_arith.c:3390)()
     46 from sage.rings.integer cimport Integer
     47 
---> 48 cpdef prime_range(start, stop=None, algorithm="pari_primes", bint py_ints=False):
     49     r"""
     50     List of all primes between start and stop-1, inclusive.  If the

/opt/sagemath-8.4/local/lib/python2.7/site-packages/sage/rings/fast_arith.pyx in sage.rings.fast_arith.prime_range (build/cythonized/sage/rings/fast_arith.c:2946)()
    145             # Adding 1500 should be sufficient to guarantee an
    146             # additional prime, given that c_stop < 2^63.
--> 147             pari.init_primes(c_stop + 1500)
    148             assert maxprime() >= c_stop
    149 

cypari2/pari_instance.pyx in cypari2.pari_instance.Pari.init_primes()

John Cremona

unread,
Mar 12, 2019, 7:44:43 AM3/12/19
to SAGE support
You did not say what command you were using.  The documentation for both primes() and prime_range() show examples with much larger primes.

John Cremona


--
You received this message because you are subscribed to the Google Groups "sage-support" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-support...@googlegroups.com.
To post to this group, send email to sage-s...@googlegroups.com.
Visit this group at https://groups.google.com/group/sage-support.
For more options, visit https://groups.google.com/d/optout.

Peter Luschny

unread,
Mar 12, 2019, 11:12:11 AM3/12/19
to sage-support
You did not say what command you were using. 

Oh, I thought that was clear from the error message: prime_range. 
The function (implementing the factorial) is on GitHub .

David Joyner

unread,
Mar 12, 2019, 11:17:07 AM3/12/19
to SAGE support
You need to add the option "pari_isprime":

sage: prime_range(436273291,436273299,algorithm="pari_isprime")
[436273291]

Peter Luschny

unread,
Mar 12, 2019, 4:57:31 PM3/12/19
to sage-support
You need to add the option "pari_isprime":

Thank you!

Since the documentation says "large", and "not too large"
and "much larger" but does not say what "large" means I 
include a table which reflects my use case. On the other
hand I have no idea whether or not these bounds depend on
available memory. 

              "pari_primes" "pari_isprime", penalty 
stop = 10^3, time=  0.001s, time=   0.002s, quot=2.00
stop = 10^4, time=  0.007s, time=   0.019s, quot=2.71
stop = 10^5, time=  0.104s, time=   0.168s, quot=1.62
stop = 10^6, time=  1.118s, time=   1.505s, quot=1.35
stop = 10^7, time= 14.997s, time=  19.069s, quot=1.27
stop = 10^8, time=181.411s, time= 225.244s, quot=1.24
stop = 10^9, crash,         time=3002.783s.

Reply all
Reply to author
Forward
0 new messages