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

Newton fails for dummy example with continuous solutions #101

Closed Kolaru closed 4 years ago

Kolaru commented 5 years ago

While exploring #100, I found that Newton fails in the dummy example presented there:

julia> f(xx) = SVector(xx[1] + xx[2], xx[1] + xx[2])
f (generic function with 1 method)

julia> roots(f, IntervalBox(-1..1, 2), Newton)
0-element Array{Root{IntervalBox{2,Float64}},1}

There are obvious solution in that interval box though, (0, 0) for example.

dpsanders commented 5 years ago

Ouch. Not sure what's going on there.

lbenet commented 5 years ago

Isn't it the fact that the solutions are not isolated? That is, there are infinitely many solutions (xx[1] = - xx[2]).

Kolaru commented 5 years ago

To me it looks like the problem is that the Jacobian is always singular (it is the constant [1, 1; 1, 1]), so the operation J \ f(m) in the Newton contractor always return an empty interval box. It should return the entire interval box however since we always have f(m) = [x, x] for some x, and thus the equation J*x = f(m) has infinitely many solutions.

Also I noticed the (possibly related) fact that the \ function of StaticArrays is considered more specific that the one defined in lin_eq.jl, so the latter is actually never used. This is probably due to the fact the StaticArrays method is parametrized over the matrix dimension.

The Krawczyk method avoid the problem by using the inv method to get the inverse of the Jacobian on a point (and not an interval) which gives [Inf -Inf; -Inf Inf] but no error (note that the inv function used is the one from StaticArrays here too, which makes sense since there is no interval involved in the Jacobian here).

dpsanders commented 5 years ago

This seems to be fixed now.

dpsanders commented 5 years ago

Or rather, Newton now "works" and returns a huge list of intervals around the diagonal. But Krawczyk now hangs.

dpsanders commented 4 years ago

Now fixed.