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
(1/(1006987929*pi - 3163545880)).n() raises division by zero error #21788
Comments
comment:1
It works with digits provided the number is big enough
The default precision is 253 which is roughly 16 digits in base 10. |
comment:2
You can also see that
|
comment:3
But
|
comment:5
This is just one of these border cases. The only thing you can do atm is raising precision, which just sets the bar higher. The only real solution would be to recognize that pi is irrational and raise the precision automatically. Drawback is that it could become slow. |
comment:6
Replying to @videlec:
Do you want infinity returned in this case too? I'll open a ticket if so. |
comment:8
Replying to @rwst:
+1. |
comment:9
Maybe I created that ticket too fast: I wrongly thought that inputs given to Maybe that ticket could be closed as won't fix. Or maybe this ticket goal could be to improve the documentation of
|
comment:10
Replying to @seblabbe:
Correct me but there is no way to get more precision out of operations with numbers of smaller precision, so the precision value is needed from the start.
Yes, and I think the division by zero |
comment:11
Replying to @rwst:
The only thing that I would correct in the last sentence is : "so some high enough precision is needed from the start". Maybe this is not what we want for sage: def high_enough_precision(X, desired_prec):
....: prec = desired_prec
....: while -log(RealIntervalField(prec)(X).diameter(),2) < desired_prec:
....: prec +=1
....: return prec
....:
sage: high_enough_precision(pi, 53)
54
sage: high_enough_precision(pi-3.14, 53)
65
sage: B = (1/(1006987929*pi - 3163545880))
sage: high_enough_precision(B, 53)
108 Then, using 108 bits of precision in the internal computations really gives 53 bits of precision for the output: sage: RealIntervalField(108)(B)
3.238995427802206?e6
sage: B.n(digits=50)
3.2389954278022058869923921595406901102762355827180e6
Yes, it might be an intermediate solution. Because sometimes there is no |
As reported on sage-devel, using 7.4.beta6, I get
But providing digits works:
Maybe also related:
CC: @paulmasson
Component: numerical
Issue created by migration from https://trac.sagemath.org/ticket/21788
The text was updated successfully, but these errors were encountered: