ERAS
The content on this page was written by AI under human supervision.
ERAS (Exact Remainder-Aware Series) computes a rigorous interval for the range of a function over a small interval of one shared parameter, in the situation where ordinary interval arithmetic returns an answer far too wide to use. You write the function with the package's dual-number or power-series types, give it a parameter interval, and get back an interval that provably contains every value the function takes there. The package also includes a verification program that any modification or extension of these interval forms should pass before its results are trusted.
What it does
Interval ("ball") arithmetic carries a midpoint and a radius through a calculation, so the final radius is a proven error bound. Its weakness is the dependency problem: when one parameter $p$ appears in many places, each occurrence is treated as varying on its own, and the bound can grow far beyond the true range. The typical case is a likelihood that is a product of hundreds of factors sharing one rate parameter, and the reference function included with the package is such a product with 318 factors. Evaluated directly over a parameter interval of radius $10^{-4}$, it returns a relative width near $10^{23}$, although its true variation there is a small fraction of its value.
ERAS uses centered forms instead. The mean-value form evaluates the function exactly at the midpoint $m$ and bounds the rest through the derivative over the whole interval $P$: $F(P) \subseteq F(m) + F'(P)\,(P-m)$. The derivative bound still suffers from dependency, but it is multiplied by the small radius. The order-$K$ Taylor form takes the first $K-1$ Taylor coefficients at the midpoint and bounds only the $K$-th, the Lagrange remainder, over the interval. Derivatives are exact: every quantity carries its $d/dp$ (forward-mode dual numbers, class D) or its truncated Taylor series with interval coefficients (class S), on top of the Arb library through python-flint. A dual evaluation costs about twice a value-only one.
The result is guaranteed to contain $F(p)$ for every $p$ in the closed interval, for functions built from the operations the two classes provide (arithmetic, integer powers, exp, and for D also log). Its width is not guaranteed to be small: on the reference function the working setting is order $K=16$ with a parameter half-width of about $3\times10^{-3}$ or less. Two pitfalls are tested for. Constants must be built at the working precision (one left at 53-bit double precision widens the reference interval by a factor near $10^{11}$), and the midpoint must be exactly representable or its rounding error added to the radius.
The second script, verify_eras_adversarial.py, tests any adaptation of these forms, such as a new function or several parameters. Your adaptation is an object with a label, an enclose(p0, radii, K) method returning an interval rigorous for the closed box $p_0 \pm$ radii ($K=0$ naive, $1$ mean-value, $\ge 2$ Taylor), and a point_eval(p, prec=None) method returning a high-precision value. The methods deriv(p, dim) and degraded() are optional. The suite collects all intervals first, then checks that precise values at the box's exact corners and faces, in thin bands just inside each face, and at two batches of random points lie inside them. It wraps the adaptation in deliberately corrupted variants (narrowed, shifted, one radius ignored) that must all be detected, compares deriv with finite differences, and requires the low-precision degraded() version to be caught. An infinite interval, one wider than 1000 times the spread of the sampled values, or one whose point_eval is too coarse to judge, counts as no information, never as a pass. The exit code is 0 PASS, 1 FAIL, or 2 INDET (nothing failed, but too little informative coverage to pass).
Limits. The core module handles one scalar parameter; multivariate forms are yours to write, and the suite tests them (MultivariateSelfTest in the verifier is a worked three-parameter example). One passing seed is not enough on its own, since a corruption confined to a thin unsampled region is caught only with some probability; rerun with several --seed values. The suite cannot protect against edits to the verifier itself. For general-purpose ball arithmetic use Baller, a separate package that leaves Taylor-form enclosures to ERAS; POSQ is a package whose engine was run through this suite.
Examples
Run the package self-test. We want to confirm the installation and see the reference forms reproduce their stored values.
python3 eras.py selftest
The script evaluates both forms of the reference function at two parameter points and compares them with stored 50-digit values to within $10^{-30}$. It then checks the forward-mode derivative against a central finite difference to within $10^{-20}$. Finally it confirms that changing one input count by one, a deliberately wrong input, shifts both forms by a clearly nonzero amount, with two independent implementations of the same form shifting identically. Each check line begins OK or FAIL, the run ends SELFTEST PASS or SELFTEST FAIL, and the exit code is 0 or 1; it takes a few seconds. python3 eras.py blowup and python3 eras.py taylork print the tables of naive, mean-value and order-$K$ widths by radius, each with a containment check of point values, and save them as JSON under $TMPDIR/eras_results (override with ERAS_RESULTS).
Run the verification suite on the included reference forms. We want the full set of checks, as a user would run them before relying on the package.
python3 verify_eras_adversarial.py all
reference in place of all runs only the univariate reference forms (radii $10^{-4}$ to $10^{-1}$, orders $K$ from 0 to 16); selftest runs only the three-parameter example and a large-value regression case. all takes about a minute. The report prints every check, then NOTES and FATALS, then one verdict line beginning VERIFY PASS, VERIFY FAIL or VERIFY INDET with counts of informative, no-information and declared-expected cells (a cell is one box at one order $K$). Most cells of the reference run sit in the regime where the interval blows up (naive evaluation, low order, or large radius); they are declared in advance as expected no-information, so the PASS rests on the working-configuration cells.
Test your own adaptation from Python. The POSQ package does this in tools/posq/verify_posq_adaptation.py; the relevant lines are
import verify_eras_adversarial as vb # noqa: E402
SHELLS = [(("709/2048", "10"), ("1e-3", "5e-2")),
(("709/2048", "10"), ("5e-3", "2.5e-1")),
(("709/2048", "10"), ("2e-2", "1e0"))]
PLANT_AT = (1, 0)
cfg = vb.Cfg(seed=a.seed, points=a.points, fd_tol=a.fd_tol)
res = vb.run_battery(adapt, SHELLS, [0], cfg, plant_at=PLANT_AT)
Here adapt is the object implementing the protocol, with two parameters, so each shell pairs a tuple of centers with a tuple of radii, written as strings. [0] is the list of orders $K$ to test, a holds the script's parsed options, and plant_at names the (shell index, $K$) cell where the corrupted variants and the precision check are applied. The call prints the same report as the command-line run and returns a result object; res.ok (equal to bool(res)) is the pass signal, and a caller that exits 0 without checking it has a bug.
Routines
eras.py, command line (python3 eras.py <subcommand>; default selftest)
selftest— reference-value, derivative and wrong-input checks; exit 0 on pass.blowup— naive against mean-value widths by radius, with containment checks.taylork— order-$K$ Taylor-form widths by radius and $K$, with containment checks.timeeval— timing of dual (value plus derivative) against value-only evaluation.
eras.py, importable
D(v, d=None)— dual number holding a value and its $d/dp$ as Arb balls; supports+,-,*,/, integer**,exp(),log().dconst(x, like)— a constant as a dual number with zero derivative.S(c)— truncated power series in $p - p_0$ with the listcof ball coefficients; supports+,-,*,/,recip(),exp(),powi(n).s_var(x0, K)— the series of $p$ itself about centerx0, to orderK.mv_form(fn, pball)— mean-value enclosure offn(a function fromDtoD) overpball; returns(mv_enclosure, naive_ball, F0_dual, Fball_dual).taylor_encl(fn_series, pball, K)— order-KTaylor enclosure offn_series(a function fromStoS); returns(enclosure, point_series, ball_series).taylor_ladder(fn_series, pball, Ks)— enclosures for several orders from one pair of series evaluations; returns{K: enclosure}.relwidth(b)— radius divided by absolute midpoint of a ball.L_prod_D,L_prod_S,G_unc_D,G_unc_series,upoly_pair,mutate_counts— the reference function in product and collapsed form, as dual or series, and its input counts with one entry changed (e.g."0001:+1").
verify_eras_adversarial.py, command line
python3 verify_eras_adversarial.py [all|reference|selftest]— options--seed,--points,--fd-tol,--degrade-factor,--vacuous-factor,--point-margin,--fd-h-bits; exit 0 PASS, 1 FAIL, 2 INDET.
verify_eras_adversarial.py, importable
Cfg(seed=..., points=100, fd_tol="1.1e-12", degrade_factor=1e3, vacuous_factor=1e3, point_margin=10, ...)— settings for one run.run_battery(adapt, shells, Ks, cfg, plant_at=None, fd_box=None, Ks_by_shell=None, expect_indet=frozenset())— run the whole suite on one adaptation;shellsis a list of(p0, radii); returns aBatteryResult.BatteryResult— fieldsok,fatals,notes,cells_pass,cells_indet,cells_declared;bool(result) == result.ok.NarrowPlant,ShiftPlant,DropDimPlant— the deliberately corrupted wrappers the suite must detect.ErasArm(kind, prec, sprec=None, counts=None)— the reference univariate forms ('unc'or'corr') wrapped in the protocol.MultivariateSelfTest(prec=128)— worked three-parameter adaptation; a template for your own.reference_battery(cfg),selftest_battery(cfg)— the two built-in runs behind the command line.
Requirements and source
Python 3 with python-flint (the Arb ball-arithmetic library). The data file QUARTET_COLLAPSE.json holds the 318 pattern counts that define the reference function (shared with POSQ), derived from the DravLex v1.0 Dravidian lexical database (Kolipakam et al. 2018). It must sit beside eras.py or in the directory named by ERAS_BASE; a missing file raises an error at import. Self-tests, run from inside the package directory: python3 eras.py selftest and python3 verify_eras_adversarial.py all. The code is in tools/eras/ in BootLoops' bootloops-dev repository (GitHub organization BootLoops-ai), released under the MIT license.