ball_float API

ball_float is interval arithmetic over BinFloat endpoints. A BallFloat is a closed real interval [x‾,x‾][\underline{x}, \overline{x}], possibly unbounded, or the empty set; every operation returns an interval that contains all exact results of the operation on points of its operands (the inclusion property). BallFloatDecorated adds the decorations of IEEE 1788-2015, BallContext rounds results into a target binary format and reports BallFlags.

Despite the name, the stored representation is the endpoint pair, not a midpoint and a radius: BallFloat::new(center, radius), center() and radius() convert to and from the midpoint–radius view. The tutorial shows typical use; the design page derives the formulas and proves the inclusion property.

Conventions used on this page:

  • RD⁡p\operatorname{RD}_p and RU⁡p\operatorname{RU}_p round toward −∞-\infty and +∞+\infty to pp significant bits. “Rounded outward” means the lower endpoint is rounded with RD⁡p\operatorname{RD}_p and the upper with RU⁡p\operatorname{RU}_p.
  • The precision of an interval is a tag in bits. Operations round their result outward to the larger precision of their operands; elementary functions use the precision of their argument.
  • The exponent range of BinFloat endpoints is the binary implementation range of bin_float, far wider than any interchange format. Use a BallContext to impose a narrower range.
  • Empty is the empty set, Entire is (−∞,+∞)(-\infty, +\infty). An unbounded interval stores −∞-\infty and/or +∞+\infty as endpoints; these mean that the set is unbounded on that side, never that it contains an infinite value.

The examples on this page use these helpers:

///|
fn iv(lo : Int, hi : Int) -> @ball_float.BallFloat {
  @ball_float.BallFloat::from_bounds(
    @bin_float.BinFloat::from_int(lo, precision=53),
    @bin_float.BinFloat::from_int(hi, precision=53),
  )
}

///|
fn fmt(x : @ball_float.BallFloat) -> String {
  if x.is_empty() {
    return "[empty]"
  }
  let down = @bin_float.BinaryContext::unbounded(
    53,
    rounding=@bin_float.BinaryRoundingMode::RoundTowardNegative,
  )
  let up = @bin_float.BinaryContext::unbounded(
    53,
    rounding=@bin_float.BinaryRoundingMode::RoundTowardPositive,
  )
  "[" +
  x.lower_bound().to_decimal_string_ctx(6, down).0 +
  ", " +
  x.upper_bound().to_decimal_string_ctx(6, up).0 +
  "]"
}

Types

BallFloat

BallFloat is a closed interval with BinFloat endpoints and a precision tag.

pub struct BallFloat {
  // private fields
} derive(Eq, @debug.Debug)

A non-empty value satisfies x‾≤x‾\underline{x} \le \overline{x}, has no NaN endpoint, never has x‾=+∞\underline{x} = +\infty or x‾=−∞\overline{x} = -\infty, and has precision ≥1\ge 1. The empty set is a separate state. The fields are private; construct values with the functions in Construction. The derived Eq compares the stored representation (endpoints and precision), not the sets; see BallFloat::set_equal.

BallFloatDecorated

BallFloatDecorated is a BallFloat paired with an IEEE 1788 Decoration, or the special value NaI (not an interval).

pub struct BallFloatDecorated {
  // private fields
} derive(Eq)

The decoration is kept canonical: an empty interval always carries Trv, an unbounded interval never carries Com, and only BallFloatDecorated::nai carries Ill.

Decoration

Decoration is the IEEE 1788 decoration of a decorated interval, ordered Ill < Trv < Def < Dac < Com.

pub(all) enum Decoration {
  Ill
  Trv
  Def
  Dac
  Com
} derive(Eq, @debug.Debug)

For a decorated result (y,d)(\boldsymbol{y}, d) of a function ff evaluated on x\boldsymbol{x}:

ConstructorMeaning
Comff is defined and continuous on x\boldsymbol{x}, and y\boldsymbol{y} is bounded
Dacff is defined and continuous on x\boldsymbol{x}
Defff is defined on x\boldsymbol{x}
Trvnothing is known
Illthe value is NaI

Show prints the lower-case IEEE 1788 names com, dac, def, trv, ill.

OverlapState

OverlapState is the result of overlap_state: the IEEE 1788 classification of the relative position of two intervals.

pub(all) enum OverlapState {
  Undefined
  BothEmpty
  FirstEmpty
  SecondEmpty
  Before
  Meets
  OverlapsState
  Starts
  ContainedBy
  Finishes
  EqualIntervals
  After
  MetBy
  OverlappedBy
  StartedBy
  ContainsInterval
  FinishedBy
} derive(Eq, @debug.Debug)

The constructors correspond to the IEEE 1788 states bothEmpty, firstEmpty, secondEmpty, before, meets, overlaps, starts, containedBy, finishes, equal, after, metBy, overlappedBy, startedBy, contains and finishedBy; OverlapsState, EqualIntervals and ContainsInterval carry a suffix only to avoid clashing with method names. Undefined is returned only by the decorated version when an operand is NaI.

BallContext

BallContext describes a target binary format: a precision in bits and an exponent range [emin⁡,emax⁡][e_{\min}, e_{\max}].

pub struct BallContext {
  // private fields
}

emin⁡e_{\min} and emax⁡e_{\max} follow IEEE 754: a finite nonzero value vv with 2e≤∣v∣<2e+12^{e} \le |v| < 2^{e+1} is in range when e≤emax⁡e \le e_{\max}, and it is normal when e≥emin⁡e \ge e_{\min}. See Contexts and flags.

BallFlags

BallFlags records the conditions raised while rounding an interval into a BallContext.

pub struct BallFlags {
  inexact : Bool
  overflow : Bool
  underflow : Bool
} derive(Eq)

inexact is set when an endpoint changed; overflow when an endpoint was beyond emax⁡e_{\max}; underflow when an endpoint was below the normal range and its subnormal rounding was inexact. The fields are readable; the accessor methods are listed under BallFlags.

Construction

BallFloat::new

BallFloat::new builds the interval [c−r,c+r][c - r, c + r] from a center and a radius, enlarged so that it is exact at the requested precision.

pub fn BallFloat::new(@bin_float.BinFloat, @bin_float.BinFloat, precision? : Int) -> Self

The default precision is the larger of the precisions of center and radius. With pp that precision, the stored interval is

[c~−R,  c~+R],c~=RN⁡p(c),R=RU⁡p(RU⁡p(r)+RU⁡p(∣c−c~∣)),[\tilde c - R,\; \tilde c + R], \qquad \tilde c = \operatorname{RN}_p(c),\quad R = \operatorname{RU}_p\bigl(\operatorname{RU}_p(r) + \operatorname{RU}_p(|c - \tilde c|)\bigr),

which contains [c−r,c+r][c - r, c + r] (proof in the design page). The endpoints c~±R\tilde c \pm R are formed exactly, so they may carry more than pp bits. Aborts when center or radius is not finite or when radius is negative. A precision below 1 is treated as 1.

BallFloat::from_bounds and BallFloat::try_from_bounds

BallFloat::from_bounds builds the interval [x‾,x‾][\underline{x}, \overline{x}] from its endpoints, rounded outward to the requested precision.

pub fn BallFloat::from_bounds(@bin_float.BinFloat, @bin_float.BinFloat, precision? : Int) -> Self
pub fn BallFloat::try_from_bounds(@bin_float.BinFloat, @bin_float.BinFloat, precision? : Int) -> Result[Self, @arithmetic.ArithmeticError]

The default precision is the larger of the endpoint precisions. Infinite endpoints build unbounded intervals: from_bounds(-inf, +inf) is Entire. The inputs are invalid when an endpoint is NaN, the lower endpoint is +∞+\infty, the upper endpoint is −∞-\infty, or x‾>x‾\underline{x} > \overline{x}; from_bounds aborts and try_from_bounds returns a domain error. There is no way to build Empty from bounds; use BallFloat::empty.

///|
test "from_bounds" {
  let two = @bin_float.BinFloat::from_int(2, precision=53)
  let three = @bin_float.BinFloat::from_int(3, precision=53)
  inspect(fmt(@ball_float.BallFloat::from_bounds(two, three)), content="[2.00000e+0, 3.00000e+0]")
  inspect(@ball_float.BallFloat::try_from_bounds(three, two) is Err(_), content="true")
}

BallFloat::exact and BallFloat::try_exact

BallFloat::exact builds the singleton {x}\{x\} of a finite BinFloat.

pub fn BallFloat::exact(@bin_float.BinFloat, precision? : Int) -> Self
pub fn BallFloat::try_exact(@bin_float.BinFloat, precision? : Int) -> Result[Self, @arithmetic.ArithmeticError]

The default precision is that of x. When x has more significant bits than the requested precision, the singleton is rounded outward to a two-point interval around x. A non-finite x aborts exact and makes try_exact return a domain error.

BallFloat::from_int and BallFloat::from_coefficient

BallFloat::from_int and BallFloat::from_coefficient build the singleton of an integer.

pub fn BallFloat::from_int(Int, precision? : Int) -> Self
pub fn BallFloat::from_coefficient(@bin_float.BinCoeff, precision? : Int, negative? : Bool) -> Self

The default precision is 16. from_coefficient takes a non-negative BinCoeff magnitude and a separate sign. The integer is first converted to a BinFloat of max⁡(p,8)\max(p, 8) bits with round-to-nearest, then embedded with exact.

BallFloat::from_double, BallFloat::from_float and their try_ forms

These functions build the singleton of the exact binary value of a Double or Float.

pub fn BallFloat::from_double(Double, precision? : Int) -> Self
pub fn BallFloat::try_from_double(Double, precision? : Int) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::from_float(Float, precision? : Int) -> Self
pub fn BallFloat::try_from_float(Float, precision? : Int) -> Result[Self, @arithmetic.ArithmeticError]

Default precisions are 53 and 24. The conversion to BinFloat is exact; a smaller requested precision rounds the singleton outward. NaN and infinities abort the plain forms and are domain errors for the try_ forms. The result encloses the binary value, not the decimal literal it was written as: from_double(0.1) does not contain 1/101/10.

BallFloat::whole and BallFloat::empty

BallFloat::whole returns Entire and BallFloat::empty returns Empty.

pub fn BallFloat::whole(precision? : Int) -> Self
pub fn BallFloat::empty(precision? : Int) -> Self

The default precision is 53.

Observers

BallFloat::lower_bound and BallFloat::upper_bound

lower_bound and upper_bound return the stored endpoints.

pub fn BallFloat::lower_bound(Self) -> @bin_float.BinFloat
pub fn BallFloat::upper_bound(Self) -> @bin_float.BinFloat

For an unbounded side the endpoint is an infinity. For Empty they return +∞+\infty and −∞-\infty respectively, so test is_empty first.

BallFloat::center and BallFloat::radius

center and radius return the midpoint–radius view of a bounded interval.

pub fn BallFloat::center(Self) -> @bin_float.BinFloat
pub fn BallFloat::radius(Self) -> @bin_float.BinFloat

center is (x‾+x‾)/2(\underline{x} + \overline{x})/2 and radius is (x‾−x‾)/2(\overline{x} - \underline{x})/2, both computed exactly (the radius is rounded up only if it underflows the exponent range), so [center−radius,center+radius][\text{center} - \text{radius}, \text{center} + \text{radius}] is the stored interval. Both abort on Empty and on unbounded intervals.

BallFloat::midpoint

midpoint returns the center rounded to nearest at the interval’s precision.

pub fn BallFloat::midpoint(Self) -> @bin_float.BinFloat

Entire has midpoint 0. Empty and half-bounded intervals abort.

BallFloat::width and BallFloat::radius_extended

width returns RU⁡p(x‾−x‾)\operatorname{RU}_p(\overline{x} - \underline{x}) and radius_extended returns the radius rounded up to the interval’s precision.

pub fn BallFloat::width(Self) -> @bin_float.BinFloat
pub fn BallFloat::radius_extended(Self) -> @bin_float.BinFloat

Both return 0 for Empty and +∞+\infty for unbounded intervals instead of aborting.

BallFloat::magnitude and BallFloat::mignitude

magnitude returns max⁡{∣ξ∣:ξ∈x}\max\{|\xi| : \xi \in \boldsymbol{x}\} and mignitude returns min⁡{∣ξ∣:ξ∈x}\min\{|\xi| : \xi \in \boldsymbol{x}\}.

pub fn BallFloat::magnitude(Self) -> @bin_float.BinFloat
pub fn BallFloat::mignitude(Self) -> @bin_float.BinFloat

Both are exact. Empty gives 0; mignitude is 0 when the interval contains 0; magnitude of an unbounded interval is +∞+\infty.

///|
test "observers" {
  let x = iv(-3, 5)
  inspect(x.center().to_string(), content="1p0")
  inspect(x.radius().to_string(), content="1p2")
  inspect(x.width().to_string(), content="1p3")
  inspect(x.magnitude().to_string(), content="5p0")
  inspect(x.mignitude().to_string(), content="0")
  inspect(iv(2, 7).mignitude().to_string(), content="1p1")
}

BallFloat::precision, BallFloat::classify and BallFloat::sign

precision returns the precision tag; classify and sign describe the interval in the vocabulary of scalar floating-point types.

pub fn BallFloat::precision(Self) -> Int
pub fn BallFloat::classify(Self) -> @arithmetic.FpClass
pub fn BallFloat::sign(Self) -> @def.Sign

classify returns NaN for Empty, Finite for a bounded interval and Infinity for an unbounded one. sign returns Positive when x‾>0\underline{x} > 0, Negative when x‾<0\overline{x} < 0, and Zero otherwise: Zero means “the interval contains 0”, not “the interval is {0}\{0\}”. sign aborts on Empty.

Shape predicates

is_empty, is_entire, is_bounded, is_common_interval, is_singleton and contains_zero test the shape of the set.

pub fn BallFloat::is_empty(Self) -> Bool
pub fn BallFloat::is_entire(Self) -> Bool
pub fn BallFloat::is_bounded(Self) -> Bool
pub fn BallFloat::is_common_interval(Self) -> Bool
pub fn BallFloat::is_singleton(Self) -> Bool
pub fn BallFloat::contains_zero(Self) -> Bool

is_bounded and is_common_interval (the IEEE 1788 name) are the same: the interval is non-empty with two finite endpoints. is_singleton holds when x‾=x‾\underline{x} = \overline{x}. contains_zero is false for Empty.

Precision

BallFloat::with_precision

with_precision re-rounds an interval to a new precision without shrinking it.

pub fn BallFloat::with_precision(Self, Int, @arithmetic.RoundingMode) -> Self

For a bounded interval the center is rounded with mode, the displacement is added to the radius, and the result is rebuilt as in BallFloat::new. For an unbounded interval the finite endpoint is rounded outward and mode is ignored. Empty stays Empty with the new precision. The result always contains the input, except in the extreme case noted under center when the new precision exceeds about 2162^{16} bits.

BallFloat::normalized

normalized rebuilds a bounded interval from its normalized center and radius (BinFloat::normalized removes trailing zero bits), and re-rounds the finite endpoints of an unbounded interval outward.

pub fn BallFloat::normalized(Self) -> Self

The result contains the input.

Set operations

BallFloat::intersection and BallFloat::convex_hull

intersection returns x∩y\boldsymbol{x} \cap \boldsymbol{y} and convex_hull returns the smallest interval containing x∪y\boldsymbol{x} \cup \boldsymbol{y}.

pub fn BallFloat::intersection(Self, Self) -> Self
pub fn BallFloat::convex_hull(Self, Self) -> Self

Both are computed by endpoint max/min and are exact apart from the final outward rounding to the larger precision. Disjoint intervals intersect to Empty; Empty is the identity of convex_hull.

BallFloat::cancel_plus and BallFloat::cancel_minus

cancel_minus(x, y) returns the interval z\boldsymbol{z} with y+z=x\boldsymbol{y} + \boldsymbol{z} = \boldsymbol{x}, the inverse of addition used to undo a previous sum; cancel_plus(x, y) is cancel_minus(x, -y).

pub fn BallFloat::cancel_plus(Self, Self) -> Self
pub fn BallFloat::cancel_minus(Self, Self) -> Self

For bounded operands cancel_minus is [x‾−y‾,x‾−y‾][\underline{x} - \underline{y}, \overline{x} - \overline{y}], rounded outward. When that is not an interval (the width of y\boldsymbol{y} exceeds the width of x\boldsymbol{x}), when an operand is unbounded, or when only y\boldsymbol{y} is empty, the result is Entire. Empty x\boldsymbol{x} with bounded or empty y\boldsymbol{y} gives Empty.

///|
test "set operations" {
  inspect(fmt(iv(0, 4).intersection(iv(2, 9))), content="[2.00000e+0, 4.00000e+0]")
  inspect(iv(0, 1).intersection(iv(2, 3)).is_empty(), content="true")
  inspect(fmt(iv(0, 1).convex_hull(iv(5, 6))), content="[0.00000e+0, 6.00000e+0]")
  // (x + y) - y widens, cancel_minus recovers x.
  let x = iv(1, 2)
  let y = iv(10, 20)
  inspect(fmt(x + y - y), content="[-9.00000e+0, 1.20000e+1]")
  inspect(fmt((x + y).cancel_minus(y)), content="[1.00000e+0, 2.00000e+0]")
}

Relations

All relations are set relations of IEEE 1788; none of them is a total order. They never abort.

BallFloat::contains

contains tests whether a point belongs to the interval.

pub fn BallFloat::contains(Self, @bin_float.BinFloat) -> Bool

It returns false for Empty and for a non-finite point (an unbounded interval contains all sufficiently large reals, but not ±∞\pm\infty or NaN). The trait method @lf_arith.Contains::contains instead takes two intervals and tests inclusion; see Trait implementations.

BallFloat::subset, BallFloat::interior, BallFloat::set_equal, BallFloat::disjoint

These test inclusion, inclusion in the interior, equality and disjointness of sets.

pub fn BallFloat::subset(Self, Self) -> Bool
pub fn BallFloat::interior(Self, Self) -> Bool
pub fn BallFloat::set_equal(Self, Self) -> Bool
pub fn BallFloat::disjoint(Self, Self) -> Bool

x.subset(y) is x⊆y\boldsymbol{x} \subseteq \boldsymbol{y} and x.interior(y) is x⊆int⁡y\boldsymbol{x} \subseteq \operatorname{int} \boldsymbol{y}, where an infinite endpoint counts as interior (so Entire is interior to itself). Empty is a subset of, interior to and disjoint from every interval. set_equal ignores the precision tag and the representation of the endpoints.

BallFloat::overlaps, BallFloat::maybe_eq, BallFloat::separated_from

overlaps tests whether two intervals share a point; maybe_eq is the same relation read as “the two unknown points may be equal”; separated_from is its negation.

pub fn BallFloat::overlaps(Self, Self) -> Bool
pub fn BallFloat::maybe_eq(Self, Self) -> Bool
pub fn BallFloat::separated_from(Self, Self) -> Bool

overlaps is false and separated_from is true when an operand is Empty.

