Here is the MWE:
using ForwardDiff
using SpecialFunctions
log_i0(z::Number) = besseli(0,z) |> log
ForwardDiff.jacobian(x -> log_i0.(x), [1.1, 2.2, 3.3])
REPL output:
ERROR: LoadError: StackOverflowError:
Stacktrace:
[1] besselix(nu::Int64, x::ForwardDiff.Dual{ForwardDiff.Tag{var"#8#9", Float64}, Float64, 3}) (repeats 79984 times)
@ SpecialFunctions ~/.julia/packages/SpecialFunctions/NBIqR/src/bessel.jl:583
in expression starting at (...)
Interestingly,
ForwardDiff.jacobian(x -> log.(besseli.(0, x)), [1.1, 2.2, 3.3])
works great. Am I missing something super-obvious here? (My honest apologies if I am.)
Environment:
- Julia Version 1.6.2
- SpecialFunctions v1.8.1
- ForwardDiff v0.10.23