From b6b8c740696fcc6ef285da5475e54566a1b64b0e Mon Sep 17 00:00:00 2001 From: "Documenter.jl" Date: Thu, 4 Jan 2024 17:26:46 +0000 Subject: [PATCH] build based on 283d9e8 --- dev/.documenter-siteinfo.json | 2 +- dev/examples/pi/index.html | 2 +- dev/index.html | 2 +- dev/intro/index.html | 2 +- dev/manual/api/index.html | 116 ++++++++++++++--------------- dev/manual/construction/index.html | 2 +- dev/manual/usage/index.html | 2 +- 7 files changed, 64 insertions(+), 64 deletions(-) diff --git a/dev/.documenter-siteinfo.json b/dev/.documenter-siteinfo.json index 23999f3ca..52d8ad6a1 100644 --- a/dev/.documenter-siteinfo.json +++ b/dev/.documenter-siteinfo.json @@ -1 +1 @@ -{"documenter":{"julia_version":"1.10.0","generation_timestamp":"2024-01-04T14:41:26","documenter_version":"1.2.1"}} \ No newline at end of file +{"documenter":{"julia_version":"1.10.0","generation_timestamp":"2024-01-04T17:26:43","documenter_version":"1.2.1"}} \ No newline at end of file diff --git a/dev/examples/pi/index.html b/dev/examples/pi/index.html index 25f1fbf04..05c5352db 100644 --- a/dev/examples/pi/index.html +++ b/dev/examples/pi/index.html @@ -34,4 +34,4 @@ improved_pi_interval = backward_sum(10^6) -midradius(improved_pi_interval)
(3.141592653589793, 4.787281682183675e-13)
+midradius(improved_pi_interval)
(3.141592653589793, 4.787281682183675e-13)
diff --git a/dev/index.html b/dev/index.html index c3dc5d947..e51a0aa3d 100644 --- a/dev/index.html +++ b/dev/index.html @@ -1,2 +1,2 @@ -Home · IntervalArithmetic.jl

IntervalArithmetic.jl

IntervalArithmetic.jl is a Julia package for validated numerics in Julia. All calculations are carried out using interval arithmetic where quantities are treated as intervals. The final result is a rigorous enclosure of the true value.

Installation

julia> using Pkg # Julia v1.9 or above
julia> Pkg.add("IntervalArithmetic")

Citation

If you use the IntervalArithmetic library in your publication, research, teaching, or other activities, please use the BibTeX template CITATION.bib.

  • MPFI.jl, a Julia wrapper around the MPFI C library, a multiple-precision interval arithmetic library based on MPFR
  • Intervals.jl, an alternative implementation of basic interval functions by Invenia Technical Computing
+Home · IntervalArithmetic.jl

IntervalArithmetic.jl

IntervalArithmetic.jl is a Julia package for validated numerics in Julia. All calculations are carried out using interval arithmetic where quantities are treated as intervals. The final result is a rigorous enclosure of the true value.

Installation

julia> using Pkg # Julia v1.9 or above
julia> Pkg.add("IntervalArithmetic")

Citation

If you use the IntervalArithmetic library in your publication, research, teaching, or other activities, please use the BibTeX template CITATION.bib.

  • MPFI.jl, a Julia wrapper around the MPFI C library, a multiple-precision interval arithmetic library based on MPFR
  • Intervals.jl, an alternative implementation of basic interval functions by Invenia Technical Computing
diff --git a/dev/intro/index.html b/dev/intro/index.html index e3a276cc6..487399faf 100644 --- a/dev/intro/index.html +++ b/dev/intro/index.html @@ -4,4 +4,4 @@ [a^2, b^2], & 0 \le a \le b, \\ [0, \max(a^2, b^2)], & a \le 0 \le b, \\ [b^2, a^2], & a \le b \le 0. -\end{cases}\]

Of course, we must round the lower endpoint down and the upper endpoint up to get a guaranteed enclosure of the true result.

IntervalArithmetic defines such behaviour for a wide set of basic functions, thereby allowing the evaluation of more complex functions such as

\[f(x) = \sin(3x^2 - 2 \cos(1/x))\]

Applications

To illustrate the use of interval arithmetic, consider the following:

julia> using IntervalArithmetic
julia> f(x) = x^2 - 2f (generic function with 1 method)
julia> x = interval(3, 4)Interval{Float64}(3.0, 4.0, com)
julia> f(x)Interval{Float64}(7.0, 14.0, com, NG)

Since f(x) does not contain 0, the true range of the function $f$ over the interval $[3, 4]$ is guaranteed not to contain $0$, and hence we obtain the following property.

Theorem: $f$ has no root in the interval $[3, 4]$.

This theorem has been obtained using floating-point computations! In fact, we can even extend this to semi-infinite intervals:

julia> f(interval(3, Inf))Interval{Float64}(7.0, Inf, dac, NG)

Therefore, we have excluded the whole unbounded set $[3, \infty)$ from possibly containing roots of $f$.

Interval arithmetic is the foundation of more powerful and elaborate methods in the field of computer-assisted proofs (see e.g. IntervalRootFinding.jl).

The interested reader may refer to the following books:

+\end{cases}\]

Of course, we must round the lower endpoint down and the upper endpoint up to get a guaranteed enclosure of the true result.

IntervalArithmetic defines such behaviour for a wide set of basic functions, thereby allowing the evaluation of more complex functions such as

\[f(x) = \sin(3x^2 - 2 \cos(1/x))\]

Applications

To illustrate the use of interval arithmetic, consider the following:

julia> using IntervalArithmetic
julia> f(x) = x^2 - 2f (generic function with 1 method)
julia> x = interval(3, 4)Interval{Float64}(3.0, 4.0, com)
julia> f(x)Interval{Float64}(7.0, 14.0, com, NG)

Since f(x) does not contain 0, the true range of the function $f$ over the interval $[3, 4]$ is guaranteed not to contain $0$, and hence we obtain the following property.

Theorem: $f$ has no root in the interval $[3, 4]$.

This theorem has been obtained using floating-point computations! In fact, we can even extend this to semi-infinite intervals:

julia> f(interval(3, Inf))Interval{Float64}(7.0, Inf, dac, NG)

Therefore, we have excluded the whole unbounded set $[3, \infty)$ from possibly containing roots of $f$.

Interval arithmetic is the foundation of more powerful and elaborate methods in the field of computer-assisted proofs (see e.g. IntervalRootFinding.jl).

The interested reader may refer to the following books:

diff --git a/dev/manual/api/index.html b/dev/manual/api/index.html index df615ed05..40c4868bc 100644 --- a/dev/manual/api/index.html +++ b/dev/manual/api/index.html @@ -1,5 +1,5 @@ -API · IntervalArithmetic.jl

API

IntervalArithmetic.BareIntervalType
BareInterval{T<:NumTypes}

Interval type for guaranteed computation with interval arithmetic according to the IEEE Standard 1788-2015. Unlike Interval, this bare interval does not have decorations, is not a subtype of Real and errors on operations mixing BareInterval and Number.

Fields:

  • lo :: T
  • hi :: T

Constructor compliant with the IEEE Standard 1788-2015: bareinterval.

See also: Interval.

source
IntervalArithmetic.DecorationType
Decoration

Enumeration constant for the types of interval decorations described in Section 11.2 of the IEEE Standard 1788-2015:

  • com -> 4 (common): non-empty, continuous and bounded interval.
  • dac -> 3 (defined and continuous): non-empty and continuous interval.
  • def -> 2 (defined): non-empty interval.
  • trv -> 1 (trivial): meaningless interval.
  • ill -> 0 (ill-formed): not an interval (NaI).
