-
Notifications
You must be signed in to change notification settings - Fork 67
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
Symbolic differentiation is failed at specific value #27
Comments
@gbaydin @barak I took a look at fixing this more out of curiosity than anything else. Is adding the conditional check the right fix? https://github.com/DiffSharp/DiffSharp/pull/31/files#diff-419be3dee4710aa72c56268abcf97b05L63 |
The issue is the x**y is continuous and differentiable except at (x,y)=(0,0). But the equation needs to be special-cased for some of the cases x=0 or y=0. Depending on which is "active", to save unnecessary computation. This is done reasonably carefully in the "FAD" package for Haskell, as I recall. |
See lines 382 and following in https://github.com/NUIM-BCL/fad/blob/master/Numeric/FAD.hs |
OK, thx |
Actually looking at that Haskell FAD code again, the division by x on line 391 is wrong when x==0. Needs special cases for that as well, basically x^(n-1) cannot be calculated as (x^n)/x when x==0, so even when x^n is in hand one needs to calculate x^(n-1) from scratch. In the FAD context, this is a particular issue when x is not just a dual number, but an infinite power series, as is often the case there. I suppose the right thing in that context is to first calculate x^(n-1) and then multiply it by x to get x^n. This is the kind of fiddly numerics that makes me avoid numeric analysis... |
Closing because this is out of date for DiffSHarp 1.x, which is currently planned to be AD only |
Hi,
Symbolic differentiation of power operator (**) is failed at 0.0 .
The text was updated successfully, but these errors were encountered: