mixle.engines.spectrum module

The precision spectrum’s front door: route a computation to the CHEAPEST backend that is accurate.

Ties the spectrum together – native float64, double-double (mixle.engines.extended), and the MPFR tail (mixle.engines.highprec) – behind one call that reads the certified error bound (mixle.engines.error_tracing) and escalates only as far as the accuracy budget demands. This is ‘use logic to preserve numerical accuracy with minimal compute’ as an actual API: a well-conditioned sum stays in fast float64, a cancelling one steps up to vectorized double-double, and only a catastrophically ill-conditioned one pays for arbitrary precision.

accurate_sum(x, target_rel_error=1e-12)[source]

Sum x to target_rel_error relative accuracy using the cheapest sufficient backend.

Returns (value, backend) where backend is "float64", "dd" (double-double), or "mpfr<bits>". Escalates only when the certified error bound says the cheaper backend cannot meet the budget – so the common (well-conditioned) case never leaves vectorized float64.

Parameters:
Return type:

tuple[float, str]

sum_certificate(x)[source]

Report the certified float64 summation error and the condition number, without choosing a backend.

Parameters:

x (Any)

Return type:

dict[str, float]

cast(x, precision)[source]

Cast x onto the spectrum: a native dtype name, "dd"/"fp128", or an integer bit width.

Returns a numpy array (native), a DoubleDouble (dd/fp128), or an MPFR object array (>= ~fp256 / explicit bit width).

Parameters:
Return type:

Any