IntervalArithmetic.jl icon indicating copy to clipboard operation
IntervalArithmetic.jl copied to clipboard

Support for special functions

Open Kolaru opened this issue 2 years ago • 1 comments

Supporting special functions would be nice (see e.g. https://github.com/JuliaIntervals/IntervalRootFinding.jl/issues/175).

I thought already was an issue here about this, but I can't find it.

This is only easy to do for monotonous functions for which we can guarantee rounding correctness (e.g. by going through BigFloat or if a rounding mode is directly available). I don't think there is a general way to treat the other special functions.

The "good" think is that special functions seem to error (more or less gracefully) right now, rather that returning incorrect results:

julia> using SpecialFunctions

julia> besselk(2, Interval(0.7))
ERROR: StackOverflowError:
Stacktrace:
 [1] besselk(nu::Int64, x::Interval{Float64}) (repeats 79984 times)
   @ SpecialFunctions C:\Users\Kolaru\.julia\packages\SpecialFunctions\oPGFg\src\bessel.jl:583

julia> zeta(Interval(1.3))
ERROR: MethodError: no method matching _zeta(::Interval{Float64})
Closest candidates are:
  _zeta(::Union{Float64, ComplexF64}) at C:\Users\Kolaru\.julia\packages\SpecialFunctions\oPGFg\src\gamma.jl:414
  _zeta(::T, ::T) where T<:Union{Float64, ComplexF64} at C:\Users\Kolaru\.julia\packages\SpecialFunctions\oPGFg\src\gamma.jl:233
  _zeta(::Union{Float16, ComplexF16}) at C:\Users\Kolaru\.julia\packages\SpecialFunctions\oPGFg\src\gamma.jl:519
  ...
Stacktrace:
 [1] zeta(s::Interval{Float64})
   @ SpecialFunctions C:\Users\Kolaru\.julia\packages\SpecialFunctions\oPGFg\src\gamma.jl:412
 [2] top-level scope
   @ REPL[22]:1

Kolaru avatar Jun 05 '22 10:06 Kolaru

There is IntervalSpecialFunctions.jl, but the repo hasn't been updated in a while (I don't . It also has this PR which despite the name adds support for several special functions using Arb. Not sure how mature it is etc, but I can try to resurrect the repo and have a look at the PR.

That being said, computing special functions of intervals is a nice beast of itself. This paper from Fredrik Johansson describes some techniques for hypergeometric functions (which cover a good piece of special functions)

lucaferranti avatar Jun 06 '22 05:06 lucaferranti