scipy 1.8.0 Pypi GitHub Homepage
Other Docs
NotesParametersBackRef
simpson(y, x=None, dx=1.0, axis=-1, even='avg')

If there are an even number of samples, N, then there are an odd number of intervals (N-1), but Simpson's rule requires an even number of intervals. The parameter 'even' controls how this is handled.

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.

Parameters

y : array_like

Array to be integrated.

x : array_like, optional

If given, the points at which y is sampled.

dx : float, optional

Spacing of integration points along axis of x. Only used when x is None. Default is 1.

axis : int, optional

Axis along which to integrate. Default is the last axis.

even : str {'avg', 'first', 'last'}, optional

'avg'

'avg'

'first'

'first'

'last'

'last'

Integrate y(x) using samples along the given axis and the composite Simpson's rule. If x is None, spacing of dx is assumed.

See Also

cumulative_trapezoid

cumulative integration for sampled data

dblquad

double integrals

fixed_quad

fixed-order Gaussian quadrature

ode

ODE integrators

odeint

ODE integrators

quad

adaptive quadrature using QUADPACK

quadrature

adaptive Gaussian quadrature

romb

integrators for sampled data

romberg

adaptive Romberg quadrature

tplquad

triple integrals

Examples

>>> from scipy import integrate
... x = np.arange(0, 10)
... y = np.arange(0, 10)
>>> integrate.simpson(y, x)
40.5
>>> y = np.power(x, 3)
... integrate.simpson(y, x) 1642.5
>>> integrate.quad(lambda x: x**3, 0, 9)[0]
1640.25
>>> integrate.simpson(y, x, even='first')
1644.5
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

scipy.integrate._quadrature.simpson scipy.integrate._quadpack_py.dblquad scipy.integrate._quadrature.simps scipy.integrate._quadrature.quadrature scipy.integrate._quadrature.romb scipy.integrate._quadrature.fixed_quad scipy.integrate._quadpack_py.quad scipy.integrate._quadrature.romberg scipy.integrate._quadpack_py.tplquad

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /scipy/integrate/_quadrature.py#434
type: <class 'function'>
Commit: