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 of type realcons
one-dimensional rtable or list of dependent data values of type complexcons
two-dimensional rtable or list of independent and dependent data values, with each row representing a single point, the first column being of type realcons, and the second column being of type complexcons
compiled : Either true or false, specifies if auxiliary procedures are to be compiled if they are currently uncompiled. The default is false.
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.
tolerance : Positive numeric value which specifies the tolerance for determining if the independent data in X is uniformly spaced. The default is HFloat(5,-15).
uniform : Either true or false, specifies if the independent data in X are to be assumed uniform. The default is false.
The IntegrateData command approximates the area beneath a 1-D data set using the specified method.
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 calling sequence IntegrateData(X,Y), either when uniform=true or X is determined to be uniform, is reduced to IntegrateData(Y,step=X-X).
Internally, the complex case (where Y is complex) is reduced to the real case by applying IntegrateData separately to the real and imaginary parts of Y. That is:
For the discussion below, assume the values in Y are real-valued.
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 the IntegrateData(X,Y) calling sequence, if sortdata=true then the values in X are sorted in increasing order, and the values in Y are sorted accordingly. If sortdata=false, on the other hand, the onus is on the user to ensure that the data is sorted. For the IntegrateData(Y) calling sequence, if sortdata=true and step<0, then abs(step) is used and Y is sorted in reverse order. 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 Float(undefined).
When method is leftendpoint, rightendpoint, or trapezoid and the number of data points is less than two, or when method is simpson and the number of data points is less than three, the result will be Float(undefined).
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.
For the IntegrateData(X,Y) calling sequence, when uniform=true, it is assumed that X is uniformly spaced, with spacing X2−X1. When uniform=false, however, the procedure first checks if X is uniform before deciding which auxiliary procedure to use to compute the volume. For X to be considered uniformly spaced, it must satisfy Δi−Δj≤τ for each i and j, where Δi=Xi+1−Xi and τ=tolerance.
Computations using regular/uniform data X, compared with irregular/non-uniform X of the same size, tend to be quicker (approximately 40%) and have smaller numerical error in the final result.
The main computations are handled internally by compilable auxiliary procedures. When IntegrateData is called for the first time with compiled=true, these procedures will be compiled before being used. Subsequent calls to IntegrateData will used these compiled versions, even if compiled=false, and execute much more quickly. If IntegrateData has yet to be called in the session with the compiled=true option, then the auxiliary procedures will be called in evalhf mode. Note: There will be a slight time delay when the procedures are first compiled.
Use of compiled=true is recommended when the number of data points in large, on the order of 10^5 or larger, or if IntegrateData is to be called many times in a Maple session.
Any input rtable/list is converted to an rtable of float or complex datatype having no infinite or undefined values, and an error is 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.
Consider the following (unsorted) independent and dependent data:
XY ≔ Matrix⁡3,9,2.5,4,1,1
The (default) Trapezoid Method gives the following for the appropriate integral:
z1 ≔ IntegrateData⁡XY,'sortdata','method'='trapezoid'
The independent data is in reverse order, so if we choose to not sort, we get the negative of the previous answer:
z2 ≔ IntegrateData⁡XY,'sortdata'='false','method'='trapezoid'
If we omit the independent data and instead use a uniform spacing of 2.0, we get the following:
z3 ≔ IntegrateData⁡XY..,2,'method'='trapezoid','step'=2.0
The following data could result from a step function:
X ≔ −10,0,0,10
Y ≔ 2,2,4,4
The independent data values are not unique, but we can still obtain an area:
Consider the following signal over the given time interval:
signal ≔ t→5+sin⁡t+0.1⁢sin⁡3⁢t+0.01⁢sin⁡5⁢t
t1 ≔ 0.0
t2 ≔ 10.0
Now take samples:
points ≔ 100
tValues,yValues ≔ GenerateSignal⁡signal,t1..t2,points,'output'='times','signal'
The approximation methods give the following answers:
area__leftendpoint ≔ IntegrateData⁡tValues,yValues,'method'='leftendpoint'
area__rightendpoint ≔ IntegrateData⁡tValues,yValues,'method'='rightendpoint'
area__simpson ≔ IntegrateData⁡tValues,yValues,'method'='simpson'
area__trapezoid ≔ IntegrateData⁡tValues,yValues,'method'='trapezoid'
Since we have the original algebraic expression for the signal, we can compute the area exactly for comparison:
area ≔ int⁡signal,t1..t2,'digits'=15
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.
Here, we will use will approximate an area with a large number of sample points and use the compiled option. Consider the following function over the given range:
f ≔ x→21+x2
a ≔ −1.0:
b ≔ 1.0:
First, we will compile the internal procedures separately using a token call of IntegrateData to measure the time it takes:
memory used=49.52KiB, alloc change=0 bytes, cpu time=1000.00us, real time=1000.00us, gc time=0ns
Now, approximate the area, which we expect to be close to π:
n ≔ 104
X,Y ≔ GenerateSignal⁡f,a..b,n,'output'='times','signal'
memory used=209.80KiB, alloc change=0 bytes, cpu time=1000.00us, real time=1000.00us, gc time=0ns
Complex data can also be handled:
T,X ≔ GenerateSignal⁡ⅇI⁢t2,t=0..2⁢Pi,104,'output'='times','signal'
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.
The SignalProcessing[IntegrateData] command was updated in Maple 2022.
The compiled, tolerance and uniform options were introduced in Maple 2022.
For more information on Maple 2022 changes, see Updates in Maple 2022.
Download Help Document