-
-
Notifications
You must be signed in to change notification settings - Fork 10.8k
numpy.tanh
gives different results on Windows and Linux
#9187
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
Comments
What does |
In general, numpy doesn't attempt to provide exactly the same results on different platforms. It's essentially impossible for floating point code. Even two different builds with the same compiler can give slightly different results depending on optimization level. In this case we're using the platform-provided One thing we can do if some platform's |
@njsmith Ok, got it that it's caused by the platform-provided functions. The results are usually far off by one ULP. Got some differences in the I'm solving this by using Just to let you know that perhaps it would be nice if |
Just a curiosity: in these examples, for |
1 ulp differences are definitely expected and ordinary. Using MKL is not a general solution either; e.g., even for trivial floating point calculations like Usually the best (and certainly most common) solution is to write your code so that it doesn't care about 1 ulp differences. |
Here is one example: the result for
tanh(-0.35898351519709742)
is-0.34431837261747228
on Linux and-0.34431837261747222
on Windows. Windows have the most approximate result.The text was updated successfully, but these errors were encountered: