Calculates the integral of a series using the trapezoidal rule.

CUMTRAPZ(series)

series |
- |
An interval or XY series, the input. |

CUMTRAPZ(xseries, yseries)

xseries |
- |
A series, the X values. |

yseries |
- |
A series, the Y values. |

A series.

W1: {0, 2, 4, 6, 8, 10}

W2: integ(W1)

W3: cumtrapz(W1)

W2 == {0.0, 1.3, 4.0, 9.3, 16.0, 25.3}

W3 == {0.0, 1.0, 4.0, 9.0, 16.0, 25.0}

W2 contains the integrated series using Simpson's rule.

W3 contains the integrated series using the Trapezoidal rule.

y1 = gnorm(1000, .001);

a1 = cumtrapz(y1);

a2 = trapz(y1);

Series a1 contains the cumulative area of y1 and scalar a2 contains the value of the total area of y1. Note that a1[end] == a2, the last point of the cumulative area equals the total area.

The trapezoidal rule fits a line between two data points and calculates the area under the resulting trapezoid such that:

where

For an interval series s, the trapezoidal rule calculates the running sum:

See TRAPZ to compute the total area using the trapezoidal rule.

See INTEG to compute the cumulative area using Simpson’s rule.