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

Do not impose `tol` to be `Float64`

Open lbenet opened this issue 6 years ago • 2 comments

The following throws a MethodError:

julia> using IntervalArithmetic, IntervalRootFinding

julia> f(x) = -4*x^3 + 5*x^4
f (generic function with 1 method)

julia> dom = big(0) .. big(1)
[0, 1]₂₅₆

julia> roots(f, dom, Newton, 1.0e-5)  # works ok
2-element Array{Root{Interval{BigFloat}},1}:
 Root([0.799999, 0.800001]₂₅₆, :unique)
 Root([0, 6.67704e-06]₂₅₆, :unknown)   

julia> roots(f, dom, Newton, parse(BigFloat, "1.0e-5"))
ERROR: MethodError: no method matching roots(::typeof(f), ::Interval{BigFloat}, ::Type{Newton}, ::BigFloat)
Closest candidates are:
  roots(::Any, ::Interval{T}, ::Union{Type{Krawczyk}, Type{Newton}}) where T at /Users/benet/.julia/dev/IntervalRootFinding/src/roots.jl:153
  roots(::Any, ::Interval{T}, ::Union{Type{Krawczyk}, Type{Newton}}, ::Float64) where T at /Users/benet/.julia/dev/IntervalRootFinding/src/roots.jl:153
  roots(::F<:Function, ::F<:Function, ::Any) where F<:Function at /Users/benet/.julia/dev/IntervalRootFinding/src/roots.jl:226
  ...
Stacktrace:
 [1] top-level scope at none:0

I think it makes sense to allow tol in the roots methods to be <:AbstractFloat?

lbenet avatar Jul 24 '19 22:07 lbenet

Sure. I think it can be any real number in fact.

dpsanders avatar Jul 25 '19 00:07 dpsanders