TaylorDiff.jl icon indicating copy to clipboard operation
TaylorDiff.jl copied to clipboard

Odd behavior for for simple user defined functions

Open CaptainKubi opened this issue 6 months ago • 2 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.

CaptainKubi avatar Dec 13 '23 13:12 CaptainKubi