Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ julia> using IntervalArithmetic, IntervalArithmetic.Symbols, IntervalRootFinding
julia> rts = roots(x -> x^2 - 2x, 0..10)
2-element Vector{Root{Interval{Float64}}}:
Root([0.0, 3.73951e-8]_com_NG, :unknown)
└ Not converged: region size smaller than the tolerance
Root([1.99999, 2.00001]_com_NG, :unique)
```

Expand Down Expand Up @@ -71,7 +72,9 @@ julia> roots(g, -10..10)
4-element Vector{Root{Interval{Float64}}}:
Root([-1.73206, -1.73205]_com_NG, :unique)
Root([-1.41422, -1.41421]_com_NG, :unknown)
└ Not converged: region size smaller than the tolerance
Root([1.41421, 1.41422]_com_NG, :unknown)
└ Not converged: region size smaller than the tolerance
Root([1.73205, 1.73206]_com_NG, :unique)
```

Expand Down
5 changes: 5 additions & 0 deletions docs/src/internals.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,15 @@ SearchState{BreadthFirst{Root{Interval{Float64}}}, Root{Interval{Float64}}}
iteration: 15
5 regions being processed
Root([-0.078125, 1.15235]_com, :unknown)
└ Not converged: the root is still being processed
Root([-3.84735, -2.5975]_com, :unknown)
└ Not converged: the root is still being processed
Root([-5.07782, -3.84734]_com, :unknown)
└ Not converged: the root is still being processed
Root([-8.78861, -7.55813]_com, :unknown)
└ Not converged: the root is still being processed
Root([-10.0, -8.7886]_com, :unknown)
└ Not converged: the root is still being processed
1 finalized regions
Root([-6.28132, -6.28131]_com, :unique)

Expand Down
4 changes: 4 additions & 0 deletions docs/src/roots.md
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ julia> roots(log, -2..2 ; contractor = Krawczyk)
julia> roots(log, -2..2 ; contractor = Bisection)
1-element Vector{Root{Interval{Float64}}}:
Root([0.999999, 1.00001]_com, :unknown)
└ Not converged: region size smaller than the tolerance
```

Note that as shown in the example, the `log` function does not complain about being given an interval going outside its domain. While this may be surprising, this is the expected behavior and no root will ever be found outside the domain of a function.
Expand Down Expand Up @@ -168,6 +169,9 @@ julia> roots(f, -10 .. 10)
3-element Vector{Root{Interval{Float64}}}:
Root([0.0, 0.0]_com, :unique)
Root([1.99999, 2.00001]_com, :unknown)
├ Not converged: region size smaller than the tolerance
├ Warning: error encountered during computation (use showerror(root.error) to see the whole stacktrace)
└ InconclusiveBooleanOperation: The operation `[2.0, 2.0]_com_NG < [1.99999, 2.00001]_com` cannot be determined unambiguously. See the documentation for more information. See also `strictprecedes`.
Root([7.0, 7.0]_com_NG, :unique)
```

Expand Down
17 changes: 8 additions & 9 deletions src/root_object.jl
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,22 @@ isunique(rt::Root{T}) where {T} = (rt.status == :unique)

function show(io::IO, rt::Root)
print(io, "Root($(rt.region), :$(rt.status))")
end

function show(io::IO, ::MIME"text/plain", rt::Root)
show(io, rt)
if rt.status == :unknown
if !get(io, :compact, false) && rt.status == :unknown
connector = isnothing(rt.error) ? "└" : "├"
if rt.convergence == :tolerance
print(io, "\n Not converged: region size smaller than the tolerance")
print(io, "\n $connector Not converged: region size smaller than the tolerance")
elseif rt.convergence == :max_iterartion
print(io, "\n Not converged: reached maximal number of iterations")
print(io, "\n $connector Not converged: reached maximal number of iterations")
elseif rt.convergence == :none
print(io, "\n Not converged: the root is still being processed")
print(io, "\n $connector Not converged: the root is still being processed")
else
print(io, "\n Not converged: unknown reason $(rt.convergence)")
print(io, "\n $connector Not converged: unknown reason $(rt.convergence)")
end

if !isnothing(rt.error)
print(io, "\n Warning: error encountered during computation (use showerror(root.error) to see the whole stacktrace)\n ")
print(io, "\n Warning: error encountered during computation (use showerror(root.error) to see the whole stacktrace)\n ")
showerror(io, rt.error[1])
end
end
Expand Down
Loading