archimedes.quadrature.quadintΒΆ
- archimedes.quadrature.quadint(
- func: Callable[[...], ndarray],
- a: float,
- b: float,
- n: int = 20,
- rule: str = 'legendre',
- axis: int = -1,
- args: Sequence[Any] | None = None,
Approximate the definite integral of
funcover[a, b].\[\int_a^b f(x) \, dx \approx \sum_{i=1}^n w_i f(x_i)\]using a fixed-order Gauss quadrature rule (by default Gauss-Legendre quadrature).
This is a convenience wrapper around the
rule(n, a, b).integrate(f)pattern (seeQuadratureRule.integrate()) for one-off integrals on a finite interval; for repeated evaluation of the same rule (e.g. inside a loop or a function decorated witharchimedes.compile()), build theQuadratureRuleonce withgauss_legendre(),gauss_radau(),gauss_lobatto(), orclenshaw_curtis()and call.integratedirectly instead.- Parameters:
func (callable) β Integrand. Called once as
func(x, *args)on the full array of quadrature nodes, so must be vectorized. Must return values with the nodes alongaxis.a (float) β Bounds of integration. Must both be finite (see Notes).
b (float) β Bounds of integration. Must both be finite (see Notes).
n (int, optional) β Number of quadrature nodes. Default 20.
rule ({"legendre", "radau_left", "radau_right", "lobatto", "clenshaw_curtis"}, optional) β Quadrature family to use, all defined on
[a, b]with uniform weight. Default"legendre"(no fixed endpoints, exact to degree2n - 1). Use"radau_left"/"radau_right"to fix the left/right endpoint as a node, or"lobatto"to fix both; seegauss_radau()andgauss_lobatto()for the accompanying loss of exactness.axis (int, optional) β Axis holding the nodes in the output of
func. Default -1.args (tuple, optional) β Extra arguments passed to
funcafterx.
- Returns:
value β Approximated integral. Shape (m,) for vector-valued integrands, or () for scalar integrands.
- Return type:
ndarray
- Raises:
ValueError β If
ruleis not one of the supported names, or ifa/bare not finite.
Notes
This function only supports finite
[a, b]. Unlikescipy.integrate.quad, it does not adapt the node count or use a variable transformation to reach infinite/semi-infinite intervals; it is a thin wrapper around a single fixed-order rule.See also
QuadratureRule.integrateUnderlying integration method.
gauss_legendre,gauss_radau,gauss_lobatto,clenshaw_curtisscipy.integrate.quadAdaptive quadrature, including infinite and semi-infinite intervals.