mixle.engines.error_tracing module¶
Sound error tracing via interval arithmetic.
An Interval carries [lo, hi] enclosing a true value. Every operation rounds the bounds
outward (one ULP via numpy.nextafter()), so the enclosure provably contains the exact result
despite float64 round-off – the interval certifies the numerical error rather than hoping it is small.
The width is a guaranteed error bound; a precision-allocation pass reads it to pick the lowest-cost format
that keeps the width under a target (pair with mixle.engines.formats.min_float_mantissa_bits()).
Interval arithmetic is sound but pessimistic because it ignores correlations between operands. Affine arithmetic can tighten the bound when that extra complexity is justified. This module provides the vectorized, dependency-free core.
- class Interval(lo, hi)[source]
Bases:
objectA guaranteed enclosure
[lo, hi]of a value (scalar or numpy array), outward-rounded.- Parameters:
lo (Any)
hi (Any)
- classmethod exact(x)[source]
A degenerate interval
[x, x]for an exactly-represented value.- Parameters:
x (Any)
- Return type:
Interval
- classmethod from_quantized(original, fmt)[source]
Enclose
originalusing the quantized format’s error bound.
- sum_error_bound(x)[source]
Return a certified bound on the float64 error of
sum(x).The standard a-priori bound
|fl(sum) - sum| <= gamma_{n-1} * sum|x_i|withgamma_k = k*u / (1 - k*u)andu = 2**-53. It is sound for any summation order. A bound that is large relative to|sum x|means the sum is ill-conditioned (cancellation) and warrants the double-doublemixle.engines.extended.dd_sum(); a tight one means float64 already suffices and no extra compute is justified.