BallFloat::definitely_lt, BallFloat::definitely_le, BallFloat::definitely_gt

These hold when the order holds for every pair of points.

pub fn BallFloat::definitely_lt(Self, Self) -> Bool
pub fn BallFloat::definitely_le(Self, Self) -> Bool
pub fn BallFloat::definitely_gt(Self, Self) -> Bool

x.definitely_lt(y) is x‾<y‾\overline{x} < \underline{y}, definitely_le is x‾≤y‾\overline{x} \le \underline{y} and definitely_gt is x‾>y‾\underline{x} > \overline{y}. All three are false when an operand is Empty (unlike precedes, which is vacuously true).

BallFloat::less, BallFloat::strictly_less, BallFloat::precedes, BallFloat::strictly_precedes

These are the order relations of IEEE 1788.

pub fn BallFloat::less(Self, Self) -> Bool
pub fn BallFloat::strictly_less(Self, Self) -> Bool
pub fn BallFloat::precedes(Self, Self) -> Bool
pub fn BallFloat::strictly_precedes(Self, Self) -> Bool

For non-empty operands:

RelationCondition
lessx‾≤y‾\underline{x} \le \underline{y} and x‾≤y‾\overline{x} \le \overline{y}
strictly_lessx‾<y‾\underline{x} < \underline{y} (or both −∞-\infty) and x‾<y‾\overline{x} < \overline{y} (or both +∞+\infty)
precedesx‾≤y‾\overline{x} \le \underline{y}
strictly_precedesx‾<y‾\overline{x} < \underline{y}

With Empty: less and strictly_less hold only when both are Empty; precedes and strictly_precedes hold when either is Empty.

BallFloat::overlap_state

overlap_state classifies the relative position of two intervals.

pub fn BallFloat::overlap_state(Self, Self) -> OverlapState

The result is one of the sixteen states of OverlapState other than Undefined; it is computed from the comparisons of the four endpoints.

///|
test "relations" {
  let a = iv(1, 3)
  let b = iv(3, 6)
  inspect(a.precedes(b), content="true")
  inspect(a.strictly_precedes(b), content="false")
  inspect(a.definitely_le(b), content="true")
  inspect(a.maybe_eq(b), content="true")
  inspect(iv(2, 3).interior(iv(1, 6)), content="true")
  inspect(iv(1, 3).interior(iv(1, 6)), content="false")
  debug_inspect(a.overlap_state(b), content="Meets")
  debug_inspect(iv(1, 6).overlap_state(iv(2, 3)), content="ContainsInterval")
}

Arithmetic

BallFloat::add, BallFloat::sub, BallFloat::mul, BallFloat::div

The four basic operations return the outward-rounded hull of {ξ∘η:ξ∈x,η∈y}\{\xi \circ \eta : \xi \in \boldsymbol{x}, \eta \in \boldsymbol{y}\}; they are also available as the operators +, -, *, /.

pub fn BallFloat::add(Self, Self) -> Self
pub fn BallFloat::sub(Self, Self) -> Self
pub fn BallFloat::mul(Self, Self) -> Self
pub fn BallFloat::div(Self, Self) -> Self

The result precision is the larger operand precision; an Empty operand gives Empty. Endpoint formulas:

x+y=[RD⁡(x‾+y‾), RU⁡(x‾+y‾)]x−y=[RD⁡(x‾−y‾), RU⁡(x‾−y‾)]x⋅y=[RD⁡min⁡S, RU⁡max⁡S],S={x‾y‾,x‾y‾,x‾y‾,x‾y‾}\begin{aligned} \boldsymbol{x} + \boldsymbol{y} &= [\operatorname{RD}(\underline{x} + \underline{y}),\ \operatorname{RU}(\overline{x} + \overline{y})] \\ \boldsymbol{x} - \boldsymbol{y} &= [\operatorname{RD}(\underline{x} - \overline{y}),\ \operatorname{RU}(\overline{x} - \underline{y})] \\ \boldsymbol{x} \cdot \boldsymbol{y} &= [\operatorname{RD}\min S,\ \operatorname{RU}\max S],\quad S = \{\underline{x}\underline{y}, \underline{x}\overline{y}, \overline{x}\underline{y}, \overline{x}\overline{y}\} \end{aligned}

with 0⋅∞0 \cdot \infty taken as 0 in SS (a zero endpoint times an unbounded side contributes 0). For bounded operands the sign of the operands selects the two products that can be extremal, so at most two (four when both operands contain 0) products are evaluated.

Division follows IEEE 1788: x/y\boldsymbol{x} / \boldsymbol{y} is the hull of {ξ/η:η≠0}\{\xi/\eta : \eta \ne 0\}.

Divisor y\boldsymbol{y}Result
0∉y0 \notin \boldsymbol{y}[RD⁡min⁡Q,RU⁡max⁡Q][\operatorname{RD}\min Q, \operatorname{RU}\max Q] over the endpoint quotients QQ
{0}\{0\}Empty
y‾<0<y‾\underline{y} < 0 < \overline{y}Entire
[0,y‾][0, \overline{y}] or [y‾,0][\underline{y}, 0]half-unbounded (see below), or Entire when x‾<0<x‾\underline{x} < 0 < \overline{x}

When the divisor touches 0 at one end, the quotient is unbounded on one side: for example [1,2]/[0,4]=[1/4,+∞)[1, 2]/[0, 4] = [1/4, +\infty) and [−2,−1]/[0,4]=(−∞,−1/4][-2, -1]/[0, 4] = (-\infty, -1/4]. A dividend equal to {0}\{0\} gives {0}\{0\} for any divisor other than {0}\{0\}.

///|
test "basic arithmetic" {
  let x = iv(1, 2)
  let y = iv(-3, 5)
  inspect(fmt(x + y), content="[-2.00000e+0, 7.00000e+0]")
  inspect(fmt(x - y), content="[-4.00000e+0, 5.00000e+0]")
  inspect(fmt(x * y), content="[-6.00000e+0, 1.00000e+1]")
  inspect((x / y).is_entire(), content="true")
  inspect(fmt(x / iv(0, 4)), content="[2.50000e-1, inf]")
  inspect((x / iv(0, 0)).is_empty(), content="true")
}

BallFloat::neg and BallFloat::abs

neg returns [−x‾,−x‾][-\overline{x}, -\underline{x}] and abs returns {∣ξ∣:ξ∈x}\{|\xi| : \xi \in \boldsymbol{x}\}.

pub fn BallFloat::neg(Self) -> Self
pub fn BallFloat::abs(Self) -> Self

Both are exact. neg is also the unary operator -.

BallFloat::reciprocal

reciprocal returns 1/x1/\boldsymbol{x} with the division rules above.

pub fn BallFloat::reciprocal(Self) -> Self

BallFloat::square and BallFloat::pown

square returns {ξ2}\{\xi^2\} and pown returns {ξn}\{\xi^n\} for an integer exponent nn.

pub fn BallFloat::square(Self) -> Self
pub fn BallFloat::pown(Self, Int) -> Self

Unlike x * x, these use the same point twice, so [-1, 2].square() is [0,4][0, 4] (while x * x is [−2,4][-2, 4]). pown evaluates the monotone pieces of ξn\xi^n at the endpoints with directed rounding: odd positive powers are increasing; even positive powers decrease then increase, with minimum 0 when 0∈x0 \in \boldsymbol{x}; negative powers have a pole at 0. pown(x, 0) is {1}\{1\} for every non-empty x; Empty stays Empty. pown(x, n) with n<0n < 0 returns Empty for x={0}\boldsymbol{x} = \{0\}, a half-unbounded interval when 0 is an endpoint, and for 0 in the interior Entire (odd nn) or [min⁡(x‾n,x‾n),+∞)[\min(\underline{x}^n, \overline{x}^n), +\infty) (even nn).

///|
test "powers" {
  let x = iv(-1, 2)
  inspect(fmt(x.square()), content="[0.00000e+0, 4.00000e+0]")
  inspect(fmt(x.pown(3)), content="[-1.00000e+0, 8.00000e+0]")
  inspect(fmt(x.pown(-2)), content="[2.50000e-1, inf]")
  inspect(x.pown(-1).is_entire(), content="true")
  inspect(fmt(iv(0, 2).pown(-1)), content="[5.00000e-1, inf]")
}

BallFloat::fma

fma(x, y, z) returns an enclosure of {ξη+ζ}\{\xi\eta + \zeta\} with a single outward rounding.

pub fn BallFloat::fma(Self, Self, Self) -> Self

The product bounds are computed as for mul and added to the endpoints of z\boldsymbol{z} before the final rounding, so the result is never wider than x * y + z.

BallFloat::minimum and BallFloat::maximum

minimum and maximum return {min⁡(ξ,η)}\{\min(\xi, \eta)\} and {max⁡(ξ,η)}\{\max(\xi, \eta)\}.

pub fn BallFloat::minimum(Self, Self) -> Self
pub fn BallFloat::maximum(Self, Self) -> Self

minimum is [min⁡(x‾,y‾),min⁡(x‾,y‾)][\min(\underline{x}, \underline{y}), \min(\overline{x}, \overline{y})] and maximum is the analogue with max. An Empty operand gives Empty.

Elementary functions

Each function ff returns an interval containing f(x∩Df)f(\boldsymbol{x} \cap D_f), where DfD_f is the domain of ff; points of x\boldsymbol{x} outside DfD_f are ignored and the result is Empty when x∩Df\boldsymbol{x} \cap D_f is empty. The result precision is the argument’s precision.

Functions come in two forms. The total form (exp_interval, sin_interval, …) always returns a valid enclosure; when the certified evaluation exhausts its refinement budget it returns a wider, still valid, interval. The try_ form (try_exp_interval, …) returns Err(ArithmeticError) in that case, with a certification-failure detail naming the operation, stage and reason. Except where noted, the try_ forms evaluate each endpoint with the corresponding bin_float try_*_ctx function rounded toward −∞-\infty or +∞+\infty; the total forms either call them or use the certified series of this package. Both forms return the same set on ordinary inputs; their bounds may differ by an ulp.

BallFloat::sqrt_interval

sqrt_interval returns x∩[0,+∞)\sqrt{\boldsymbol{x} \cap [0, +\infty)}.

pub fn BallFloat::sqrt_interval(Self) -> Self

The endpoints are the downward and upward square roots at the interval’s precision. Empty when x‾<0\overline{x} < 0. There is no try_ form: square root never fails.

Exponentials

exp_interval, exp2_interval, exp10_interval and expm1_interval return enclosures of eξe^{\xi}, 2ξ2^{\xi}, 10ξ10^{\xi} and eξ−1e^{\xi} - 1.

pub fn BallFloat::exp_interval(Self) -> Self
pub fn BallFloat::exp2_interval(Self) -> Self
pub fn BallFloat::exp10_interval(Self) -> Self
pub fn BallFloat::expm1_interval(Self) -> Self
pub fn BallFloat::try_exp_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_exp2_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_exp10_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_expm1_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]

All four are increasing, so the result is [RD⁡f(x‾),RU⁡f(x‾)][\operatorname{RD} f(\underline{x}), \operatorname{RU} f(\overline{x})]. exp_interval uses a certified Taylor series with argument halving and never needs a fallback; for ∣ξ∣≥230|\xi| \ge 2^{30} it returns [largest finite,+∞)[\text{largest finite}, +\infty) or [0,smallest positive][0, \text{smallest positive}]. exp2_interval and exp10_interval evaluate eξln⁡be^{\xi \ln b} at 96 extra bits and return exact powers for integer endpoints (for exp10_interval, exponents 0≤n≤1000000 \le n \le 100000). The total expm1_interval falls back to [−1,+∞)[-1, +\infty).

Logarithms

ln_interval, log2_interval, log10_interval and log1p_interval return enclosures of ln⁡ξ\ln \xi, log⁡2ξ\log_2 \xi, log⁡10ξ\log_{10} \xi and ln⁡(1+ξ)\ln(1 + \xi) over their domains (0,∞)(0, \infty) and (−1,∞)(-1, \infty).

pub fn BallFloat::ln_interval(Self) -> Self
pub fn BallFloat::log2_interval(Self) -> Self
pub fn BallFloat::log10_interval(Self) -> Self
pub fn BallFloat::log1p_interval(Self) -> Self
pub fn BallFloat::try_ln_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_log2_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_log10_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_log1p_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]

When the interval reaches the domain boundary (x‾≤0\underline{x} \le 0, or x‾≤−1\underline{x} \le -1 for log1p) the lower endpoint is −∞-\infty; when it lies entirely outside the domain the result is Empty. log10_interval returns exact integers at endpoints 10k10^k, 0≤k≤90 \le k \le 9. The total log1p_interval falls back to Entire.

///|
test "exponentials and logarithms" {
  inspect(fmt(iv(0, 1).exp_interval()), content="[1.00000e+0, 2.71829e+0]")
  inspect(fmt(iv(-1, 10).exp2_interval()), content="[5.00000e-1, 1.02400e+3]")
  inspect(fmt(iv(0, 4).ln_interval()), content="[-inf, 1.38630e+0]")
  inspect(fmt(iv(1, 1000).log10_interval()), content="[0.00000e+0, 3.00000e+0]")
  inspect(iv(-2, -1).ln_interval().is_empty(), content="true")
}

BallFloat::pow_interval and BallFloat::try_pow_interval

pow_interval(x, y) returns an enclosure of {ξη:ξ∈x,η∈y}\{\xi^{\eta} : \xi \in \boldsymbol{x}, \eta \in \boldsymbol{y}\} over the IEEE 1788 domain of pow: ξ>0\xi > 0, or ξ=0\xi = 0 and η>0\eta > 0.

pub fn BallFloat::pow_interval(Self, Self) -> Self
pub fn BallFloat::try_pow_interval(Self, Self) -> Result[Self, @arithmetic.ArithmeticError]

Negative parts of the base are ignored (use pown or rootn for negative bases). The result is the hull of the four corner values, extended by 1 when the base interval contains 1 or the exponent interval contains 0, by 0 when the base reaches 0 with positive exponents, and by +∞+\infty when the base reaches 0 with negative exponents. 0η0^{\eta} for η≤0\eta \le 0 is excluded, so pow_interval([0, 0], y) is Empty when y‾≤0\overline{y} \le 0. The result precision is the larger operand precision. The total form falls back to an evaluation of eηln⁡ξe^{\eta \ln \xi} at 192 extra bits.

BallFloat::rootn and BallFloat::try_rootn

rootn(x, n) returns an enclosure of the real nn-th roots {ξ1/n}\{\xi^{1/n}\}: for even nn over ξ≥0\xi \ge 0, for odd nn over all reals, and for negative nn the reciprocal of the root.

pub fn BallFloat::rootn(Self, Int) -> Self
pub fn BallFloat::try_rootn(Self, Int) -> Result[Self, @arithmetic.ArithmeticError]

rootn(x, 0) and rootn(x, Int min) are Empty; try_rootn(x, 0) is a domain error. rootn(x, 1) is x and rootn(x, 2) is sqrt_interval. The total form evaluates other degrees through pow_interval with an enclosure of 1/n1/n, so it may be slightly wider than try_rootn. For negative nn, try_rootn returns Entire when an odd root’s argument contains 0.

BallFloat::hypot and BallFloat::try_hypot

hypot returns an enclosure of {ξ2+η2}\{\sqrt{\xi^2 + \eta^2}\}.

pub fn BallFloat::hypot(Self, Self) -> Self
pub fn BallFloat::try_hypot(Self, Self) -> Result[Self, @arithmetic.ArithmeticError]

The function is increasing in ∣ξ∣|\xi| and ∣η∣|\eta|, so the result is evaluated at the endpoints of abs(x) and abs(y). The total form falls back to sqrt_interval(square(x) + square(y)).

Trigonometric functions

sin_interval, cos_interval and tan_interval return enclosures of sin⁡\sin, cos⁡\cos and tan⁡\tan over the interval (in radians).

pub fn BallFloat::sin_interval(Self) -> Self
pub fn BallFloat::cos_interval(Self) -> Self
pub fn BallFloat::tan_interval(Self) -> Self
pub fn BallFloat::try_sin_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_cos_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_tan_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]

Both forms reduce each endpoint by a certified enclosure of π/2\pi/2 and evaluate certified Taylor series. A critical point kπ/2k\pi/2 inside the interval contributes the extremum ±1\pm 1 of sin/cos; for tan an odd multiple of π/2\pi/2 inside the interval (a pole) makes the result Entire. Unbounded arguments give [−1,1][-1, 1] (Entire for tan). When the larger endpoint magnitude is at least 2max⁡(65536, 4p)+12^{\max(65536,\, 4p) + 1}, the total forms return [−1,1][-1, 1] (Entire) without evaluating and the try_ forms return a resource-limit error; the total forms use the same fallback when the 12 refinement steps are exhausted.

Trigonometric functions of πx\pi x

sinpi_interval, cospi_interval and tanpi_interval return enclosures of sin⁡πξ\sin \pi\xi, cos⁡πξ\cos \pi\xi and tan⁡πξ\tan \pi\xi.

pub fn BallFloat::sinpi_interval(Self) -> Self
pub fn BallFloat::cospi_interval(Self) -> Self
pub fn BallFloat::tanpi_interval(Self) -> Self
pub fn BallFloat::try_sinpi_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_cospi_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_tanpi_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]

Here the critical points are the exact half-integers k/2k/2, located without approximating π\pi. tanpi_interval returns a half-unbounded interval when a pole is exactly an endpoint (for example [1/2,1][1/2, 1] gives (−∞,0](-\infty, 0]), Empty for the singleton of a pole, and Entire when a pole lies inside. Unbounded arguments and fallbacks give [−1,1][-1, 1] (Entire for tanpi).

///|
test "trigonometric functions" {
  inspect(fmt(iv(0, 4).sin_interval()), content="[-7.56803e-1, 1.00000e+0]")
  inspect(fmt(iv(0, 4).cos_interval()), content="[-1.00000e+0, 1.00000e+0]")
  inspect(iv(1, 2).tan_interval().is_entire(), content="true")
  let half = @bin_float.BinFloat::make(@bin_float.BinCoeff::one(), -1, 53)
  let x = @ball_float.BallFloat::from_bounds(half, @bin_float.BinFloat::one(precision=53))
  inspect(fmt(x.sinpi_interval()), content="[0.00000e+0, 1.00000e+0]")
  inspect(fmt(x.tanpi_interval()), content="[-inf, 0.00000e+0]")
}

Inverse trigonometric functions

asin_interval, acos_interval and atan_interval return enclosures of arcsin⁡\arcsin, arccos⁡\arccos (over [−1,1][-1, 1]) and arctan⁡\arctan.

pub fn BallFloat::asin_interval(Self) -> Self
pub fn BallFloat::acos_interval(Self) -> Self
pub fn BallFloat::atan_interval(Self) -> Self
pub fn BallFloat::try_asin_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_acos_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_atan_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]

