quadax.trapezoid
- quadax.trapezoid(y: Array | ndarray | bool | number | bool | int | float | complex, *, x: None | Array | ndarray | bool | number | bool | int | float | complex = None, dx: float = 1.0, axis: int = -1) ArraySource
Integrate along the given axis using the composite trapezoidal rule.
If
xis provided, the integration happens in sequence along its elements - they are not sorted.Integrate
y(x) along each 1d slice on the given axis, compute \(\int y(x) dx\). Whenxis specified, this integrates along the parametric curve, computing \(\int_t y(t) dt = \int_t y(t) \left.\frac{dx}{dt}\right|_{x=x(t)} dt\).- Parameters:
y (
array_like) – Input array to integrate.x (
array_like, optional) – The sample points corresponding to theyvalues. Ifxis None, the sample points are assumed to be evenly spaceddxapart. The default is None.dx (
scalar, optional) – The spacing between sample points whenxis None. The default is 1.axis (
int, optional) – The axis along which to integrate.
- Returns:
trapezoid (
floatorndarray) – Definite integral ofy= n-dimensional array as approximated along a single axis by the trapezoidal rule. Ifyis a 1-dimensional array, then the result is a float. Ifnis greater than 1, then the result is ann-1 dimensional array.