Interval
Arithmetic over compute-engine's native Interval(a, b) -- extended in place by @enumeratio/analytic, since compute-engine declares it only as a real set with no arithmetic of its own. A result contains every value the operation takes on its inputs.
Interval(a, b)the real interval [a, b], carried through arithmetic and the elementary and special functions: each result encloses the true image.AccumBounds(a, b)Typed signatures
| Type | Package | Applies |
|---|---|---|
(number, number) -> set<real> | compute-engine | always |
Details
- Rigorous containment, as Wolfram's Interval promises: an exact endpoint is exactly right, and an inexact one is rounded outward -- a lower bound down, an upper bound up. Decimal arithmetic is exact in compute-engine, so Interval(1.4, 1.5) + 1 is exactly Interval(2.4, 2.5); a function value at an inexact point is rounded one double outward from its value at working precision.
- A function's image is its least and greatest value at the endpoints and at every critical point inside. Sin, Cos, Tan, Cot, Sec and Csc enumerate theirs period by period; Arcsin, Arccos, Arctan, Sinh, Cosh, Tanh, Exp, Ln, Log, Sqrt, Erf, Erfc and ErfInv, Gamma, GammaLn, LogGamma and Digamma on the positive reals, and Zeta right of its pole, have a known shape (monotonic, or a single minimum: Cosh's at 0, Γ's at 1.4616…), so their images are exact when the endpoints are.
- Across a pole the image comes in unbounded pieces, returned as a Union of intervals: Cot(Interval(-π/4, π/4)) is (-∞, -1] ∪ [1, ∞), and pieces that meet merge, so Tan(Interval(0, π)) is all of ℝ.
- Proven over balls: BarnesG and LogBarnesG, and PolyLog in z inside the unit disk, at exact arguments and ends. Their critical points aren't known, but their values and first two derivatives have certified kernels (see N). The interval is cut into pieces: where the derivative provably keeps one sign, a piece's image is its values at its ends, and elsewhere a second-order Taylor bound closes in on the turning point. The image is tight to about 1e-13 and rounded outward to 15 digits. Where the proof can't settle it (an inexact end, an interval reaching G's zeros or |z| = 1, a series too loose over a wide interval), the image is sampled as below.
- Not rigorous: DirichletEta, DirichletBeta, CatalanNumber, Zeta left of its pole, and the multi-argument StieltjesGamma, HarmonicNumber, DirichletL, PolyGamma, GammaRegularized, BetaRegularized and Binomial, along with the proven heads wherever their proof declines. Their images come from sampling the derivative's sign, which can miss a pair of extrema between two samples.
- The 'dependency problem' is not modeled: Interval(1,2) − Interval(1,2) is Interval(-1,1), not Interval(0,0), because the two copies are treated as independent quantities, exactly as Wolfram's own interval arithmetic does.
Examples
1 more kept as data, checked against the oraclesBasic #
Scope #
's minimum at lies inside, so it is the lower bound, rounded down; the upper bound, , stays exact
live ↗The dependency problem: interval arithmetic doesn't know both operands are the same quantity
live ↗About
| Examples | 21 |
|---|---|
| Checked against | Wolfram Language 16 agree5 differSymPy 15 agree6 differ |
| Crosswalk | SymPy |
Implementation
sympypackages/oracle/src/mappings.tsAccumBounds is SymPy's interval arithmetic for real endpoints, but it is mapped for every Interval, a set use included: a Union of AccumBounds raises, AccumBounds(a, a) collapses to the scalar a, and reversed bounds raise. It holds accumulation bounds, not a rigorous enclosure: an inexact endpoint is not rounded outward, and a function over it is not built from its critical points as ours is, so the rows on rigour agree on endpoints only. Abs over an Interval is emitted as abs() (emit.ts), since Abs() leaves an AccumBounds held.
See also: CenteredInterval, Around