Skip to content

JuliaIntervals/IntervalRootFinding.jl

Repository files navigation

IntervalRootFinding

Stable Build Status coverage

IntervalRootFinding.jl is a Julia package for finding the roots of functions, i.e. solutions to the equation $f(x) = 0$. To do so, it uses interval arithmetic from the IntervalArithmetic library.

Documentation

The official documentation is available online: https://juliaintervals.github.io/IntervalRootFinding.jl/stable.

Installation

The IntervalRootFinding.jl package requires to install Julia.

Then, start Julia and execute the following command in the REPL:

using Pkg; Pkg.add("IntervalRootFinding")

Basic usage examples

The basic function is roots. Given a standard Julia function and an interval, the roots function returns a list of intervals containing all roots of the function located in the prescribed interval.

julia> using IntervalArithmetic, IntervalRootFinding

julia> f(x) = sin(x) - 0.1*x^2 + 1
f (generic function with 1 method)

julia> roots(f, -10..10)
4-element Array{Root{Interval{Float64}},1}:
 Root([3.14959, 3.1496], :unique)
 Root([-4.42654, -4.42653], :unique)
 Root([-1.08205, -1.08204], :unique)
 Root([-3.10682, -3.10681], :unique)

The :unique status indicates that each listed interval contains exactly one root. The other possible status is :unknown, which corresponds to intervals that may contain zero, one, or more roots (no guarantee is provided for these intervals).

These results are represented in the following plot, the region containing roots being in green.

basic usage