quadax.simpson
- quadax.simpson(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 y(x) from samples using the composite Simpson’s rule.
If x is None, spacing of dx is assumed.
- Parameters:
y (
array_like) – Array to be integrated.x (
array_like, optional) – If given, the points at whichyis sampled.dx (
float, optional) – Spacing of integration points along axis ofx. Only used whenxis None. Default is 1.axis (
int, optional) – Axis along which to integrate. Default is the last axis.
- Returns:
float– The estimated integral computed with the composite Simpson’s rule.
Notes
For an odd number of samples that are equally spaced the result is exact if the function is a polynomial of order 3 or less. If the samples are not equally spaced, then the result is exact only if the function is a polynomial of order 2 or less.