-
Notifications
You must be signed in to change notification settings - Fork 30
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
Using a strong zero in Dual(0.0, 1)^0 to avoid NaN #84
Conversation
Shouldn't this also work for julia> 0.0^0.0
1.0
julia> h = 0.000001; ((0+h)^0.0 - 0.0^0.0)/h
0.0 Also make sure there are tests for |
Pleases and thank yous go a long way. |
For reference, this is a longstanding and known issue, see https://github.com/JuliaDiff/ForwardDiff.jl/blob/3fb16ac21ac06b7c42c807e898395ad3bd9f54ae/docs/src/user/advanced.md#fixing-naninf-issues. I guess DualNumbers isn't especially focused on performance, so the 5%-10% overhead may be acceptable. |
Why? julia> 0^0
1
julia> (0+eps())^0
1.0 |
In the previous implementation I've also fixed the type instability of |
Is there anything remaining that needs to be done before this is merged (other than semver bump)? |
Pleas do the semvar bump |
I found another minor bug-ette:
The behaviour from this PR gives:
What do you reckon?