CUMTRAPZ

Purpose:

Calculates the integral of a series using the trapezoidal rule.

Syntax:

CUMTRAPZ(series)

series

-

An interval or XY series, the input.

Alternate Syntax:

CUMTRAPZ(xseries, yseries)

xseries

-

A series, the X values.

yseries

-

A series, the Y values.

Returns:

A series.

Example:

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.

Example:

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.

Remarks:

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

 

image\cumtrapz01.gif

 

where

 

image\cumtrapz02.gif

 

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

 

image\trapz01.gif

 

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

 

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

See Also:

AREA

CUMTRAPZ

DERIV

INTEG

LDERIV

RDERIV

TRAPZ