source
IntervalArithmetic.FlavorType
Flavor{F}

A flavor defining how an interval behaves in edge cases. For instance, infinity may or not be considered part of unbounded intervals.

Some flavors F include:

  • :set_based (default): elements of an interval are real numbers. In particular, infinity is never part of an interval. This flavor is described and required in Part 2 of the IEEE Standard 1788-2015. Edge cases: - any unbounded interval does not contain infinity. - $[0, 0] / [0, 0] = \emptyset$. - $x / [0, 0] = \emptyset$ for any interval $x$. - $x \times [0, 0] = [0, 0]$ for any interval $x$.
  • :cset: elements of an interval are either real numbers, or $\pm \infty$, applying standard rule for arithmetic with infinity. Edge cases: - any unbounded interval contains infinity. - $[0, 0] / [0, 0] = [-\infty, \infty]$. - $x / [0, 0] = [-\infty, \infty]$ for any interval $x$. - $x \times [0, 0] = [-\infty, \infty]$ for any unbounded interval $x$.
Note

Currently only the flavor :set_based is supported and implemented.

Examples

julia> IntervalArithmetic.default_flavor()
+API · IntervalArithmetic.jl

API

IntervalArithmetic.BareIntervalType
BareInterval{T<:NumTypes}

Interval type for guaranteed computation with interval arithmetic according to the IEEE Standard 1788-2015. Unlike Interval, this bare interval does not have decorations, is not a subtype of Real and errors on operations mixing BareInterval and Number.

Fields:

  • lo :: T
  • hi :: T

Constructor compliant with the IEEE Standard 1788-2015: bareinterval.

See also: Interval.

source
IntervalArithmetic.DecorationType
Decoration

Enumeration constant for the types of interval decorations described in Section 11.2 of the IEEE Standard 1788-2015:

  • com -> 4 (common): non-empty, continuous and bounded interval.
  • dac -> 3 (defined and continuous): non-empty and continuous interval.
  • def -> 2 (defined): non-empty interval.
  • trv -> 1 (trivial): meaningless interval.
  • ill -> 0 (ill-formed): not an interval (NaI).
source
IntervalArithmetic.FlavorType
Flavor{F}

A flavor defining how an interval behaves in edge cases. For instance, infinity may or not be considered part of unbounded intervals.

Some flavors F include:

  • :set_based (default): elements of an interval are real numbers. In particular, infinity is never part of an interval. This flavor is described and required in Part 2 of the IEEE Standard 1788-2015. Edge cases: - any unbounded interval does not contain infinity. - $[0, 0] / [0, 0] = \emptyset$. - $x / [0, 0] = \emptyset$ for any interval $x$. - $x \times [0, 0] = [0, 0]$ for any interval $x$.
  • :cset: elements of an interval are either real numbers, or $\pm \infty$, applying standard rule for arithmetic with infinity. Edge cases: - any unbounded interval contains infinity. - $[0, 0] / [0, 0] = [-\infty, \infty]$. - $x / [0, 0] = [-\infty, \infty]$ for any interval $x$. - $x \times [0, 0] = [-\infty, \infty]$ for any unbounded interval $x$.
Note

Currently only the flavor :set_based is supported and implemented.

Examples

julia> IntervalArithmetic.default_flavor()
 IntervalArithmetic.Flavor{:set_based}()
 
 julia> isempty_interval(bareinterval(Inf, Inf))
@@ -17,15 +17,15 @@
 true
 
 julia> isthinzero(bareinterval(0)*bareinterval(-Inf, Inf))
-true
source
IntervalArithmetic.IntervalType
Interval{T<:NumTypes} <: Real

Interval type for guaranteed computation with interval arithmetic according to the IEEE Standard 1788-2015. This structure combines a BareInterval together with a Decoration.

Fields:

  • bareinterval :: BareInterval{T}
  • decoration :: Decoration
  • isguaranteed :: Bool

Constructors compliant with the IEEE Standard 1788-2015:

See also: ±, .. and @I_str.

source
IntervalArithmetic.PowerModeType
PowerMode

Power mode type for ^.

Available mode types:

  • :fast (default): x ^ y is semantically equivalent to fastpow(x, y),

unless isthininteger(y) is true in which case it is semantically equivalent to fastpown(x, sup(y)).

  • :slow: x ^ y is semantically equivalent to pow(x, y), unless

isthininteger(y) is true in which case it is semantically equivalent to pown(x, sup(y)).

source
Base.:*Method
*(x::BareInterval, y::BareInterval)
-*(x::Interval, y::Interval)

Implement the mul function of the IEEE Standard 1788-2015 (Table 9.1).

Note

The behavior of * is flavor dependent for some edge cases.

source
Base.:+Method
+(x::BareInterval, y::BareInterval)
-+(x::Interval, y::Interval)

Implement the add function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.:-Method
-(x::BareInterval)
--(x::Interval)

Implement the neg function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.:-Method
-(x::BareInterval, y::BareInterval)
--(x::Interval, y::Interval)

Implement the sub function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.:/Method
/(x::BareInterval, y::BareInterval)
-/(x::Interval, y::Interval)

Implement the div function of the IEEE Standard 1788-2015 (Table 9.1).

Note

The behavior of / is flavor dependent for some edge cases.

source
IntervalArithmetic.IntervalType
Interval{T<:NumTypes} <: Real

Interval type for guaranteed computation with interval arithmetic according to the IEEE Standard 1788-2015. This structure combines a BareInterval together with a Decoration.

Fields:

  • bareinterval :: BareInterval{T}
  • decoration :: Decoration
  • isguaranteed :: Bool

Constructors compliant with the IEEE Standard 1788-2015:

See also: ±, .. and @I_str.

source
IntervalArithmetic.PowerModeType
PowerMode

Power mode type for ^.

Available mode types:

  • :fast (default): x ^ y is semantically equivalent to fastpow(x, y),

unless isthininteger(y) is true in which case it is semantically equivalent to fastpown(x, sup(y)).

  • :slow: x ^ y is semantically equivalent to pow(x, y), unless

isthininteger(y) is true in which case it is semantically equivalent to pown(x, sup(y)).

source
Base.:*Method
*(x::BareInterval, y::BareInterval)
+*(x::Interval, y::Interval)

Implement the mul function of the IEEE Standard 1788-2015 (Table 9.1).

Note

The behavior of * is flavor dependent for some edge cases.

source
Base.:+Method
+(x::BareInterval, y::BareInterval)
++(x::Interval, y::Interval)

Implement the add function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.:-Method
-(x::BareInterval)
+-(x::Interval)

Implement the neg function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.:-Method
-(x::BareInterval, y::BareInterval)
+-(x::Interval, y::Interval)

Implement the sub function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.:/Method
/(x::BareInterval, y::BareInterval)
+/(x::Interval, y::Interval)

Implement the div function of the IEEE Standard 1788-2015 (Table 9.1).

Note

The behavior of / is flavor dependent for some edge cases.

source
Base.:==Method
==(::BareInterval, ::Number)
 ==(::Number, ::BareInterval)
 ==(::Interval, ::Number)
-==(::Number, ::Interval)

Test whether an interval is the singleton of a given number. In other words, the result is true if and only if the interval contains only that number.

Note

Comparison between intervals is purposely disallowed. Indeed, equality between non-singleton intervals has distinct properties, notably $x = y$ does not imply $x - y = 0$. See instead isequal_interval.

source
Base.:^Method
^(x::BareInterval, y::BareInterval)
+==(::Number, ::Interval)

Test whether an interval is the singleton of a given number. In other words, the result is true if and only if the interval contains only that number.

Note

Comparison between intervals is purposely disallowed. Indeed, equality between non-singleton intervals has distinct properties, notably $x = y$ does not imply $x - y = 0$. See instead isequal_interval.

source
Base.:^Method
^(x::BareInterval, y::BareInterval)
 ^(x::Interval, y::Interval)

Compute the power of the positive real part of x by y. This function is not in the IEEE Standard 1788-2015. Its behaviour depend on the current PowerMode.

See also: pow and pown.

Examples

julia> setdisplay(:full);
 
 julia> bareinterval(2, 3) ^ bareinterval(2)
@@ -35,34 +35,34 @@
 Interval{Float64}(-1.0, 1.0, com)
 
 julia> interval(-1, 1) ^ interval(-3)
-Interval{Float64}(-Inf, Inf, trv)
source
Base.Math.acotMethod
acot(::BareInterval)
-acot(::Interval)

Implement the acot function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.Math.acothMethod
acoth(::BareInterval)
-acoth(::Interval)

Implement the acoth function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.Math.cotMethod
cot(::BareInterval)
-cot(::Interval)

Implement the cot function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.Math.cothMethod
coth(::BareInterval)
-coth(::Interval)

Implement the coth function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.Math.cscMethod
csc(::BareInterval)
-csc(::Interval)

Implement the csc function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.Math.cschMethod
csch(::BareInterval)
-csch(::Interval)

Implement the csch function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.Math.hypotMethod
hypot(x, y)

Compute the hypotenuse.

Implement the hypot function of the IEEE Standard 1788-2015 (Table 10.5).

source
Base.Math.secMethod
sec(::BareInterval)
-sec(::Interval)

Implement the sec function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.Math.sechMethod
sech(::BareInterval)
-sech(::Interval)

Implement the sech function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.absMethod
abs(x::BareInterval)
-abs(x::Interval)

Implement the abs function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.abs2Method
abs2(x::BareInterval)
-abs2(x::Interval)

Implement the square absolute value.

Note

This function calls ^ internally, hence it depends on IntervalArithmetic.power_mode().

source
Base.acosMethod
acos(::BareInterval)
-acos(::Interval)

Implement the acos function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.acoshMethod
acosh(::BareInterval)
-acosh(::Interval)

Implement the acosh function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.asinMethod
asin(::BareInterval)
-asin(::Interval)

Implement the asin function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.asinhMethod
asinh(::BareInterval)
-asinh(::Interval)

Implement the asinh function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.atanMethod
atan(::BareInterval)
-atan(::Interval)

Implement the atan function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.atanMethod
atan(::BareInterval, ::BareInterval)
-atan(::Interval, ::Interval)

Implement the atan2 function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.atanhMethod
atanh(::BareInterval)
-atanh(::Interval)

Implement the atanh function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.ceilMethod
ceil(x::BareInterval)
-ceil(x::Interval)

Implement the ceil function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.cosMethod
cos(::BareInterval)
-cos(::Interval)

Implement the cos function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.coshMethod
cosh(::BareInterval)
-cosh(::Interval)

Implement the cosh function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.floorMethod
floor(x::BareInterval)
-floor(x::Interval)

Implement the floor function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.fmaMethod
fma(x::BareInterval, y::BareInterval, z::BareInterval)
-fma(x::Interval, y::Interval, z::Interval)

Implement the fma function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.hashMethod
hash(x::BareInterval, h::UInt)
-hash(x::Interval, h::UInt)

Compute the integer hash code for an interval. Note that equality of intervals is given by isequal_interval rather than the == operator.

source
Base.invMethod
inv(x::BareInterval)
-inv(x::Interval)

Implement the recip function of the IEEE Standard 1788-2015 (Table 9.1).

Note

The behavior of inv is flavor dependent for some edge cases.

source
Base.maxMethod
max(x::BareInterval, y::BareInterval)
-max(x::Interval, y::Interval)

Implement the max function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.minMethod
min(x::BareInterval, y::BareInterval)
-min(x::Interval, y::Interval)

Implement the min function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.muladdMethod
muladd(x::BareInterval, y::BareInterval z::BareInterval)
-muladd(x::Interval, y::Interval z::Interval)

Implement the combined multiply-add; this is semantically equivalent to x * y + z.

source
Base.parseMethod
parse(T<:BareInterval, str)
+Interval{Float64}(-Inf, Inf, trv)
source
Base.Math.acotMethod
acot(::BareInterval)
+acot(::Interval)

Implement the acot function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.Math.acothMethod
acoth(::BareInterval)
+acoth(::Interval)

Implement the acoth function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.Math.cotMethod
cot(::BareInterval)
+cot(::Interval)

Implement the cot function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.Math.cothMethod
coth(::BareInterval)
+coth(::Interval)

Implement the coth function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.Math.cscMethod
csc(::BareInterval)
+csc(::Interval)

Implement the csc function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.Math.cschMethod
csch(::BareInterval)
+csch(::Interval)

Implement the csch function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.Math.hypotMethod
hypot(x, y)

Compute the hypotenuse.

Implement the hypot function of the IEEE Standard 1788-2015 (Table 10.5).

source
Base.Math.secMethod
sec(::BareInterval)
+sec(::Interval)

Implement the sec function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.Math.sechMethod
sech(::BareInterval)
+sech(::Interval)

Implement the sech function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.absMethod
abs(x::BareInterval)
+abs(x::Interval)

Implement the abs function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.abs2Method
abs2(x::BareInterval)
+abs2(x::Interval)

Implement the square absolute value.

Note

This function calls ^ internally, hence it depends on IntervalArithmetic.power_mode().

source
Base.acosMethod
acos(::BareInterval)
+acos(::Interval)

Implement the acos function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.acoshMethod
acosh(::BareInterval)
+acosh(::Interval)

Implement the acosh function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.asinMethod
asin(::BareInterval)
+asin(::Interval)

Implement the asin function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.asinhMethod
asinh(::BareInterval)
+asinh(::Interval)

Implement the asinh function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.atanMethod
atan(::BareInterval)
+atan(::Interval)

Implement the atan function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.atanMethod
atan(::BareInterval, ::BareInterval)
+atan(::Interval, ::Interval)

Implement the atan2 function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.atanhMethod
atanh(::BareInterval)
+atanh(::Interval)

Implement the atanh function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.ceilMethod
ceil(x::BareInterval)
+ceil(x::Interval)

Implement the ceil function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.cosMethod
cos(::BareInterval)
+cos(::Interval)

Implement the cos function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.coshMethod
cosh(::BareInterval)
+cosh(::Interval)

Implement the cosh function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.floorMethod
floor(x::BareInterval)
+floor(x::Interval)

Implement the floor function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.fmaMethod
fma(x::BareInterval, y::BareInterval, z::BareInterval)
+fma(x::Interval, y::Interval, z::Interval)

Implement the fma function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.hashMethod
hash(x::BareInterval, h::UInt)
+hash(x::Interval, h::UInt)

Compute the integer hash code for an interval. Note that equality of intervals is given by isequal_interval rather than the == operator.

source
Base.invMethod
inv(x::BareInterval)
+inv(x::Interval)

Implement the recip function of the IEEE Standard 1788-2015 (Table 9.1).

Note

The behavior of inv is flavor dependent for some edge cases.

source
Base.maxMethod
max(x::BareInterval, y::BareInterval)
+max(x::Interval, y::Interval)

Implement the max function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.minMethod
min(x::BareInterval, y::BareInterval)
+min(x::Interval, y::Interval)

Implement the min function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.muladdMethod
muladd(x::BareInterval, y::BareInterval z::BareInterval)
+muladd(x::Interval, y::Interval z::Interval)

Implement the combined multiply-add; this is semantically equivalent to x * y + z.

source
Base.parseMethod
parse(T<:BareInterval, str)
 parse(T<:Interval, str)

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).

Parse a string of the form "[a, b]_dec" as an Interval 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 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> setdisplay(:full);
 
 julia> parse(BareInterval{Float64}, "[1, 2]")
@@ -84,15 +84,15 @@
 Interval{Float64}(1.0, 2.0, def)
 
 julia> parse(Interval{Float64}, "[1, 1e400]_com")
-Interval{Float64}(1.0, Inf, dac)
source
Base.roundMethod
round(x::BareInterval, [RoundingMode])
-round(x::Interval, [RoundingMode])

Return an interval with the bounds of x rounded to an integer.

Implement the functions roundTiesToEven and roundTiesToAway of the IEEE Standard 1788-2015.

source
Base.signMethod
sign(x::BareInterval)
-sign(x::Interval)

Implement the sign function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.sinMethod
sin(::BareInterval)
-sin(::Interval)

Implement the sin function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.sinhMethod
sinh(::BareInterval)
-sinh(::Interval)

Implement the sinh function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.sqrtMethod
sqrt(x::BareInterval)
-sqrt(x::Interval)

Implement the sqrt function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.tanMethod
tan(::BareInterval)
-tan(::Interval)

Implement the tan function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.tanhMethod
tanh(::BareInterval)
-tanh(::Interval)

Implement the tanh function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.truncMethod
trunc(x::BareInterval)
-trunc(x::Interval)

Implement the trunc function of the IEEE Standard 1788-2015 (Table 9.1).

source
IntervalArithmetic._interval_infsupMethod
_interval_infsup(T<:NumTypes, a, b, [d::Decoration])

Internal constructor for intervals described by their lower and upper bounds, i.e. of the form $[a, b]$.

source
IntervalArithmetic._round_exprMethod
_round_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)
source
IntervalArithmetic._unsafe_bareintervalFunction
_unsafe_bareinterval(T<:NumTypes, lo, hi)

Internal constructor which assumes that is_valid_interval(lo, hi) == true.

Danger

This constructor is not compliant with the IEEE Standard 1788-2015. Since misuse of this function can deeply corrupt code, its usage is strongly discouraged in favour of bareinterval.

source
IntervalArithmetic._unsafe_intervalFunction
_unsafe_interval(bareinterval::BareInterval, decoration::Decoration, isguaranteed::Bool)

Internal constructor which assumes that bareinterval and its decoration decoration are compliant with the IEEE Standard 1788-2015.

Danger

This constructor is not compliant with the IEEE Standard 1788-2015. Since misuse of this function can deeply corrupt code, its usage is strongly discouraged in favour of interval.

source
IntervalArithmetic.atomicMethod
atomic(T<:Union{Rational,AbstractFloat}, x)

Create an interval according to the IEEE Standard 1788-2015. The returned Interval{T} always contains the value x; this is semantically equivalent to parse(Interval{T}, string(x)) if x is a Number.

Examples

julia> setdisplay(:full);
+Interval{Float64}(1.0, Inf, dac)
source
Base.roundMethod
round(x::BareInterval, [RoundingMode])
+round(x::Interval, [RoundingMode])

Return an interval with the bounds of x rounded to an integer.

Implement the functions roundTiesToEven and roundTiesToAway of the IEEE Standard 1788-2015.

source
Base.signMethod
sign(x::BareInterval)
+sign(x::Interval)

Implement the sign function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.sinMethod
sin(::BareInterval)
+sin(::Interval)

Implement the sin function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.sinhMethod
sinh(::BareInterval)
+sinh(::Interval)

Implement the sinh function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.sqrtMethod
sqrt(x::BareInterval)
+sqrt(x::Interval)

Implement the sqrt function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.tanMethod
tan(::BareInterval)
+tan(::Interval)

Implement the tan function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.tanhMethod
tanh(::BareInterval)
+tanh(::Interval)

Implement the tanh function of the IEEE Standard 1788-2015 (Table 9.1).

source
Base.truncMethod
trunc(x::BareInterval)
+trunc(x::Interval)

Implement the trunc function of the IEEE Standard 1788-2015 (Table 9.1).

source
IntervalArithmetic._interval_infsupMethod
_interval_infsup(T<:NumTypes, a, b, [d::Decoration])

Internal constructor for intervals described by their lower and upper bounds, i.e. of the form $[a, b]$.

source
IntervalArithmetic._round_exprMethod
_round_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)
source
IntervalArithmetic._unsafe_bareintervalFunction
_unsafe_bareinterval(T<:NumTypes, lo, hi)

Internal constructor which assumes that is_valid_interval(lo, hi) == true.

Danger

This constructor is not compliant with the IEEE Standard 1788-2015. Since misuse of this function can deeply corrupt code, its usage is strongly discouraged in favour of bareinterval.

source
IntervalArithmetic._unsafe_intervalFunction
_unsafe_interval(bareinterval::BareInterval, decoration::Decoration, isguaranteed::Bool)

Internal constructor which assumes that bareinterval and its decoration decoration are compliant with the IEEE Standard 1788-2015.

Danger

This constructor is not compliant with the IEEE Standard 1788-2015. Since misuse of this function can deeply corrupt code, its usage is strongly discouraged in favour of interval.

source
IntervalArithmetic.atomicMethod
atomic(T<:Union{Rational,AbstractFloat}, x)

Create an interval according to the IEEE Standard 1788-2015. The returned Interval{T} always contains the value x; this is semantically equivalent to parse(Interval{T}, string(x)) if x is a Number.

Examples

julia> setdisplay(:full);
 
 julia> x = IntervalArithmetic.atomic(Float64, 0.1)
 Interval{Float64}(0.09999999999999999, 0.1, com)
@@ -104,7 +104,7 @@
 Interval{Float64}(0.3, 0.30000000000000004, com)
 
 julia> in_interval(3//10, IntervalArithmetic.atomic(Float64, 0.3))
-true
source
IntervalArithmetic.bareintervalMethod
bareinterval([T<:Union{Rational,AbstractFloat}=default_numtype()], a, b)

Create the bare interval $[a, b]$ according to the IEEE Standard 1788-2015. The validity of the interval is checked by is_valid_interval: if true then a BareInterval{T} is constructed, otherwise an empty interval is returned.

Danger

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, parse the string containing the desired value to ensure its tight enclosure.

See also: interval, ±, .. and @I_str.

Examples

julia> setdisplay(:full);
+true
source
IntervalArithmetic.bareintervalMethod
bareinterval([T<:Union{Rational,AbstractFloat}=default_numtype()], a, b)

Create the bare interval $[a, b]$ according to the IEEE Standard 1788-2015. The validity of the interval is checked by is_valid_interval: if true then a BareInterval{T} is constructed, otherwise an empty interval is returned.

Danger

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, parse the string containing the desired value to ensure its tight enclosure.

See also: interval, ±, .. and @I_str.

Examples

julia> setdisplay(:full);
 
 julia> bareinterval(1//1, π)
 BareInterval{Rational{Int64}}(1//1, 85563208//27235615)
@@ -116,8 +116,8 @@
 BareInterval{Float64}(1.0, 3.1415926535897936)
 
 julia> bareinterval(BigFloat, 1, π)
-BareInterval{BigFloat}(1.0, 3.141592653589793238462643383279502884197169399375105820974944592307816406286233)
source
IntervalArithmetic.bisectMethod
bisect(x, α=0.5)
-bisect(x, i, α=0.5)

Split an interval x at a relative position α, where α = 0.5 corresponds to the midpoint.

Split the i-th component of a vector x at a relative position α, where α = 0.5 corresponds to the midpoint.

source
IntervalArithmetic.cancelminusMethod
cancelminus(x, y)

Compute the unique interval z such that y + z == x.

The result is decorated by at most trv (Section 11.7.1).

Implement the cancelMinus function of the IEEE Standard 1788-2015 (Section 9.2).

source
IntervalArithmetic.cancelplusMethod
cancelplus(x, y)

Compute the unique interval z such that y - z == x; this is semantically equivalent to cancelminus(x, -y).

The result is decorated by at most trv (Section 11.7.1).

Implement the cancelPlus function of the IEEE Standard 1788-2015 (Section 9.2).

source
IntervalArithmetic.default_numtypeMethod
default_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 NumTypes.

Examples

julia> IntervalArithmetic.default_numtype() = Float32
+BareInterval{BigFloat}(1.0, 3.141592653589793238462643383279502884197169399375105820974944592307816406286233)
source
IntervalArithmetic.bisectMethod
bisect(x, α=0.5)
+bisect(x, i, α=0.5)

Split an interval x at a relative position α, where α = 0.5 corresponds to the midpoint.

Split the i-th component of a vector x at a relative position α, where α = 0.5 corresponds to the midpoint.

source
IntervalArithmetic.cancelminusMethod
cancelminus(x, y)

Compute the unique interval z such that y + z == x.

The result is decorated by at most trv (Section 11.7.1).

Implement the cancelMinus function of the IEEE Standard 1788-2015 (Section 9.2).

source
IntervalArithmetic.cancelplusMethod
cancelplus(x, y)

Compute the unique interval z such that y - z == x; this is semantically equivalent to cancelminus(x, -y).

The result is decorated by at most trv (Section 11.7.1).

Implement the cancelPlus function of the IEEE Standard 1788-2015 (Section 9.2).

source
IntervalArithmetic.default_numtypeMethod
default_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 NumTypes.

Examples

julia> IntervalArithmetic.default_numtype() = Float32
 
 julia> typeof(interval(1, 2))
 Interval{Float32}
@@ -131,7 +131,7 @@
 Interval{Float64}
 
 julia> typeof(interval(1, big(2)))
-Interval{BigFloat}
source
IntervalArithmetic.emptyintervalMethod
emptyinterval(T=default_numtype())

Create an empty interval. This interval is an exception to the fact that the lower bound is larger than the upper one.

Implement the empty function of the IEEE Standard 1788-2015 (Section 10.5.2).

source
IntervalArithmetic.entireintervalMethod
entireinterval(T=default_numtype())

Create an interval representing the entire real line, or the entire complex plane if T is complex.

Note

Depending on the flavor, infinity may or may not be considered part of the interval.

Implement the entire function of the IEEE Standard 1788-2015 (Section 10.5.2).

source
IntervalArithmetic.hullMethod
hull(x, y)

Return the interval hull of the intervals x and y, considered as (extended) sets of real numbers, i.e. the smallest interval that contains all of x and y.

The result is decorated by at most trv (Section 11.7.1).

Implement the convexHull function of the IEEE Standard 1788-2015 (Section 9.3).

source
IntervalArithmetic.intersect_intervalMethod
intersect_interval(x, y)

Returns the intersection of the intervals x and y, considered as (extended) sets of real numbers. That is, the set that contains the points common in x and y.

The result is decorated by at most trv (Section 11.7.1).

Implement the intersection function of the IEEE Standard 1788-2015 (Section 9.3).

source
IntervalArithmetic.intervalMethod
interval([T<:Union{Rational,AbstractFloat}=default_numtype()], a, b, d = com)

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 an NaI (Not an Interval) is returned.

Danger

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, parse the string containing the desired value to ensure its tight enclosure.

See also: ±, .. and @I_str.

Examples

julia> setdisplay(:full);
+Interval{BigFloat}
source
IntervalArithmetic.emptyintervalMethod
emptyinterval(T=default_numtype())

Create an empty interval. This interval is an exception to the fact that the lower bound is larger than the upper one.

Implement the empty function of the IEEE Standard 1788-2015 (Section 10.5.2).

source
IntervalArithmetic.entireintervalMethod
entireinterval(T=default_numtype())

Create an interval representing the entire real line, or the entire complex plane if T is complex.

Note

Depending on the flavor, infinity may or may not be considered part of the interval.

Implement the entire function of the IEEE Standard 1788-2015 (Section 10.5.2).

source
IntervalArithmetic.hullMethod
hull(x, y)

Return the interval hull of the intervals x and y, considered as (extended) sets of real numbers, i.e. the smallest interval that contains all of x and y.

The result is decorated by at most trv (Section 11.7.1).

Implement the convexHull function of the IEEE Standard 1788-2015 (Section 9.3).

source
IntervalArithmetic.intersect_intervalMethod
intersect_interval(x, y)

Returns the intersection of the intervals x and y, considered as (extended) sets of real numbers. That is, the set that contains the points common in x and y.

The result is decorated by at most trv (Section 11.7.1).

Implement the intersection function of the IEEE Standard 1788-2015 (Section 9.3).

source
IntervalArithmetic.intervalMethod
interval([T<:Union{Rational,AbstractFloat}=default_numtype()], a, b, d = com)

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 an NaI (Not an Interval) is returned.

Danger

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, parse the string containing the desired value to ensure its tight enclosure.

See also: ±, .. and @I_str.

Examples

julia> setdisplay(:full);
 
 julia> interval(1//1, π)
 Interval{Rational{Int64}}(1//1, 85563208//27235615, com)
@@ -143,7 +143,7 @@
 Interval{Float64}(1.0, 3.1415926535897936, com)
 
 julia> interval(BigFloat, 1, π)
-Interval{BigFloat}(1.0, 3.141592653589793238462643383279502884197169399375105820974944592307816406286233, com)
source
IntervalArithmetic.isatomicMethod
isatomic(x)

Test whether x is unable to be split. This occurs if the interval is empty, or if its lower and upper bounds are equal, or if the bounds are consecutive floating-point numbers.

source
IntervalArithmetic.iscommonMethod
iscommon(x)

Test whether x is not empty and bounded.

Note

This is does not take into consideration the decoration of the interval.

source
IntervalArithmetic.isguaranteedMethod
isguaranteed(x::BareInterval)
+Interval{BigFloat}(1.0, 3.141592653589793238462643383279502884197169399375105820974944592307816406286233, com)
source
IntervalArithmetic.isatomicMethod
isatomic(x)

Test whether x is unable to be split. This occurs if the interval is empty, or if its lower and upper bounds are equal, or if the bounds are consecutive floating-point numbers.

source
IntervalArithmetic.iscommonMethod
iscommon(x)

Test whether x is not empty and bounded.

Note

This is does not take into consideration the decoration of the interval.

source
IntervalArithmetic.isguaranteedMethod
isguaranteed(x::BareInterval)
 isguaranteed(x::Interval)
 isguaranteed(x::Complex{<:Interval})

Test whether the interval is not guaranteed to encompass all possible numerical errors. This happens whenever an Interval is constructed using convert(::Type{<:Interval}, ::Real), which may occur implicitly when mixing intervals and Real types.

Since conversion between BareInterval and Number is prohibited, this implies that isguaranteed(::BareInterval) == true.

In the case of a complex interval x, this is semantically equivalent to isguaranteed(real(x)) & isguaranteed(imag(x)).

Examples

julia> isguaranteed(bareinterval(1))
 true
@@ -155,12 +155,12 @@
 false
 
 julia> isguaranteed(interval(1) + 0)
-false
source
IntervalArithmetic.isstrictlessMethod
isstrictless(x, y)

Test whether inf(x) < inf(y) and sup(x) < sup(y), where < is replaced by for infinite values.

Implement the strictLess function of the IEEE Standard 1788-2015 (Table 10.3).

source
IntervalArithmetic.isstrictsubsetMethod
isstrictsubset(x, y)

Test whether x is a strict subset of y. If x and y are intervals, this is semantically equivalent to isinterior(x, y). If x and y are vectors, at least one component of x must be in the interior of y.

See also: isinterior.

source
IntervalArithmetic.isthinMethod
isthin(x)

Test whether x contains only a real.

Implement the isSingleton function of the IEEE Standard 1788-2015 (Table 9.3).

source
IntervalArithmetic.isweaklessMethod
isweakless(x, y)

Test whether inf(x) ≤ inf(y) and sup(x) ≤ sup(y), where < is replaced by for infinite values.

Implement the less function of the IEEE Standard 1788-2015 (Table 10.3).

source
IntervalArithmetic.minceMethod
mince(x, n)

Split an interval x in n intervals of the same diameter.

Split the i-th component of a vector x in n[i] intervals of the same diameter; n can be a tuple of integers, or a single integer in which case the same n is used for all the components of x.

source
IntervalArithmetic.isstrictlessMethod
isstrictless(x, y)

Test whether inf(x) < inf(y) and sup(x) < sup(y), where < is replaced by for infinite values.

Implement the strictLess function of the IEEE Standard 1788-2015 (Table 10.3).

source
IntervalArithmetic.isstrictsubsetMethod
isstrictsubset(x, y)

Test whether x is a strict subset of y. If x and y are intervals, this is semantically equivalent to isinterior(x, y). If x and y are vectors, at least one component of x must be in the interior of y.

See also: isinterior.

source
IntervalArithmetic.isthinMethod
isthin(x)

Test whether x contains only a real.

Implement the isSingleton function of the IEEE Standard 1788-2015 (Table 9.3).

source
IntervalArithmetic.isweaklessMethod
isweakless(x, y)

Test whether inf(x) ≤ inf(y) and sup(x) ≤ sup(y), where < is replaced by for infinite values.

Implement the less function of the IEEE Standard 1788-2015 (Table 10.3).

source
IntervalArithmetic.minceMethod
mince(x, n)

Split an interval x in n intervals of the same diameter.

Split the i-th component of a vector x in n[i] intervals of the same diameter; n can be a tuple of integers, or a single integer in which case the same n is used for all the components of x.

source
IntervalArithmetic.numtypeMethod
numtype(T)

Return the bounds type of the interval.

Examples

julia> IntervalArithmetic.numtype(interval(1, 2))
 Float64
 
 julia> IntervalArithmetic.numtype(interval(Float32, 1, 2))
-Float32
source
IntervalArithmetic.overlapMethod
overlap(x::BareInterval, y::BareInterval)
-overlap(x::Interval, y::Interval)

Implement the overlap function of the IEEE Standard 1788-2015 (Table 10.7).

source
IntervalArithmetic.powMethod
pow(x, y)

Compute the power of the positive real part of x by y. In particular, even if y is a thin integer, this is not equivalent to pown(x, sup(y)).

Implement the pow function of the IEEE Standard 1788-2015 (Table 9.1).

See also: pown.

Examples

julia> setdisplay(:full);
+Float32
source
IntervalArithmetic.overlapMethod
overlap(x::BareInterval, y::BareInterval)
+overlap(x::Interval, y::Interval)

Implement the overlap function of the IEEE Standard 1788-2015 (Table 10.7).

source
IntervalArithmetic.powMethod
pow(x, y)

Compute the power of the positive real part of x by y. In particular, even if y is a thin integer, this is not equivalent to pown(x, sup(y)).

Implement the pow function of the IEEE Standard 1788-2015 (Table 9.1).

See also: pown.

Examples

julia> setdisplay(:full);
 
 julia> pow(bareinterval(2, 3), bareinterval(2))
 BareInterval{Float64}(4.0, 9.0)
@@ -169,7 +169,7 @@
 Interval{Float64}(0.0, 1.0, trv)
 
 julia> pow(interval(-1, 1), interval(-3))
-Interval{Float64}(1.0, Inf, trv)
source
IntervalArithmetic.pownMethod
pown(x, n)

Implement the pown function of the IEEE Standard 1788-2015 (Table 9.1).

Examples

julia> setdisplay(:full);
+Interval{Float64}(1.0, Inf, trv)
source
IntervalArithmetic.pownMethod
pown(x, n)

Implement the pown function of the IEEE Standard 1788-2015 (Table 9.1).

Examples

julia> setdisplay(:full);
 
 julia> pown(bareinterval(2, 3), 2)
 BareInterval{Float64}(4.0, 9.0)
@@ -178,7 +178,7 @@
 Interval{Float64}(-1.0, 1.0, com)
 
 julia> pown(interval(-1, 1), -3)
-Interval{Float64}(-Inf, Inf, trv)
source
IntervalArithmetic.precedesMethod
precedes(x, y)

Test whether any element of x is lesser or equal to every elements of y.

Implement the precedes function of the IEEE Standard 1788-2015 (Table 10.3).

source
IntervalArithmetic.promote_numtypeMethod
promote_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).

source
IntervalArithmetic.radiusMethod
radius(x)

Radius of x, such that issubset_interval(x, mid(x) ± radius(x)). If x is complex, then the radius is the maximum radius between its real and imaginary parts.

Implement the rad function of the IEEE Standard 1788-2015 (Table 9.2).

See also: inf, sup, bounds, mid, diam and midradius.

source
IntervalArithmetic.rootnMethod
rootn(x::BareInterval, n::Integer)

Compute the real n-th root of x.

Implement the rootn function of the IEEE Standard 1788-2015 (Table 9.1).

source
IntervalArithmetic.setdisplayFunction
setdisplay(format::Symbol; decorations::Bool, sigdigits::Int)

Change the format used by show to display intervals.

Possible options:

  • format can be:
    • :infsup: display intervals as [a, b].
    • :midpoint: display intervals as m ± r.
    • :full: display interval bounds entirely, ignoring sigdigits.
  • decorations: display the decorations or not.
  • sigdigits: number (greater or equal to 1) of significant digits to display.

Initially, the display options are set to setdisplay(:infsup; decorations = false, sigdigits = 6). If any of the three argument format, decorations and sigdigits is omitted, then their value is left unchanged.

Examples

julia> setdisplay(:infsup; decorations = true, sigdigits = 6) # default display options
+Interval{Float64}(-Inf, Inf, trv)
source
IntervalArithmetic.precedesMethod
precedes(x, y)

Test whether any element of x is lesser or equal to every elements of y.

Implement the precedes function of the IEEE Standard 1788-2015 (Table 10.3).

source
IntervalArithmetic.promote_numtypeMethod
promote_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).

source
IntervalArithmetic.radiusMethod
radius(x)

Radius of x, such that issubset_interval(x, mid(x) ± radius(x)). If x is complex, then the radius is the maximum radius between its real and imaginary parts.

Implement the rad function of the IEEE Standard 1788-2015 (Table 9.2).

See also: inf, sup, bounds, mid, diam and midradius.

source
IntervalArithmetic.rootnMethod
rootn(x::BareInterval, n::Integer)

Compute the real n-th root of x.

Implement the rootn function of the IEEE Standard 1788-2015 (Table 9.1).

source
IntervalArithmetic.setdisplayFunction
setdisplay(format::Symbol; decorations::Bool, sigdigits::Int)

Change the format used by show to display intervals.

Possible options:

  • format can be:
    • :infsup: display intervals as [a, b].
    • :midpoint: display intervals as m ± r.
    • :full: display interval bounds entirely, ignoring sigdigits.
  • decorations: display the decorations or not.
  • sigdigits: number (greater or equal to 1) of significant digits to display.

Initially, the display options are set to setdisplay(:infsup; decorations = false, sigdigits = 6). If any of the three argument format, decorations and sigdigits is omitted, then their value is left unchanged.

Examples

julia> setdisplay(:infsup; decorations = true, sigdigits = 6) # default display options
 Display options:
   - format: infsup
   - decorations: true
@@ -212,7 +212,7 @@
   - significant digits: 3
 
 julia> x
-[0.0999, 0.301]
source
IntervalArithmetic.strictprecedesMethod
strictprecedes(x, y)

Test whether any element of x is strictly lesser than every elements of y.

Implement the strictPrecedes function of the IEEE Standard 1788-2015 (Table 10.3).

source
IntervalArithmetic.@I_strMacro
I"str"

Create an interval by parsing the string "str"; this is semantically equivalent to parse(Interval{default_numtype()}, "str").

Examples

julia> setdisplay(:full);
+[0.0999, 0.301]
source
IntervalArithmetic.strictprecedesMethod
strictprecedes(x, y)

Test whether any element of x is strictly lesser than every elements of y.

Implement the strictPrecedes function of the IEEE Standard 1788-2015 (Table 10.3).

source
IntervalArithmetic.@I_strMacro
I"str"

Create an interval by parsing the string "str"; this is semantically equivalent to parse(Interval{default_numtype()}, "str").

Examples

julia> setdisplay(:full);
 
 julia> I"[3, 4]"
 Interval{Float64}(3.0, 4.0, com)
@@ -221,11 +221,11 @@
 Interval{Float64}(0.09999999999999999, 0.1, com)
 
 julia> in_interval(1//10, I"0.1")
-true
source
IntervalArithmetic.@intervalMacro
@interval(T, expr)
 @interval(T, expr1, expr2)

Walk through an expression and wrap each argument of functions with the internal constructor atomic.

Examples

julia> setdisplay(:full);
 
 julia> @macroexpand @interval Float64 sin(1)
 :(sin(IntervalArithmetic.atomic(Float64, 1)))
 
 julia> @interval Float64 sin(1) exp(1)
-Interval{Float64}(0.8414709848078965, 2.7182818284590455, com)
source
IntervalArithmetic.@roundMacro
@round(T, ex1, ex2)

Macro for internal use that creates an interval 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).

source
+Interval{Float64}(0.8414709848078965, 2.7182818284590455, com)
source
IntervalArithmetic.@roundMacro
@round(T, ex1, ex2)

Macro for internal use that creates an interval 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).

source
diff --git a/dev/manual/construction/index.html b/dev/manual/construction/index.html index 4cb88e07b..cfc5a011e 100644 --- a/dev/manual/construction/index.html +++ b/dev/manual/construction/index.html @@ -6,4 +6,4 @@ └ @ IntervalArithmetic ~/work/IntervalArithmetic.jl/IntervalArithmetic.jl/src/intervals/construction.jl:432 Interval{Float64}(∅, ill)
julia> interval(NaN)┌ Warning: invalid interval, NaI is returned └ @ IntervalArithmetic ~/work/IntervalArithmetic.jl/IntervalArithmetic.jl/src/intervals/construction.jl:432 -Interval{Float64}(∅, ill)

These are all examples of ill-formed intervals, resulting in the decoration ill.

Danger

The decoration ill is an indicator that an error has occured. Therefore, any interval marked by this decoration cannot be trusted and the code needs to be debugged.

Guarantee

A guarantee is yet another label, independent of decorations, and not described by the IEEE Standard 1788-2015 specifications. Its purpose is to accomodate for Julia's extensive conversion and promotion system, while retaining reliability in computations. Specifically, an interval x constructed via interval satisfies isguaranteed(x) == true. However, if a call to convert(::Type{<:Interval}, ::Real) occurs, then the resulting interval x satisfies isguaranteed(x) == false.

In contrast, a BareInterval can only be constructed via bareinterval, it is not a subtype of Real, and there are no allowed conversion with Number. Thus, this interval type is always guaranteed.

Danger

A user interested in validated numerics should always have a resulting interval for which isguaranteed is true.

More constructors

The submodule IntervalArithmetic.Symbols exports the infix operator .. and ± as an alias for interval; this submodule must be explicitly imported.

julia> using IntervalArithmetic.Symbols
julia> 0.1 .. 0.2 # interval(0.1, 0.2; format = :infsup)Interval{Float64}(0.1, 0.2, com)
julia> 0.1 ± 0.2 # interval(0.1, 0.2; format = :midpoint)Interval{Float64}(-0.1, 0.30000000000000004, com)

Moreover, one can parse strings into intervals. The various string formats are the following:

To add a specific decoration, add "_com", "_dac", "_dec", "_trv" and "_ill" at the end of the string.

Danger

Most real numbers cannot be exactly represented by floating-points. In such cases, the literal expression is rounded at parse time. To construct an interval enclosing the true real number, one must rely on the string constructor mentioned above.

For instance, consider

julia> x = 0.10.1

This appears to store the real number $1/10$ in a variable x of type Float64. Yet,

julia> x > 1//10true

Hence, the floating-point 0.1 is (slightly) greater than the real number $1/10$ since $1/10$ cannot be represented exactly in binary floating-point arithmetic, at any precision. The true value must be approximated by a floating-point number with fixed precision – this procedure is called rounding.

In particular, this implies that interval(0.1) does not contain the real number $1/10$. A valid interval containing the real number $1/10$ can be constructed by

julia> I"0.1"Interval{Float64}(0.09999999999999999, 0.1, com)
+Interval{Float64}(∅, ill)

These are all examples of ill-formed intervals, resulting in the decoration ill.

Danger

The decoration ill is an indicator that an error has occured. Therefore, any interval marked by this decoration cannot be trusted and the code needs to be debugged.

Guarantee

A guarantee is yet another label, independent of decorations, and not described by the IEEE Standard 1788-2015 specifications. Its purpose is to accomodate for Julia's extensive conversion and promotion system, while retaining reliability in computations. Specifically, an interval x constructed via interval satisfies isguaranteed(x) == true. However, if a call to convert(::Type{<:Interval}, ::Real) occurs, then the resulting interval x satisfies isguaranteed(x) == false.

In contrast, a BareInterval can only be constructed via bareinterval, it is not a subtype of Real, and there are no allowed conversion with Number. Thus, this interval type is always guaranteed.

Danger

A user interested in validated numerics should always have a resulting interval for which isguaranteed is true.

More constructors

The submodule IntervalArithmetic.Symbols exports the infix operator .. and ± as an alias for interval; this submodule must be explicitly imported.

julia> using IntervalArithmetic.Symbols
julia> 0.1 .. 0.2 # interval(0.1, 0.2; format = :infsup)Interval{Float64}(0.1, 0.2, com)
julia> 0.1 ± 0.2 # interval(0.1, 0.2; format = :midpoint)Interval{Float64}(-0.1, 0.30000000000000004, com)

Moreover, one can parse strings into intervals. The various string formats are the following:

To add a specific decoration, add "_com", "_dac", "_dec", "_trv" and "_ill" at the end of the string.

Danger

Most real numbers cannot be exactly represented by floating-points. In such cases, the literal expression is rounded at parse time. To construct an interval enclosing the true real number, one must rely on the string constructor mentioned above.

For instance, consider

julia> x = 0.10.1

This appears to store the real number $1/10$ in a variable x of type Float64. Yet,

julia> x > 1//10true

Hence, the floating-point 0.1 is (slightly) greater than the real number $1/10$ since $1/10$ cannot be represented exactly in binary floating-point arithmetic, at any precision. The true value must be approximated by a floating-point number with fixed precision – this procedure is called rounding.

In particular, this implies that interval(0.1) does not contain the real number $1/10$. A valid interval containing the real number $1/10$ can be constructed by

julia> I"0.1"Interval{Float64}(0.09999999999999999, 0.1, com)
diff --git a/dev/manual/usage/index.html b/dev/manual/usage/index.html index ccf1f46b9..35467a4fc 100644 --- a/dev/manual/usage/index.html +++ b/dev/manual/usage/index.html @@ -17,4 +17,4 @@ - significant digits: 4
julia> a[1.099, 3.142]

Arithmetic operations

Basic arithmetic operations (+, -, *, /, ^) are defined for pairs of intervals in a standard way: the result is the smallest interval containing the result of operating with each element of each interval. More precisely, for two intervals $X$ and $Y$ and an operation $\bigcirc$, we define the operation on the two intervals by

\[X \bigcirc Y \bydef \{ x \bigcirc y \,:\, x \in X \text{ and } y \in Y \}.\]

For example,

julia> using IntervalArithmetic
julia> setdisplay(:full)Display options: - format: full - decorations: false - - significant digits: 4 (ignored)
julia> X = interval(0, 1)Interval{Float64}(0.0, 1.0, com)
julia> Y = interval(1, 2)Interval{Float64}(1.0, 2.0, com)
julia> X + YInterval{Float64}(1.0, 3.0, com)

Due to the above definition, subtraction of two intervals may give poor enclosures:

julia> X - XInterval{Float64}(-1.0, 1.0, com)

Elementary functions

The main elementary functions are implemented. The functions for Interval{Float64} internally use routines from the correctly-rounded CRlibm library where possible, i.e. for the following functions defined in that library:

Other functions that are implemented for Interval{Float64} internally convert to an Interval{BigFloat}, and then use routines from the MPFR library (BigFloat in Julia):

In particular, in order to obtain correct rounding for the power function (^), intervals are converted to and from BigFloat; this implies a significant slow-down in this case.

For example,

julia> X = interval(1)Interval{Float64}(1.0, 1.0, com)
julia> sin(X)Interval{Float64}(0.8414709848078965, 0.8414709848078966, com)
julia> cos(cosh(X))Interval{Float64}(0.027712143770207736, 0.02771214377020796, com)
julia> setprecision(BigFloat, 53)53
julia> Y = big(X)Interval{BigFloat}(1.0, 1.0, com)
julia> sin(Y)Interval{BigFloat}(0.8414709848078965, 0.84147098480789662, com)
julia> cos(cosh(Y))Interval{BigFloat}(0.027712143770207736, 0.027712143770207961, com)
julia> setprecision(BigFloat, 128)128
julia> sin(Y)Interval{BigFloat}(0.841470984807896506652502321630298999621, 0.8414709848078965066525023216302989996239, com)

Comparisons and set operations

All comparisons and set operations for Real have been purposely disallowed to prevent silent errors.

julia> interval(1) < interval(2)ERROR: ArgumentError: `<` is purposely not supported for intervals. See instead `isstrictless`, `strictprecedes`
julia> precedes(interval(1), interval(2))true
julia> issubset(interval(1, 2), interval(2))ERROR: ArgumentError: `issubset` is purposely not supported for intervals. See instead `issubset_interval`
julia> issubset_interval(interval(1, 2), interval(2))false
julia> intersect(interval(1, 2), interval(2))ERROR: ArgumentError: `union!` is purposely not supported for intervals. See instead `hull`
julia> intersect_interval(interval(1, 2), interval(2))Interval{Float64}(2.0, 2.0, trv)

Custom interval bounds type

A BareInterval{T} or Interval{T} have the restriction T <: Union{Rational,AbstractFloat} which is the parametric type for the bounds of the interval. Supposing one wishes to use their own numeric type MyNumType <: Union{Rational,AbstractFloat}, they must provide their own arithmetic operations (with correct rounding!).

+ - significant digits: 4 (ignored)
julia> X = interval(0, 1)Interval{Float64}(0.0, 1.0, com)
julia> Y = interval(1, 2)Interval{Float64}(1.0, 2.0, com)
julia> X + YInterval{Float64}(1.0, 3.0, com)

Due to the above definition, subtraction of two intervals may give poor enclosures:

julia> X - XInterval{Float64}(-1.0, 1.0, com)

Elementary functions

The main elementary functions are implemented. The functions for Interval{Float64} internally use routines from the correctly-rounded CRlibm library where possible, i.e. for the following functions defined in that library:

Other functions that are implemented for Interval{Float64} internally convert to an Interval{BigFloat}, and then use routines from the MPFR library (BigFloat in Julia):

In particular, in order to obtain correct rounding for the power function (^), intervals are converted to and from BigFloat; this implies a significant slow-down in this case.

For example,

julia> X = interval(1)Interval{Float64}(1.0, 1.0, com)
julia> sin(X)Interval{Float64}(0.8414709848078965, 0.8414709848078966, com)
julia> cos(cosh(X))Interval{Float64}(0.027712143770207736, 0.02771214377020796, com)
julia> setprecision(BigFloat, 53)53
julia> Y = big(X)Interval{BigFloat}(1.0, 1.0, com)
julia> sin(Y)Interval{BigFloat}(0.8414709848078965, 0.84147098480789662, com)
julia> cos(cosh(Y))Interval{BigFloat}(0.027712143770207736, 0.027712143770207961, com)
julia> setprecision(BigFloat, 128)128
julia> sin(Y)Interval{BigFloat}(0.841470984807896506652502321630298999621, 0.8414709848078965066525023216302989996239, com)

Comparisons and set operations

All comparisons and set operations for Real have been purposely disallowed to prevent silent errors.

julia> interval(1) < interval(2)ERROR: ArgumentError: `<` is purposely not supported for intervals. See instead `isstrictless`, `strictprecedes`
julia> precedes(interval(1), interval(2))true
julia> issubset(interval(1, 2), interval(2))ERROR: ArgumentError: `issubset` is purposely not supported for intervals. See instead `issubset_interval`
julia> issubset_interval(interval(1, 2), interval(2))false
julia> intersect(interval(1, 2), interval(2))ERROR: ArgumentError: `union!` is purposely not supported for intervals. See instead `hull`
julia> intersect_interval(interval(1, 2), interval(2))Interval{Float64}(2.0, 2.0, trv)

Custom interval bounds type

A BareInterval{T} or Interval{T} have the restriction T <: Union{Rational,AbstractFloat} which is the parametric type for the bounds of the interval. Supposing one wishes to use their own numeric type MyNumType <: Union{Rational,AbstractFloat}, they must provide their own arithmetic operations (with correct rounding!).