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

Extra precision hidden #168

Open
user202729 opened this issue Nov 21, 2024 · 2 comments
Open

Extra precision hidden #168

user202729 opened this issue Nov 21, 2024 · 2 comments

Comments

@user202729
Copy link

Looks like pari real objects are always displayed to ≈ 15 digits of precision regardless of internal precision:

sage: pari(RealField(100)(sqrt(2)))
1.41421356237310
sage: pari(RealField(300)(sqrt(2)))
1.41421356237310

internally stored precision can be seen to be higher:

sage: pari(RealField(100)(sqrt(2)))^2-2
-1.47595429215023 E-30
sage: pari(RealField(300)(sqrt(2)))^2-2
1.27815007960614 E-90
@tornaria
Copy link
Contributor

Indeed, pari has a "default display precision":

sage: pari.default("realprecision")
15
sage: pari(RealField(100)(sqrt(2)))
1.41421356237310
sage: pari.default("realprecision", 100)
sage: pari(RealField(100)(sqrt(2)))
1.41421356237309504880168872420917624993
sage: pari(RealField(335)(sqrt(2)))
1.414213562373095048801688724209698078569671875376948073176679737990732478462107038850387534327641573

Note that it won't print 100 digits if the precision of the object is smaller. Note also that the internal precision is stored in bits and a multiple of 64 bits:

sage: pari.default("realprecision", 100)
sage: pari.default("realprecision")
115
sage: pari.default("realbitprecision")
384
sage: pari.default()
[...]
   realbitprecision = 384 significant bits (100 decimal digits displayed)
   realprecision = 115 significant digits (100 digits displayed)
[...]

@user202729
Copy link
Author

I see.

Then the next question is whether this behavior is desirable? On one hand it is consistent with pari's default display precision, on the other hand we're using pari from inside sage, so it should conform to sage's convention.

Looking at RealField having everything displayed by default, maybe pari should follow that. Or at least have a global flag that configures the setting.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants