scipy.integrate.trapz

scipy.integrate.trapz(y, x=None, dx=1.0, axis=-1)

Integrate along the given axis using the composite trapezoidal rule.

Integrate y (x) along given axis.

Parameters:

y : array_like

Input array to integrate.

x : array_like, optional

If x is None, then spacing between all y elements is dx.

dx : scalar, optional

If x is None, spacing given by dx is assumed. Default is 1.

axis : int, optional

Specify the axis.

Examples

>>> np.trapz([1,2,3])
>>> 4.0
>>> np.trapz([1,2,3], [4,6,8])
>>> 8.0

Previous topic

scipy.integrate.romberg

Next topic

scipy.integrate.cumtrapz

This Page

Quick search