quadax.TanhSinhRule
- class quadax.TanhSinhRule(order: int = 61, norm: Callable | float | int = inf, batch_size: int | None = None)Source
Integrate a function from a to b using a fixed order Tanh-Sinh trapezoidal rule.
Integration is performed using an order n rule with error estimated using an embedded n//2 order rule.
- Parameters:
order (
int) – Order of integration scheme. Must be odd.norm (
int,callable) – Norm to use for measuring error for vector valued integrands. No effect if the integrand is scalar valued. If an int, uses p-norm of the given order, otherwise should be callable.batch_size (
int, optional) – Maximum number of points at which to evaluate the integrand in parallel. Default is all of the rule’s nodes at once, which is fastest but makes peak memory scale with the order. Values above the number of nodes are clipped to it. A value that does not divide the number of nodes leaves a remainder, which is evaluated together in one smaller batch, so the integrand is traced twice but never evaluated at more points than the rule has nodes.
Notes
Below about order 15 the embedded rule is too coarse for the error estimate to be trusted on any integrand with structure, including peaked and endpoint-singular ones that the other rules handle at much lower order; halving the points of a doubly-exponential rule costs far more accuracy than halving a polynomial one.
The nodes stop short of the endpoints, leaving a sliver of the interval unsampled at each end, and the reported error includes a bound on the mass out there. Comparing the two rules cannot supply it, both of them stopping at the same place. The term is at the level of roundoff on a bounded integrand and can be the whole of the error on one singular at an endpoint.
Methods
integrate(fun, a, b, args)Integrate a function from a to b using a nested rule.
norm(x)Norm to use for measuring error for vector valued integrands.
Attributes
How many evaluations of the integrand one application of the rule costs.