The question this method answers¶
Adaptive quadrature estimates a one-dimensional integral while deciding where additional function evaluations are most useful. It is appropriate when a single fixed rule would waste work on easy regions or miss difficult local structure.
Before computation: what should be true?¶
Write the integral, domain, measure, and expected difficult structure before choosing a method. Known discontinuities or sharp transitions should be passed as breakpoints when the method supports them. Decide what absolute and relative errors would be scientifically meaningful in the units of the raw-array problem.
The current support boundary is:
| Method | Domain | Breakpoints | Error evidence |
|---|---|---|---|
GaussKronrod | finite Interval | yes | embedded Gauss-Kronrod difference |
AdaptiveClenshawCurtis | finite Interval | yes | nested-resolution difference |
AdaptiveTanhSinh | finite or improper | finite intervals only | adjacent-level, summation, and tail evidence |
Romberg | finite Interval | no | extrapolated refinement difference |
RombergTanhSinh | finite or improper | no | adjacent global-level difference |
Adaptive methods accept LebesgueMeasure and WeightedMeasure. Raw arrays are
the numerical kernel representation. quad.integrate also provides an alpha,
opt-in quantity boundary that validates units, converts to raw arrays, calls
the same engine, and restores integral units.
Define the mathematical objects¶
Let
and partition the transformed reference domain into active regions . A regional method produces a value and a nonnegative payload-shaped indicator . An error norm maps scalar, vector, complex, or higher-rank payload evidence to one scalar stopping quantity.
QuadResult returns the value, QuadError, effective tolerance, QuadStatus,
and QuadWork. These records distinguish a numerical estimate from evidence
about how it was obtained.
Derive the method¶
Regional accounting and tolerance¶
For active regions, Jaxstro accumulates the value and componentwise error evidence before applying the chosen norm:
The effective stopping threshold is
The absolute term protects integrals near zero; the relative term scales with the estimated integral. Neither term can repair a structurally blind estimator.
Embedded Gauss-Kronrod¶
A Kronrod rule reuses the Gauss nodes and adds nodes. Let , let estimate the integral of , and let estimate absolute deviation from the Kronrod mean. Jaxstro follows the QUADPACK stabilization shape before applying a roundoff-scale floor:
When or , the implementation uses the raw difference rather than dividing by zero. The floor is applied only where its floating-point construction is representable.
The public pairs contain 15, 21, 31, 41, 51, or 61 Kronrod nodes.
Nested Clenshaw-Curtis¶
Clenshaw-Curtis evaluates cosine-spaced nodes. An order rule contains the lower-resolution node set, so one high-resolution evaluation supplies both approximations:
Double-exponential refinement¶
Tanh-sinh maps a real parameter toward the endpoints double exponentially,
Jaxstro combines adjacent-level disagreement, floating-point summation evidence, and an outer-shell tail account:
This open rule avoids evaluating finite endpoints directly. Domain maps and their Jacobians extend the same logic to half-infinite and infinite domains.
Characteristic scales for improper domains¶
An improper map needs a physical scale , not merely a display unit. Jaxstro uses
The same physical must define the same map whether it is written in metres, centimetres, or another compatible unit. Raw domains retain the legacy default . Dimensional quantity domains require an explicit quantity scale so a presentation unit cannot silently become a convergence parameter.
Romberg families¶
Classical Romberg starts from nested trapezoid estimates and applies Richardson extrapolation:
RombergTanhSinh instead compares nested global tanh-sinh levels without using
the polynomial-error assumption behind Richardson extrapolation. Its reported
error retains the adjacent-level, summation, and terminal-tail terms:
Logical work¶
For a regional rule with nodes, initial regions, and bisections, the exact logical integrand count is
Classical Romberg at completed level uses unique logical points.
RombergTanhSinh reports the active-node count at its finest completed level.
These are integrand evaluations, not padded accelerator lanes, compile time, or
wall time.
An exact zero-width finite interval takes the shared fast path and returns an
all-zero QuadWork record.
What the algorithm actually does¶
Regional controllers evaluate every declared initial region, sum their value and error evidence, and repeatedly bisect the region with the largest scalar error priority. Arrays have fixed capacity so the loop remains JAX transformable. Global Romberg controllers increase one shared level instead of building a region partition.
Initial and completed estimates resolve invalid input before nonfinite values
and nonfinite values before convergence. An explicit representability failure
or repeated stagnation then produces ROUNDOFF_LIMITED. If another refinement
cannot begin, midpoint collapse takes precedence over exhausted evaluation
capacity, which takes precedence over exhausted region capacity. Thus a
floor-dominated error at an already exhausted budget returns
MAX_EVALUATIONS, not ROUNDOFF_LIMITED; an error floor is evidence, not by
itself a status trigger. Regional capacity distinguishes MAX_EVALUATIONS from
MAX_REGIONS. Current controllers emit INVALID_INPUT,
NONFINITE_INTEGRAND, CONVERGED, ROUNDOFF_LIMITED, MAX_EVALUATIONS, or
MAX_REGIONS as applicable.
DIVERGENCE_SUSPECTED and ERROR_ESTIMATE_UNAVAILABLE are reserved vocabulary,
not current controller outputs.
ErrorKind.EMBEDDED_RULE identifies Gauss-Kronrod evidence; the other current
families use ErrorKind.REFINEMENT_DIFFERENCE. Sparse-grid and replicate-based
kinds are reserved for later method families.
What JAX differentiates¶
gradient="replay" differentiates the fixed formula accepted by the primal
adaptive solve. It does not differentiate sorting, region selection,
refinement, stopping, capacity decisions, breakpoint motion, status, error
estimation, or work accounting. Only QuadResult.value receives the replay
derivative. Diagnostics have exact zero or JAX float0 tangents.
gradient="stop" remains available and applies jax.lax.stop_gradient to the
complete result tree. JIT and VMAP are supported within the static boundaries
above, but VMAP repeats the bounded controller independently for each batch
member; it is not shared adaptive work.
The derivation, moving-bound contract, units, complex conventions, and independent audit are in Differentiating an integral.
Using it in Jaxstro¶
import jax.numpy as jnp
from jaxstro import quad
domain = quad.Interval(0.0, 1.0)
methods = (
quad.GaussKronrod(pair=21),
quad.AdaptiveClenshawCurtis(initial_order=17),
quad.AdaptiveTanhSinh(initial_level=3),
quad.Romberg(initial_level=1),
quad.RombergTanhSinh(initial_level=1),
)
result = quad.integrate(
lambda x: x**2,
domain,
method=methods[0],
epsabs=1e-5,
epsrel=1e-5,
max_evaluations=2048,
max_regions=64,
gradient="replay",
)
assert result.status == quad.QuadStatus.CONVERGED
assert jnp.allclose(result.value, 1.0 / 3.0, rtol=1e-6, atol=1e-6)The same call shape selects each family. Use quad.Infinite(),
quad.RightInfinite(lower), or quad.LeftInfinite(upper) only with
AdaptiveTanhSinh or RombergTanhSinh. The complete callable contract is in
Jaxstro quadrature.
Quantity mode is activated by quantity-valued coordinates,
Infinite(unit=..., scale=...), or a quantity epsabs. A raw domain activated by
quantity epsabs is dimensionless. Quantity mode requires a
quantity-returning integrand and a quantity epsabs compatible with the
integral unit. Dimensional improper domains also require a compatible physical
scale, for example quad.Infinite(unit=q.cm, scale=100.0 * q.cm).
Lower-level quad.fixed and mapping helpers remain raw-only.
How to audit the result¶
Check the status before using the value. Then compare observed behavior across
tolerances or capacities, inspect result.error.kind, and verify that
result.work.evaluations matches the chosen family’s logical cost. Use known
breakpoints and independent references whenever the integrand has narrow or
nonsmooth structure.
Executable analytic and failure-envelope cases live in
tests/validation/test_quad_adaptive_reference.py; their generated record is
docs/validation/quad-adaptive-envelope.json.
The broader evidence boundary is indexed in Validation.
Where the claim stops¶
CONVERGED means the named estimator satisfied the named tolerance. It does
not prove that the true error is below that tolerance. In particular, embedded
or nested rules can both miss the same narrow feature and report false
estimator convergence. Independent structure-aware checks remain necessary.
Replay derivatives are validated first-order derivatives of accepted formulas; they do not establish differentiability of adaptive decisions. Quantity-aware adaptive integration is alpha and opt-in. Jaxstro does not claim direct Quantity-PyTree quotient-unit Jacobians, multidimensional integration, universal convergence, or performance superiority. Quadax is an independent comparison and benchmark implementation, not Jaxstro’s runtime owner or dependency.