-
Notifications
You must be signed in to change notification settings - Fork 64
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
Small example with different values when using PyPI symengine
and shared library
#476
Comments
Can you do |
# PyPI package
print(expr1, expr2)
# 1000000.0*f 1000000*f
# Arch packages
print(expr1, expr2)
# 1000000.0*f 1000000*f There is no visible difference here, only later when substituting the symbol. |
I think the difference is already visible here: float(expr1.args[0])
# 999999.9999999998 |
Interesting! The difference between |
Yes, exactly, but if there is any rounding error it should be in the 14 or 15 digit, not in the 10th. Were you able to replicate the issue on your side? There are the flags used by Arch Linux to compile
I can start to disable libraries to check if some of them are causing the issue. Any other ideas? |
No, I couldn't reproduce it, but I only tried with my installation. Could you try the following using the "bad" symengine version?
|
That works as expected: RealDouble(1000000000.0) / Integer(1000) * RealDouble(3.14)
# 3140000.0 |
Oh, I think the problem is with from symengine import *
float(Rational(1, 1000))
# 0.0009999999999999998 So the expr = f / 1000
float(expr.subs("f", 1))
# 0.0009999999999999998 This works even if the factor is a float: expr = f * 1e-3
float(expr.subs("f", 1))
# 0.001 |
I recently noticed a numerical difference when using the
symengine
wheel package from PyPI and the one provided by Arch Linux. This leads to aqiskit
unit test to fail.Here is a small example :
I can imagine it is not a good practice to do
expr * 1e9
in the first place, but is this documented somewhere?And why if I manually create the expression I get the correct result? I.e.,
The text was updated successfully, but these errors were encountered: