JuliaIntervals / IntervalRootFinding.jl

Library for finding the roots of a function using interval arithmetic
https://juliaintervals.github.io/IntervalRootFinding.jl/
Other
127 stars 26 forks source link

roots should not return "unique" for multiple roots #75

Closed dpsanders closed 4 years ago

dpsanders commented 6 years ago

Seems to be a special case when the root is exact:

julia> f5(x) = (x^2 - 1)^4 * (x^2 - 2)^4             #two quadruple roots
f5 (generic function with 1 method)

julia>

julia> roots(f5, -10..10)
4-element Array{IntervalRootFinding.Root{IntervalArithmetic.Interval{Float64}},1}:
 Root([1.41421, 1.41422], :unknown)
 Root([1, 1], :unique)
 Root([-1, -1], :unique)
 Root([-1.41422, -1.41421], :unknown)
Kolaru commented 5 years ago

I believe this comes from a division bug in IntervalArithmetic.jl when the numerator is exactly 0:

julia> 0.0/((-10)..10)
[0, 0]

Here the mid of the interval simply appears to be an exact solution at some point of the computation.

Cf. https://github.com/JuliaIntervals/IntervalArithmetic.jl/issues/264

dpsanders commented 4 years ago

Has since been fixed:

julia> roots(f5, -10..10)
4-element Array{Root{Interval{Float64}},1}:
 Root([0.999999, 1.00001], :unknown)
 Root([-1.41422, -1.41421], :unknown)
 Root([-1.00001, -0.999999], :unknown)
 Root([1.41421, 1.41422], :unknown)