How to work around this error in expint?

amrods
Thu, 10 Feb 2022 00:31:22 +0000
Numerics

I ran into this error while evaluating the Gamma function from SpecialFunctions:

julia> using SpecialFunctions

julia> gamma(exp(19.39)+1, 0.0125*0.6)
ERROR: ArgumentError: Unsupported order |ν| > 50 off the positive real axis
Stacktrace:
 [1] _expint(ν::Float64, z::Float64, niter::Int64, ::Val{false})
   @ SpecialFunctions ~/.julia/packages/SpecialFunctions/9pXme/src/expint.jl:400
 [2] expint (repeats 2 times)
   @ ~/.julia/packages/SpecialFunctions/9pXme/src/expint.jl:516 [inlined]
 [3] _gamma(a::Float64, x::Float64)
   @ SpecialFunctions ~/.julia/packages/SpecialFunctions/9pXme/src/gamma_inc.jl:1059
 [4] gamma(a::Float64, x::Float64)
   @ SpecialFunctions ~/.julia/packages/SpecialFunctions/9pXme/src/gamma_inc.jl:1036
 [5] top-level scope
   @ REPL[43]:1

I traced it to this evaluation of expint

julia> expint(1-(exp(19.39)+1), 0.0125*0.6)
ERROR: ArgumentError: Unsupported order |ν| > 50 off the positive real axis
Stacktrace:
 [1] _expint(ν::Float64, z::Float64, niter::Int64, ::Val{false})
   @ SpecialFunctions ~/.julia/packages/SpecialFunctions/9pXme/src/expint.jl:400
 [2] expint (repeats 2 times)
   @ ~/.julia/packages/SpecialFunctions/9pXme/src/expint.jl:516 [inlined]
 [3] top-level scope
   @ REPL[41]:1

which in turn arises from this definition of _expint:

function _expint(ν::Number, z::Number, niter::Int=1000, ::Val{expscaled}=Val{false}()) where {expscaled}
    if abs(ν) > 50 && !(isreal(ν) && real(ν) > 0)
        throw(ArgumentError("Unsupported order |ν| > 50 off the positive real axis"))
    end
# rest of code here
end

How can I work around this?

2 posts - 2 participants