asin and atan are increasing and acos is decreasing, so only endpoints are evaluated. The total atan_interval uses a certified series with a Machin-formula enclosure of π\pi; asin is computed as arctan⁡(ξ/1−ξ2)\arctan(\xi/\sqrt{1 - \xi^2}) and acos as π/2−arcsin⁡ξ\pi/2 - \arcsin \xi, at 64 extra bits. atan of an infinite endpoint is ±π/2\pm\pi/2.

BallFloat::atan2_interval and BallFloat::try_atan2_interval

y.atan2_interval(x) returns an enclosure of the angles atan2⁡(η,ξ)∈(−π,π]\operatorname{atan2}(\eta, \xi) \in (-\pi, \pi] of the points (ξ,η)≠(0,0)(\xi, \eta) \ne (0, 0) of the box x×y\boldsymbol{x} \times \boldsymbol{y}.

pub fn BallFloat::atan2_interval(Self, Self) -> Self
pub fn BallFloat::try_atan2_interval(Self, Self) -> Result[Self, @arithmetic.ArithmeticError]

The receiver is the ordinate. The result is the hull of the angles at the four corners and at the points where the box meets the axes. When the box crosses the branch cut (negative ξ\xi, and η\eta ranging over negative values and 0) the result is [−π,π][-\pi, \pi]. The box {(0,0)}\{(0, 0)\} gives Empty. The total form falls back to [−π,π][-\pi, \pi].

Hyperbolic functions

sinh_interval, cosh_interval, tanh_interval, asinh_interval, acosh_interval and atanh_interval return enclosures of the hyperbolic functions and their inverses over their domains ([1,∞)[1, \infty) for acosh, (−1,1)(-1, 1) for atanh).

pub fn BallFloat::sinh_interval(Self) -> Self
pub fn BallFloat::cosh_interval(Self) -> Self
pub fn BallFloat::tanh_interval(Self) -> Self
pub fn BallFloat::asinh_interval(Self) -> Self
pub fn BallFloat::acosh_interval(Self) -> Self
pub fn BallFloat::atanh_interval(Self) -> Self
pub fn BallFloat::try_sinh_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_cosh_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_tanh_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_asinh_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_acosh_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_atanh_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]

cosh has its minimum 1 at 0; the others are monotone. The total forms evaluate the defining formulas ((eξ−e−ξ)/2(e^\xi - e^{-\xi})/2, ln⁡(ξ+ξ2+1)\ln(\xi + \sqrt{\xi^2 + 1}), 12ln⁡1+ξ1−ξ\tfrac12 \ln\frac{1+\xi}{1-\xi}, …) in interval arithmetic at 192 extra bits at each endpoint, so they never fail; tanh_interval is clipped to [−1,1][-1, 1]. atanh of an interval reaching ±1\pm 1 is unbounded on that side.

///|
test "inverse and hyperbolic functions" {
  let unit = iv(-1, 1)
  inspect(fmt(unit.asin_interval()), content="[-1.57080e+0, 1.57080e+0]")
  inspect(fmt(iv(-2, 2).acos_interval()), content="[0.00000e+0, 3.14160e+0]")
  inspect(fmt(iv(1, 1).atan2_interval(iv(1, 1))), content="[7.85398e-1, 7.85399e-1]")
  inspect(fmt(unit.cosh_interval()), content="[1.00000e+0, 1.54309e+0]")
  inspect(fmt(unit.atanh_interval()), content="[-inf, inf]")
}

Contexts and flags

BallContext::new and BallContext::try_new

BallContext::new builds a context from a precision and an exponent range.

pub fn BallContext::new(precision? : Int, e_min? : Int, e_max? : Int) -> Self
pub fn BallContext::try_new(precision? : Int, e_min? : Int, e_max? : Int) -> Result[Self, @arithmetic.ArithmeticError]

The defaults are those of binary64: precision 53, emin⁡=−1022e_{\min} = -1022, emax⁡=1023e_{\max} = 1023. A precision below 1 or emin⁡>emax⁡e_{\min} > e_{\max} aborts new and is a domain error for try_new.

BallContext::binary32 and BallContext::binary64

These return the contexts of the IEEE 754 binary32 (p=24p = 24, [−126,127][-126, 127]) and binary64 (p=53p = 53, [−1022,1023][-1022, 1023]) formats.

pub fn BallContext::binary32() -> Self
pub fn BallContext::binary64() -> Self

BallContext::precision, BallContext::e_min, BallContext::e_max

These return the parameters of a context.

pub fn BallContext::precision(Self) -> Int
pub fn BallContext::e_min(Self) -> Int
pub fn BallContext::e_max(Self) -> Int

BallFlags::new, BallFlags::combine and accessors

BallFlags::new returns the flags with nothing raised; combine is their union; the accessors read the fields.

pub fn BallFlags::new() -> Self
pub fn BallFlags::combine(Self, Self) -> Self
pub fn BallFlags::inexact(Self) -> Bool
pub fn BallFlags::overflow(Self) -> Bool
pub fn BallFlags::underflow(Self) -> Bool

BallFloat::apply_ctx

apply_ctx rounds an interval outward into a context and reports the flags.

pub fn BallFloat::apply_ctx(Self, BallContext) -> (Self, BallFlags)

Each finite nonzero endpoint is rounded outward to the context precision. An endpoint whose rounded exponent exceeds emax⁡e_{\max} overflows: it becomes ∓∞\mp\infty if it is a negative lower or a positive upper endpoint, and the largest finite value of the right sign otherwise (a positive lower endpoint becomes the largest finite value, which is still below it). An endpoint below the normal range is rounded outward on the subnormal grid 2emin⁡−p+1Z2^{e_{\min} - p + 1}\mathbb{Z}, so a tiny positive upper endpoint becomes the smallest subnormal rather than 0. Zeros and infinities are kept. Empty gives Empty with no flags. The result has the context precision.

BallFloat::add_ctx, BallFloat::sub_ctx, BallFloat::mul_ctx, BallFloat::div_ctx

These compute the operation and then apply the context.

pub fn BallFloat::add_ctx(Self, Self, BallContext) -> (Self, BallFlags)
pub fn BallFloat::sub_ctx(Self, Self, BallContext) -> (Self, BallFlags)
pub fn BallFloat::mul_ctx(Self, Self, BallContext) -> (Self, BallFlags)
pub fn BallFloat::div_ctx(Self, Self, BallContext) -> (Self, BallFlags)

x.add_ctx(y, ctx) is (x + y).apply_ctx(ctx). When the operands’ precision is at least the context precision, the double rounding gives the same endpoints as a single outward rounding into the context (see the design page).

BallFloat::exp_ctx and BallFloat::ln_ctx

exp_ctx and ln_ctx evaluate exp_interval and ln_interval at 32 bits more than the context precision and then apply the context.

pub fn BallFloat::exp_ctx(Self, BallContext) -> (Self, BallFlags)
pub fn BallFloat::ln_ctx(Self, BallContext) -> (Self, BallFlags)

BallFloat::midpoint_ctx

midpoint_ctx returns the center rounded to nearest at the context precision.

pub fn BallFloat::midpoint_ctx(Self, BallContext) -> (@bin_float.BinFloat, BallFlags)

Subnormal results are rounded on the subnormal grid and raise underflow when inexact; inexact is set when the center changed. The exponent upper limit is not applied, so overflow is never raised. Entire gives 0; Empty and half-bounded intervals abort.

///|
test "contexts" {
  let ctx = @ball_float.BallContext::new(precision=8, e_min=-10, e_max=10)
  let (third, flags) = iv(1, 1).div_ctx(iv(3, 3), ctx)
  inspect(third.lower_bound().to_string(), content="85p-8")
  inspect(third.upper_bound().to_string(), content="171p-9")
  inspect(flags.inexact(), content="true")
  let (big, big_flags) = iv(5000, 5000).apply_ctx(ctx)
  inspect(fmt(big), content="[2.04000e+3, inf]")
  inspect(big_flags.overflow(), content="true")
  let merged = flags.combine(big_flags)
  inspect(merged.overflow() && merged.inexact(), content="true")
}

Decorated intervals

A decorated operation computes the bare result and the decoration d=min⁡(d1,…,dk,df)d = \min(d_1, \dots, d_k, d_f), where did_i are the operand decorations and dfd_f is the decoration of the operation on these operands (Com when the function is defined and continuous on the whole input box, Trv when the input leaves the domain, as listed below). The minimum is then made canonical (Empty → Trv, unbounded with Com → Dac). Any NaI operand gives NaI.

BallFloatDecorated::new

BallFloatDecorated::new decorates a bare interval.

pub fn BallFloatDecorated::new(BallFloat, decoration? : Decoration) -> Self

The default decoration is Com. The decoration is made canonical, and Ill is replaced by Trv: new never builds NaI.

BallFloatDecorated::nai and BallFloatDecorated::is_nai

nai returns NaI, the result of an invalid decorated construction; is_nai tests for it.

pub fn BallFloatDecorated::nai(precision? : Int) -> Self
pub fn BallFloatDecorated::is_nai(Self) -> Bool

NaI has decoration Ill and an Empty interval (default precision 53), but it is not Empty: is_empty is false for NaI.

BallFloatDecorated::interval and BallFloatDecorated::decoration

These return the bare interval and the decoration.

pub fn BallFloatDecorated::interval(Self) -> BallFloat
pub fn BallFloatDecorated::decoration(Self) -> Decoration

Decorated predicates and relations

The predicates and relations of BallFloatDecorated apply the bare relation to the intervals and return false when an operand is NaI.

