TorchLean API

NN.Examples.DeepDives.Floats.ArbIEEEExecCompare

Arb vs configured binary32 interval tutorial #

This tutorial prints side-by-side enclosures for a few unary functions over a one-dimensional input interval:

import numpy as np

lo, hi = np.float32(-0.5), np.float32(0.5)
endpoint_box = (np.tanh(lo), np.tanh(hi))   # common fast check, not a rigorous enclosure

TorchLean's lesson is more explicit: endpoint evaluation is useful for debugging, but rigorous transcendental enclosures need a trusted real enclosure source (here Arb) plus outward rounding back to the binary32 grid.

Implementation note: the reusable baseline interval helpers live in NN.Floats.Interval.Comparison; this file only chooses tutorial cases and prints their results.

Run:

lake exe torchlean floats_arb_ieee_compare

If Arb is not installed, the tutorial still prints the configured binary32 side and reports the Arb failure.

JSON expression for $x^2+0.1x-0.5$, in the safe Arb expression language.

Instances For

    Run one tutorial comparison.

    The output has four conceptual rows:

    • Arb: rigorous real interval from the external oracle when available;
    • ExecFloat.Binary 8 23: endpoint evaluation using FloatLib's configured binary32 arithmetic;
    • Float32: ordinary runtime endpoint evaluation;
    • configured binary32+Arb: Arb real enclosure rounded outward to binary32 endpoints.
    Instances For

      The classic round-to-nearest-even tie: 1 + 2^-24 in binary32.

      The exact sum needs 25 significand bits, so it sits exactly halfway between 1 and the next float. Round-to-nearest-even therefore returns 1, not the next value up. Comparing the naive interval arithmetic against the directed addDown/addUp pair here is the point: only the directed version still encloses the exact rational sum.

      Instances For

        Division by negative zero, which IEEE 754 defines as -∞ rather than an error.

        The sign of zero is observable precisely through operations like this one, which is why the float32 model keeps +0 and -0 distinct instead of collapsing them.

        Instances For

          Run a small fixed set of comparisons (unary funcs + a polynomial + some edge cases).

          Instances For

            Command-line help for the Arb-vs-IEEE32 interval tutorial.

            Instances For

              Entrypoint: run the Arb-vs-ExecFloat.Binary 8 23 interval tutorial.

              Instances For