Bisection of atomic interval
One solution for the bisection of an atomic interval [l, h] would be to return three intervals:
- the point l
- the interval [l, h]
- the point h
Probably the easiest solution is not to bisect it.
Note that this will cause problems since currently it is expected that bisect returns two intervals.
Could return the same interval twice, together with an :atomic flag.
Or an object of a new type
How is an interval decided to be atomic? If diam(X) < tolerance?
A thin interval is an interval such that its lower bound and its upper one are the same. I think the notion of an atomic interval is the generalization of a thin interval for real numbers which are not exactly representable as floating points. (@dpsanders , please correct me if I'm wrong.)
So we have
julia> using IntervalArithmetic
julia> Interval(1.0,1.0)
Interval(1.0, 1.0)
julia> isthin(ans)
true
julia> a = @interval(sqrt(2))
[1.41421, 1.41422]
julia> @format full
6
julia> a
Interval(1.414213562373095, 1.4142135623730951)
julia> isthin(a)
false
julia> diam(a) ≤ eps(a) # `a` has the smallest diam that contains the true answer
true
At the end, I have compared diam(a) with eps(a) , where eps(a) acts on intervals. I am not considering any tolerance parameter, as you wrote above, but the interval whose with contains the true number and has smallest width.
An atomic interval is literally one that cannot be split up, in other words it's either thin or consists of two adjacent floating point numbers.
There is an exported isatomic function to check this.
@dpsanders @lbenet Thanks a lot for the clarification!
So for fixing the issue, what would be the preferred action?
Same interval twice with an :atomic flag?
That is probably a good solution, but that information would have to be used in the functions that call bisect, presumably so that they realise that they can just return and that a root has not been found.
(Or both of the floating point numbers in the atomic interval should be checked in case they are in fact exact roots, although this case seems very rare.)
Atomic interval are special cased in bisect and related function to avoid problems.