-
Notifications
You must be signed in to change notification settings - Fork 16
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
Precision issues of isotope_qty #358
Comments
@cosama the tricky part is using mpmath with the uncertainties package |
Could we use the standard library import decimal
import numpy as np
a = decimal.Decimal(100)
decimal.getcontext().prec = 30
print(a)
print(np.exp(a))
print(np.exp(float(a)))
And it avoids overflow/underflow: a = decimal.Decimal(1000)
print(a)
print(np.exp(a))
print(np.exp(float(a)))
a = decimal.Decimal(-1000)
print(a)
print(np.exp(a))
print(np.exp(float(a)))
(For reference, WolframAlpha gives |
I agree a Decimal would work. I somehow thought Decimal are Fraction. Looks like Decimals are also faster than
while
|
The isotope quantity module does two things that are not great for numerical precision: It subtracts two very large numbers or multiplies very large numbers with very small once.
It is hard to get this right and the best (only?) way would be to move the internals to https://github.com/fredrik-johansson/mpmath.
Shouldn't be to much of a lift.
The text was updated successfully, but these errors were encountered: