calculate the area under a 1-D data set
IntegrateData( X, Y, options )
IntegrateData( Y, options )
IntegrateData( XY, options )
One-dimensional rtable or list of independent data values.
One-dimensional rtable or list of dependent data values.
Two-dimensional rtable or list of independent and dependent data values, with each row representing a single point.
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.
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:
where n=numelems⁡X. 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:
where n=numelems⁡X. 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:
where n=numelems⁡X. 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 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.
Consider the following (unsorted) independent and dependent data:
The (default) Trapezoid Method gives the following for the appropriate integral:
The independent data is in reverse order, so if we choose to not sort, we get the negative of the previous answer:
If we omit the independent data and instead use a uniform spacing of 2.0, we get the following:
The following data could result from a step function:
The independent data values are not unique, but that is allowed except when Simpson's Method is used:
Consider the following signal over the given time interval:
Now take samples:
tValues≔0.0.1010101010101010.2020202020202020.3030303030303030.4040404040404040.5050505050505050.6060606060606060.7070707070707070.8080808080808080.909090909090909⋮100 element Vector[column]
yValues≔5.5.135518317107255.266081122849615.387292873001075.495779939120795.589477388979045.667700302208445.731003583381615.780875711121205.81934122416630⋮100 element Vector[column]
The approximation methods give the following answers:
Since we have the original algebraic expression for the signal, we can compute the area exactly for comparison:
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.
Shklov, N. "Simpson's Rule for Unequally Spaced Ordinates." The American Mathematical Monthly. Vol. 67, No. 10, 1960, pp. 1022-1023.
The SignalProcessing[IntegrateData] command was introduced in Maple 2021.
For more information on Maple 2021 changes, see Updates in Maple 2021.
Download Help Document
What kind of issue would you like to report? (Optional)