Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support with JuliaIntervals? #317

Closed
jarroyoe opened this issue Jul 14, 2022 · 4 comments
Closed

Support with JuliaIntervals? #317

jarroyoe opened this issue Jul 14, 2022 · 4 comments

Comments

@jarroyoe
Copy link

I have a function that requires finding a root using Roots.jl to give me a value. However, when I try to find all the roots using a package such as IntervalRootFinding.jl, my code gives me the following error:

ERROR: Roots.ConvergenceFailed("Algorithm failed to converge")

After debugging, the problem seems to be that the Roots functions are failing to handle the JuliaIntervals objects properly. I was wondering if there's a way to use this correctly, or if there's an alternative to using JuliaIntervals. Here's a MVE:

using Roots
using IntervalRootFinding

function f((x,y))
    g(z) = z^2-x
    z0 = find_zero(g,2)

    return SVector(x+y-z0,y+x-1)
end
X = IntervalBox(0..1,2)
roots(f,X)
@jverzani
Copy link
Member

jverzani commented Jul 14, 2022 via email

@jarroyoe
Copy link
Author

I've tried transforming my code into a code supported by IntervalRootFinding, independent of Roots. In that case the roots that are found inside the function (z0 in my MVE) are intervals, and there seems to be issues regarding those roots.

Is there a way to use this package to find roots of multidimensional systems?

@jverzani
Copy link
Member

Roots.jl is only for function f: R -> R, nothing multidimensional. As for your problem, it seems you have a function which returns an interval, so you'd need to have some stopping criteria to adjust for that. (small diameter that depends on the size of the interval in f?) I tried using IntervalRootFinding.roots and don't get anything working if I start nearby, but do if I start at the answer, so there is something at play here that can maybe be adapted for your problem.


julia> f(x) = x^2 - Interval(2,2.001)
f (generic function with 1 method)

julia> f(√2)
[-0.001, 4.4409e-16]

julia> IntervalRootFinding.roots(f, Interval(1.5))
Root{Interval{Float64}}[]

julia> IntervalRootFinding.roots(f, Interval(√2))
1-element Vector{Root{Interval{Float64}}}:
 Root([1.41421, 1.41422], :unknown)

@jarroyoe
Copy link
Author

Thank you, it seems also that IntervalRootFinding is not capable at this moment of reliably using intervals as parameters to find roots. I ended up finding a workaround using a method that reduces my system to a 1D system and using the find_zeros function of Roots.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants