Loading [MathJax]/extensions/tex2jax.js
scipy 1.10.1 Pypi GitHub Homepage
Other Docs

ParametersReturnsBackRef
cumulative_trapezoid(y, x=None, dx=1.0, axis=-1, initial=None)

Parameters

y : array_like

Values to integrate.

x : array_like, optional

The coordinate to integrate along. If None (default), use spacing dx between consecutive elements in y.

dx : float, optional

Spacing between elements of y. Only used if x is None.

axis : int, optional

Specifies the axis to cumulate. Default is -1 (last axis).

initial : scalar, optional

If given, insert this value at the beginning of the returned result. Typically this value should be 0. Default is None, which means no value at x[0] is returned and res has one element less than y along the axis of integration.

Returns

res : ndarray

The result of cumulative integration of y along axis. If initial is None, the shape is such that the axis of integration has one less value than y. If initial is given, the shape is equal to that of y.

Cumulatively integrate y(x) using the composite trapezoidal rule.

See Also

dblquad

double integrals

fixed_quad

fixed-order Gaussian quadrature

numpy.cumprod
numpy.cumsum
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
import numpy as np
import matplotlib.pyplot as plt
x = np.linspace(-2, 2, num=20)
y = x
y_int = integrate.cumulative_trapezoid(y, x, initial=0)
plt.plot(x, y_int, 'ro', x, y[0] + 0.5 * x**2, 'b-')
plt.show()
See :

Back References

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

scipy.integrate._quadrature:romb scipy.integrate._quadrature:simpson scipy.integrate._quadrature:trapezoid scipy.integrate._quadrature:romberg scipy.integrate._quadrature:fixed_quad scipy.integrate._quadrature:cumtrapz scipy.integrate._quadrature:quadrature

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.

quadquadscipy.integrate._quadrature:romberg_quadrature:rombergquadraturequadraturescipy.integrate._quadrature:quadrature_quadrature:quadratureodeodescipy.integrate._quadrature:romb_quadrature:rombrombergrombergscipy.integrate._quadpack_py:tplquad_quadpack_py:tplquadscipy.integrate._quadpack_py:dblquad_quadpack_py:dblquadrombrombnumpy.cumprodcumprodscipy.integrate._quadrature:cumtrapz_quadrature:cumtrapznumpy.cumsumcumsumscipy.integrate._quadrature:fixed_quad_quadrature:fixed_quadscipy.integrate._quadrature:simpson_quadrature:simpsonodeintodeintscipy.integrate._quadrature:trapezoid_quadrature:trapezoid

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#395
type: <class 'function'>
Commit: