IntegrateData - Maple Help

Online Help

All Products    Maple    MapleSim


SignalProcessing

  

IntegrateData

  

calculate the area under a 1-D data set

 

Calling Sequence

Parameters

Options

Description

Examples

References

Compatibility

Calling Sequence

IntegrateData( X, Y, options )

IntegrateData( Y, options )

IntegrateData( XY, options )

Parameters

X

-

One-dimensional rtable or list of independent data values.

Y

-

One-dimensional rtable or list of dependent data values.

XY

-

Two-dimensional rtable or list of independent and dependent data values, with each row representing a single point.

Options

• 

method : One of leftendpoint, rightendpoint, simpson, and trapezoid. The default is trapezoid.

• 

sortdata : Either true or false, this specifies whether to sort the data when both independent and dependent values are provided. The default is true.

• 

step : Positive numeric value, this specifies the uniform step size when only dependent data values are provided. The default is 1.0.

Description

• 

The IntegrateData command approximates the area beneath a 1-D data set using the specified method.

• 

For the IntegrateData(X,Y) calling sequence, X and Y must be of the same size. Note that the independent data values do not need to be uniformly-spaced. For method=simpson, the independent data values are required to be unique, but the other methods have no such restriction.

• 

For the IntegrateData(X,Y) calling sequence, if sortdata=true then the values in X will be sorted in increasing order, and the values in Y will be sorted accordingly. If sortdata=false, on the other hand, the onus is on the user to ensure that the data is sorted. Caution: If sortdata=false and the data is in fact not sorted or unique, then the result may be unreliable, and when method=simpson, the result may be HFloat(undefined).

• 

The IntegrateData(XY) calling sequence is reduced to the IntegrateData(X,Y) calling sequence by taking X and Y to be, respectively, the first and second columns of XY. Similarly, the IntegrateData(Y) calling sequence is reduced to the IntegrateData(X,Y) calling sequence by taking X to be the Vector of size numelems(Y) with elements X[i]=i*step. Note that the sortdata option has no effect in this case.

• 

If the number of data points is 1, then the result will be HFloat(0.0). Passing an empty rtable/list will result in an error.

• 

When method is not simpson, IntegrateData can integrate data representing piecewise-continuous expressions. To this end, the x-value for a jump discontinuity can be listed twice in X, with the dependent values on the left and right included, in order, in Y. See below for an example.

• 

When method=leftendpoint, the following formula is used:

IntegrateDataX,Y=i=2nXiXi1Yi1

  

where n=numelemsX. That is, the area is approximated by using rectangles of height determined by the left-endpoint of each sub-interval. The above assumes that the values in X have already been sorted.

• 

When method=rightendpoint, the following formula is used:

IntegrateDataX,Y=i=2nXiXi1Yi

  

where n=numelemsX. That is, the area is approximated by using rectangles of height determined by the right-endpoint of each sub-interval. The above assumes that the values in X have already been sorted.

• 

When method=trapezoid, the following formula is used:

IntegrateDataX,Y=i=2nXiXi1Yi1+Yi2

  

where n=numelemsX. That is, the area is approximated by using trapezoids over each sub-interval, which is equivalent to finding the area beneath a piecewise-linear interpolation. The above assumes that the values in X have already been sorted.

• 

When method=simpson, the formula for Simpson's Composite Method for irregularly-spaced data is used. See references below. The full formula is omitted here for brevity, but it is derived using quadratic interpolants for data points in adjacent sub-intervals. The method requires three or more data points.

• 

There are a few internal procedures which are first compiled in a session under certain circumstances when the number of data points is larger than 10^5. When this happens, there may be a slight delay in returning the result. Subsequent executions will use the compiled versions of these internal procedures, and not have this delay, even when the number of data points is not larger than 10^5.

• 

Any input rtable/list is converted to an rtable of float[8] datatype, and an error will be thrown if this is not possible. For this reason, it is most efficient for any input to already be an rtable having the appropriate datatype. Note: The rtables cannot have an indexing function, and they need to have rectangular storage.

• 

The IntegrateData command is not thread safe.

• 

As the underlying implementation of the SignalProcessing package is a module, it is also possible to use the form SignalProcessing:-IntegrateData to access the command from the package. For more information, see Module Members.

Examples

withSignalProcessing:

Example 1

• 

Consider the following (unsorted) independent and dependent data:

XYMatrix3,9,2.5,4,1,1

XY392.5411

(1)
• 

The (default) Trapezoid Method gives the following for the appropriate integral:

z1IntegrateDataXY,sortdata=true,method=trapezoid

z17.

(2)
• 

The independent data is in reverse order, so if we choose to not sort, we get the negative of the previous answer:

z2IntegrateDataXY,sortdata=false,method=trapezoid

z2−7.

(3)
• 

If we omit the independent data and instead use a uniform spacing of 2.0, we get the following:

z3IntegrateDataXY..,2,method=trapezoid,step=2.0

z318.

(4)

Example 2

• 

The following data could result from a step function:

X10,0,0,10

X−100010

(5)

Y2,2,4,4

Y2244

(6)

dataplotX,Y,view=10..10,0..5,thickness=3

• 

The independent data values are not unique, but that is allowed except when Simpson's Method is used:

IntegrateDataX,Y,method=trapezoid,sortdata=false

60.

(7)

Example 3

• 

Consider the following signal over the given time interval:

signalt5+sint+0.1sin3t+0.01sin5t

signalt5+sint+0.1sin3t+0.01sin5t

(8)

t10.

t10.

(9)

t210.0

t210.0

(10)
• 

Now take samples:

points100

points100

(11)

tValuesVectorpoints,ievalhft1+i1t2points1,datatype=float8

tValues0.0.1010101010101010.2020202020202020.3030303030303030.4040404040404040.5050505050505050.6060606060606060.7070707070707070.8080808080808080.909090909090909100 element Vector[column]

(12)

yValues`~`signaltValues

yValues5.5.135518317107255.266081122849615.387292873001075.495779939120795.589477388979045.667700302208445.731003583381615.780875711121205.81934122416630100 element Vector[column]

(13)
• 

The approximation methods give the following answers:

area__leftendpointIntegrateDatatValues,yValues,method=leftendpoint

area__leftendpoint51.8981501007383912

(14)

area__rightendpointIntegrateDatatValues,yValues,method=rightendpoint

area__rightendpoint51.8329533308560002

(15)

area__simpsonIntegrateDatatValues,yValues,method=simpson

area__simpson51.8673373379068607

(16)

area__trapezoidIntegrateDatatValues,yValues,method=trapezoid

area__trapezoid51.8655517157971957

(17)
• 

Since we have the original algebraic expression for the signal, we can compute the area exactly for comparison:

areaintsignal,t1..t2

area51.86733322

(18)
• 

Simpson's Method is usually (but not always) the most accurate, so it is not surprising that it gives the closest approximation here, but it tends to be the slowest.

References

  

Shklov, N. "Simpson's Rule for Unequally Spaced Ordinates." The American Mathematical Monthly. Vol. 67, No. 10, 1960, pp. 1022-1023.

Compatibility

• 

The SignalProcessing[IntegrateData] command was introduced in Maple 2021.

• 

For more information on Maple 2021 changes, see Updates in Maple 2021.

See Also

SignalProcessing

Student[Calculus1]