Skip to content

StackOverflowError when applying ForwardDiff.derivative to scaled bessel functions, e.g. besseljx #412

@morgan-mitchell

Description

@morgan-mitchell

I am getting a StackOverflowError when I attempt to compute the derivative of besselix using ForwardDiff. This seems to induce besselix to call itself recursively ad infinitum:

julia> ForwardDiff.derivative(x->besselix(0,x),1.)
ERROR: StackOverflowError:
Stacktrace:
 [1] besselix(nu::Int64, x::ForwardDiff.Dual{ForwardDiff.Tag{var"#664#665", Float64}, Float64, 1}) (repeats 79984 times)
   @ SpecialFunctions ~/.julia/packages/SpecialFunctions/FhmL1/src/bessel.jl:583

This does not happen with besseli, used in the same way:

julia> ForwardDiff.derivative(x->besseli(0,x),1.)
0.565159103992485

Similarly, I can take the derivative of besselj but not besseljx.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions