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()