-
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
Wrong hyperbolic tangent for argument >> 0 #37
Comments
TL;DRAs a work-around, set the DA cutoff value to zero (or something very small) by calling
Analysis
With large, but not yet overflowing arguments, the coefficients of DiscussionThis is another instance of the default DA epsilon (~1e-20) optimization causing unexpected issues. Initially this measure was introduced from COSY as a way to speed up a limited set of computations where
It is questionable how relevant this optimization is now in the "real world" where code is not specifically optimized for these conditions, and typical DA vectors are most of the time close to fully populated. Contributing to the problem is the lack of floating point exception handling in the DACE at the moment, as the library is not made for validated computing. This means overflows to infinity, and subsequent division by infinite values will silently produce zeros without error messages to the user. See separate ticket #38. Partial SolutionA DA epsilon value close to the floating point underflow limit (~ 1e-308) or zero to prevent flushing small but valid coefficients should be made the permanent (safe) default within the DACE, with the potentially unsafe optimization having to be enabled by the user explicitly through The above will fix While that solves the immediate problem at hand, it just moves the underlying cause from the DACE library into user code where similar overflow issues might arise depending on how a user implements their equations. A correct solution requires more careful consideration of how to handle floating point exceptions in the DACE which is much harder to do correctly (see ticket #38). |
Previous commit should fix the issue by changing NaN and Inf handling as well as implementing an improved algorithm for tanh that works for full argument range. |
Computing the hyperbolic tangent of a
DA
object with constant part|c0|>>0
returns always zero. The correct behaviour would be+1
forc0
that goes to plus infinity and-1
forc0
that goes to minus infinity.Examples:
DACE::DA x = 100 + DACE::DA(1)
x.tanh() --> 0
but should be1
DACE::DA x = -100 + DACE::DA(1)
x.tanh() --> 0
but should be-1
The text was updated successfully, but these errors were encountered: