API
IntervalArithmetic.DECORATION
IntervalArithmetic.DecoratedInterval
IntervalArithmetic.Flavor
IntervalArithmetic.Interval
IntervalArithmetic.IntervalBox
IntervalArithmetic.IntervalRounding
IntervalArithmetic.Region
IntervalArithmetic.@I_str
IntervalArithmetic.@round
Base.:*
Base.:+
Base.:-
Base.:-
Base.:/
Base.:^
Base.Math.acot
Base.Math.acoth
Base.Math.cot
Base.Math.coth
Base.Math.csc
Base.Math.csch
Base.Math.hypot
Base.Math.sec
Base.Math.sech
Base.abs
Base.acos
Base.acosh
Base.asin
Base.asinh
Base.atan
Base.atanh
Base.ceil
Base.cos
Base.cosh
Base.floor
Base.fma
Base.hash
Base.in
Base.intersect
Base.intersect
Base.intersect
Base.inv
Base.isdisjoint
Base.issubset
Base.max
Base.min
Base.parse
Base.parse
Base.round
Base.setdiff
Base.setdiff
Base.sign
Base.signbit
Base.sin
Base.sinh
Base.sqrt
Base.tan
Base.tanh
Base.trunc
Base.union
Base.union
Base.zero
IntervalArithmetic.:±
IntervalArithmetic.:≛
IntervalArithmetic.:≛
IntervalArithmetic.:⊂
IntervalArithmetic._parse
IntervalArithmetic._setdiff
IntervalArithmetic.atomic
IntervalArithmetic.bigequiv
IntervalArithmetic.bisect
IntervalArithmetic.bisect
IntervalArithmetic.bisect
IntervalArithmetic.bounds
IntervalArithmetic.cancelminus
IntervalArithmetic.cancelminus
IntervalArithmetic.cancelplus
IntervalArithmetic.cancelplus
IntervalArithmetic.default_numtype
IntervalArithmetic.diam
IntervalArithmetic.div_by_thin_zero
IntervalArithmetic.emptyinterval
IntervalArithmetic.entireinterval
IntervalArithmetic.extended_div
IntervalArithmetic.find_quadrants
IntervalArithmetic.hull
IntervalArithmetic.hull
IntervalArithmetic.inf
IntervalArithmetic.interval
IntervalArithmetic.is_valid_interval
IntervalArithmetic.isatomic
IntervalArithmetic.iscommon
IntervalArithmetic.isinterior
IntervalArithmetic.isstrictless
IntervalArithmetic.isthin
IntervalArithmetic.isthininteger
IntervalArithmetic.isthinzero
IntervalArithmetic.isweaklyless
IntervalArithmetic.mag
IntervalArithmetic.mid
IntervalArithmetic.mid
IntervalArithmetic.midpoint_radius
IntervalArithmetic.mig
IntervalArithmetic.mince
IntervalArithmetic.mince
IntervalArithmetic.mince
IntervalArithmetic.mince
IntervalArithmetic.nai
IntervalArithmetic.nthroot
IntervalArithmetic.numtype
IntervalArithmetic.overlap
IntervalArithmetic.parse_num
IntervalArithmetic.pow
IntervalArithmetic.precedes
IntervalArithmetic.promote_numtype
IntervalArithmetic.radius
IntervalArithmetic.round_expr
IntervalArithmetic.scaled_mid
IntervalArithmetic.setformat
IntervalArithmetic.strictprecedes
IntervalArithmetic.sup
IntervalArithmetic.symmetric_box
IntervalArithmetic.unsafe_scale
IntervalArithmetic.zero_times_infinity
IntervalArithmetic.DECORATION
— TypeDECORATION
Enumeration constant for the types of interval decorations. The nomenclature follows Section 11.2 of the IEEE Standard 1788-2015:
com -> 4
: non-empty, continuous and bounded (common)dac -> 3
: non-empty and continuous (defined and continuous)def -> 2
: non-empty (defined)trv -> 1
: always true (trivial)ill -> 0
: not an interval (ill-formed)
IntervalArithmetic.DecoratedInterval
— TypeDecoratedInterval{T<:NumTypes}
Wraps an Interval
together with a DECORATION
, i.e. a flag that records the status of the interval when thought of as the result of a previously executed sequence of functions acting on an initial interval.
IntervalArithmetic.Flavor
— TypeFlavor{F}
Super type of all interval flavors.
A flavor defines (following the IEEE Std 1788-2015) how an interval behaves in edge cases. This mostly makes a difference when dealing with infinity and division by zero.
Currently only Flavor{:set_based} is supported.
:set_based
(default) : Elements of an interval are real number. In particular, infinity is never part of an interval and is only used as a shorthand. For example, the interval(2..Inf)
contain all real number greater than 2. In particular, this means that(Inf..Inf)
is an empty interval, and division by a thin zero returns the empty interval. The edge cases are -x/(0..0) ≛ ∅
-(0..0)/(0..0) ≛ ∅
-(0..0)*(-Inf..Inf) ≛ 0
-Inf ∈ (0..Inf) == false
This flavor is described and required in part 2 of the IEEE Std 1799-2015.:cset
(not implemented) : Elements of an interval are either real numbers or±Inf
, applying standard rule for arithmetic with infinity. The edge cases are -x/(0..0) ≛ (-Inf..Inf)
-(0..0)/(0..0) ≛ (-Inf..Inf)
-(0..0)*(-Inf..Inf) ≛ (-Inf..Inf)
-Inf ∈ (0..Inf) == true
IntervalArithmetic.Interval
— TypeInterval{T<:NumTypes} <: Real
Interval type for guaranteed computation with interval arithmetic according to the IEEE Standard 1788-2015.
Fields:
lo::T
hi::T
Constructors compliant with the IEEE Standard 1788-2015:
The internal constructor unsafe_interval
is not compliant with the IEEE Standard 1788-2015.
IntervalArithmetic.IntervalBox
— TypeAn IntervalBox
is an N
-dimensional rectangular box, given by a Cartesian product of a vector of N
Interval
s.
IntervalArithmetic.IntervalRounding
— TypeIntervalRounding{T}
Interval rounding trait type.
Allowed rounding types are
:tight
: fast, tight (correct) rounding with errorfree arithmetic via FastRounding.jl.:accurate
: fast "accurate" rounding using prevfloat and nextfloat (slightly wider than needed).:slow
: tight (correct) rounding by changing rounding mode (slow).:none
: no rounding (for speed comparisons; no enclosure is guaranteed).
IntervalArithmetic.@I_str
— MacroI"str"
Create an interval according to the IEEE Standard 1788-2015. This is semantically equivalent to parse(DecoratedInterval{default_numtype()}, str)
if the string contains the character _
which delimits the interval and its decoration; otherwise, it is semantically equivalent to parse(Interval{default_numtype()}, str)
.
Examples
julia> setformat(:full);
+API · IntervalArithmetic API
IntervalArithmetic.DECORATION
IntervalArithmetic.DecoratedInterval
IntervalArithmetic.Flavor
IntervalArithmetic.Interval
IntervalArithmetic.IntervalBox
IntervalArithmetic.IntervalRounding
IntervalArithmetic.Region
IntervalArithmetic.@I_str
IntervalArithmetic.@round
Base.:*
Base.:+
Base.:-
Base.:-
Base.:/
Base.:^
Base.Math.acot
Base.Math.acoth
Base.Math.cot
Base.Math.coth
Base.Math.csc
Base.Math.csch
Base.Math.hypot
Base.Math.sec
Base.Math.sech
Base.abs
Base.acos
Base.acosh
Base.asin
Base.asinh
Base.atan
Base.atanh
Base.ceil
Base.cos
Base.cosh
Base.floor
Base.fma
Base.hash
Base.in
Base.intersect
Base.intersect
Base.intersect
Base.inv
Base.isdisjoint
Base.issubset
Base.max
Base.min
Base.parse
Base.parse
Base.round
Base.setdiff
Base.setdiff
Base.sign
Base.signbit
Base.sin
Base.sinh
Base.sqrt
Base.tan
Base.tanh
Base.trunc
Base.union
Base.union
Base.zero
IntervalArithmetic.:±
IntervalArithmetic.:≛
IntervalArithmetic.:≛
IntervalArithmetic.:⊂
IntervalArithmetic._parse
IntervalArithmetic._setdiff
IntervalArithmetic.atomic
IntervalArithmetic.bigequiv
IntervalArithmetic.bisect
IntervalArithmetic.bisect
IntervalArithmetic.bisect
IntervalArithmetic.bounds
IntervalArithmetic.cancelminus
IntervalArithmetic.cancelminus
IntervalArithmetic.cancelplus
IntervalArithmetic.cancelplus
IntervalArithmetic.default_numtype
IntervalArithmetic.diam
IntervalArithmetic.div_by_thin_zero
IntervalArithmetic.emptyinterval
IntervalArithmetic.entireinterval
IntervalArithmetic.extended_div
IntervalArithmetic.find_quadrants
IntervalArithmetic.hull
IntervalArithmetic.hull
IntervalArithmetic.inf
IntervalArithmetic.interval
IntervalArithmetic.is_valid_interval
IntervalArithmetic.isatomic
IntervalArithmetic.iscommon
IntervalArithmetic.isinterior
IntervalArithmetic.isstrictless
IntervalArithmetic.isthin
IntervalArithmetic.isthininteger
IntervalArithmetic.isthinzero
IntervalArithmetic.isweaklyless
IntervalArithmetic.mag
IntervalArithmetic.mid
IntervalArithmetic.mid
IntervalArithmetic.midpoint_radius
IntervalArithmetic.mig
IntervalArithmetic.mince
IntervalArithmetic.mince
IntervalArithmetic.mince
IntervalArithmetic.mince
IntervalArithmetic.nai
IntervalArithmetic.nthroot
IntervalArithmetic.numtype
IntervalArithmetic.overlap
IntervalArithmetic.parse_num
IntervalArithmetic.pow
IntervalArithmetic.precedes
IntervalArithmetic.promote_numtype
IntervalArithmetic.radius
IntervalArithmetic.round_expr
IntervalArithmetic.scaled_mid
IntervalArithmetic.setformat
IntervalArithmetic.strictprecedes
IntervalArithmetic.sup
IntervalArithmetic.symmetric_box
IntervalArithmetic.unsafe_scale
IntervalArithmetic.zero_times_infinity
IntervalArithmetic.DECORATION
— TypeDECORATION
Enumeration constant for the types of interval decorations. The nomenclature follows Section 11.2 of the IEEE Standard 1788-2015:
com -> 4
: non-empty, continuous and bounded (common)dac -> 3
: non-empty and continuous (defined and continuous)def -> 2
: non-empty (defined)trv -> 1
: always true (trivial)ill -> 0
: not an interval (ill-formed)
sourceIntervalArithmetic.DecoratedInterval
— TypeDecoratedInterval{T<:NumTypes}
Wraps an Interval
together with a DECORATION
, i.e. a flag that records the status of the interval when thought of as the result of a previously executed sequence of functions acting on an initial interval.
sourceIntervalArithmetic.Flavor
— TypeFlavor{F}
Super type of all interval flavors.
A flavor defines (following the IEEE Std 1788-2015) how an interval behaves in edge cases. This mostly makes a difference when dealing with infinity and division by zero.
Currently only Flavor{:set_based} is supported.
:set_based
(default) : Elements of an interval are real number. In particular, infinity is never part of an interval and is only used as a shorthand. For example, the interval (2..Inf)
contain all real number greater than 2. In particular, this means that (Inf..Inf)
is an empty interval, and division by a thin zero returns the empty interval. The edge cases are - x/(0..0) ≛ ∅
- (0..0)/(0..0) ≛ ∅
- (0..0)*(-Inf..Inf) ≛ 0
- Inf ∈ (0..Inf) == false
This flavor is described and required in part 2 of the IEEE Std 1799-2015.:cset
(not implemented) : Elements of an interval are either real numbers or ±Inf
, applying standard rule for arithmetic with infinity. The edge cases are - x/(0..0) ≛ (-Inf..Inf)
- (0..0)/(0..0) ≛ (-Inf..Inf)
- (0..0)*(-Inf..Inf) ≛ (-Inf..Inf)
- Inf ∈ (0..Inf) == true
sourceIntervalArithmetic.Interval
— TypeInterval{T<:NumTypes} <: Real
Interval type for guaranteed computation with interval arithmetic according to the IEEE Standard 1788-2015.
Fields:
lo::T
hi::T
Constructors compliant with the IEEE Standard 1788-2015:
Warning The internal constructor unsafe_interval
is not compliant with the IEEE Standard 1788-2015.
sourceIntervalArithmetic.IntervalBox
— TypeAn IntervalBox
is an N
-dimensional rectangular box, given by a Cartesian product of a vector of N
Interval
s.
sourceIntervalArithmetic.IntervalRounding
— TypeIntervalRounding{T}
Interval rounding trait type.
Allowed rounding types are
:tight
: fast, tight (correct) rounding with errorfree arithmetic via FastRounding.jl.:accurate
: fast "accurate" rounding using prevfloat and nextfloat (slightly wider than needed).:slow
: tight (correct) rounding by changing rounding mode (slow).:none
: no rounding (for speed comparisons; no enclosure is guaranteed).
sourceIntervalArithmetic.@I_str
— MacroI"str"
Create an interval according to the IEEE Standard 1788-2015. This is semantically equivalent to parse(DecoratedInterval{default_numtype()}, str)
if the string contains the character _
which delimits the interval and its decoration; otherwise, it is semantically equivalent to parse(Interval{default_numtype()}, str)
.
Examples
julia> setformat(:full);
julia> I"[3, 4]"
Interval{Float64}(3.0, 4.0)
julia> I"0.1"
-Interval{Float64}(0.09999999999999999, 0.1)
sourceIntervalArithmetic.@round
— Macro@round(F, ex1, ex2)
Macro for internal use that creates an interval of flavor F by rounding down ex1
and rounding up ex2
. Each expression may consist of only a single operation that needs rounding, e.g. a.lo + b.lo
or sin(a.lo)
. It also handles min(...)
and max(...)
, where the arguments are each themselves single operations.
The macro uses the internal round_expr
function to transform e.g. a + b
into +(a, b, RoundDown)
.
sourceBase.:*
— Method*(a::Interval, b::Interval)
+Interval{Float64}(0.09999999999999999, 0.1)
sourceIntervalArithmetic.@round
— Macro@round(F, ex1, ex2)
Macro for internal use that creates an interval of flavor F by rounding down ex1
and rounding up ex2
. Each expression may consist of only a single operation that needs rounding, e.g. a.lo + b.lo
or sin(a.lo)
. It also handles min(...)
and max(...)
, where the arguments are each themselves single operations.
The macro uses the internal round_expr
function to transform e.g. a + b
into +(a, b, RoundDown)
.
sourceBase.:*
— Method*(a::Interval, b::Interval)
*(a::Interval, b::Real)
-*(a::Real, b::Interval)
Implement the mul
function of the IEEE Standard 1788-2015 (Table 9.1).
Note The behavior of the multiplication is flavor dependent for some edge cases.
sourceBase.:+
— Method+(a::Interval, b::Interval)
+*(a::Real, b::Interval)
Implement the mul
function of the IEEE Standard 1788-2015 (Table 9.1).
Note The behavior of the multiplication is flavor dependent for some edge cases.
sourceBase.:+
— Method+(a::Interval, b::Interval)
+(a::Interval, b::Real)
-+(a::Real, b::Interval)
Implement the add
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.:-
— Method-(a::Interval)
Implement the neg
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.:-
— Method-(a::Interval, b::Interval)
++(a::Real, b::Interval)
Implement the add
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.:-
— Method-(a::Interval)
Implement the neg
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.:-
— Method-(a::Interval, b::Interval)
-(a::Interval, b::Real)
--(a::Real, b::Interval)
Implement the sub
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.:/
— Method/(a::Interval, b::Interval)
+-(a::Real, b::Interval)
Implement the sub
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.:/
— Method/(a::Interval, b::Interval)
/(a::Interval, b::Real)
-/(a::Real, b::Interval)
Implement the div
function of the IEEE Standard 1788-2015 (Table 9.1).
Note The behavior of the division is flavor dependent for some edge cases.
sourceBase.:^
— Method^(a::Interval, b::Interval)
-^(a::Interval, b)
Implement the pow
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.Math.acot
— Methodacot(a::Interval)
Implement the acot
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.Math.acoth
— Methodacoth(a::Interval)
Implement the acoth
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.Math.cot
— Methodcot(a::Interval)
Implement the cot
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.Math.coth
— Methodcoth(a::Interval)
Implement the coth
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.Math.csc
— Methodcsc(a::Interval)
Implement the csc
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.Math.csch
— Methodcsch(a::Interval)
Implement the csch
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.Math.hypot
— Methodhypot(x::Interval, n::Integer)
Direct implemntation of hypot
using intervals.
sourceBase.Math.sec
— Methodsec(a::Interval)
Implement the sec
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.Math.sech
— Methodsech(a::Interval)
Implement the sech
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.abs
— Methodabs(a::Interval)
Implement the abs
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.acos
— Methodacos(a::Interval)
Implement the acos
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.acosh
— Methodacosh(a::Interval)
Implement the acosh
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.asin
— Methodasin(a::Interval)
Implement the asin
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.asinh
— Methodasinh(a::Interval)
Implement the asinh
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.atan
— Methodatan(a::Interval)
Implement the atan
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.atanh
— Methodatanh(a::Interval)
Implement the atanh
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.ceil
— Methodceil(a::Interval)
Implement the ceil
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.cos
— Methodcos(a::Interval)
Implement the cos
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.cosh
— Methodcosh(a::Interval)
Implement the cosh
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.floor
— Methodfloor(a::Interval)
Implement the floor
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.fma
— Methodfma(a::Interval, b::Interval, c::Interval)
Fused multiply-add.
Implement the fma
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.hash
— Methodhash(x::Interval, h)
Compute the integer hash code for an interval using the method for composite types used in AutoHashEquals.jl
.
Note that in IntervalArithmetic.jl
, equality of intervals is given by ≛
rather than the ==
operator. The latter is reserved for the pointwise extension of equality to intervals and uses three-way logic by default.
sourceBase.in
— Methodin(x, a)
-∈(x, a)
Checks if the number x
is a member of the interval a
, treated as a set.
Implement the isMember
function of the IEEE Standard 1788-2015 (section 10.6.3).
sourceBase.intersect
— Functionintersect(xx, yy)
Decorated interval extension; the result is decorated as trv
, following the IEEE-1788 Standard (see Sect. 11.7.1, pp 47).
sourceBase.intersect
— Methodintersect(a::Interval{T}...) where T
Return the n-ary intersection of its arguments.
This function is applicable to any number of input intervals, as in intersect(a1, a2, a3, a4)
where ai
is an interval. If your use case needs to splat the input, as in intersect(a...)
, consider reduce(intersect, a)
instead, because you save the cost of splatting.
sourceBase.intersect
— Methodintersect(a, b)
-∩(a,b)
Returns the intersection of the intervals a
and b
, considered as (extended) sets of real numbers. That is, the set that contains the points common in a
and b
.
Implement the intersection
function of the IEEE Standard 1788-2015 (Section 9.3).
sourceBase.inv
— Methodinv(a::Interval)
Implement the recip
function of the IEEE Standard 1788-2015 (Table 9.1).
Note The behavior of the division is flavor dependent for some edge cases.
sourceBase.isdisjoint
— Methodisdisjoint(a,b)
Checks if all the points of the interval a
are within the interior of interval b
.
Implement the disjoint
function of the IEEE Standard 1788-2015 (Table 9.3).
sourceBase.issubset
— Method⊆(a,b)
Checks if all the points of the interval a
are within the interval b
.
Typed with \subseteq<TAB>.
Implement the subset
function of the IEEE Standard 1788-2015 (Table 9.3).
sourceBase.max
— Methodmax(a::Interval, b::Interval)
Implement the max
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.min
— Methodmin(a::Interval, b::Interval)
Implement the min
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.parse
— Methodparse(Interval, s::AbstractString)
Create an interval according to the IEEE Standard 1788-2015. In contrast with constructors that do not use strings, this constructor guarantees that the returned interval tightly encloses the values described by the string, including numbers that have no exact float representation (e.g. 0.1).
Examples of allowed string formats:
I"[1.33]"
or I"1.33"
: the interval containing $1.33$.I"[1.44, 2.78]"
: the interval $[1.44, 2.78]$.I"[empty]"
: the empty interval.I"[entire]"
or I"[,]"
: the interval $[-\infty, \infty]$.I"[3,]"
: the interval $[3, \infty]$.I"6.42?2"
: the interval $[6.4, 6.44]$. The number after ?
represents the uncertainty in the last digit; by default this value is 0.5
. The direction of the uncertainty can be given by adding u
or d
at the end for the error to only go up or down respectively (e.g. I"4.5?5u"
represents $[4.5, 5]$).I"6.42?2e2"
: the interval $[642, 644]$.I"3??u"
: the interval $[3, \infty]$.I"3??u"
: the interval $[3, \infty]$.I"3??"
: the interval $[-\infty, \infty]$.
For more details, see sections 9.7 and 12.11 of the IEEE Standard 1788-2015.
Examples
julia> setformat(:full);
+/(a::Real, b::Interval)
Implement the div
function of the IEEE Standard 1788-2015 (Table 9.1).
Note The behavior of the division is flavor dependent for some edge cases.
sourceBase.:^
— Method^(a::Interval, b::Interval)
+^(a::Interval, b)
Implement the pow
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.Math.acot
— Methodacot(a::Interval)
Implement the acot
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.Math.acoth
— Methodacoth(a::Interval)
Implement the acoth
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.Math.cot
— Methodcot(a::Interval)
Implement the cot
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.Math.coth
— Methodcoth(a::Interval)
Implement the coth
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.Math.csc
— Methodcsc(a::Interval)
Implement the csc
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.Math.csch
— Methodcsch(a::Interval)
Implement the csch
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.Math.hypot
— Methodhypot(x::Interval, n::Integer)
Direct implemntation of hypot
using intervals.
sourceBase.Math.sec
— Methodsec(a::Interval)
Implement the sec
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.Math.sech
— Methodsech(a::Interval)
Implement the sech
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.abs
— Methodabs(a::Interval)
Implement the abs
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.acos
— Methodacos(a::Interval)
Implement the acos
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.acosh
— Methodacosh(a::Interval)
Implement the acosh
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.asin
— Methodasin(a::Interval)
Implement the asin
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.asinh
— Methodasinh(a::Interval)
Implement the asinh
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.atan
— Methodatan(a::Interval)
Implement the atan
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.atanh
— Methodatanh(a::Interval)
Implement the atanh
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.ceil
— Methodceil(a::Interval)
Implement the ceil
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.cos
— Methodcos(a::Interval)
Implement the cos
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.cosh
— Methodcosh(a::Interval)
Implement the cosh
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.floor
— Methodfloor(a::Interval)
Implement the floor
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.fma
— Methodfma(a::Interval, b::Interval, c::Interval)
Fused multiply-add.
Implement the fma
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.hash
— Methodhash(x::Interval, h)
Compute the integer hash code for an interval using the method for composite types used in AutoHashEquals.jl
.
Note that in IntervalArithmetic.jl
, equality of intervals is given by ≛
rather than the ==
operator. The latter is reserved for the pointwise extension of equality to intervals and uses three-way logic by default.
sourceBase.in
— Methodin(x, a)
+∈(x, a)
Checks if the number x
is a member of the interval a
, treated as a set.
Implement the isMember
function of the IEEE Standard 1788-2015 (section 10.6.3).
sourceBase.intersect
— Functionintersect(xx, yy)
Decorated interval extension; the result is decorated as trv
, following the IEEE-1788 Standard (see Sect. 11.7.1, pp 47).
sourceBase.intersect
— Methodintersect(a::Interval{T}...) where T
Return the n-ary intersection of its arguments.
This function is applicable to any number of input intervals, as in intersect(a1, a2, a3, a4)
where ai
is an interval. If your use case needs to splat the input, as in intersect(a...)
, consider reduce(intersect, a)
instead, because you save the cost of splatting.
sourceBase.intersect
— Methodintersect(a, b)
+∩(a,b)
Returns the intersection of the intervals a
and b
, considered as (extended) sets of real numbers. That is, the set that contains the points common in a
and b
.
Implement the intersection
function of the IEEE Standard 1788-2015 (Section 9.3).
sourceBase.inv
— Methodinv(a::Interval)
Implement the recip
function of the IEEE Standard 1788-2015 (Table 9.1).
Note The behavior of the division is flavor dependent for some edge cases.
sourceBase.isdisjoint
— Methodisdisjoint(a,b)
Checks if all the points of the interval a
are within the interior of interval b
.
Implement the disjoint
function of the IEEE Standard 1788-2015 (Table 9.3).
sourceBase.issubset
— Method⊆(a,b)
Checks if all the points of the interval a
are within the interval b
.
Typed with \subseteq<TAB>.
Implement the subset
function of the IEEE Standard 1788-2015 (Table 9.3).
sourceBase.max
— Methodmax(a::Interval, b::Interval)
Implement the max
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.min
— Methodmin(a::Interval, b::Interval)
Implement the min
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.parse
— Methodparse(Interval, s::AbstractString)
Create an interval according to the IEEE Standard 1788-2015. In contrast with constructors that do not use strings, this constructor guarantees that the returned interval tightly encloses the values described by the string, including numbers that have no exact float representation (e.g. 0.1).
Examples of allowed string formats:
I"[1.33]"
or I"1.33"
: the interval containing $1.33$.I"[1.44, 2.78]"
: the interval $[1.44, 2.78]$.I"[empty]"
: the empty interval.I"[entire]"
or I"[,]"
: the interval $[-\infty, \infty]$.I"[3,]"
: the interval $[3, \infty]$.I"6.42?2"
: the interval $[6.4, 6.44]$. The number after ?
represents the uncertainty in the last digit; by default this value is 0.5
. The direction of the uncertainty can be given by adding u
or d
at the end for the error to only go up or down respectively (e.g. I"4.5?5u"
represents $[4.5, 5]$).I"6.42?2e2"
: the interval $[642, 644]$.I"3??u"
: the interval $[3, \infty]$.I"3??u"
: the interval $[3, \infty]$.I"3??"
: the interval $[-\infty, \infty]$.
For more details, see sections 9.7 and 12.11 of the IEEE Standard 1788-2015.
Examples
julia> setformat(:full);
julia> parse(Interval{Float64}, "[1, 2]")
Interval{Float64}(1.0, 2.0)
@@ -31,13 +31,13 @@
Interval{Float64}(-Inf, Inf)
julia> parse(Interval{Float64}, "6.42?2e2")
-Interval{Float64}(640.0, 644.0)
sourceBase.parse
— Methodparse(DecoratedInterval, s::AbstractString)
Parse a string of the form "[a, b]_dec"
as a DecoratedInterval
with decoration dec
. If the decoration is not specified, it is computed based on the parsed interval. If the input is an invalid string, a warning is printed and [NaI] is returned. The parser is case unsensitive.
Examples
julia> setformat(:full);
+Interval{Float64}(640.0, 644.0)
sourceBase.parse
— Methodparse(DecoratedInterval, s::AbstractString)
Parse a string of the form "[a, b]_dec"
as a DecoratedInterval
with decoration dec
. If the decoration is not specified, it is computed based on the parsed interval. If the input is an invalid string, a warning is printed and [NaI] is returned. The parser is case unsensitive.
Examples
julia> setformat(:full);
julia> parse(DecoratedInterval{Float64}, "[1, 2]")
[1, 2]_com
julia> parse(DecoratedInterval{Float64}, "[1, 2]_def")
-[1, 2]_def
sourceBase.round
— Methodround(a::Interval[, RoundingMode])
Return the interval with limits rounded to an integer.
Implement the functions roundTiesToEven
and roundTiesToAway
of the IEEE Standard 1788-2015.
sourceBase.setdiff
— Methodsetdiff(x::Interval, y::Interval)
Calculate the set difference x ∖ y
, i.e. the set of values that are inside the interval x
but not inside y
.
Returns an array of intervals. The array may:
- be empty if
x ⊆ y
; - contain a single interval, if
y
overlaps x
- contain two intervals, if
y
is strictly contained within x
.
sourceBase.setdiff
— Methodsetdiff(A::IntervalBox{N,T}, B::IntervalBox{N,T})
Returns a vector of IntervalBox
es that are in the set difference A ∖ B
, i.e. the set of x
that are in A
but not in B
.
Algorithm: Start from the total overlap (in all directions); expand each direction in turn.
sourceBase.sign
— Methodsign(a::Interval)
Implement the sign
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.signbit
— Methodsignbit(a::Interval)
Return an interval containing 1 if any element in a
is negative and containing 0 if any element in a
is positive. An empty interval is returned if a
is empty.
Examples
julia> setformat(:full);
+[1, 2]_def
sourceBase.round
— Methodround(a::Interval[, RoundingMode])
Return the interval with limits rounded to an integer.
Implement the functions roundTiesToEven
and roundTiesToAway
of the IEEE Standard 1788-2015.
sourceBase.setdiff
— Methodsetdiff(x::Interval, y::Interval)
Calculate the set difference x ∖ y
, i.e. the set of values that are inside the interval x
but not inside y
.
Returns an array of intervals. The array may:
- be empty if
x ⊆ y
; - contain a single interval, if
y
overlaps x
- contain two intervals, if
y
is strictly contained within x
.
sourceBase.setdiff
— Methodsetdiff(A::IntervalBox{N,T}, B::IntervalBox{N,T})
Returns a vector of IntervalBox
es that are in the set difference A ∖ B
, i.e. the set of x
that are in A
but not in B
.
Algorithm: Start from the total overlap (in all directions); expand each direction in turn.
sourceBase.sign
— Methodsign(a::Interval)
Implement the sign
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.signbit
— Methodsignbit(a::Interval)
Return an interval containing 1 if any element in a
is negative and containing 0 if any element in a
is positive. An empty interval is returned if a
is empty.
Examples
julia> setformat(:full);
julia> signbit(interval(-4))
Interval{Float64}(1.0, 1.0)
@@ -46,22 +46,22 @@
Interval{Float64}(0.0, 0.0)
julia> signbit(interval(-4,5))
-Interval{Float64}(0.0, 1.0)
sourceBase.sin
— Methodsin(a::Interval)
Implement the sin
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.sinh
— Methodsinh(a::Interval)
Implement the sinh
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.sqrt
— Methodsqrt(a::Interval)
Square root of an interval.
Implement the sqrt
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.tan
— Methodtan(a::Interval)
Implement the tan
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.tanh
— Methodtanh(a::Interval)
Implement the tanh
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.trunc
— Methodtrunc(a::Interval)
Implement the trunc
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.union
— Functionunion(xx, yy)
Decorated interval extension; the result is decorated as trv
, following the IEEE-1788 Standard (see Sect. 11.7.1, pp 47).
sourceBase.union
— Methodunion(a, b)
-∪(a,b)
Return the union (convex hull) of the intervals a
and b
; it is equivalent to hull(a,b)
.
Implement the converxHull
function of the IEEE Standard 1788-2015 (Section 9.3).
sourceBase.zero
— Methodzero(IntervalBox{N, T})
Return the zero interval box of dimension N
in the numeric type T
.
sourceIntervalArithmetic.:±
— Method±(m, r)
+Interval{Float64}(0.0, 1.0)
sourceBase.sin
— Methodsin(a::Interval)
Implement the sin
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.sinh
— Methodsinh(a::Interval)
Implement the sinh
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.sqrt
— Methodsqrt(a::Interval)
Square root of an interval.
Implement the sqrt
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.tan
— Methodtan(a::Interval)
Implement the tan
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.tanh
— Methodtanh(a::Interval)
Implement the tanh
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.trunc
— Methodtrunc(a::Interval)
Implement the trunc
function of the IEEE Standard 1788-2015 (Table 9.1).
sourceBase.union
— Functionunion(xx, yy)
Decorated interval extension; the result is decorated as trv
, following the IEEE-1788 Standard (see Sect. 11.7.1, pp 47).
sourceBase.union
— Methodunion(a, b)
+∪(a,b)
Return the union (convex hull) of the intervals a
and b
; it is equivalent to hull(a,b)
.
Implement the converxHull
function of the IEEE Standard 1788-2015 (Section 9.3).
sourceBase.zero
— Methodzero(IntervalBox{N, T})
Return the zero interval box of dimension N
in the numeric type T
.
sourceIntervalArithmetic.:±
— Method±(m, r)
m ± r
Create the interval $[m - r, m + r]$ according to the IEEE Standard 1788-2015. Despite using the midpoint-radius notation, the returned interval is still an Interval
represented by its bounds.
Warning Nothing is done to compensate for the fact that floating point literals are rounded to the nearest when parsed (e.g. 0.1). In such cases, use the string macro @I_str
to ensure tight enclosure around the typed numbers.
See also: interval
, ..
and @I_str
.
Examples
julia> setformat(:full);
julia> 0 ± π
Interval{Float64}(-3.1415926535897936, 3.1415926535897936)
julia> 0//1 ± π
-Interval{Rational{Int64}}(-85563208//27235615, 85563208//27235615)
sourceIntervalArithmetic.:≛
— Method≛(a::Interval, b::Interval)
Checks if the intervals a
and b
are identical.
Typed as \starequal<TAB>.
Implement the equal
function of the IEEE Standard 1788-2015 (Table 9.3).
The more common ==
operator is reserved for flavor dependent pointwise equality.
In most case this is equivalent to the built-in ===
.
sourceIntervalArithmetic.:≛
— Method≛(a::Interval, x::Real)
Check if the interval a
contains exactly (and only) the number x
.
sourceIntervalArithmetic.:⊂
— Method⊂(a,b)
Checks if a
is a strict subset of interval b
.
Typed with \subset<TAB>.
sourceIntervalArithmetic._parse
— Method_parse(::Type{Interval{T}}, s::AbstractString) where T
tries to parse the string s
to an interval of type Interval{T}
and throws an argument error if an invalid string is given.
Output
- the parsed interval
- a flag
isnotcom
, which is set to true if the input interval is not com
and to false otherwise. This is used to distinguish the case when an interval is supposed to be unbounded (e.g. input "[3, infinity]"
) or becomes unbounded because of overflow (e.g. the input "[3, 1e400]", which is parse to
[3, ∞]when using
Float64`).
sourceIntervalArithmetic._setdiff
— Method_setdiff(x::Interval{T}, y::Interval{T})
Computes the set difference x\y and always returns a tuple of two intervals. If the set difference is only one interval or is empty, then the returned tuple contains 1 or 2 empty intervals.
sourceIntervalArithmetic.atomic
— Methodatomic(T<:Union{Rational,AbstractFloat}, a)
Create an interval according to the IEEE Standard 1788-2015. The returned Interval{T}
always contains the value a
but its construction depends on its type. If a
is an AbstractString
, then the interval is constructed by calling parse
. If a
is an AbstractFloat
, the interval is widen to two eps to be sure to contain the number that was typed in. In all other cases, this is semantically equivalent to interval(T, a)
.
Examples
julia> setformat(:full);
+Interval{Rational{Int64}}(-85563208//27235615, 85563208//27235615)
sourceIntervalArithmetic.:≛
— Method≛(a::Interval, b::Interval)
Checks if the intervals a
and b
are identical.
Typed as \starequal<TAB>.
Implement the equal
function of the IEEE Standard 1788-2015 (Table 9.3).
The more common ==
operator is reserved for flavor dependent pointwise equality.
In most case this is equivalent to the built-in ===
.
sourceIntervalArithmetic.:≛
— Method≛(a::Interval, x::Real)
Check if the interval a
contains exactly (and only) the number x
.
sourceIntervalArithmetic.:⊂
— Method⊂(a,b)
Checks if a
is a strict subset of interval b
.
Typed with \subset<TAB>.
sourceIntervalArithmetic._parse
— Method_parse(::Type{Interval{T}}, s::AbstractString) where T
tries to parse the string s
to an interval of type Interval{T}
and throws an argument error if an invalid string is given.
Output
- the parsed interval
- a flag
isnotcom
, which is set to true if the input interval is not com
and to false otherwise. This is used to distinguish the case when an interval is supposed to be unbounded (e.g. input "[3, infinity]"
) or becomes unbounded because of overflow (e.g. the input "[3, 1e400]", which is parse to
[3, ∞]when using
Float64`).
sourceIntervalArithmetic._setdiff
— Method_setdiff(x::Interval{T}, y::Interval{T})
Computes the set difference x\y and always returns a tuple of two intervals. If the set difference is only one interval or is empty, then the returned tuple contains 1 or 2 empty intervals.
sourceIntervalArithmetic.atomic
— Methodatomic(T<:Union{Rational,AbstractFloat}, a)
Create an interval according to the IEEE Standard 1788-2015. The returned Interval{T}
always contains the value a
but its construction depends on its type. If a
is an AbstractString
, then the interval is constructed by calling parse
. If a
is an AbstractFloat
, the interval is widen to two eps to be sure to contain the number that was typed in. In all other cases, this is semantically equivalent to interval(T, a)
.
Examples
julia> setformat(:full);
julia> IntervalArithmetic.atomic(Float64, 0.1)
Interval{Float64}(0.09999999999999999, 0.10000000000000002)
julia> IntervalArithmetic.atomic(Float64, 0.1)
-Interval{Float64}(0.29999999999999993, 0.30000000000000004)
sourceIntervalArithmetic.bigequiv
— Methodbigequiv(x::Interval)
-bigequiv(x::Union{Rational,AbstractFloat})
Create a BigFloat
equivalent with the same underlying precision as x
.
sourceIntervalArithmetic.bisect
— Functionbisect(X::IntervalBox, α=0.49609375)
Bisect the IntervalBox
X
at position α ∈ [0,1] along its longest side.
sourceIntervalArithmetic.bisect
— Functionbisect(X::IntervalBox, i::Integer, α=0.49609375)
Bisect the IntervalBox
in side number i
.
sourceIntervalArithmetic.bisect
— Methodbisect(X::Interval, α=0.49609375)
Split the interval X
at position α; α=0.5 corresponds to the midpoint. Returns a tuple of the new intervals.
sourceIntervalArithmetic.bounds
— Methodbounds(a::Interval)
Bounds of an interval as a tuple. This is semantically equivalent to (a.lo, sup(a))
. In particular, this function does not normalize the lower bound.
sourceIntervalArithmetic.cancelminus
— Functioncancelminus(xx, yy)
Decorated interval extension; the result is decorated as trv
, following the IEEE-1788 Standard (see Sect. 11.7.1, pp 47).
sourceIntervalArithmetic.cancelminus
— Methodcancelminus(a, b)
Return the unique interval c
such that b + c = a
.
Implement the cancelMinus
function of the IEEE Standard 1788-2015 (Section 9.2).
sourceIntervalArithmetic.cancelplus
— Functioncancelplus(xx, yy)
Decorated interval extension; the result is decorated as trv
, following the IEEE-1788 Standard (see Sect. 11.7.1, pp 47).
sourceIntervalArithmetic.cancelplus
— Methodcancelplus(a, b)
Return the unique interval c
such that b - c = a
.
Equivalent to cancelminus(a, -b)
.
Implement the cancelPlus
function of the IEEE Standard 1788-2015 (Section 9.2).
sourceIntervalArithmetic.default_numtype
— Methoddefault_numtype()
Return the default bound type used in promote_numtype
. By default, default_numtype()
is set to Float64
. It can be modified by redefining the function, however it should be set to a concrete subtype of Rational
or AbstractFloat
.
Examples
julia> IntervalArithmetic.default_numtype()
+Interval{Float64}(0.29999999999999993, 0.30000000000000004)
sourceIntervalArithmetic.bigequiv
— Methodbigequiv(x::Interval)
+bigequiv(x::Union{Rational,AbstractFloat})
Create a BigFloat
equivalent with the same underlying precision as x
.
sourceIntervalArithmetic.bisect
— Functionbisect(X::IntervalBox, i::Integer, α=0.49609375)
Bisect the IntervalBox
in side number i
.
sourceIntervalArithmetic.bisect
— Functionbisect(X::IntervalBox, α=0.49609375)
Bisect the IntervalBox
X
at position α ∈ [0,1] along its longest side.
sourceIntervalArithmetic.bisect
— Methodbisect(X::Interval, α=0.49609375)
Split the interval X
at position α; α=0.5 corresponds to the midpoint. Returns a tuple of the new intervals.
sourceIntervalArithmetic.bounds
— Methodbounds(a::Interval)
Bounds of an interval as a tuple. This is semantically equivalent to (a.lo, sup(a))
. In particular, this function does not normalize the lower bound.
sourceIntervalArithmetic.cancelminus
— Functioncancelminus(xx, yy)
Decorated interval extension; the result is decorated as trv
, following the IEEE-1788 Standard (see Sect. 11.7.1, pp 47).
sourceIntervalArithmetic.cancelminus
— Methodcancelminus(a, b)
Return the unique interval c
such that b + c = a
.
Implement the cancelMinus
function of the IEEE Standard 1788-2015 (Section 9.2).
sourceIntervalArithmetic.cancelplus
— Functioncancelplus(xx, yy)
Decorated interval extension; the result is decorated as trv
, following the IEEE-1788 Standard (see Sect. 11.7.1, pp 47).
sourceIntervalArithmetic.cancelplus
— Methodcancelplus(a, b)
Return the unique interval c
such that b - c = a
.
Equivalent to cancelminus(a, -b)
.
Implement the cancelPlus
function of the IEEE Standard 1788-2015 (Section 9.2).
sourceIntervalArithmetic.default_numtype
— Methoddefault_numtype()
Return the default bound type used in promote_numtype
. By default, default_numtype()
is set to Float64
. It can be modified by redefining the function, however it should be set to a concrete subtype of Rational
or AbstractFloat
.
Examples
julia> IntervalArithmetic.default_numtype()
Float64
julia> typeof(interval(1, 2))
@@ -76,7 +76,7 @@
Interval{Float32}
julia> typeof(interval(1, big(2)))
-Interval{BigFloat}
sourceIntervalArithmetic.diam
— Methoddiam(a::Interval)
Return the diameter (length) of the interval a
.
Implement the wid
function of the IEEE Standard 1788-2015 (Table 9.2).
sourceIntervalArithmetic.div_by_thin_zero
— Methoddiv_by_thin_zero(::Flavor, x::Interval)
Divide x
by the interval containing only 0
.
sourceIntervalArithmetic.emptyinterval
— Methodemptyinterval
emptyinterval
s are represented as the interval [∞, -∞]; note that this interval is an exception to the fact that the lower bound is larger than the upper one.
Note that if the type of the returned interval can not be inferred from the argument given, the default interval bound type is used.
Implement the empty
function of the IEEE Standard 1788-2015 (Section 10.5.2).
sourceIntervalArithmetic.entireinterval
— Methodentireinterval
RR
represent the entire real line [-Inf, Inf].
Depending on the flavor, -Inf
and Inf
may or may not be considerd inside this interval.
Note that if the type of the returned interval can not be inferred from the argument given, the default interval flavor will be used. See the documentation of Interval
for more information about the default interval falvor.
Implement the entire
function of the IEEE Standard 1788-2015 (Section 10.5.2).
sourceIntervalArithmetic.extended_div
— Methodextended_div(a::Interval, b::Interval)
Two-output division.
Implement the mulRevToPair
function of the IEEE Standard 1788-2015 (Section 10.5.5).
sourceIntervalArithmetic.find_quadrants
— Methodfind_quadrants(x)
Finds the quadrant(s) corresponding to a given floating-point number. The quadrants are labelled as 0 for x ∈ [0, π/2], etc. A tuple of two quadrants is returned. The minimum or maximum must then be chosen appropriately.
This is a rather indirect way to determine if π/2 and 3π/2 are contained in the interval; cf. the formula for sine of an interval in Tucker, Validated Numerics.
sourceIntervalArithmetic.hull
— Functionhull(xx, yy)
Decorated interval extension; the result is decorated as trv
, following the IEEE-1788 Standard (see Sect. 11.7.1, pp 47).
sourceIntervalArithmetic.hull
— Methodhull(a, b)
Return the "interval hull" of the intervals a
and b
, considered as (extended) sets of real numbers, i.e. the smallest interval that contains all of a
and b
.
Implement the converxHull
function of the IEEE Standard 1788-2015 (Section 9.3).
sourceIntervalArithmetic.inf
— Methodinf(a::Interval)
Infimum of an interval. For a zero AbstractFloat
lower bound, a negative zero is returned.
Implement the inf
function of the IEEE Standard 1788-2015 (Table 9.2 and Section 12.12.8).
sourceIntervalArithmetic.interval
— Methodinterval([T<:Union{Rational,AbstractFloat}=default_numtype()], a, b)
Create the interval $[a, b]$ according to the IEEE Standard 1788-2015. The validity of the interval is checked by is_valid_interval
: if true
then an Interval{T}
is constructed, otherwise a warning is printed and the empty interval is returned.
Warning Nothing is done to compensate for the fact that floating point literals are rounded to the nearest when parsed (e.g. 0.1). In such cases, use the string macro @I_str
to ensure tight enclosure around the typed numbers.
Examples
julia> setformat(:full);
+Interval{BigFloat}
sourceIntervalArithmetic.diam
— Methoddiam(a::Interval)
Return the diameter (length) of the interval a
.
Implement the wid
function of the IEEE Standard 1788-2015 (Table 9.2).
sourceIntervalArithmetic.div_by_thin_zero
— Methoddiv_by_thin_zero(::Flavor, x::Interval)
Divide x
by the interval containing only 0
.
sourceIntervalArithmetic.emptyinterval
— Methodemptyinterval
emptyinterval
s are represented as the interval [∞, -∞]; note that this interval is an exception to the fact that the lower bound is larger than the upper one.
Note that if the type of the returned interval can not be inferred from the argument given, the default interval bound type is used.
Implement the empty
function of the IEEE Standard 1788-2015 (Section 10.5.2).
sourceIntervalArithmetic.entireinterval
— Methodentireinterval
RR
represent the entire real line [-Inf, Inf].
Depending on the flavor, -Inf
and Inf
may or may not be considerd inside this interval.
Note that if the type of the returned interval can not be inferred from the argument given, the default interval flavor will be used. See the documentation of Interval
for more information about the default interval falvor.
Implement the entire
function of the IEEE Standard 1788-2015 (Section 10.5.2).
sourceIntervalArithmetic.extended_div
— Methodextended_div(a::Interval, b::Interval)
Two-output division.
Implement the mulRevToPair
function of the IEEE Standard 1788-2015 (Section 10.5.5).
sourceIntervalArithmetic.find_quadrants
— Methodfind_quadrants(x)
Finds the quadrant(s) corresponding to a given floating-point number. The quadrants are labelled as 0 for x ∈ [0, π/2], etc. A tuple of two quadrants is returned. The minimum or maximum must then be chosen appropriately.
This is a rather indirect way to determine if π/2 and 3π/2 are contained in the interval; cf. the formula for sine of an interval in Tucker, Validated Numerics.
sourceIntervalArithmetic.hull
— Functionhull(xx, yy)
Decorated interval extension; the result is decorated as trv
, following the IEEE-1788 Standard (see Sect. 11.7.1, pp 47).
sourceIntervalArithmetic.hull
— Methodhull(a, b)
Return the "interval hull" of the intervals a
and b
, considered as (extended) sets of real numbers, i.e. the smallest interval that contains all of a
and b
.
Implement the converxHull
function of the IEEE Standard 1788-2015 (Section 9.3).
sourceIntervalArithmetic.inf
— Methodinf(a::Interval)
Infimum of an interval. For a zero AbstractFloat
lower bound, a negative zero is returned.
Implement the inf
function of the IEEE Standard 1788-2015 (Table 9.2 and Section 12.12.8).
sourceIntervalArithmetic.interval
— Methodinterval([T<:Union{Rational,AbstractFloat}=default_numtype()], a, b)
Create the interval $[a, b]$ according to the IEEE Standard 1788-2015. The validity of the interval is checked by is_valid_interval
: if true
then an Interval{T}
is constructed, otherwise a warning is printed and the empty interval is returned.
Warning Nothing is done to compensate for the fact that floating point literals are rounded to the nearest when parsed (e.g. 0.1). In such cases, use the string macro @I_str
to ensure tight enclosure around the typed numbers.
Examples
julia> setformat(:full);
julia> interval(1//1, π)
Interval{Rational{Int64}}(1//1, 85563208//27235615)
@@ -88,9 +88,9 @@
Interval{Float64}(1.0, 3.1415926535897936)
julia> interval(BigFloat, 1, π)
-Interval{BigFloat}(1.0, 3.141592653589793238462643383279502884197169399375105820974944592307816406286233)
sourceIntervalArithmetic.is_valid_interval
— Methodis_valid_interval(a, b)
Check if (a, b)
constitute a valid interval.
sourceIntervalArithmetic.isatomic
— Methodisatomic(x::Interval)
Check whether an interval x
is atomic, i.e. is unable to be split. This occurs when the interval is empty, or when the upper bound equals the lower bound or the bounds are consecutive floating point numbers.
sourceIntervalArithmetic.iscommon
— Methodiscommon(x)
Checks if x
is a common interval, i.e. a non-empty, bounded, real interval.
sourceIntervalArithmetic.isinterior
— Methodisinterior(a,b)
Checks if all the points of the interval a
are within the interior of interval b
.
Implement the interior
function of the IEEE Standard 1788-2015 (Table 9.3).
sourceIntervalArithmetic.isstrictless
— Methodisstrictless(a, b)
Checks if the interval a
is strictly less than interval b
, which is true if inf(a) < inf(b)
and sup(a) < sup(b)
.
For variants in the definition of "strictly less than" for intervals see strictprecedes
and <
.
Implement the strictLess
function of the IEEE Standard 1788-2015 (Table 10.3).
sourceIntervalArithmetic.isthin
— Methodisthin(x)
Checks if x
is the set consisting of a single exactly representable float. Any float which is not exactly representable does not yield a thin interval. Corresponds to isSingleton
of the standard.
sourceIntervalArithmetic.isthininteger
— Methodisthininteger(x)
Return whether the inverval only contains a single integer.
sourceIntervalArithmetic.isthinzero
— Methodisthinzero(x)
Return whether the interval only contains zero.
sourceIntervalArithmetic.isweaklyless
— Methodisweaklyless(a, b)
Checks if the interval a
is weakly less than interval b
.
Note that this is not equivalent as saying every element of a
is less than any element of b
.
Implement the less
function of the IEEE Standard 1788-2015 (Table 10.3).
sourceIntervalArithmetic.mag
— Methodmag(a::Interval)
Magnitude of an interval. Return NaN
for empty intervals.
Implement the mag
function of the IEEE Standard 1788-2015 (Table 9.2).
sourceIntervalArithmetic.mid
— Methodmid(X::IntervalBox, α=0.5)
Return a vector of the mid
of each interval composing the IntervalBox
.
See mid(X::Interval, α=0.5)
for more information.
sourceIntervalArithmetic.mid
— Methodmid(a::Interval)
Find the midpoint of the interval a
.
Implement the mid
function of the IEEE Standard 1788-2015 (Table 9.2).
sourceIntervalArithmetic.midpoint_radius
— Methodmidpoint_radius(a::Interval)
Return the midpoint of an interval a
together with its radius.
Function required by the IEEE Standard 1788-2015 in Section 10.5.9 for the set-based flavor.
sourceIntervalArithmetic.mig
— Methodmig(a::Interval)
Mignitude of an interval. Return NaN
for empty intervals.
Implement the mig
function of the IEEE Standard 1788-2015 (Table 9.2).
sourceIntervalArithmetic.mince
— Methodmince(x::IntervalBox, n::Int)
Splits x
in n
intervals in each dimension of the same diameter. These intervals are combined in all possible IntervalBox
-es, which are returned as a vector.
sourceIntervalArithmetic.mince
— Methodmince(x::Interval, n)
Split x
in n
intervals of the same diameter, which are returned as a vector.
sourceIntervalArithmetic.mince
— Methodmince(x::IntervalBox, n)
Split x
in n
intervals in each dimension of the same diameter. These intervals are combined in all possible IntervalBox
-es, which are returned as a vector.
sourceIntervalArithmetic.mince
— Methodmince(x::IntervalBox, ncuts::::NTuple{N,Int})
Splits x[i]
in ncuts[i]
intervals . These intervals are combined in all possible IntervalBox
-es, which are returned as a vector.
sourceIntervalArithmetic.nai
— MethodNaI
not-an-interval: [NaN, NaN].
sourceIntervalArithmetic.nthroot
— Methodnthroot(a::Interval, n::Integer)
Compute the real n-th root of Interval.
sourceIntervalArithmetic.numtype
— Methodnumtype(::T)
+Interval{BigFloat}(1.0, 3.141592653589793238462643383279502884197169399375105820974944592307816406286233)
sourceIntervalArithmetic.is_valid_interval
— Methodis_valid_interval(a, b)
Check if (a, b)
constitute a valid interval.
sourceIntervalArithmetic.isatomic
— Methodisatomic(x::Interval)
Check whether an interval x
is atomic, i.e. is unable to be split. This occurs when the interval is empty, or when the upper bound equals the lower bound or the bounds are consecutive floating point numbers.
sourceIntervalArithmetic.iscommon
— Methodiscommon(x)
Checks if x
is a common interval, i.e. a non-empty, bounded, real interval.
sourceIntervalArithmetic.isinterior
— Methodisinterior(a,b)
Checks if all the points of the interval a
are within the interior of interval b
.
Implement the interior
function of the IEEE Standard 1788-2015 (Table 9.3).
sourceIntervalArithmetic.isstrictless
— Methodisstrictless(a, b)
Checks if the interval a
is strictly less than interval b
, which is true if inf(a) < inf(b)
and sup(a) < sup(b)
.
For variants in the definition of "strictly less than" for intervals see strictprecedes
and <
.
Implement the strictLess
function of the IEEE Standard 1788-2015 (Table 10.3).
sourceIntervalArithmetic.isthin
— Methodisthin(x)
Checks if x
is the set consisting of a single exactly representable float. Any float which is not exactly representable does not yield a thin interval. Corresponds to isSingleton
of the standard.
sourceIntervalArithmetic.isthininteger
— Methodisthininteger(x)
Return whether the inverval only contains a single integer.
sourceIntervalArithmetic.isthinzero
— Methodisthinzero(x)
Return whether the interval only contains zero.
sourceIntervalArithmetic.isweaklyless
— Methodisweaklyless(a, b)
Checks if the interval a
is weakly less than interval b
.
Note that this is not equivalent as saying every element of a
is less than any element of b
.
Implement the less
function of the IEEE Standard 1788-2015 (Table 10.3).
sourceIntervalArithmetic.mag
— Methodmag(a::Interval)
Magnitude of an interval. Return NaN
for empty intervals.
Implement the mag
function of the IEEE Standard 1788-2015 (Table 9.2).
sourceIntervalArithmetic.mid
— Methodmid(X::IntervalBox, α=0.5)
Return a vector of the mid
of each interval composing the IntervalBox
.
See mid(X::Interval, α=0.5)
for more information.
sourceIntervalArithmetic.mid
— Methodmid(a::Interval)
Find the midpoint of the interval a
.
Implement the mid
function of the IEEE Standard 1788-2015 (Table 9.2).
sourceIntervalArithmetic.midpoint_radius
— Methodmidpoint_radius(a::Interval)
Return the midpoint of an interval a
together with its radius.
Function required by the IEEE Standard 1788-2015 in Section 10.5.9 for the set-based flavor.
sourceIntervalArithmetic.mig
— Methodmig(a::Interval)
Mignitude of an interval. Return NaN
for empty intervals.
Implement the mig
function of the IEEE Standard 1788-2015 (Table 9.2).
sourceIntervalArithmetic.mince
— Methodmince(x::IntervalBox, n::Int)
Splits x
in n
intervals in each dimension of the same diameter. These intervals are combined in all possible IntervalBox
-es, which are returned as a vector.
sourceIntervalArithmetic.mince
— Methodmince(x::Interval, n)
Split x
in n
intervals of the same diameter, which are returned as a vector.
sourceIntervalArithmetic.mince
— Methodmince(x::IntervalBox, n)
Split x
in n
intervals in each dimension of the same diameter. These intervals are combined in all possible IntervalBox
-es, which are returned as a vector.
sourceIntervalArithmetic.mince
— Methodmince(x::IntervalBox, ncuts::::NTuple{N,Int})
Splits x[i]
in ncuts[i]
intervals . These intervals are combined in all possible IntervalBox
-es, which are returned as a vector.
sourceIntervalArithmetic.nai
— MethodNaI
not-an-interval: [NaN, NaN].
sourceIntervalArithmetic.nthroot
— Methodnthroot(a::Interval, n::Integer)
Compute the real n-th root of Interval.
sourceIntervalArithmetic.numtype
— Methodnumtype(::T)
numtype(::Type{T})
Return the type T
of the bounds of the interval.
Example
julia> IntervalArithmetic.numtype(interval(1, 2))
-Float64
sourceIntervalArithmetic.overlap
— Methodoverlap(a::Interval, b::Interval)
Implement the overlap
function according to the IEEE Standard 1788-2015 (Section 10.6.4 and Table 10.7).
sourceIntervalArithmetic.parse_num
— MethodSame as parse(T, s, rounding_mode)
, but also accept string representing rational numbers.
sourceIntervalArithmetic.pow
— Methodpow(x::Interval, n::Integer)
A faster implementation of x^n
, currently using power_by_squaring
. pow(x, n)
will usually return an interval that is slightly larger than that calculated by x^n
, but is guaranteed to be a correct enclosure when using multiplication with correct rounding.
sourceIntervalArithmetic.precedes
— Methodprecedes(a, b)
Checks if the interval a
is to the left of interval b
.
Implement the precedes
function of the IEEE Standard 1788-2015 (Table 10.3).
sourceIntervalArithmetic.promote_numtype
— Methodpromote_numtype(T, S)
Return the bound type used to construct intervals. The bound type is given by promote_type(T, S)
if T
or S
is a Rational
or an AbstractFloat
; except when T
is a Rational{R}
and S
is an AbstractIrrational
(or vice-versa), in which case the bound type is given by Rational{promote_type(R, Int64)}
. In all other cases, the bound type is given by promote_type(default_numtype(), T, S)
.
sourceIntervalArithmetic.radius
— Methodradius(a::Interval)
Return the radius of the interval a
, such that a ⊆ m ± radius
, where m = mid(a)
is the midpoint.
Implement the rad
function of the IEEE Standard 1788-2015 (Table 9.2).
sourceIntervalArithmetic.round_expr
— Methodround_expr(ex::Expr, rounding_mode::RoundingMode)
Transforms a single expression by applying a rounding mode, e.g.
a + b
into +(a, b, RoundDown)
sin(a)
into sin(a, RoundDown)
sourceIntervalArithmetic.scaled_mid
— Methodscaled_mid(a::Interval, α)
Find an intermediate point at a relative position α
in the interval a
instead.
Assume 0 ≤ α ≤ 1.
Note that scaled_mid(a, 0.5)
does not equal mid(a)
for unbounded set-based intervals.
sourceIntervalArithmetic.setformat
— Functionsetformat(format::Symbol; decorations::Bool, sigdigits::Int)
+Float64
sourceIntervalArithmetic.overlap
— Methodoverlap(a::Interval, b::Interval)
Implement the overlap
function according to the IEEE Standard 1788-2015 (Section 10.6.4 and Table 10.7).
sourceIntervalArithmetic.parse_num
— MethodSame as parse(T, s, rounding_mode)
, but also accept string representing rational numbers.
sourceIntervalArithmetic.pow
— Methodpow(x::Interval, n::Integer)
A faster implementation of x^n
, currently using power_by_squaring
. pow(x, n)
will usually return an interval that is slightly larger than that calculated by x^n
, but is guaranteed to be a correct enclosure when using multiplication with correct rounding.
sourceIntervalArithmetic.precedes
— Methodprecedes(a, b)
Checks if the interval a
is to the left of interval b
.
Implement the precedes
function of the IEEE Standard 1788-2015 (Table 10.3).
sourceIntervalArithmetic.promote_numtype
— Methodpromote_numtype(T, S)
Return the bound type used to construct intervals. The bound type is given by promote_type(T, S)
if T
or S
is a Rational
or an AbstractFloat
; except when T
is a Rational{R}
and S
is an AbstractIrrational
(or vice-versa), in which case the bound type is given by Rational{promote_type(R, Int64)}
. In all other cases, the bound type is given by promote_type(default_numtype(), T, S)
.
sourceIntervalArithmetic.radius
— Methodradius(a::Interval)
Return the radius of the interval a
, such that a ⊆ m ± radius
, where m = mid(a)
is the midpoint.
Implement the rad
function of the IEEE Standard 1788-2015 (Table 9.2).
sourceIntervalArithmetic.round_expr
— Methodround_expr(ex::Expr, rounding_mode::RoundingMode)
Transforms a single expression by applying a rounding mode, e.g.
a + b
into +(a, b, RoundDown)
sin(a)
into sin(a, RoundDown)
sourceIntervalArithmetic.scaled_mid
— Methodscaled_mid(a::Interval, α)
Find an intermediate point at a relative position α
in the interval a
instead.
Assume 0 ≤ α ≤ 1.
Note that scaled_mid(a, 0.5)
does not equal mid(a)
for unbounded set-based intervals.
sourceIntervalArithmetic.setformat
— Functionsetformat(format::Symbol; decorations::Bool, sigdigits::Int)
setformat()
Change the format used by show
to display intervals.
Initially, the display options are format = :standard
, decorations = false
and sigdigits = 6
.
If any of the three argument format
, decorations
and sigdigits
is omitted, then their value is left unchanged.
If the three arguments are omitted, i.e. calling setformat()
, then the values are reset to the default display options.
Possible options:
format
can be::standard
: [1, 2]
.:midpoint
: display x::Interval
in the form "mid(x) ± radius(x)".:full
: display the entire bounds regardless of sigdigits
.
sigdigits
: number (greater or equal to 1) of significant digits to display.decorations
: display the decorations or not.
Example
julia> x = interval(0.1, 0.3) # Default display options
[0.0999999, 0.300001]
@@ -110,4 +110,4 @@
- significant digits: 3
julia> x
-[0.0999, 0.301]
sourceIntervalArithmetic.strictprecedes
— Methodstrictprecedes(a, b)
Checks if the interval a
is strictly to the left of interval b
.
Implement the strictPrecedes
function of the IEEE Standard 1788-2015 (Table 10.3).
sourceIntervalArithmetic.sup
— Methodsup(a::Interval)
Supremum of an interval.
Implement the sup
function of the IEEE Standard 1788-2015 (Table 9.2).
sourceIntervalArithmetic.symmetric_box
— Methodsymmetric_box(N, T)
Return the symmetric interval box of dimension N
in the numeric type T
, each side is Interval(-1, 1)
.
sourceIntervalArithmetic.unsafe_scale
— Methodunsafe_scale(α, a::Interval)
Multiply an interval by a positive scalar. For efficiency, does not check that the constant is positive.
sourceIntervalArithmetic.zero_times_infinity
— Methodzero_times_infinity(::Flavor, ::Type{T})
Return the result of zero times positive infinity for the given flavor and number type T
.
sourceIntervalArithmetic.Region
— TypeRegion{T} = Union{Interval{T}, IntervalBox{T}}
sourceSettings
This document was generated with Documenter.jl version 0.27.25 on Monday 28 August 2023. Using Julia version 1.9.2.
+[0.0999, 0.301]
IntervalArithmetic.strictprecedes
— Methodstrictprecedes(a, b)
Checks if the interval a
is strictly to the left of interval b
.
Implement the strictPrecedes
function of the IEEE Standard 1788-2015 (Table 10.3).
IntervalArithmetic.sup
— Methodsup(a::Interval)
Supremum of an interval.
Implement the sup
function of the IEEE Standard 1788-2015 (Table 9.2).
IntervalArithmetic.symmetric_box
— Methodsymmetric_box(N, T)
Return the symmetric interval box of dimension N
in the numeric type T
, each side is Interval(-1, 1)
.
IntervalArithmetic.unsafe_scale
— Methodunsafe_scale(α, a::Interval)
Multiply an interval by a positive scalar. For efficiency, does not check that the constant is positive.
IntervalArithmetic.zero_times_infinity
— Methodzero_times_infinity(::Flavor, ::Type{T})
Return the result of zero times positive infinity for the given flavor and number type T
.
IntervalArithmetic.Region
— TypeRegion{T} = Union{Interval{T}, IntervalBox{T}}