Ticket #3658 (closed defect: fixed)
[with patch, positive review] A PARI bug results in an unreliable prime_pi
| Reported by: | fwclarke | Owned by: | craigcitro |
|---|---|---|---|
| Priority: | minor | Milestone: | sage-3.3 |
| Component: | number theory | Keywords: | |
| Cc: | Work issues: | ||
| Report Upstream: | Reviewers: | ||
| Authors: | Merged in: | ||
| Dependencies: | Stopgaps: |
Description
---------------------------------------------------------------------- | SAGE Version 3.0.5, Release Date: 2008-07-11 | | Type notebook() for the GUI, and license() for information. | ---------------------------------------------------------------------- sage: [prime_pi(n) for n in [500508..500510]] [41580, 45056, 41581] sage: [prime_pi(n) for n in [500508..500510]] [41580, 41581, 41581]
The problem lies with pari/gp:
sage: %gp --> Switching to GP/PARI interpreter <-- '' gp: for(n=500508, 500510, print(primepi(n))) 41580 45056 *** primepi: not enough precomputed primes, need primelimit ~ 500510.
Attachments
Change History
comment:1 Changed 4 years ago by craigcitro
- Owner changed from was to craigcitro
- Status changed from new to assigned
- Summary changed from A PARI bug results in an unreliable prime_pi to [with patch, needs review] A PARI bug results in an unreliable prime_pi
comment:3 Changed 4 years ago by boothby
- Summary changed from [with patch, needs review] A PARI bug results in an unreliable prime_pi to [with patch, positive review] A PARI bug results in an unreliable prime_pi
works for me
comment:4 Changed 4 years ago by mabshoff
- Summary changed from [with patch, positive review] A PARI bug results in an unreliable prime_pi to [with patch, needs work] A PARI bug results in an unreliable prime_pi
On sage.math: oops:
sage -t -long "devel/sage/sage/libs/pari/gen.pyx"
**********************************************************************
File "/scratch/mabshoff/sage-3.3.alpha2/devel/sage/sage/libs/pari/gen.pyx", line 7400:
sage: pari._primelimit()
Expected:
500000
Got:
500519
**********************************************************************
Cheers,
Michael
comment:5 Changed 4 years ago by craigcitro
- Summary changed from [with patch, needs work] A PARI bug results in an unreliable prime_pi to [with patch, needs quick review] A PARI bug results in an unreliable prime_pi
Note: See
TracTickets for help on using
tickets.


The attached patch fixes the issue. This was a strange case -- in some cases, Pari is more than happy to return an (incorrect!) answer when you call primepi with a number larger than the prime limit. This patch fixes this in a uniform way.