JuliaMath / SpecialFunctions.jl

Special mathematical functions in Julia

Home Page:https://specialfunctions.juliamath.org/stable/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Overflow for besselh(85.5,0.001)

abhayap opened this issue · comments

The following code gives an overflow. Is there a way to support BigFloat or could it return infinity instead of an exception?

julia> besselh(85.5,0.001)
ERROR: AmosException with id 2: overflow.
Stacktrace:
 [1] _bessely(nu::Float64, z::ComplexF64, kode::Int32)
   @ SpecialFunctions ~/.julia/packages/SpecialFunctions/9pXme/src/bessel.jl:292
 [2] bessely(nu::Float64, z::ComplexF64)
   @ SpecialFunctions ~/.julia/packages/SpecialFunctions/9pXme/src/bessel.jl:429
 [3] bessely(nu::Float64, x::Float64)
   @ SpecialFunctions ~/.julia/packages/SpecialFunctions/9pXme/src/bessel.jl:560
 [4] besselh(nu::Float64, k::Int64, x::Float64)
   @ SpecialFunctions ~/.julia/packages/SpecialFunctions/9pXme/src/bessel.jl:320
 [5] besselh(nu::Float64, z::Float64)
   @ SpecialFunctions ~/.julia/packages/SpecialFunctions/9pXme/src/bessel.jl:597
 [6] top-level scope
   @ REPL[12]:1

julia> 

Higher precision for noninteger orders is unlikely to be supported in the near future. You should check out an arbitrary precision library (e.g., ArbNumerics.jl). Also, I would be careful because the correct return result is actually 0 - Inf*im for this.

This is handled a little better for integer orders but that is calling GNU MPFR instead of the Amos routine.

julia> besselh(85.0, 0.001)
0.0 - Inf*im

Unfortuntately, Amos just returns overflow for the call to bessely so it's difficult to make the inference about what the return should be.