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

Odd behavior for for simple user defined functions

Open MKubullek opened this issue 2 years 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.

MKubullek avatar Dec 13 '23 13:12 MKubullek

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

MKubullek avatar Dec 13 '23 13:12 MKubullek

Also this one: https://github.com/JuliaDiff/TaylorDiff.jl/issues/61

lrnv avatar Mar 07 '24 19:03 lrnv

0.2.2 contains the fix and would be good for these functions

tansongchen avatar May 22 '24 19:05 tansongchen