This is documentation for an old release of SciPy (version 0.12.0). Read this page in the documentation of the latest stable release (version 1.15.1).
Cumulatively integrate y(x) using the composite trapezoidal rule.
Parameters : | y : array_like
x : array_like, optional
dx : int, optional
axis : int, optional
initial : scalar, optional
|
---|---|
Returns : | res : ndarray
|
See also
Examples
>>> from scipy import integrate
>>> x = np.linspace(-2, 2, num=20)
>>> y = x
>>> y_int = integrate.cumtrapz(y, x, initial=0)
>>> plt.plot(x, y_int, 'ro', x, y[0] + 0.5 * x**2, 'b-')
>>> plt.show()