Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

A PARI bug results in an unreliable prime_pi #3658

Closed
sagetrac-fwclarke mannequin opened this issue Jul 15, 2008 · 6 comments
Closed

A PARI bug results in an unreliable prime_pi #3658

sagetrac-fwclarke mannequin opened this issue Jul 15, 2008 · 6 comments

Comments

@sagetrac-fwclarke
Copy link
Mannequin

sagetrac-fwclarke mannequin commented Jul 15, 2008

----------------------------------------------------------------------
| 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.

Component: number theory

Issue created by migration from https://trac.sagemath.org/ticket/3658

@sagetrac-fwclarke sagetrac-fwclarke mannequin added this to the sage-3.4.1 milestone Jul 15, 2008
@craigcitro
Copy link
Member

comment:1

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.

@boothby
Copy link

boothby commented Jan 24, 2009

comment:3

works for me

@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented Jan 24, 2009

comment:4

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

@craigcitro
Copy link
Member

Attachment: trac-3658.patch.gz

@craigcitro craigcitro changed the title A PARI bug results in an unreliable prime_pi [needs quick review] A PARI bug results in an unreliable prime_pi Jan 24, 2009
@boothby
Copy link

boothby commented Jan 24, 2009

comment:6

+1

@boothby boothby changed the title [needs quick review] A PARI bug results in an unreliable prime_pi A PARI bug results in an unreliable prime_pi Jan 24, 2009
@sagetrac-mabshoff
Copy link
Mannequin

sagetrac-mabshoff mannequin commented Jan 24, 2009

comment:7

Merged in Sage 3.3.alpha2.

Cheers,

Michael

@sagetrac-mabshoff sagetrac-mabshoff mannequin closed this as completed Jan 24, 2009
vbraun pushed a commit to vbraun/sage that referenced this issue Jun 16, 2024
    
Discovered by tornaria [here](sagemath#3658
1/files/5c51f54b1a193c3f9964da3e1388efd87623d45c#r1575566025).

Sorry for the incorrect implementation! Please merge this quickly,
before the next beta (I think).
    
URL: sagemath#38209
Reported by: grhkm21
Reviewer(s): Travis Scrimshaw
vbraun pushed a commit to vbraun/sage that referenced this issue Jun 16, 2024
    
Discovered by tornaria [here](sagemath#3658
1/files/5c51f54b1a193c3f9964da3e1388efd87623d45c#r1575566025).

Sorry for the incorrect implementation! Please merge this quickly,
before the next beta (I think).
    
URL: sagemath#38209
Reported by: grhkm21
Reviewer(s): Travis Scrimshaw
vbraun pushed a commit to vbraun/sage that referenced this issue Jun 17, 2024
    
Discovered by tornaria [here](sagemath#3658
1/files/5c51f54b1a193c3f9964da3e1388efd87623d45c#r1575566025).

Sorry for the incorrect implementation! Please merge this quickly,
before the next beta (I think).
    
URL: sagemath#38209
Reported by: grhkm21
Reviewer(s): Travis Scrimshaw
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants