### interval method usage examples Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/api Demonstrates creating intervals with different types and formats. ```julia julia> using IntervalArithmeticjulia> setdisplay(:full);julia> interval(1//1, π)Interval{Rational{Int64}}(1//1, 85563208//27235615, com, true)julia> interval(Rational{Int32}, 1//1, π)Interval{Rational{Int32}}(1//1, 85563208//27235615, com, true)julia> interval(1, π)Interval{Float64}(1.0, 3.1415926535897936, com, true)julia> interval(BigFloat, 1, π)Interval{BigFloat}(1.0, 3.141592653589793238462643383279502884197169399375105820974944592307816406286233, com, true) ``` -------------------------------- ### IntervalArithmetic.Symbols.:.. Example Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/symbols Example of using the `..` operator with rational and floating-point bounds. Requires `using IntervalArithmetic` and `using IntervalArithmetic.Symbols`, and `setdisplay(:full)` for full display. ```julia julia> using IntervalArithmetic julia> using IntervalArithmetic.Symbols julia> setdisplay(:full); julia> (1//1)..π Interval{Rational{Int64}}(1//1, 85563208//27235615, com, true) julia> 0.1..0.3 Interval{Float64}(0.1, 0.3, com, true) ``` -------------------------------- ### fastpown usage examples Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/api Demonstrates the use of fastpown for interval exponentiation. ```julia julia> using IntervalArithmeticjulia> setdisplay(:full);julia> fastpown(bareinterval(2, 3), 2)BareInterval{Float64}(4.0, 9.0)julia> fastpown(interval(-4, -2), 2)Interval{Float64}(4.0, 16.0, com, true)julia> fastpown(interval(-1, 1), -3)Interval{Float64}(-Inf, Inf, trv, true) ``` -------------------------------- ### Install IntervalArithmetic.jl Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable Use the Julia Pkg manager to add the IntervalArithmetic package to your environment. ```julia julia> using Pkg # Julia v1.10 or abovejulia> Pkg.add("IntervalArithmetic") ``` -------------------------------- ### IntervalArithmetic.Symbols.:± Example Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/symbols Example of using the `±` operator with floating-point and rational midpoints. Requires `using IntervalArithmetic` and `using IntervalArithmetic.Symbols`, and `setdisplay(:full)` for full display. ```julia julia> using IntervalArithmetic julia> using IntervalArithmetic.Symbols julia> setdisplay(:full); julia> 0 ± π Interval{Float64}(-3.1415926535897936, 3.1415926535897936, com, true) julia> 0//1 ± π Interval{Rational{Int64}}(-85563208//27235615, 85563208//27235615, com, true) ``` -------------------------------- ### Using IntervalArithmetic.Symbols Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/symbols Example of using the Symbols submodule to create intervals and perform comparisons with unicode operators. Requires `using IntervalArithmetic, IntervalArithmetic.Symbols`. ```julia julia> using IntervalArithmetic, IntervalArithmetic.Symbols julia> a = 0 .. 2 Interval{Float64}(0.0, 2.0, com, true) julia> b = 1 ± 0.5 Interval{Float64}(0.5, 1.5, com, true) julia> a ≛ a true julia> b ⊑ a true julia> b ⋤ a true julia> ∅ ⪽ ℝ true ``` -------------------------------- ### Common interval and sqrt with com decoration Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/construction Creates a common interval and computes its square root. Both the input and output are common (com) because the interval is closed, bounded, non-empty, and the square root is continuous over [1/2, 3]. This example demonstrates the Schauder Fixed-Point Theorem: the computation proves the existence of a fixed point of the square root in [1/2, 3]. ```julia julia> x = interval(0.5, 3) Interval{Float64}(0.5, 3.0, com, true) julia> sqrt(x) Interval{Float64}(0.7071067811865475, 1.7320508075688774, com, true) ``` -------------------------------- ### Basic linear algebra operations with ArbMatrix and AcbMatrix Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/interfaces/arblib Convert an interval matrix to ArbMatrix for real operations or AcbMatrix for eigenvalues. The example shows matrix multiplication, inversion, solving a linear system, and computing eigenvalues. Eigenvalues are only supported for AcbMatrix. ```julia julia> using IntervalArithmetic, Arblib, LinearAlgebra julia> A = interval.(BigFloat, [1 2; 3 4]) 2×2 Matrix{Interval{BigFloat}}: Interval{BigFloat}(1.0, 1.0, com, true) … Interval{BigFloat}(2.0, 2.0, com, true) Interval{BigFloat}(3.0, 3.0, com, true) Interval{BigFloat}(4.0, 4.0, com, true) julia> B = ArbMatrix(A) 2×2 Arblib.ArbMatrix: 1.0 2.0 3.0 4.0 julia> B * B 2×2 Arblib.ArbMatrix: 7.0 10.0 15.0 22.0 julia> inv(B) 2×2 Arblib.ArbMatrix: [-2.00{…71 digits…}00 ± 1.44e-76] [1.00{…71 digits…}00 ± 7.78e-77] [1.50{…72 digits…}00 ± 9.07e-77] [-0.50{…72 digits…}00 ± 3.68e-77] julia> B \ B 2×2 Arblib.ArbMatrix: [1.00{…71 digits…}00 ± 7.20e-77] [+/- 6.91e-77] [+/- 3.24e-77] [1.00{…72 digits…}00 ± 5.19e-77] julia> eigvals(AcbMatrix(B)) # Eigenvalues are only supported for AcbMatrix 2-element Arblib.AcbVector: [-0.372281323269014329925305734109464659110132228991396183849938735282950360729 +/- 5.90e-76] + [+/- 2.51e-76]im [5.372281323269014329925305734109464659110132228991396183849938735282950360729 +/- 8.90e-76] + [+/- 2.51e-76]im ``` -------------------------------- ### Get upper bound with sup Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/api Returns the supremum of an interval. ```julia sup(x) ``` -------------------------------- ### Elementary functions with Interval{Float64} and Interval{BigFloat} Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/usage Demonstrates applying elementary functions like sin and cosh to intervals, including switching precision for BigFloat calculations. ```julia julia> X = interval(1)Interval{Float64}(1.0, 1.0, com, true)julia> sin(X)Interval{Float64}(0.8414709848078965, 0.8414709848078966, com, true)julia> cos(cosh(X))Interval{Float64}(0.027712143770207736, 0.02771214377020796, com, true)julia> setprecision(BigFloat, 53)53julia> Y = big(X)Interval{BigFloat}(1.0, 1.0, com, true)julia> sin(Y)Interval{BigFloat}(0.8414709848078965, 0.84147098480789662, com, true)julia> cos(cosh(Y))Interval{BigFloat}(0.027712143770207736, 0.027712143770207961, com, true)julia> setprecision(BigFloat, 128)128julia> sin(Y)Interval{BigFloat}(0.8414709848078965, 0.84147098480789662, com, true) ``` -------------------------------- ### Construct bare and decorated intervals with `bareinterval` and `interval` Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/construction Shows how to construct bare and decorated intervals with `bareinterval` and `interval`. The `setdisplay(:full)` call changes the display format; the output shows the default decoration `com` for `interval`. ```julia julia> using IntervalArithmetic julia> setdisplay(:full) # print the interval in full Display options: - format: full - decorations: true (ignored) - NG flag: true (ignored) - significant digits: 6 (ignored) julia> bareinterval(1, π) # `bareinterval(Float64, 1, π)` BareInterval{Float64}(1.0, 3.1415926535897936) julia> interval(1, π) # `interval(Float64, 1, π)`, interval decorated with `com` (common) Interval{Float64}(1.0, 3.1415926535897936, com, true) ``` -------------------------------- ### isguaranteed Method Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/api Tests whether the interval is not guaranteed to encompass all possible numerical errors. Examples show usage with different interval types. ```julia isguaranteed(x::BareInterval) isguaranteed(x::Interval) isguaranteed(x::Complex{<:Interval}) ``` ```julia julia> using IntervalArithmetic julia> isguaranteed(bareinterval(1)) true julia> isguaranteed(interval(1)) true julia> isguaranteed(convert(Interval{Float64}, 1)) false julia> isguaranteed(interval(1) + 0) false ``` -------------------------------- ### Configure power mode with IntervalArithmetic.configure Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/configuration Shows how to switch the power implementation between :slow and :fast using IntervalArithmetic.configure, and the effect on the radius of x^3. The :slow mode gives a tighter result (7.105e-15) than the default :fast mode (1.421e-14). ```julia julia> using IntervalArithmetic julia> x = interval(π) Interval{Float64}(3.141592653589793, 3.1415926535897936, com, true) julia> IntervalArithmetic.configure(; power = :slow) Configuration options: - bound type: Float64 - flavor: set_based - interval rounding: correct - power mode: slow - matrix multiplication mode: fast - number of threads for `:fast` matrix multiplication mode: 2 julia> radius(x^3) 7.105427357601002e-15 julia> IntervalArithmetic.configure(; power = :fast) # default Configuration options: - bound type: Float64 - flavor: set_based - interval rounding: correct - power mode: fast - matrix multiplication mode: fast - number of threads for `:fast` matrix multiplication mode: 2 julia> radius(x^3) 1.4210854715202004e-14 ``` -------------------------------- ### ExactReal construction Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/api Demonstrates the construction of an ExactReal value using the exact function. ```julia julia> exact(0.1)ExactReal{Float64}(0.1000000000000000055511151231257827021181583404541015625) ``` -------------------------------- ### fastpown Method Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/api Fast power implementation for integer exponents. ```julia fastpown(x, n) ``` -------------------------------- ### Using FLINT special functions via low-level wrapper Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/interfaces/arblib Shows how to use FLINT special functions not in SpecialFunctions.jl, such as dirichlet_lerch_phi, through the low-level wrapper. Requires using IntervalArithmetic and Arblib. ```julia julia> using IntervalArithmetic, Arblib julia> z = interval(BigFloat, 2 + 3im) Interval{BigFloat}(2.0, 2.0, com, true) + im*Interval{BigFloat}(3.0, 3.0, com, true) julia> s = interval(BigFloat, 2) Interval{BigFloat}(2.0, 2.0, com, true) julia> a = interval(BigFloat, 4) Interval{BigFloat}(4.0, 4.0, com, true) julia> interval(Arblib.dirichlet_lerch_phi!(Acb(), Acb(z), Acb(s), Acb(a))) Interval{BigFloat}(-0.0002662647805245549465036569063000041468826679484039490012317600272567739198984341, -0.0002662647805245549465036569063000041468826679484039490012317600272567739198722642, com, true) + im*Interval{BigFloat}(0.03373697955708857151314153116051267066240962948450506837346469744178310287937996, 0.03373697955708857151314153116051267066240962948450506837346469744178310287944149, com, true) ``` -------------------------------- ### Use ExactReal for precise interval arithmetic Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/guarantee Shows how to use exact() and the @exact macro to ensure literal numbers are treated as exact values within interval computations. ```julia julia> interval(1)Interval{Float64}(1.0, 1.0, com, true)julia> interval(1) + exact(1)Interval{Float64}(2.0, 2.0, com, true)julia> @exact 2interval(1) + 1 + exp(im * interval(1))Interval{Float64}(3.5403023058681393, 3.5403023058681398, com, true) + im*Interval{Float64}(0.8414709848078965, 0.8414709848078966, com, true)julia> @exact foo(x) = 2x + 1 + exp(im * x)foo (generic function with 1 method)julia> foo(1.)3.5403023058681398 + 0.8414709848078965imjulia> foo(interval(1))Interval{Float64}(3.5403023058681393, 3.5403023058681398, com, true) + im*Interval{Float64}(0.8414709848078965, 0.8414709848078966, com, true) ``` -------------------------------- ### Using SpecialFunctions.jl with Arblib Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/interfaces/arblib Shows how to apply SpecialFunctions.jl functions (besselj0, gamma, zeta) to an Arb interval and convert back to an Interval. Requires using IntervalArithmetic, Arblib, and SpecialFunctions. ```julia julia> using IntervalArithmetic, Arblib, SpecialFunctions julia> x = interval(BigFloat, 2) Interval{BigFloat}(2.0, 2.0, com, true) julia> interval(besselj0(Arb(x))) # Convert to Arb and then back Interval{BigFloat}(0.2238907791412356680518274546499486258251544822186076031283497060108539577680058, 0.2238907791412356680518274546499486258251544822186076031283497060108539577680145, com, true) julia> interval(gamma(Arb(x))) Interval{BigFloat}(1.0, 1.0, com, true) julia> interval(zeta(Arb(x))) Interval{BigFloat}(1.644934066848226436472415166646025189218949901206798437735558229370007470403185, 1.644934066848226436472415166646025189218949901206798437735558229370007470403219, com, true) ``` -------------------------------- ### Interval comparisons Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/usage Shows how comparisons between intervals work, noting that ambiguous comparisons throw an InconclusiveBooleanOperation error. ```julia julia> interval(1) < interval(2)truejulia> interval(1, 5) < interval(7, 9)truejulia> interval(1, 5) < interval(4.99, 9)ERROR: InconclusiveBooleanOperation: The operation `Interval{Float64}(1.0, 5.0, com, true) < Interval{Float64}(4.99, 9.0, com, true)` cannot be determined unambiguously. See the documentation for more information. See also `strictprecedes`.julia> interval(1.23) == interval(1.23)truejulia> interval(1.23) == interval(4.99, 9)falsejulia> interval(1.23) == interval(1.2, 1.3)ERROR: InconclusiveBooleanOperation: The operation `Interval{Float64}(1.23, 1.23, com, true) == Interval{Float64}(1.2, 1.3, com, true)` cannot be determined unambiguously. See the documentation for more information. See also `isequal_interval`. ``` -------------------------------- ### Using @exact for exact interval arithmetic Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/api Demonstrates the use of the @exact macro to ensure interval arithmetic operations maintain exact representations where possible. ```julia julia> using IntervalArithmeticjulia> setdisplay(:infsup);julia> f(x) = 1.2 * x + 0.1f (generic function with 1 method)julia> f(interval(1, 2))[1.29999, 2.5]_com_NGjulia> @exact g(x) = 1.2 * x + 0.1g (generic function with 1 method)julia> g(interval(1, 2))[1.29999, 2.5]_comjulia> g(1.4)1.78 ``` -------------------------------- ### Compare Float64 0.1 with rational 1//10 Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/construction Demonstrates that the floating-point value 0.1 is slightly greater than the rational 1//10 because 1/10 cannot be represented exactly in binary floating-point arithmetic at any precision. ```julia julia> x > 1//10true ``` -------------------------------- ### exact Method Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/api Wraps a number into an ExactReal. ```julia exact(x) ``` -------------------------------- ### Step-by-step evaluation of asin ∘ sqrt with trv Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/construction Shows the individual steps of the composed function f = asin ∘ sqrt. sqrt(x) has trv because x contains negative values; sqrt(y) has com; asin(sqrt(y)) has trv because sqrt(y) contains values strictly greater than 1. This demonstrates where loose evaluation occurred in the composed function. ```julia julia> sqrt(x) # `f(x)` has the decoration is `trv` since `x` contains negative values Interval{Float64}(0.0, 1.7320508075688774, trv, true) julia> sqrt(y) # the decoration is `com` Interval{Float64}(0.0, 1.7320508075688774, com, true) julia> asin(sqrt(y)) # `f(x)` has the decoration is `trv` since `sqrt(y)` contains values stricly greater than `1` Interval{Float64}(0.0, 1.5707963267948968, trv, true) ``` -------------------------------- ### Construct exact interval with I"0.1" string macro Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/construction Uses the string macro I"..." to parse the decimal string and construct an interval that encloses the true real number 1/10. This is the recommended way to obtain an interval containing the exact real value. ```julia julia> I"0.1"Interval{Float64}(0.09999999999999999, 0.1, com, true) ``` -------------------------------- ### ..(a, b) Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/symbols Creates an interval [a, b] using bounds. This is semantically equivalent to interval(a, b). ```APIDOC ## ..(a, b) ### Description Create the interval [a, b] according to the IEEE Standard 1788-2015. This is semantically equivalent to `interval(a, b)`. ### Method `..` ### Parameters - `a` - Lower bound - `b` - Upper bound ### Request Example julia (1//1)..π 0.1..0.3 ### Response Returns an `Interval` object. ### Response Example julia Interval{Rational{Int64}}(1//1, 85563208//27235615, com, true) Interval{Float64}(0.1, 0.3, com, true) ``` -------------------------------- ### Converting between Interval and Arblib types Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/interfaces/arblib Demonstrates conversion between Interval and Arb/Acb types. Shows default BigFloat behavior and explicit type specification. ```julia julia> using IntervalArithmetic, Arblibjulia> x = interval(π)Interval{Float64}(3.141592653589793, 3.1415926535897936, com, true)julia> Arb(x)[3.141592653589793 +/- 5.61e-16]julia> y = Arb(π)[3.1415926535897932384626433832795028841971693993751058209749445923078164062862 +/- 1.93e-77]julia> interval(y) # Defaults to BigFloatInterval{BigFloat}(3.141592653589793238462643383279502884197169399375105820974944592307816406286163, 3.141592653589793238462643383279502884197169399375105820974944592307816406286233, com, true)julia> interval(Float64, y) # Other type can be explicitly specifiedInterval{Float64}(3.141592653589793, 3.1415926535897936, com, true)julia> z = complex(interval(2), interval(1 // 3))Interval{Float64}(2.0, 2.0, com, true) + im*Interval{Float64}(0.3333333333333333, 0.33333333333333337, com, true)julia> Acb(z)2.0 + [0.3333333333333333 +/- 7.04e-17]imjulia> w = Acb(2, 1 // 3)2.0 + [0.33333333333333333333333333333333333333333333333333333333333333333333333333333 +/- 4.78e-78]imjulia> interval(w)Interval{BigFloat}(2.0, 2.0, com, true) + im*Interval{BigFloat}(0.3333333333333333333333333333333333333333333333333333333333333333333333333333261, 0.3333333333333333333333333333333333333333333333333333333333333333333333333333348, com, true)julia> interval(Float64, w)Interval{Float64}(2.0, 2.0, com, true) + im*Interval{Float64}(0.3333333333333333, 0.33333333333333337, com, true) ``` -------------------------------- ### interval([T,] a, b, d = com; format = :infsup) Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/api Create an interval according to the IEEE Standard 1788-2015. ```APIDOC ## interval([T,] a, b, d = com; format = :infsup) ### Description 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. ### Method Function ### Endpoint `interval([T,] a, b, d = com; format = :infsup)` ### Parameters - **T** (Type) - Optional - The type of the interval endpoints. - **a** (Real) - Required - Lower bound. - **b** (Real) - Required - Upper bound. - **d** (Decoration) - Optional - Decoration, default `com`. - **format** (Symbol) - Optional - Format, default `:infsup`. ### Request Example ```julia interval(1//1, π) interval(Rational{Int32}, 1//1, π) interval(1, π) interval(BigFloat, 1, π) ``` ### Response #### Success Response Returns an `Interval{T}`. #### Response Example ```julia Interval{Rational{Int64}}(1//1, 85563208//27235615, com, true) Interval{Rational{Int32}}(1//1, 85563208//27235615, com, true) Interval{Float64}(1.0, 3.1415926535897936, com, true) Interval{BigFloat}(1.0, 3.141592653589793238462643383279502884197169399375105820974944592307816406286233, com, true) ``` ### Notes See also: `±`, `..`, `@I_str`. ``` -------------------------------- ### Configure interval display modes with setdisplay Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/usage Use setdisplay to globally control how intervals are represented, including options for infsup, full, and midpoint formats, as well as significant digits and decorations. ```julia julia> using IntervalArithmeticjulia> a = interval(1.1, pi) # default displayInterval{Float64}(1.1, 3.1415926535897936, com, true)julia> setdisplay(; sigdigits = 10)Display options: - format: full - decorations: true (ignored) - NG flag: true (ignored) - significant digits: 10 (ignored)julia> aInterval{Float64}(1.1, 3.1415926535897936, com, true)julia> setdisplay(:full)Display options: - format: full - decorations: true (ignored) - NG flag: true (ignored) - significant digits: 10 (ignored)julia> aInterval{Float64}(1.1, 3.1415926535897936, com, true)julia> setdisplay(:midpoint)Display options: - format: midpoint - decorations: true - NG flag: true - significant digits: 10julia> a(2.120796327 ± 1.020796327)_comjulia> setdisplay(; sigdigits = 4)Display options: - format: midpoint - decorations: true - NG flag: true - significant digits: 4julia> a(2.121 ± 1.021)_comjulia> setdisplay(:infsup)Display options: - format: infsup - decorations: true - NG flag: true - significant digits: 4julia> a[1.1, 3.142]_com ``` -------------------------------- ### interval method definition Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/api Creates an interval [a,b] according to IEEE Standard 1788-2015. ```julia interval([T,] a, b, d = com; format = :infsup) ``` -------------------------------- ### isweakless Method Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/api Tests whether inf(x) ≤ inf(y) and sup(x) ≤ sup(y). ```julia isweakless(x, y) ``` -------------------------------- ### Evaluate function over interval with IntervalArithmetic.jl Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/intro Shows how to define a function and evaluate it over an interval using IntervalArithmetic.jl. The output shows the resulting interval and its decoration. ```julia julia> using IntervalArithmetic julia> f(x) = x^2 - 2 f (generic function with 1 method) julia> x = interval(3, 4) Interval{Float64}(3.0, 4.0, com, true) julia> f(x) Interval{Float64}(7.0, 14.0, com, false) ``` -------------------------------- ### Using @interval macro for expression wrapping Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/api Shows how to use the @interval macro to walk through an expression and wrap function arguments with the atomic constructor, optionally specifying the bound type. ```julia julia> using IntervalArithmeticjulia> setdisplay(:full);julia> @interval sin(1) # Float64 is the default bound typeInterval{Float64}(0.8414709848078965, 0.8414709848078966, com, true)julia> @interval Float32 sin(1)Interval{Float32}(0.84147096f0, 0.841471f0, com, true)julia> @interval sin(1) exp(1)Interval{Float64}(0.8414709848078965, 2.7182818284590455, com, true)julia> @interval Float64 sin(1) exp(1)Interval{Float64}(0.8414709848078965, 2.7182818284590455, com, true) ``` -------------------------------- ### mince! Method Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/api In-place version of the mince function. ```julia mince!(v, x, n) ``` -------------------------------- ### Compare `sqrt` on bare and decorated intervals Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/construction Compares `sqrt` on a bare interval and a decorated interval. The bare interval silently discards the negative part, while the decorated interval returns a `trv` decoration, indicating the result is trivial. ```julia julia> sqrt(bareinterval(-1, 1)) # `sqrt(bareinterval(0, 1))` BareInterval{Float64}(0.0, 1.0) julia> sqrt(interval(-1, 1)) # interval decorated with `trv` (trivial) Interval{Float64}(0.0, 1.0, trv, true) ``` -------------------------------- ### precedes Method Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/api Tests whether every element of x is less than or equal to every element of y. ```julia precedes(x, y) ``` -------------------------------- ### Unbounded interval and sqrt with dac decoration Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/construction Creates an unbounded interval and computes its square root. Both intervals are unbounded, so the maximum possible decoration is dac (defined and continuous). ```julia julia> x = interval(3, Inf) Interval{Float64}(3.0, Inf, dac, true) julia> sqrt(x) Interval{Float64}(1.7320508075688772, Inf, dac, true) ``` -------------------------------- ### fastpown(x, n) Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/api A faster implementation of `pown(x, n)` that may return a larger interval but obeys the same domain convention. ```APIDOC ## fastpown(x, n) ### Description A faster implementation of `pown(x, n)`, at the cost of maybe returning a larger interval. In particular, it obeys the same domain convention so negative values of `x` are allowed. ### Method Function ### Endpoint `fastpown(x, n)` ### Parameters - **x** (interval) - Required - The interval to be raised to the power. - **n** (integer) - Required - The exponent. ### Request Example ```julia fastpown(bareinterval(2, 3), 2) fastpown(interval(-4, -2), 2) fastpown(interval(-1, 1), -3) ``` ### Response #### Success Response Returns an interval (possibly larger than the exact result). #### Response Example ```julia BareInterval{Float64}(4.0, 9.0) Interval{Float64}(4.0, 16.0, com, true) Interval{Float64}(-Inf, Inf, trv, true) ``` ### See Also `pown`, `pow`, `fastpow` ``` -------------------------------- ### configure function signature Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/configuration Signature of the configure function. Each keyword defaults to the value currently in use, so only the given options are modified. ```julia configure(; numtype=Float64, flavor=:set_based, rounding=:correct, power=:fast, matmul=:fast, nthreads=IntervalArithmetic.default_threads()) ``` -------------------------------- ### decoration Method for Interval Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/api Returns the decoration of an interval x. ```julia decoration(x::Interval) ``` -------------------------------- ### mince Method Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/api Splits an interval x into n intervals of the same diameter. Unbounded intervals are rejected. ```julia mince(x, n) ``` -------------------------------- ### Compute π with forward sum using IntervalArithmetic.jl Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/examples/pi Computes rigorous bounds on π by splitting the Basel sum into a finite sum and a tail bound, then returns the midpoint and radius of the resulting interval. The output shows the midpoint is correct to about 10 decimal places. ```julia using IntervalArithmetic function forward_sum(N) S_N = interval(0) for i ∈ 1:N S_N += interval(1) / interval(i) ^ interval(2) end T_N = interval(1) / interval(N, N+1) S = S_N + T_N return sqrt(interval(6) * S) end pi_interval = forward_sum(10^6) midradius(pi_interval) ``` ```text (3.14159265358984, 1.0649436887888442e-10) ``` -------------------------------- ### isstrictless Method Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/api Tests whether inf(x) < inf(y) and sup(x) < sup(y), with adjustments for infinite values. ```julia isstrictless(x, y) ``` -------------------------------- ### Evaluate function over semi-infinite interval with IntervalArithmetic.jl Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/intro Shows how to evaluate a function over a semi-infinite interval using IntervalArithmetic.jl. The output shows the resulting interval and its decoration. ```julia julia> f(interval(3, Inf)) Interval{Float64}(7.0, Inf, dac, false) ``` -------------------------------- ### mig Method Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/api Calculates the mignitude of x, implementing the IEEE Standard 1788-2015 Table 9.2. ```julia mig(x) ``` -------------------------------- ### Interval set operations Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/usage Demonstrates that standard set operations are disallowed for intervals and must be replaced by their *_interval equivalents. ```julia 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))falsejulia> intersect(interval(1, 2), interval(2))ERROR: ArgumentError: `intersect` is purposely not supported for intervals. See instead `intersect_interval`julia> intersect_interval(interval(1, 2), interval(2))Interval{Float64}(2.0, 2.0, trv, true) ``` -------------------------------- ### isbounded method Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/api Tests whether x is empty or has finite bounds. ```julia isbounded(x) ``` -------------------------------- ### mince!(v, x, n) Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/api In-place version of `mince`. Splits an interval `x` into `n` intervals of the same diameter and stores the result in `v`. ```APIDOC ## `mince!(v, x, n)` ### Description In-place version of `mince`. Splits an interval `x` into `n` intervals of the same diameter and stores the result in `v`. ### Method Function call ### Endpoint `mince!(v, x, n)` ### Parameters - **v** (vector) - Required - The vector to store the resulting intervals. - **x** (interval) - Required - The interval to split. - **n** (integer) - Required - The number of intervals to split into. ### Return Value Returns the modified vector `v`. ``` -------------------------------- ### extended_div Method Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/api Performs two-output division, corresponding to mulRevToPair(y, x) of the IEEE Standard 1788-2015. ```julia extended_div(x, y) ``` -------------------------------- ### isbounded(x) Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/api Test whether an interval is empty or has finite bounds. ```APIDOC ## isbounded(x) ### Description Test whether `x` is empty or has finite bounds. ### Method Function ### Endpoint `isbounded(x)` ### Parameters - **x** (interval) - Required - The interval to test. ### Response #### Success Response Returns a boolean indicating whether the interval is bounded. ``` -------------------------------- ### Perform basic interval arithmetic Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/usage Basic arithmetic operations like addition are defined such that the result is the smallest interval containing all possible results of the operation on the input intervals. ```julia julia> using IntervalArithmeticjulia> setdisplay(:full)Display options: - format: full - decorations: true (ignored) - NG flag: true (ignored) - significant digits: 4 (ignored)julia> X = interval(0, 1)Interval{Float64}(0.0, 1.0, com, true)julia> Y = interval(1, 2)Interval{Float64}(1.0, 2.0, com, true)julia> X + YInterval{Float64}(1.0, 3.0, com, true) ``` ```julia julia> X - XInterval{Float64}(-1.0, 1.0, com, true) ``` -------------------------------- ### iscommon(x) Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/api Test whether an interval is not empty and bounded. ```APIDOC ## iscommon(x) ### Description Test whether `x` is not empty and bounded. Implements the `isCommonInterval` function of the IEEE Standard 1788-2015. ### Method Function ### Endpoint `iscommon(x)` ### Parameters - **x** (interval) - Required - The interval to test. ### Response #### Success Response Returns a boolean indicating whether the interval is common. ### Notes This does not take into consideration the decoration of the interval. ``` -------------------------------- ### iscommon method Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/api Tests whether x is not empty and bounded. ```julia iscommon(x) ``` -------------------------------- ### Check interval guarantee status Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/guarantee Demonstrates how implicit conversion results in an 'NG' label, while explicit construction via interval() is marked as guaranteed. ```julia julia> using IntervalArithmeticjulia> setdisplay(; sigdigits = 6)Display options: - format: full - decorations: true (ignored) - NG flag: true (ignored) - significant digits: 6 (ignored)julia> convert(Interval{Float64}, 1.) # considered "not guaranteed" as this call can be done implicitlyInterval{Float64}(1.0, 1.0, com, false)julia> interval(1) # considered "guaranteed" as the user explicitly constructed the intervalInterval{Float64}(1.0, 1.0, com, true) ``` -------------------------------- ### ⪯(x, y) Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/symbols Unicode alias of precedes. Precedes relation. ```APIDOC ## ⪯(x, y) ### Description Unicode alias of `precedes`. Precedes relation. ### Method `⪯` ### Parameters - `x` - First interval - `y` - Second interval ### Response Returns a boolean indicating whether `x` precedes `y`. ``` -------------------------------- ### Calculate interval powers with pown and pow Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/usage The pown and pow functions handle powers with different domain constraints. Arguments outside the domain of definition result in empty intervals with trv decoration. ```julia julia> x = interval(-4, -2)Interval{Float64}(-4.0, -2.0, com, true)julia> pown(x, 2)Interval{Float64}(4.0, 16.0, com, true)julia> pow(x, interval(2))∅_trv ``` ```julia julia> x ^ interval(2)Interval{Float64}(4.0, 16.0, com, true)julia> x ^ interval(2.5)∅_trv ``` -------------------------------- ### emptyinterval Method Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/api Creates an empty interval, which is an exception to the rule that the lower bound is less than or equal to the upper bound. ```julia emptyinterval(T=[default_numtype()]) ``` -------------------------------- ### inf method Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/api Returns the lower bound, or infimum, of x. ```julia inf(x) ``` -------------------------------- ### bareinterval construction Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/api Creates bare intervals using different types, noting that floating point literals are rounded to the nearest value. ```julia julia> using IntervalArithmeticjulia> setdisplay(:full);julia> bareinterval(1//1, π)BareInterval{Rational{Int64}}(1//1, 85563208//27235615)julia> bareinterval(Rational{Int32}, 1//1, π)BareInterval{Rational{Int32}}(1//1, 85563208//27235615)julia> bareinterval(1, π)BareInterval{Float64}(1.0, 3.1415926535897936)julia> bareinterval(BigFloat, 1, π)BareInterval{BigFloat}(1.0, 3.141592653589793238462643383279502884197169399375105820974944592307816406286233) ``` -------------------------------- ### Assign floating-point literal 0.1 to x Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/construction Shows that assigning the literal 0.1 to x stores a Float64 approximation, not the exact real number 1/10. This motivates using the string constructor for exact intervals. ```julia julia> x = 0.10.1 ``` -------------------------------- ### Use infix operators .. and ± from IntervalArithmetic.Symbols Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/construction Requires explicitly importing the IntervalArithmetic.Symbols submodule. The infix operator .. creates an interval in infsup format, while ± creates one in midpoint format; both are aliases for interval. ```julia julia> using IntervalArithmetic.Symbolsjulia> 0.1 .. 0.2 # interval(0.1, 0.2; format = :infsup)Interval{Float64}(0.1, 0.2, com, true)julia> 0.1 ± 0.2 # interval(0.1, 0.2; format = :midpoint)Interval{Float64}(-0.1, 0.30000000000000004, com, true) ``` -------------------------------- ### mag Method Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/api Calculates the magnitude of an interval. ```julia mag(x) ``` -------------------------------- ### decoration Method for BareInterval Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/api Returns the default decoration for a BareInterval based on its value. ```julia decoration(x::BareInterval) ``` -------------------------------- ### midradius Method Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/api Calculates the midpoint and radius of an interval x, as required by IEEE Standard 1788-2015 Section 10.5.9. ```julia midradius(x) ``` -------------------------------- ### ExactReal usage with intervals Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/api Shows how ExactReal prevents the 'NG' (not guaranteed) flag when performing arithmetic with intervals. ```julia julia> using IntervalArithmeticjulia> setdisplay(:full);julia> 0.5 * interval(1)Interval{Float64}(0.5, 0.5, com, false)julia> exact(0.5) * interval(1)Interval{Float64}(0.5, 0.5, com, true)julia> setdisplay(:infsup);julia> [1, interval(2)]2-element Vector{Interval{Float64}}: [1.0, 1.0]_com_NG [2.0, 2.0]_comjulia> [exact(1), interval(2)]2-element Vector{Interval{Float64}}: [1.0, 1.0]_com [2.0, 2.0]_com ``` -------------------------------- ### mince(x, n) Source: https://juliaintervals.github.io/IntervalArithmetic.jl/stable/manual/api Splits an interval `x` into `n` intervals of the same diameter. An unbounded `x` has no such splitting and is rejected; use `bisect` instead. Also splits 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 components. ```APIDOC ## `mince(x, n)` ### Description Splits an interval `x` into `n` intervals of the same diameter. An unbounded `x` has no such splitting and is rejected; use `bisect` instead. Also splits 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 components. ### Method Function call ### Endpoint `mince(x, n)` ### Parameters - **x** (interval or vector) - Required - The interval or vector of intervals to split. - **n** (integer or tuple) - Required - The number of intervals to split into, or a tuple of integers for each component. ### Return Value Returns a vector of intervals resulting from the split. ```