pub fn BallFloatDecorated::is_empty(Self) -> Bool
pub fn BallFloatDecorated::is_entire(Self) -> Bool
pub fn BallFloatDecorated::is_common_interval(Self) -> Bool
pub fn BallFloatDecorated::is_singleton(Self) -> Bool
pub fn BallFloatDecorated::contains(Self, @bin_float.BinFloat) -> Bool
pub fn BallFloatDecorated::set_equal(Self, Self) -> Bool
pub fn BallFloatDecorated::subset(Self, Self) -> Bool
pub fn BallFloatDecorated::interior(Self, Self) -> Bool
pub fn BallFloatDecorated::disjoint(Self, Self) -> Bool
pub fn BallFloatDecorated::less(Self, Self) -> Bool
pub fn BallFloatDecorated::strictly_less(Self, Self) -> Bool
pub fn BallFloatDecorated::precedes(Self, Self) -> Bool
pub fn BallFloatDecorated::strictly_precedes(Self, Self) -> Bool
pub fn BallFloatDecorated::overlap_state(Self, Self) -> OverlapState

overlap_state returns Undefined when an operand is NaI.

Decorated set operations

intersection, convex_hull, cancel_plus and cancel_minus apply the bare operation and always lower the decoration to Trv (set operations are not point functions).

pub fn BallFloatDecorated::intersection(Self, Self) -> Self
pub fn BallFloatDecorated::convex_hull(Self, Self) -> Self
pub fn BallFloatDecorated::cancel_plus(Self, Self) -> Self
pub fn BallFloatDecorated::cancel_minus(Self, Self) -> Self

Decorated arithmetic

The arithmetic operations apply the bare operation; their operation decoration is Com except where the table says otherwise.

pub fn BallFloatDecorated::add(Self, Self) -> Self
pub fn BallFloatDecorated::sub(Self, Self) -> Self
pub fn BallFloatDecorated::mul(Self, Self) -> Self
pub fn BallFloatDecorated::div(Self, Self) -> Self
pub fn BallFloatDecorated::pos(Self) -> Self
pub fn BallFloatDecorated::neg(Self) -> Self
pub fn BallFloatDecorated::abs(Self) -> Self
pub fn BallFloatDecorated::reciprocal(Self) -> Self
pub fn BallFloatDecorated::square(Self) -> Self
pub fn BallFloatDecorated::pown(Self, Int) -> Self
pub fn BallFloatDecorated::fma(Self, Self, Self) -> Self
pub fn BallFloatDecorated::minimum(Self, Self) -> Self
pub fn BallFloatDecorated::maximum(Self, Self) -> Self
OperationOperation decoration
div, reciprocalTrv when the divisor contains 0
pown(x, n)Trv when n<0n < 0 and 0∈x0 \in \boldsymbol{x}
posidentity (IEEE 1788 pos)
othersCom

Decorated elementary functions

The decorated elementary functions apply the bare total form (there are no decorated try_ forms) and lower the decoration when the input leaves the domain of the function.

pub fn BallFloatDecorated::sqrt_interval(Self) -> Self
pub fn BallFloatDecorated::exp_interval(Self) -> Self
pub fn BallFloatDecorated::exp2_interval(Self) -> Self
pub fn BallFloatDecorated::exp10_interval(Self) -> Self
pub fn BallFloatDecorated::expm1_interval(Self) -> Self
pub fn BallFloatDecorated::ln_interval(Self) -> Self
pub fn BallFloatDecorated::log2_interval(Self) -> Self
pub fn BallFloatDecorated::log10_interval(Self) -> Self
pub fn BallFloatDecorated::log1p_interval(Self) -> Self
pub fn BallFloatDecorated::pow_interval(Self, Self) -> Self
pub fn BallFloatDecorated::rootn(Self, Int) -> Self
pub fn BallFloatDecorated::hypot(Self, Self) -> Self
pub fn BallFloatDecorated::sin_interval(Self) -> Self
pub fn BallFloatDecorated::cos_interval(Self) -> Self
pub fn BallFloatDecorated::tan_interval(Self) -> Self
pub fn BallFloatDecorated::sinpi_interval(Self) -> Self
pub fn BallFloatDecorated::cospi_interval(Self) -> Self
pub fn BallFloatDecorated::tanpi_interval(Self) -> Self
pub fn BallFloatDecorated::asin_interval(Self) -> Self
pub fn BallFloatDecorated::acos_interval(Self) -> Self
pub fn BallFloatDecorated::atan_interval(Self) -> Self
pub fn BallFloatDecorated::atan2_interval(Self, Self) -> Self
pub fn BallFloatDecorated::sinh_interval(Self) -> Self
pub fn BallFloatDecorated::cosh_interval(Self) -> Self
pub fn BallFloatDecorated::tanh_interval(Self) -> Self
pub fn BallFloatDecorated::asinh_interval(Self) -> Self
pub fn BallFloatDecorated::acosh_interval(Self) -> Self
pub fn BallFloatDecorated::atanh_interval(Self) -> Self
FunctionOperation decoration Trv when
sqrt_intervalx‾<0\underline{x} < 0 (or the input is Empty)
ln_interval, log2_interval, log10_intervalx‾≤0\underline{x} \le 0
log1p_intervalx‾≤−1\underline{x} \le -1
asin_interval, acos_intervalx⊈[−1,1]\boldsymbol{x} \not\subseteq [-1, 1]
acosh_intervalx‾<1\underline{x} < 1
atanh_intervalx‾≤−1\underline{x} \le -1 or x‾≥1\overline{x} \ge 1
rootn(x, n)n=0n = 0, or nn even and x‾<0\underline{x} < 0
pow_interval(x, y)x‾<0\underline{x} < 0, or 0∈x0 \in \boldsymbol{x} and y‾≤0\underline{y} \le 0, or the result is Empty
tan_interval, tanpi_intervalthe result is Entire (a pole may lie inside)
atan2_intervalboth operands contain 0

All other functions have operation decoration Com. For y.atan2_interval(x) the decoration is Def when the box crosses the branch cut (x‾<0\underline{x} < 0, y‾<0≤y‾\underline{y} < 0 \le \overline{y}) and Dac when it touches the cut from above (x‾<0\overline{x} < 0, y‾=0\underline{y} = 0).

BallFloatDecorated::apply_ctx

apply_ctx applies BallFloat::apply_ctx to the interval and keeps the decoration (made canonical again, so an overflowed Com becomes Dac).

pub fn BallFloatDecorated::apply_ctx(Self, BallContext) -> (Self, BallFlags)

NaI stays NaI, with the context precision.

///|
test "decorated intervals" {
  let x = @ball_float.BallFloatDecorated::new(iv(-1, 4))
  inspect(x.sqrt_interval().decoration(), content="trv")
  inspect(x.exp_interval().decoration(), content="com")
  inspect((x / x).decoration(), content="trv")
  let unbounded = @ball_float.BallFloatDecorated::new(@ball_float.BallFloat::whole())
  inspect(unbounded.decoration(), content="dac")
  let nai = @ball_float.BallFloatDecorated::nai()
  inspect((x + nai).to_string(), content="[nai]")
  debug_inspect(nai.overlap_state(x), content="Undefined")
}

Trait implementations

Operators

BallFloat implements Add, Sub, Mul, Div and Neg; BallFloatDecorated implements Add, Sub, Mul and Div. The operators call the methods of the same name.

pub impl Add for BallFloat
pub impl Sub for BallFloat
pub impl Mul for BallFloat
pub impl Div for BallFloat
pub impl Neg for BallFloat
pub impl Add for BallFloatDecorated
pub impl Sub for BallFloatDecorated
pub impl Mul for BallFloatDecorated
pub impl Div for BallFloatDecorated

Show

Show writes an interval in an exact text form.

pub impl Show for BallFloat
pub fn BallFloat::to_string(Self) -> String
pub fn BallFloat::output(Self, &Logger) -> Unit
pub impl Show for BallFloatDecorated
pub fn BallFloatDecorated::to_string(Self) -> String
pub fn BallFloatDecorated::output(Self, &Logger) -> Unit
pub impl Show for Decoration
pub fn Decoration::to_string(Self) -> String
pub fn Decoration::output(Self, &Logger) -> Unit

A bounded BallFloat prints as center +/- radius with both numbers in the exact BinFloat notation (3p-1 is 3⋅2−13 \cdot 2^{-1}), so the text denotes exactly the stored set; an unbounded one prints as [lo, hi], Empty as [empty]. A decorated interval appends _ and the decoration; NaI prints as [nai].

///|
test "show" {
  inspect(iv(1, 2).to_string(), content="3p-1 +/- 1p-1")
  inspect(@ball_float.BallFloat::whole().to_string(), content="[-inf, inf]")
  inspect(@ball_float.BallFloatDecorated::new(iv(1, 2)).to_string(), content="3p-1 +/- 1p-1_com")
}

Eq and Debug

pub fn BallFloat::equal(Self, Self) -> Bool
pub fn BallFloat::not_equal(Self, Self) -> Bool
pub fn BallFloat::to_repr(Self) -> @debug.Repr
pub fn BallFloatDecorated::equal(Self, Self) -> Bool
pub fn BallFloatDecorated::not_equal(Self, Self) -> Bool
pub fn BallFlags::equal(Self, Self) -> Bool
pub fn BallFlags::not_equal(Self, Self) -> Bool
pub fn Decoration::equal(Self, Self) -> Bool
pub fn Decoration::not_equal(Self, Self) -> Bool
pub fn Decoration::to_repr(Self) -> @debug.Repr
pub fn OverlapState::equal(Self, Self) -> Bool
pub fn OverlapState::not_equal(Self, Self) -> Bool
pub fn OverlapState::to_repr(Self) -> @debug.Repr

The Eq implementations are derived and compare representations. For BallFloat and BallFloatDecorated this distinguishes equal sets stored with different precision tags or endpoint precisions; use set_equal for sets. to_repr gives the structural Debug form.

