Opened 14 years ago

Closed 13 years ago

#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: Merged in:
Authors: Reviewers:
Report Upstream: Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

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 (1)

trac-3658.patch (2.3 KB) - added by craigcitro 13 years ago.

Download all attachments as: .zip

Change History (8)

comment:1 Changed 13 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

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.

comment:2 Changed 13 years ago by craigcitro

  • Milestone changed from sage-3.4.1 to sage-3.3

comment:3 Changed 13 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 13 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

Changed 13 years ago by craigcitro

comment:5 Changed 13 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

comment:6 Changed 13 years ago by boothby

  • Summary changed from [with patch, needs quick review] A PARI bug results in an unreliable prime_pi to [with patch, positive review] A PARI bug results in an unreliable prime_pi

+1

comment:7 Changed 13 years ago by mabshoff

  • Resolution set to fixed
  • Status changed from assigned to closed

Merged in Sage 3.3.alpha2.

Cheers,

Michael

Note: See TracTickets for help on using tickets.