JuliaDiff / TaylorDiff.jl

Taylor-mode automatic differentiation for higher-order derivatives

Home Page:https://juliadiff.org/TaylorDiff.jl/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Odd behavior for for simple user defined functions

CaptainKubi opened this issue · comments

The derivative function behaves really odd for simple user defined function.
If I define two simple functions as follows

julia> f(x) = x*x
julia> h(x) = x^2

then the first order derivatives a 0.0 only gives the correct result for f(x).

julia> derivative(f, 0.0, 1)
0.0
julia> derivative(h, 0.0, 1)
NaN

Oddly, if the derivative is evaluated at 1.0 both functions work as expected.

julia> derivative(f, 1.0, 1)
2.0
julia> derivative(h, 1.0,1)
2.0

I tested this on v0.2.1.

I was hoping to use TaylorDiff to calculate higher order derivatives for Sellmeier Equations. But it also seems to fail for these in a not easy to understand way.

This apparantly was already addressed in #33.
However it seems it is not part of the currently available latest version.

Also this one: #61

0.2.2 contains the fix and would be good for these functions