Skip to main content

Module interval

Module interval 

Source
Expand description

Interval arithmetic for filtered predicates.

An Interval encloses a real number the program cannot represent: every operation returns bounds that certainly contain the true result, obtained by computing with the IEEE operations (which are correctly rounded, so the true value lies within one ulp of the computed one) and then widening each bound one step outward. The enclosure is conservative, never wrong.

The point of carrying bounds is Interval::certain_sign: a sign decision made through an interval is either certain, because zero lies outside the bounds, or honestly undecided, because it does not. That is the filter a predicate wants: answer fast when floating point can, and say so when it cannot, instead of reading rounding noise as a direction.

The vocabulary is the arithmetic predicates need: add, subtract, multiply, negate, square, absolute value, square root, and division away from zero. Transcendentals are deliberately absent; the standard library does not state error bounds for them, and an enclosure that might not enclose is worse than none.

Structsยง

Interval
A closed interval [lo, hi] certainly containing a true real value.