JuliaDiff / TaylorDiff.jl

Taylor-mode automatic differentiation for higher-order derivatives
https://juliadiff.org/TaylorDiff.jl/
MIT License
73 stars 8 forks source link

Powers w/ 0 constant term returns NaN #33

Closed agerlach closed 1 year ago

agerlach commented 1 year ago
x0 = 0.0
order = 10
td = TaylorScalar{typeof(x0), order}(x0, one(x0));
td*td  # TaylorScalar{Float64, 4}((0.0, 0.0, 2.0, 0.0))
td^2   # TaylorScalar{Float64, 4}((0.0, NaN, NaN, NaN))

Divide by 0 when you have a 0 constant term: https://github.com/JuliaDiff/TaylorDiff.jl/blob/126af68485fbcd3e516febfa9ba4d5be0bbe3c7d/src/primitive.jl#L140

tansongchen commented 1 year ago

Yes this is a bug... didn't consider the case that we have a 0 on zeroth order. May need to add as a special case

tansongchen commented 1 year ago

Fix in #57