@def.Floating

BallFloat implements the Floating trait of def with classify, sign, precision, with_precision and normalized as described above, so the generic predicates @def.is_finite (bounded), @def.is_infinite (unbounded), @def.is_nan (Empty) and @def.is_zero (sign Zero, that is, contains 0) apply to intervals.

pub impl @def.Floating for BallFloat

Enclosure relations of arithmetic

BallFloat implements the enclosure relation traits of Luna-Flow/arithmetic.

pub impl @arithmetic.Contains for BallFloat
pub impl @arithmetic.Overlaps for BallFloat
pub impl @arithmetic.DefinitelyLt for BallFloat
pub impl @arithmetic.DefinitelyLe for BallFloat
pub impl @arithmetic.MaybeEq for BallFloat

Contains::contains(x, y) is y.subset(x) (set inclusion, not the point-taking method); the others call the methods of the same name.

Checked capabilities of arithmetic

BallFloat implements DivChecked, PowNatChecked and PowIntChecked; their methods are promoted.

pub impl @arithmetic.DivChecked for BallFloat
pub impl @arithmetic.PowNatChecked for BallFloat
pub impl @arithmetic.PowIntChecked for BallFloat
pub fn BallFloat::div_checked(Self, Self, @arithmetic.ArithmeticContext) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::pow_nat_checked(Self, UInt, @arithmetic.ArithmeticContext) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::pow_int_checked(Self, Int, @arithmetic.ArithmeticContext) -> Result[Self, @arithmetic.ArithmeticError]

Only ctx.precision is used: the operands are re-rounded to it with with_precision, the operation is applied, and the result is re-rounded. They always return Ok. div_checked follows the division rules above (a divisor containing 0 gives an unbounded result, not an error). pow_int_checked uses pown. pow_nat_checked uses binary powering by repeated interval multiplication, which treats the factors as independent: for an argument containing 0 its result is wider than pown.

///|
test "checked capabilities" {
  let ctx = @lf_arith.ArithmeticContext::new(53)
  let x = iv(-1, 2)
  inspect(fmt(x.pow_int_checked(2, ctx).unwrap()), content="[0.00000e+0, 4.00000e+0]")
  inspect(fmt(x.pow_nat_checked(2U, ctx).unwrap()), content="[-2.00000e+0, 4.00000e+0]")
  inspect(x.div_checked(iv(-1, 1), ctx).unwrap().is_entire(), content="true")
  inspect(@lf_arith.Contains::contains(iv(0, 9), iv(1, 2)), content="true")
}

Complete public interface

This snapshot is the generated pkg.generated.mbti of the package. It is the authority when prose and interface disagree.

// Generated using `moon info`, DON'T EDIT IT
package "Luna-Flow/floating/ball_float"

import {
  "Luna-Flow/arithmetic",
  "Luna-Flow/floating/bin_float",
  "Luna-Flow/floating/def",
  "moonbitlang/core/debug",
}

// Values

// Errors

// Types and methods
pub struct BallContext {
  // private fields
}
pub fn BallContext::binary32() -> Self
pub fn BallContext::binary64() -> Self
pub fn BallContext::e_max(Self) -> Int
pub fn BallContext::e_min(Self) -> Int
pub fn BallContext::new(precision? : Int, e_min? : Int, e_max? : Int) -> Self
pub fn BallContext::precision(Self) -> Int
pub fn BallContext::try_new(precision? : Int, e_min? : Int, e_max? : Int) -> Result[Self, @arithmetic.ArithmeticError]

pub struct BallFlags {
  inexact : Bool
  overflow : Bool
  underflow : Bool
} derive(Eq)
pub fn BallFlags::combine(Self, Self) -> Self
pub fn BallFlags::equal(Self, Self) -> Bool
pub fn BallFlags::inexact(Self) -> Bool
pub fn BallFlags::new() -> Self
pub fn BallFlags::not_equal(Self, Self) -> Bool
pub fn BallFlags::overflow(Self) -> Bool
pub fn BallFlags::underflow(Self) -> Bool

