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

CC -> PARI: return t_REAL for real numbers #15888

Closed
jdemeyer opened this issue Mar 5, 2014 · 11 comments
Closed

CC -> PARI: return t_REAL for real numbers #15888

jdemeyer opened this issue Mar 5, 2014 · 11 comments

Comments

@jdemeyer
Copy link

jdemeyer commented Mar 5, 2014

When converting Sage complex numbers to PARI, we should return a PARI t_REAL if the original number was actually real. This fixes a problem with ellwp() in #15767. In PARI's floating point model, the number 1e-19 + 0.0*I has less precision than the real 1e-19.

It is also consistent with the PARI philosophy of returning simplified types (examples: (1.1*I)^2 and ellj(1.1*I) in PARI gives real numbers).

CC: @pjbruin

Component: interfaces

Author: Jeroen Demeyer

Branch/Commit: 7067299

Reviewer: Peter Bruin

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

@jdemeyer jdemeyer added this to the sage-6.2 milestone Mar 5, 2014
@jdemeyer
Copy link
Author

jdemeyer commented Mar 5, 2014

Branch: u/jdemeyer/ticket/15888

@jdemeyer
Copy link
Author

jdemeyer commented Mar 5, 2014

New commits:

988c1f8Improve conversion of complex numbers to PARI

@jdemeyer
Copy link
Author

jdemeyer commented Mar 5, 2014

Commit: 988c1f8

@pjbruin
Copy link
Contributor

pjbruin commented Mar 5, 2014

comment:3

It would seem to make sense to treat purely imaginary numbers similarly, by setting the real component to the t_INT 0, as PARI does. With your patch,

sage: pari(CC(1))
1.00000000000000
sage: pari(CC(I))
0.E-19 + 1.00000000000000*I
sage: _.debug()
[&=0000000004a45468] COMPLEX(lg=3):0c00000000000003 0000000004a45458 0000000004a45440 
  real = [&=0000000004a45458] REAL(lg=2):0400000000000002 (0,expo=-64):1fffffffffffffc0 
  imag = [&=0000000004a45440] REAL(lg=3):0400000000000003 (+,expo=0):6000000000000000 8000000000000000 
sage: pari('1.0*I')
1.00000000000000*I
sage: _.debug()
[&=000000000332b280] COMPLEX(lg=3):0c00000000000003 000000000332b270 000000000332b250 
  real = [&=000000000332b270] INT(lg=2):0200000000000002 (0,lgefint=2):0000000000000002 
  imag = [&=000000000332b250] REAL(lg=4):0400000000000004 (+,expo=0):6000000000000000 8000000000000000 0000000000000000 

@jdemeyer
Copy link
Author

jdemeyer commented Mar 6, 2014

Reviewer: Peter Bruin

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 6, 2014

Changed commit from 988c1f8 to d6fdd0c

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 6, 2014

Branch pushed to git repo; I updated commit sha1. New commits:

d6fdd0cCC->PARI: convert purely imaginary numbers to t_COMPLEX with real part exactly 0

@pjbruin
Copy link
Contributor

pjbruin commented Mar 6, 2014

comment:7

There are a few doctest failures:

File "src/sage/schemes/elliptic_curves/heegner.py", line 3154, in sage.schemes.elliptic_curves.heegner.HeegnerPointOnEllipticCurve.numerical_approx
Failed example:
    P.numerical_approx()
Expected:
    (-6.68...e-16 + 1.41421356237310*I : 1.00000000000000 - 1.41421356237309*I : 1.00000000000000)
Got:
    (-6.67918322963967e-16 + 1.41421356237310*I : 1.00000000000000 - 1.41421356237309*I : 1.00000000000000)
**********************************************************************
File "src/sage/libs/pari/gen.pyx", line 4835, in sage.libs.pari.gen.gen.tan
Failed example:
    pari(i).tan()
Expected:
    0.E-19 + 0.761594155955765*I
Got:
    0.761594155955765*I
**********************************************************************
File "src/sage/libs/pari/gen.pyx", line 4855, in sage.libs.pari.gen.gen.tanh
Failed example:
    z = pari(i); z
Expected:
    0.E-19 + 1.00000000000000*I
Got:
    1.00000000000000*I
**********************************************************************
File "src/sage/libs/pari/gen.pyx", line 4940, in sage.libs.pari.gen.gen.weber
Failed example:
    pari(i).weber(1)
Expected:
    1.09050773266526 + 0.E-19*I
Got:
    1.09050773266526
**********************************************************************

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 6, 2014

Branch pushed to git repo; I updated commit sha1. New commits:

7067299CC->PARI conversion: fix doctest failures

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Mar 6, 2014

Changed commit from d6fdd0c to 7067299

@vbraun
Copy link
Member

vbraun commented Mar 13, 2014

Changed branch from u/jdemeyer/ticket/15888 to 7067299

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