pub struct BallFloat {
  // private fields
} derive(Eq, @debug.Debug)
pub fn BallFloat::abs(Self) -> Self
pub fn BallFloat::acos_interval(Self) -> Self
pub fn BallFloat::acosh_interval(Self) -> Self
pub fn BallFloat::add(Self, Self) -> Self
pub fn BallFloat::add_ctx(Self, Self, BallContext) -> (Self, BallFlags)
pub fn BallFloat::apply_ctx(Self, BallContext) -> (Self, BallFlags)
pub fn BallFloat::asin_interval(Self) -> Self
pub fn BallFloat::asinh_interval(Self) -> Self
pub fn BallFloat::atan2_interval(Self, Self) -> Self
pub fn BallFloat::atan_interval(Self) -> Self
pub fn BallFloat::atanh_interval(Self) -> Self
pub fn BallFloat::cancel_minus(Self, Self) -> Self
pub fn BallFloat::cancel_plus(Self, Self) -> Self
pub fn BallFloat::center(Self) -> @bin_float.BinFloat
pub fn BallFloat::classify(Self) -> @arithmetic.FpClass
pub fn BallFloat::contains(Self, @bin_float.BinFloat) -> Bool
pub fn BallFloat::contains_zero(Self) -> Bool
pub fn BallFloat::convex_hull(Self, Self) -> Self
pub fn BallFloat::cos_interval(Self) -> Self
pub fn BallFloat::cosh_interval(Self) -> Self
pub fn BallFloat::cospi_interval(Self) -> Self
pub fn BallFloat::definitely_gt(Self, Self) -> Bool
pub fn BallFloat::definitely_le(Self, Self) -> Bool
pub fn BallFloat::definitely_lt(Self, Self) -> Bool
pub fn BallFloat::disjoint(Self, Self) -> Bool
pub fn BallFloat::div(Self, Self) -> Self
pub fn BallFloat::div_checked(Self, Self, @arithmetic.ArithmeticContext) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::div_ctx(Self, Self, BallContext) -> (Self, BallFlags)
pub fn BallFloat::empty(precision? : Int) -> Self
pub fn BallFloat::equal(Self, Self) -> Bool
pub fn BallFloat::exact(@bin_float.BinFloat, precision? : Int) -> Self
pub fn BallFloat::exp10_interval(Self) -> Self
pub fn BallFloat::exp2_interval(Self) -> Self
pub fn BallFloat::exp_ctx(Self, BallContext) -> (Self, BallFlags)
pub fn BallFloat::exp_interval(Self) -> Self
pub fn BallFloat::expm1_interval(Self) -> Self
pub fn BallFloat::fma(Self, Self, Self) -> Self
pub fn BallFloat::from_bounds(@bin_float.BinFloat, @bin_float.BinFloat, precision? : Int) -> Self
pub fn BallFloat::from_coefficient(@bin_float.BinCoeff, precision? : Int, negative? : Bool) -> Self
pub fn BallFloat::from_double(Double, precision? : Int) -> Self
pub fn BallFloat::from_float(Float, precision? : Int) -> Self
pub fn BallFloat::from_int(Int, precision? : Int) -> Self
pub fn BallFloat::hypot(Self, Self) -> Self
pub fn BallFloat::interior(Self, Self) -> Bool
pub fn BallFloat::intersection(Self, Self) -> Self
pub fn BallFloat::is_bounded(Self) -> Bool
pub fn BallFloat::is_common_interval(Self) -> Bool
pub fn BallFloat::is_empty(Self) -> Bool
pub fn BallFloat::is_entire(Self) -> Bool
pub fn BallFloat::is_singleton(Self) -> Bool
pub fn BallFloat::less(Self, Self) -> Bool
pub fn BallFloat::ln_ctx(Self, BallContext) -> (Self, BallFlags)
pub fn BallFloat::ln_interval(Self) -> Self
pub fn BallFloat::log10_interval(Self) -> Self
pub fn BallFloat::log1p_interval(Self) -> Self
pub fn BallFloat::log2_interval(Self) -> Self
pub fn BallFloat::lower_bound(Self) -> @bin_float.BinFloat
pub fn BallFloat::magnitude(Self) -> @bin_float.BinFloat
pub fn BallFloat::maximum(Self, Self) -> Self
pub fn BallFloat::maybe_eq(Self, Self) -> Bool
pub fn BallFloat::midpoint(Self) -> @bin_float.BinFloat
pub fn BallFloat::midpoint_ctx(Self, BallContext) -> (@bin_float.BinFloat, BallFlags)
pub fn BallFloat::mignitude(Self) -> @bin_float.BinFloat
pub fn BallFloat::minimum(Self, Self) -> Self
pub fn BallFloat::mul(Self, Self) -> Self
pub fn BallFloat::mul_ctx(Self, Self, BallContext) -> (Self, BallFlags)
pub fn BallFloat::neg(Self) -> Self
pub fn BallFloat::new(@bin_float.BinFloat, @bin_float.BinFloat, precision? : Int) -> Self
pub fn BallFloat::normalized(Self) -> Self
pub fn BallFloat::not_equal(Self, Self) -> Bool
pub fn BallFloat::output(Self, &Logger) -> Unit
pub fn BallFloat::overlap_state(Self, Self) -> OverlapState
pub fn BallFloat::overlaps(Self, Self) -> Bool
pub fn BallFloat::pow_int_checked(Self, Int, @arithmetic.ArithmeticContext) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::pow_interval(Self, Self) -> Self
pub fn BallFloat::pow_nat_checked(Self, UInt, @arithmetic.ArithmeticContext) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::pown(Self, Int) -> Self
pub fn BallFloat::precedes(Self, Self) -> Bool
pub fn BallFloat::precision(Self) -> Int
pub fn BallFloat::radius(Self) -> @bin_float.BinFloat
pub fn BallFloat::radius_extended(Self) -> @bin_float.BinFloat
pub fn BallFloat::reciprocal(Self) -> Self
pub fn BallFloat::rootn(Self, Int) -> Self
pub fn BallFloat::separated_from(Self, Self) -> Bool
pub fn BallFloat::set_equal(Self, Self) -> Bool
pub fn BallFloat::sign(Self) -> @def.Sign
pub fn BallFloat::sin_interval(Self) -> Self
pub fn BallFloat::sinh_interval(Self) -> Self
pub fn BallFloat::sinpi_interval(Self) -> Self
pub fn BallFloat::sqrt_interval(Self) -> Self
pub fn BallFloat::square(Self) -> Self
pub fn BallFloat::strictly_less(Self, Self) -> Bool
pub fn BallFloat::strictly_precedes(Self, Self) -> Bool
pub fn BallFloat::sub(Self, Self) -> Self
pub fn BallFloat::sub_ctx(Self, Self, BallContext) -> (Self, BallFlags)
pub fn BallFloat::subset(Self, Self) -> Bool
pub fn BallFloat::tan_interval(Self) -> Self
pub fn BallFloat::tanh_interval(Self) -> Self
pub fn BallFloat::tanpi_interval(Self) -> Self
pub fn BallFloat::to_repr(Self) -> @debug.Repr
pub fn BallFloat::to_string(Self) -> String
pub fn BallFloat::try_acos_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_acosh_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_asin_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_asinh_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_atan2_interval(Self, Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_atan_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_atanh_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_cos_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_cosh_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_cospi_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_exact(@bin_float.BinFloat, precision? : Int) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_exp10_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_exp2_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_exp_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_expm1_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_from_bounds(@bin_float.BinFloat, @bin_float.BinFloat, precision? : Int) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_from_double(Double, precision? : Int) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_from_float(Float, precision? : Int) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_hypot(Self, Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_ln_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_log10_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_log1p_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_log2_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_pow_interval(Self, Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_rootn(Self, Int) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_sin_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_sinh_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_sinpi_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_tan_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_tanh_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::try_tanpi_interval(Self) -> Result[Self, @arithmetic.ArithmeticError]
pub fn BallFloat::upper_bound(Self) -> @bin_float.BinFloat
pub fn BallFloat::whole(precision? : Int) -> Self
pub fn BallFloat::width(Self) -> @bin_float.BinFloat
pub fn BallFloat::with_precision(Self, Int, @arithmetic.RoundingMode) -> Self
pub impl @arithmetic.Contains for BallFloat
pub impl @arithmetic.DefinitelyLe for BallFloat
pub impl @arithmetic.DefinitelyLt for BallFloat
pub impl @arithmetic.DivChecked for BallFloat
pub impl @arithmetic.MaybeEq for BallFloat
pub impl @arithmetic.Overlaps for BallFloat
pub impl @arithmetic.PowIntChecked for BallFloat
pub impl @arithmetic.PowNatChecked for BallFloat
pub impl @def.Floating for BallFloat
pub impl Add for BallFloat
pub impl Div for BallFloat
pub impl Mul for BallFloat
pub impl Neg for BallFloat
pub impl Show for BallFloat
pub impl Sub for BallFloat

pub struct BallFloatDecorated {
  // private fields
} derive(Eq)
pub fn BallFloatDecorated::abs(Self) -> Self
pub fn BallFloatDecorated::acos_interval(Self) -> Self
pub fn BallFloatDecorated::acosh_interval(Self) -> Self
pub fn BallFloatDecorated::add(Self, Self) -> Self
pub fn BallFloatDecorated::apply_ctx(Self, BallContext) -> (Self, BallFlags)
pub fn BallFloatDecorated::asin_interval(Self) -> Self
pub fn BallFloatDecorated::asinh_interval(Self) -> Self
pub fn BallFloatDecorated::atan2_interval(Self, Self) -> Self
pub fn BallFloatDecorated::atan_interval(Self) -> Self
pub fn BallFloatDecorated::atanh_interval(Self) -> Self
pub fn BallFloatDecorated::cancel_minus(Self, Self) -> Self
pub fn BallFloatDecorated::cancel_plus(Self, Self) -> Self
pub fn BallFloatDecorated::contains(Self, @bin_float.BinFloat) -> Bool
pub fn BallFloatDecorated::convex_hull(Self, Self) -> Self
pub fn BallFloatDecorated::cos_interval(Self) -> Self
pub fn BallFloatDecorated::cosh_interval(Self) -> Self
pub fn BallFloatDecorated::cospi_interval(Self) -> Self
pub fn BallFloatDecorated::decoration(Self) -> Decoration
pub fn BallFloatDecorated::disjoint(Self, Self) -> Bool
pub fn BallFloatDecorated::div(Self, Self) -> Self
pub fn BallFloatDecorated::equal(Self, Self) -> Bool
pub fn BallFloatDecorated::exp10_interval(Self) -> Self
pub fn BallFloatDecorated::exp2_interval(Self) -> Self
pub fn BallFloatDecorated::exp_interval(Self) -> Self
pub fn BallFloatDecorated::expm1_interval(Self) -> Self
pub fn BallFloatDecorated::fma(Self, Self, Self) -> Self
pub fn BallFloatDecorated::hypot(Self, Self) -> Self
pub fn BallFloatDecorated::interior(Self, Self) -> Bool
pub fn BallFloatDecorated::intersection(Self, Self) -> Self
pub fn BallFloatDecorated::interval(Self) -> BallFloat
pub fn BallFloatDecorated::is_common_interval(Self) -> Bool
pub fn BallFloatDecorated::is_empty(Self) -> Bool
pub fn BallFloatDecorated::is_entire(Self) -> Bool
pub fn BallFloatDecorated::is_nai(Self) -> Bool
pub fn BallFloatDecorated::is_singleton(Self) -> Bool
pub fn BallFloatDecorated::less(Self, Self) -> Bool
pub fn BallFloatDecorated::ln_interval(Self) -> Self
pub fn BallFloatDecorated::log10_interval(Self) -> Self
pub fn BallFloatDecorated::log1p_interval(Self) -> Self
pub fn BallFloatDecorated::log2_interval(Self) -> Self
pub fn BallFloatDecorated::maximum(Self, Self) -> Self
pub fn BallFloatDecorated::minimum(Self, Self) -> Self
pub fn BallFloatDecorated::mul(Self, Self) -> Self
pub fn BallFloatDecorated::nai(precision? : Int) -> Self
pub fn BallFloatDecorated::neg(Self) -> Self
pub fn BallFloatDecorated::new(BallFloat, decoration? : Decoration) -> Self
pub fn BallFloatDecorated::not_equal(Self, Self) -> Bool
pub fn BallFloatDecorated::output(Self, &Logger) -> Unit
pub fn BallFloatDecorated::overlap_state(Self, Self) -> OverlapState
pub fn BallFloatDecorated::pos(Self) -> Self
pub fn BallFloatDecorated::pow_interval(Self, Self) -> Self
pub fn BallFloatDecorated::pown(Self, Int) -> Self
pub fn BallFloatDecorated::precedes(Self, Self) -> Bool
pub fn BallFloatDecorated::reciprocal(Self) -> Self
pub fn BallFloatDecorated::rootn(Self, Int) -> Self
pub fn BallFloatDecorated::set_equal(Self, Self) -> Bool
pub fn BallFloatDecorated::sin_interval(Self) -> Self
pub fn BallFloatDecorated::sinh_interval(Self) -> Self
pub fn BallFloatDecorated::sinpi_interval(Self) -> Self
pub fn BallFloatDecorated::sqrt_interval(Self) -> Self
pub fn BallFloatDecorated::square(Self) -> Self
pub fn BallFloatDecorated::strictly_less(Self, Self) -> Bool
pub fn BallFloatDecorated::strictly_precedes(Self, Self) -> Bool
pub fn BallFloatDecorated::sub(Self, Self) -> Self
pub fn BallFloatDecorated::subset(Self, Self) -> Bool
pub fn BallFloatDecorated::tan_interval(Self) -> Self
pub fn BallFloatDecorated::tanh_interval(Self) -> Self
pub fn BallFloatDecorated::tanpi_interval(Self) -> Self
pub fn BallFloatDecorated::to_string(Self) -> String
pub impl Add for BallFloatDecorated
pub impl Div for BallFloatDecorated
pub impl Mul for BallFloatDecorated
pub impl Show for BallFloatDecorated
pub impl Sub for BallFloatDecorated

pub(all) enum Decoration {
  Ill
  Trv
  Def
  Dac
  Com
} derive(Eq, @debug.Debug)
pub fn Decoration::equal(Self, Self) -> Bool
pub fn Decoration::not_equal(Self, Self) -> Bool
pub fn Decoration::output(Self, &Logger) -> Unit
pub fn Decoration::to_repr(Self) -> @debug.Repr
pub fn Decoration::to_string(Self) -> String
pub impl Show for Decoration

pub(all) enum OverlapState {
  Undefined
  BothEmpty
  FirstEmpty
  SecondEmpty
  Before
  Meets
  OverlapsState
  Starts
  ContainedBy
  Finishes
  EqualIntervals
  After
  MetBy
  OverlappedBy
  StartedBy
  ContainsInterval
  FinishedBy
} derive(Eq, @debug.Debug)
pub fn OverlapState::equal(Self, Self) -> Bool
pub fn OverlapState::not_equal(Self, Self) -> Bool
pub fn OverlapState::to_repr(Self) -> @debug.Repr

// Type aliases

// Traits