DifferentiateData - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

SignalProcessing

 DifferentiateData
 compute the derivative of a 1-D rtable of data

 Calling Sequence DifferentiateData( X, n, options )

Parameters

 X - 1-D rtable or list of complexcons data n - (optional) positive integer, specifies the order of differentiation. The default is 1.

Options

 • degree: Positive integer, specifies the degree of the polynomial or spline used to extrapolate points for the finite difference and Savitzky-Golay methods. The default is 3.
 • frameradius: Positive integer, specifies the radius of the frame used for the Savitzky-Golay method. The default is 5.
 • extrapolation: One of periodic, polynomial, and spline, specifies how the data in X is extrapolated. The default is polynomial.
 • splinepoints: Positive integer other than 1 or infinity, specifies the maximum number of data points used to perform spline extrapolation. The default is 10.
 • method: One of backward, central, forward, savitzkygolay, and spectral. The default is central.
 • step: Positive numeric value, specifies the time step between successive data points. The default is 1.0.

Description

 • The DifferentiateData(X,n) command computes the derivative of order n for data container X. It is assumed that the data in X originated from a signal sampled uniformly with the time between samples being step.
 • For the discussion below, assume $X$ is indexed from $1$ to $m$ with $m$ being the size of $X$, and let $n$ be the order of differentiation, $T$ be the size of the time interval over which the signal is sampled, $d=\mathrm{degree}$, and $h=\mathrm{step}$. Moreover, we denote by ${\mathrm{D}}_{n}\left(X\right)$ the derivative of order $n$ for $X$.
 • The three finite difference methods, namely backward, central, and forward, and the savitzkygolay method all use extrapolation on the left and right ends to lengthen $X$ so that the derivative of order $n$ is of the same size as $X$. This extrapolation can be performed in three ways:
 • extrapolation=periodic: The data is assumed to be periodic, so that ${X}_{i+m}={X}_{i}$ for each integer $i$.
 • extrapolation=polynomial: Using the CurveFitting[PolynomialInterpolation] command, interpolating polynomials of degree (at most) $d$ are used to extend $X$ on the left and right.
 • extrapolation=spline: Using the CurveFitting[ArrayInterpolation] command, splines of degree (at most) $d$ are used to extend $X$ on the left and right.
 • For method=central, the size of the signal must satisfy $3\le n$. For the other methods, $2\le n$.
 • For both method=backward and method=forward, $m$ and $n$ must satisfy $n\le m-1$, whereas for method=central, they must satisfy $n\le \frac{m}{2}-\frac{1}{2}$. Moreover, $d$ must satisfy $d\le m-1$.
 • For the finite difference methods, we use the standard formulas. For method=forward:

${{\mathrm{D}}_{n}\left(X\right)}_{i}={\left(\frac{1}{h}\right)}^{n}\left(\sum _{j=0}^{n}{\left(-1\right)}^{n-j}\left(\genfrac{}{}{0}{}{n}{j}\right){X}_{i+j}\right)$

 • For method=backward:

${{\mathrm{D}}_{n}\left(X\right)}_{i}={\left(\frac{1}{h}\right)}^{n}\left(\sum _{j=0}^{n}{\left(-1\right)}^{j}\left(\genfrac{}{}{0}{}{n}{j}\right){X}_{i+n-j}\right)$

 • For method=central:

${{\mathrm{D}}_{n}\left(X\right)}_{i}={\left(\frac{1}{2h}\right)}^{n}\left(\sum _{j=0}^{n}{\left(-1\right)}^{j}\left(\genfrac{}{}{0}{}{n}{j}\right){X}_{i+2n-2j}\right)$

 • When method=savitzkygolay, the Savitzky-Golay Filter is used to estimate the derivative. The frame radius $r$ should satisfy $d<2r$ and $2r+1\le m$, and the degree should satisfy $n\le d$. Note that the option degree serves the additional role as the degree of the fitting polynomials used in the Savitzky-Golay smoothing.
 • When method=spectral, the derivative property of the Fourier Transform is used to find the derivative of order $n$ for $X$:
 1 Compute the FFT $Y$ of $X$.
 2 Compute the element-wise product $Z$ of  $Y$ and $H$, where $H$ is defined below.
 3 Compute the Inverse FFT ${\mathrm{D}}_{n}\left(X\right)$ of Z, which is the derivative of order $n$ of $X$.
 The elements of $H$ are given by the following:

${H}_{i}=\left\{\begin{array}{cc}0& m::\mathrm{even}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{and}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}n::\mathrm{odd}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{and}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}i=\frac{m}{2}+1\\ {\left(\frac{2I\mathrm{\pi }\left(i-1\right)}{T}\right)}^{n}& i\le \frac{m}{2}+1\\ {\left(\frac{2I\mathrm{\pi }\left(i-m-1\right)}{T}\right)}^{n}& \mathrm{otherwise}\end{array}\right\$

 • The spectral method works best when the data represents periodic data, particularly when it is a finite linear combination of sinusoidal terms having frequency no larger than the sample rate. Note: If the original signal is periodic with period $T$, the final data point should correspond to the final sample before $T$, since the sample at time $T$ would be the same as time $0$. See below for an example.
 • The DifferentiateData command is most accurate when the signal is not too noisy, the size of the signal is large, and the order of differentiation is small.
 • Maple will attempt to coerce the provided data container $X$ to a 1-D Vector of either float[8] or complex[8] datatype for the Savitzky-Golay method and any of the finite difference methods, and complex[8] for the spectral differentiation method. An error will be thrown if this is not possible. For this reason, it is most efficient for the passed input to use the appropriate datatype (float[8] or complex[8]).
 • The data container $X$ must have no indexing function, and use Fortran ordering and rectangular storage.
 • The DifferentiateData command is not thread safe.

Examples

 > $\mathrm{with}\left(\mathrm{SignalProcessing}\right):$

Example 1

 • For our first example, we will differentiate data, obtained (for the convenience of comparison) from a polynomial source. First, generate the times and signal Vectors, and note the time step, all using the GenerateSignal command:
 > $f≔-{t}^{2}+7t+4$
 ${f}{≔}{-}{{t}}^{{2}}{+}{7}{}{t}{+}{4}$ (1)
 > $a≔0:$
 > $b≔5:$
 > $n≔250:$
 > $T,\mathrm{dt},X≔\mathrm{GenerateSignal}\left(f,t=a..b,n,'\mathrm{output}'=\left['\mathrm{times}','\mathrm{timestep}','\mathrm{signal}'\right]\right)$
 • Now, differentiate:
 > $\mathrm{DX}≔\mathrm{DifferentiateData}\left(X,1,'\mathrm{step}'=\mathrm{dt},'\mathrm{method}'='\mathrm{forward}','\mathrm{extrapolation}'='\mathrm{polynomial}'\right)$
 • Since the data does not have any erratic behavior, we expect this approximation to be good:
 > $\mathrm{RelativeRootMeanSquareError}\left(\mathrm{DX},\mathrm{GenerateSignal}\left(\frac{\partial }{\partial t}f,t=a..b,n\right)\right)$
 ${0.00570236649300122009}$ (2)
 • Visually:
 > $\mathrm{dataplot}\left(T,\left[X,\mathrm{DX}\right],'\mathrm{style}'='\mathrm{line}','\mathrm{color}'=\left['\mathrm{blue}','\mathrm{darkgreen}'\right],'\mathrm{legend}'=\left["Signal","First derivative"\right]\right)$

Example 2

 • In this example, we consider real-valued, periodic data. First, generate a signal, along with the times Vector and time step:
 > $f≔5\mathrm{cos}\left(t\right)+\mathrm{sin}\left(3t\right)$
 ${f}{≔}{5}{}{\mathrm{cos}}{}\left({t}\right){+}{\mathrm{sin}}{}\left({3}{}{t}\right)$ (3)
 > $a≔0:$
 > $b≔2\mathrm{Pi}:$
 > $n≔64:$
 > $T,\mathrm{dt},X≔\mathrm{GenerateSignal}\left(f,t=a..b,n,'\mathrm{includefinishtime}'='\mathrm{false}','\mathrm{output}'=\left['\mathrm{times}','\mathrm{timestep}','\mathrm{signal}'\right]\right):$
 • Second, compute the first derivative three ways, one directly with the GenerateSignal command (for comparison), and two with the DifferentiateData using different options:
 > $Y≔\mathrm{GenerateSignal}\left(\frac{\partial }{\partial t}f,t=a..b,n,'\mathrm{includefinishtime}'='\mathrm{false}'\right):$
 > $\mathrm{Y1}≔\mathrm{DifferentiateData}\left(X,1,'\mathrm{step}'=\mathrm{dt},'\mathrm{method}'='\mathrm{central}','\mathrm{extrapolation}'='\mathrm{periodic}'\right):$
 > $\mathrm{Y2}≔\mathrm{DifferentiateData}\left(X,1,'\mathrm{step}'=\mathrm{dt},'\mathrm{method}'='\mathrm{spectral}'\right):$
 • The central approximation for the first derivative is fairly accurate, and the spectral approximation is exceptionally accurate:
 > $\mathrm{RelativeRootMeanSquareError}\left(\mathrm{Y1},Y\right)$
 ${0.00753297720724115192}$ (4)
 > $\mathrm{RelativeRootMeanSquareError}\left(\mathrm{Y2},Y\right)$
 ${4.82327325373904705}{×}{{10}}^{{-15}}$ (5)
 • Third, compute the second derivative, again in three ways, and calculate the accuracy of the approximations:
 > $Z≔\mathrm{GenerateSignal}\left(\frac{{\partial }^{2}}{\partial {t}^{2}}f,t=a..b,n,'\mathrm{includefinishtime}'='\mathrm{false}'\right):$
 > $\mathrm{Z1}≔\mathrm{DifferentiateData}\left(X,2,'\mathrm{step}'=\mathrm{dt},'\mathrm{method}'='\mathrm{central}','\mathrm{extrapolation}'='\mathrm{periodic}'\right):$
 > $\mathrm{Z2}≔\mathrm{DifferentiateData}\left(X,2,'\mathrm{step}'=\mathrm{dt},'\mathrm{method}'='\mathrm{spectral}'\right):$
 • As with the first derivative, the approximations for the second derivative are fairly accurate (but less so than for the first derivative):
 > $\mathrm{RelativeRootMeanSquareError}\left(\mathrm{Z1},Z\right)$
 ${0.0250341382145814959}$ (6)
 > $\mathrm{RelativeRootMeanSquareError}\left(\mathrm{Z2},Z\right)$
 ${7.35080030302369947}{×}{{10}}^{{-14}}$ (7)
 • Visually:
 > $\mathrm{dataplot}\left(T,\left[X,Y,Z\right],'\mathrm{style}'='\mathrm{line}','\mathrm{color}'=\left['\mathrm{blue}','\mathrm{darkgreen}','\mathrm{purple}'\right],'\mathrm{legend}'=\left["Signal","First derivative","Second derivative"\right]\right)$
 • When we constructed the data, we omitted the point at $t=2\mathrm{\pi }$ since it corresponds to the point at $t=0$. If the final point is included, the spectral approximation for the derivative is greatly affected at the endpoints:
 > $U,h,V≔\mathrm{GenerateSignal}\left(f,t=a..b,n,'\mathrm{includefinishtime}'='\mathrm{true}','\mathrm{output}'=\left['\mathrm{times}','\mathrm{timestep}','\mathrm{signal}'\right]\right):$
 > $\mathrm{W1}≔\mathrm{GenerateSignal}\left(\frac{\partial }{\partial t}f,t=a..b,n,'\mathrm{includefinishtime}'='\mathrm{true}'\right):$
 > $\mathrm{W2}≔\mathrm{DifferentiateData}\left(V,1,'\mathrm{step}'=h,'\mathrm{method}'='\mathrm{spectral}'\right):$
 > $\mathrm{RelativeRootMeanSquareError}\left(\mathrm{W2},\mathrm{W1}\right)$
 ${0.106321866987499819}$ (8)
 > $\mathrm{RelativeRootMeanSquareError}\left({\mathrm{W2}}_{20..-20},{\mathrm{W1}}_{20..-20}\right)$
 ${0.00768251003253226511}$ (9)

Example 3

 • First, generate a signal:
 > $f≔\mathrm{piecewise}\left(t<\mathrm{Pi}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{or}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}3\mathrm{Pi}
 ${f}{≔}\left\{\begin{array}{cc}{\mathrm{sin}}{}\left({4}{}{t}\right){+}{5}& {t}{<}{\mathrm{\pi }}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{\mathbf{or}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{3}{}{\mathrm{\pi }}{<}{t}\\ \frac{{\mathrm{sin}}{}\left({40}{}{t}\right)}{{10}}{+}{5}& {\mathrm{otherwise}}\end{array}\right\$ (10)
 > $a≔0:$
 > $b≔4\mathrm{Pi}:$
 > $n≔{2}^{14}:$
 > $X,\mathrm{dt}≔\mathrm{GenerateSignal}\left(f,t=a..b,n,'\mathrm{includefinishtime}'='\mathrm{false}','\mathrm{output}'=\left['\mathrm{signal}','\mathrm{timestep}'\right]\right):$
 • Second, compute the first and second derivatives, both directly and numerically:
 > $\mathrm{D1X1}≔\mathrm{DifferentiateData}\left(X,1,'\mathrm{step}'=\mathrm{dt},'\mathrm{method}'='\mathrm{spectral}'\right):$
 > $\mathrm{D2X1}≔\mathrm{DifferentiateData}\left(X,2,'\mathrm{step}'=\mathrm{dt},'\mathrm{method}'='\mathrm{spectral}'\right):$
 > $\mathrm{D1X2}≔\mathrm{GenerateSignal}\left(\frac{\partial }{\partial t}f,t=a..b,n,'\mathrm{includefinishtime}'='\mathrm{false}'\right):$
 > $\mathrm{D2X2}≔\mathrm{GenerateSignal}\left(\frac{{\partial }^{2}}{\partial {t}^{2}}f,t=a..b,n,'\mathrm{includefinishtime}'='\mathrm{false}'\right):$
 > $\mathrm{RelativeRootMeanSquareError}\left(\mathrm{D1X1},\mathrm{D1X2}\right)$
 ${3.52534042480501931}{×}{{10}}^{{-7}}$ (11)
 > $\mathrm{RelativeRootMeanSquareError}\left(\mathrm{D2X1},\mathrm{D2X2}\right)$
 ${0.0000559512699727594801}$ (12)
 • Finally, plot the first and second derivatives:
 > $\mathrm{SignalPlot}\left(X,'\mathrm{title}'="Plot of Signal",'\mathrm{color}'='\mathrm{blue}'\right)$
 > $\mathrm{SignalPlot}\left(\mathrm{D1X1},'\mathrm{title}'="Plot of First Derivative",'\mathrm{color}'='\mathrm{blue}'\right)$
 > $\mathrm{SignalPlot}\left(\mathrm{D2X1},'\mathrm{title}'="Plot of Second Derivative",'\mathrm{color}'='\mathrm{blue}'\right)$

Example 4

 • Complex data can also be differentiated:
 > $T,\mathrm{dt},X≔\mathrm{GenerateSignal}\left({t}^{2}{ⅇ}^{-It},t=0..5,{10}^{4},'\mathrm{output}'=\left['\mathrm{times}','\mathrm{timestep}','\mathrm{signal}'\right]\right):$
 > $\mathrm{DX}≔\mathrm{DifferentiateData}\left(X,1,'\mathrm{step}'=\mathrm{dt},'\mathrm{method}'='\mathrm{forward}','\mathrm{extrapolation}'='\mathrm{spline}'\right):$
 > $\mathrm{X1},\mathrm{X2}≔\mathrm{ComplexToReal}\left(X\right):$
 > $\mathrm{DX1},\mathrm{DX2}≔\mathrm{ComplexToReal}\left(\mathrm{DX}\right):$
 > $\mathrm{dataplot}\left(T,\left[\mathrm{X1},\mathrm{DX1}\right],'\mathrm{style}'='\mathrm{line}','\mathrm{title}'="Signal",'\mathrm{legend}'=\left["Real part","Imaginary part"\right],'\mathrm{color}'=\left['\mathrm{red}','\mathrm{blue}'\right]\right)$
 > $\mathrm{dataplot}\left(T,\left[\mathrm{X2},\mathrm{DX2}\right],'\mathrm{style}'='\mathrm{line}','\mathrm{title}'="First Derivative",'\mathrm{legend}'=\left["Real part","Imaginary part"\right],'\mathrm{color}'=\left['\mathrm{red}','\mathrm{blue}'\right]\right)$

Example 5

 • The Savitzky-Golay method can also be used to estimate the derivative:
 > $f≔\mathrm{sin}\left(t\right)+5{ⅇ}^{It}\mathrm{cos}\left(3t\right)+10$
 ${f}{≔}{\mathrm{sin}}{}\left({t}\right){+}{5}{}{{ⅇ}}^{{I}{}{t}}{}{\mathrm{cos}}{}\left({3}{}{t}\right){+}{10}$ (13)
 > $a≔0$
 ${a}{≔}{0}$ (14)
 > $b≔2\mathrm{Pi}$
 ${b}{≔}{2}{}{\mathrm{\pi }}$ (15)
 > $n≔250$
 ${n}{≔}{250}$ (16)
 > $\mathrm{dt},X≔\mathrm{GenerateSignal}\left(f,t=a..b,n,'\mathrm{includefinishtime}'='\mathrm{false}','\mathrm{output}'=\left['\mathrm{timestep}','\mathrm{signal}'\right]\right):$
 > $Y≔\mathrm{DifferentiateData}\left(X,1,'\mathrm{step}'=\mathrm{dt},'\mathrm{method}'='\mathrm{savitzkygolay}','\mathrm{frameradius}'=10,'\mathrm{extrapolation}'='\mathrm{periodic}','\mathrm{degree}'=3\right):$
 • Comparing with the actual derivative:
 > $Z≔\mathrm{GenerateSignal}\left(\frac{\partial }{\partial t}f,t=a..b,n,'\mathrm{includefinishtime}'='\mathrm{false}'\right):$
 > $\mathrm{RelativeRootMeanSquareError}\left(Y,Z\right)$
 ${0.00205478287629157685}$ (17)

Compatibility

 • Since internal commands are now compiled in external code, the compiled option is now deprecated. For backwards compatibility, the command can still be passed, but it will be ignored.
 • The SignalProcessing:-DifferentiateData command was introduced in Maple 2022.
 • For more information on Maple 2022 changes, see Updates in Maple 2022.
 • The SignalProcessing:-DifferentiateData command was updated in Maple 2023.
 • The frameradius option was introduced in Maple 2023.
 • The method and compiled options were updated in Maple 2023.
 • For more information on Maple 2023 changes, see Updates in Maple 2023.
The text passage is a detailed documentation of the `DifferentiateData` command in Maple, which is used to compute the derivative of a 1-D rtable of data. The passage includes a description of the command, its parameters, options, and several examples demonstrating its usage.
no_question

the passage does not contain any explicit mathematical questions or problems that require solving. it is primarily a reference document explaining how to use the `differentiatedata` command in maple.
Given a text passage, determine:
    1. If it contains a mathematical question (including word problems or calculations)
    2. If an answer to that mathematical question is provided in the text

First, describe the content structure you found in 1-2 sentences.

Then provide your analysis in the following format:
TYPE: <one of the following values>
- NO_QUESTION
- SINGLE_QUESTION
- SINGLE_QUESTION_WITH_ANSWER
- MULTIPLE_QUESTIONS
- MULTIPLE_QUESTIONS_WITH_ANSWERS
system
DifferentiateData - Maple Help
For the best experience, we recommend viewing online help using Google Chrome or Microsoft Edge.

SignalProcessing

 DifferentiateData
 compute the derivative of a 1-D rtable of data

 Calling Sequence DifferentiateData( X, n, options )

Parameters

 X - 1-D rtable or list of complexcons data n - (optional) positive integer, specifies the order of differentiation. The default is 1.

Options

 • degree: Positive integer, specifies the degree of the polynomial or spline used to extrapolate points for the finite difference and Savitzky-Golay methods. The default is 3.
 • frameradius: Positive integer, specifies the radius of the frame used for the Savitzky-Golay method. The default is 5.
 • extrapolation: One of periodic, polynomial, and spline, specifies how the data in X is extrapolated. The default is polynomial.
 • splinepoints: Positive integer other than 1 or infinity, specifies the maximum number of data points used to perform spline extrapolation. The default is 10.
 • method: One of backward, central, forward, savitzkygolay, and spectral. The default is central.
 • step: Positive numeric value, specifies the time step between successive data points. The default is 1.0.

Description

 • The DifferentiateData(X,n) command computes the derivative of order n for data container X. It is assumed that the data in X originated from a signal sampled uniformly with the time between samples being step.
 • For the discussion below, assume $X$ is indexed from $1$ to $m$ with $m$ being the size of $X$, and let $n$ be the order of differentiation, $T$ be the size of the time interval over which the signal is sampled, $d=\mathrm{degree}$, and $h=\mathrm{step}$. Moreover, we denote by ${\mathrm{D}}_{n}\left(X\right)$ the derivative of order $n$ for $X$.
 • The three finite difference methods, namely backward, central, and forward, and the savitzkygolay method all use extrapolation on the left and right ends to lengthen $X$ so that the derivative of order $n$ is of the same size as $X$. This extrapolation can be performed in three ways:
 • extrapolation=periodic: The data is assumed to be periodic, so that ${X}_{i+m}={X}_{i}$ for each integer $i$.
 • extrapolation=polynomial: Using the CurveFitting[PolynomialInterpolation] command, interpolating polynomials of degree (at most) $d$ are used to extend $X$ on the left and right.
 • extrapolation=spline: Using the CurveFitting[ArrayInterpolation] command, splines of degree (at most) $d$ are used to extend $X$ on the left and right.
 • For method=central, the size of the signal must satisfy $3\le n$. For the other methods, $2\le n$.
 • For both method=backward and method=forward, $m$ and $n$ must satisfy $n\le m-1$, whereas for method=central, they must satisfy $n\le \frac{m}{2}-\frac{1}{2}$. Moreover, $d$ must satisfy $d\le m-1$.
 • For the finite difference methods, we use the standard formulas. For method=forward:

${{\mathrm{D}}_{n}\left(X\right)}_{i}={\left(\frac{1}{h}\right)}^{n}\left(\sum _{j=0}^{n}{\left(-1\right)}^{n-j}\left(\genfrac{}{}{0}{}{n}{j}\right){X}_{i+j}\right)$

 • For method=backward:

${{\mathrm{D}}_{n}\left(X\right)}_{i}={\left(\frac{1}{h}\right)}^{n}\left(\sum _{j=0}^{n}{\left(-1\right)}^{j}\left(\genfrac{}{}{0}{}{n}{j}\right){X}_{i+n-j}\right)$

 • For method=central:

${{\mathrm{D}}_{n}\left(X\right)}_{i}={\left(\frac{1}{2h}\right)}^{n}\left(\sum _{j=0}^{n}{\left(-1\right)}^{j}\left(\genfrac{}{}{0}{}{n}{j}\right){X}_{i+2n-2j}\right)$

 • When method=savitzkygolay, the Savitzky-Golay Filter is used to estimate the derivative. The frame radius $r$ should satisfy $d<2r$ and $2r+1\le m$, and the degree should satisfy $n\le d$. Note that the option degree serves the additional role as the degree of the fitting polynomials used in the Savitzky-Golay smoothing.
 • When method=spectral, the derivative property of the Fourier Transform is used to find the derivative of order $n$ for $X$:
 1 Compute the FFT $Y$ of $X$.
 2 Compute the element-wise product $Z$ of  $Y$ and $H$, where $H$ is defined below.
 3 Compute the Inverse FFT ${\mathrm{D}}_{n}\left(X\right)$ of Z, which is the derivative of order $n$ of $X$.
 The elements of $H$ are given by the following:

${H}_{i}=\left\{\begin{array}{cc}0& m::\mathrm{even}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{and}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}n::\mathrm{odd}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}\mathbf{and}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}i=\frac{m}{2}+1\\ {\left(\frac{2I\mathrm{\pi }\left(i-1\right)}{T}\right)}^{n}& i\le \frac{m}{2}+1\\ {\left(\frac{2I\mathrm{\pi }\left(i-m-1\right)}{T}\right)}^{n}& \mathrm{otherwise}\end{array}\right\$

 • The spectral method works best when the data represents periodic data, particularly when it is a finite linear combination of sinusoidal terms having frequency no larger than the sample rate. Note: If the original signal is periodic with period $T$, the final data point should correspond to the final sample before $T$, since the sample at time $T$ would be the same as time $0$. See below for an example.
 • The DifferentiateData command is most accurate when the signal is not too noisy, the size of the signal is large, and the order of differentiation is small.
 • Maple will attempt to coerce the provided data container $X$ to a 1-D Vector of either float[8] or complex[8] datatype for the Savitzky-Golay method and any of the finite difference methods, and complex[8] for the spectral differentiation method. An error will be thrown if this is not possible. For this reason, it is most efficient for the passed input to use the appropriate datatype (float[8] or complex[8]).
 • The data container $X$ must have no indexing function, and use Fortran ordering and rectangular storage.
 • The DifferentiateData command is not thread safe.

Examples

 > $\mathrm{with}\left(\mathrm{SignalProcessing}\right):$

Example 1

 • For our first example, we will differentiate data, obtained (for the convenience of comparison) from a polynomial source. First, generate the times and signal Vectors, and note the time step, all using the GenerateSignal command:
 > $f≔-{t}^{2}+7t+4$
 ${f}{≔}{-}{{t}}^{{2}}{+}{7}{}{t}{+}{4}$ (1)
 > $a≔0:$
 > $b≔5:$
 > $n≔250:$
 > $T,\mathrm{dt},X≔\mathrm{GenerateSignal}\left(f,t=a..b,n,'\mathrm{output}'=\left['\mathrm{times}','\mathrm{timestep}','\mathrm{signal}'\right]\right)$
 • Now, differentiate:
 > $\mathrm{DX}≔\mathrm{DifferentiateData}\left(X,1,'\mathrm{step}'=\mathrm{dt},'\mathrm{method}'='\mathrm{forward}','\mathrm{extrapolation}'='\mathrm{polynomial}'\right)$
 • Since the data does not have any erratic behavior, we expect this approximation to be good:
 > $\mathrm{RelativeRootMeanSquareError}\left(\mathrm{DX},\mathrm{GenerateSignal}\left(\frac{\partial }{\partial t}f,t=a..b,n\right)\right)$
 ${0.00570236649300122009}$ (2)
 • Visually:
 > $\mathrm{dataplot}\left(T,\left[X,\mathrm{DX}\right],'\mathrm{style}'='\mathrm{line}','\mathrm{color}'=\left['\mathrm{blue}','\mathrm{darkgreen}'\right],'\mathrm{legend}'=\left["Signal","First derivative"\right]\right)$

Example 2

 • In this example, we consider real-valued, periodic data. First, generate a signal, along with the times Vector and time step:
 > $f≔5\mathrm{cos}\left(t\right)+\mathrm{sin}\left(3t\right)$
 ${f}{≔}{5}{}{\mathrm{cos}}{}\left({t}\right){+}{\mathrm{sin}}{}\left({3}{}{t}\right)$ (3)
 > $a≔0:$
 > $b≔2\mathrm{Pi}:$
 > $n≔64:$
 > $T,\mathrm{dt},X≔\mathrm{GenerateSignal}\left(f,t=a..b,n,'\mathrm{includefinishtime}'='\mathrm{false}','\mathrm{output}'=\left['\mathrm{times}','\mathrm{timestep}','\mathrm{signal}'\right]\right):$
 • Second, compute the first derivative three ways, one directly with the GenerateSignal command (for comparison), and two with the DifferentiateData using different options:
 > $Y≔\mathrm{GenerateSignal}\left(\frac{\partial }{\partial t}f,t=a..b,n,'\mathrm{includefinishtime}'='\mathrm{false}'\right):$
 > $\mathrm{Y1}≔\mathrm{DifferentiateData}\left(X,1,'\mathrm{step}'=\mathrm{dt},'\mathrm{method}'='\mathrm{central}','\mathrm{extrapolation}'='\mathrm{periodic}'\right):$
 > $\mathrm{Y2}≔\mathrm{DifferentiateData}\left(X,1,'\mathrm{step}'=\mathrm{dt},'\mathrm{method}'='\mathrm{spectral}'\right):$
 • The central approximation for the first derivative is fairly accurate, and the spectral approximation is exceptionally accurate:
 > $\mathrm{RelativeRootMeanSquareError}\left(\mathrm{Y1},Y\right)$
 ${0.00753297720724115192}$ (4)
 > $\mathrm{RelativeRootMeanSquareError}\left(\mathrm{Y2},Y\right)$
 ${4.82327325373904705}{×}{{10}}^{{-15}}$ (5)
 • Third, compute the second derivative, again in three ways, and calculate the accuracy of the approximations:
 > $Z≔\mathrm{GenerateSignal}\left(\frac{{\partial }^{2}}{\partial {t}^{2}}f,t=a..b,n,'\mathrm{includefinishtime}'='\mathrm{false}'\right):$
 > $\mathrm{Z1}≔\mathrm{DifferentiateData}\left(X,2,'\mathrm{step}'=\mathrm{dt},'\mathrm{method}'='\mathrm{central}','\mathrm{extrapolation}'='\mathrm{periodic}'\right):$
 > $\mathrm{Z2}≔\mathrm{DifferentiateData}\left(X,2,'\mathrm{step}'=\mathrm{dt},'\mathrm{method}'='\mathrm{spectral}'\right):$
 • As with the first derivative, the approximations for the second derivative are fairly accurate (but less so than for the first derivative):
 > $\mathrm{RelativeRootMeanSquareError}\left(\mathrm{Z1},Z\right)$
 ${0.0250341382145814959}$ (6)
 > $\mathrm{RelativeRootMeanSquareError}\left(\mathrm{Z2},Z\right)$
 ${7.35080030302369947}{×}{{10}}^{{-14}}$ (7)
 • Visually:
 > $\mathrm{dataplot}\left(T,\left[X,Y,Z\right],'\mathrm{style}'='\mathrm{line}','\mathrm{color}'=\left['\mathrm{blue}','\mathrm{darkgreen}','\mathrm{purple}'\right],'\mathrm{legend}'=\left["Signal","First derivative","Second derivative"\right]\right)$
 • When we constructed the data, we omitted the point at $t=2\mathrm{\pi }$ since it corresponds to the point at $t=0$. If the final point is included, the spectral approximation for the derivative is greatly affected at the endpoints:
 > $U,h,V≔\mathrm{GenerateSignal}\left(f,t=a..b,n,'\mathrm{includefinishtime}'='\mathrm{true}','\mathrm{output}'=\left['\mathrm{times}','\mathrm{timestep}','\mathrm{signal}'\right]\right):$
 > $\mathrm{W1}≔\mathrm{GenerateSignal}\left(\frac{\partial }{\partial t}f,t=a..b,n,'\mathrm{includefinishtime}'='\mathrm{true}'\right):$
 > $\mathrm{W2}≔\mathrm{DifferentiateData}\left(V,1,'\mathrm{step}'=h,'\mathrm{method}'='\mathrm{spectral}'\right):$
 > $\mathrm{RelativeRootMeanSquareError}\left(\mathrm{W2},\mathrm{W1}\right)$
 ${0.106321866987499819}$ (8)
 > $\mathrm{RelativeRootMeanSquareError}\left({\mathrm{W2}}_{20..-20},{\mathrm{W1}}_{20..-20}\right)$
 ${0.00768251003253226511}$ (9)

Example 3

 • First, generate a signal:
 > $f≔\mathrm{piecewise}\left(t<\mathrm{Pi}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}\mathbf{or}\phantom{\rule[-0.0ex]{0.5em}{0.0ex}}3\mathrm{Pi}
 ${f}{≔}\left\{\begin{array}{cc}{\mathrm{sin}}{}\left({4}{}{t}\right){+}{5}& {t}{<}{\mathrm{\pi }}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{\mathbf{or}}\phantom{\rule[-0.0ex]{0.3em}{0.0ex}}{3}{}{\mathrm{\pi }}{<}{t}\\ \frac{{\mathrm{sin}}{}\left({40}{}{t}\right)}{{10}}{+}{5}& {\mathrm{otherwise}}\end{array}\right\$ (10)
 > $a≔0:$
 > $b≔4\mathrm{Pi}:$
 > $n≔{2}^{14}:$
 > $X,\mathrm{dt}≔\mathrm{GenerateSignal}\left(f,t=a..b,n,'\mathrm{includefinishtime}'='\mathrm{false}','\mathrm{output}'=\left['\mathrm{signal}','\mathrm{timestep}'\right]\right):$
 • Second, compute the first and second derivatives, both directly and numerically:
 > $\mathrm{D1X1}≔\mathrm{DifferentiateData}\left(X,1,'\mathrm{step}'=\mathrm{dt},'\mathrm{method}'='\mathrm{spectral}'\right):$
 > $\mathrm{D2X1}≔\mathrm{DifferentiateData}\left(X,2,'\mathrm{step}'=\mathrm{dt},'\mathrm{method}'='\mathrm{spectral}'\right):$
 > $\mathrm{D1X2}≔\mathrm{GenerateSignal}\left(\frac{\partial }{\partial t}f,t=a..b,n,'\mathrm{includefinishtime}'='\mathrm{false}'\right):$
 > $\mathrm{D2X2}≔\mathrm{GenerateSignal}\left(\frac{{\partial }^{2}}{\partial {t}^{2}}f,t=a..b,n,'\mathrm{includefinishtime}'='\mathrm{false}'\right):$
 > $\mathrm{RelativeRootMeanSquareError}\left(\mathrm{D1X1},\mathrm{D1X2}\right)$
 ${3.52534042480501931}{×}{{10}}^{{-7}}$ (11)
 > $\mathrm{RelativeRootMeanSquareError}\left(\mathrm{D2X1},\mathrm{D2X2}\right)$
 ${0.0000559512699727594801}$ (12)
 • Finally, plot the first and second derivatives:
 > $\mathrm{SignalPlot}\left(X,'\mathrm{title}'="Plot of Signal",'\mathrm{color}'='\mathrm{blue}'\right)$
 > $\mathrm{SignalPlot}\left(\mathrm{D1X1},'\mathrm{title}'="Plot of First Derivative",'\mathrm{color}'='\mathrm{blue}'\right)$
 > $\mathrm{SignalPlot}\left(\mathrm{D2X1},'\mathrm{title}'="Plot of Second Derivative",'\mathrm{color}'='\mathrm{blue}'\right)$

Example 4

 • Complex data can also be differentiated:
 > $T,\mathrm{dt},X≔\mathrm{GenerateSignal}\left({t}^{2}{ⅇ}^{-It},t=0..5,{10}^{4},'\mathrm{output}'=\left['\mathrm{times}','\mathrm{timestep}','\mathrm{signal}'\right]\right):$
 > $\mathrm{DX}≔\mathrm{DifferentiateData}\left(X,1,'\mathrm{step}'=\mathrm{dt},'\mathrm{method}'='\mathrm{forward}','\mathrm{extrapolation}'='\mathrm{spline}'\right):$
 > $\mathrm{X1},\mathrm{X2}≔\mathrm{ComplexToReal}\left(X\right):$
 > $\mathrm{DX1},\mathrm{DX2}≔\mathrm{ComplexToReal}\left(\mathrm{DX}\right):$
 > $\mathrm{dataplot}\left(T,\left[\mathrm{X1},\mathrm{DX1}\right],'\mathrm{style}'='\mathrm{line}','\mathrm{title}'="Signal",'\mathrm{legend}'=\left["Real part","Imaginary part"\right],'\mathrm{color}'=\left['\mathrm{red}','\mathrm{blue}'\right]\right)$
 > $\mathrm{dataplot}\left(T,\left[\mathrm{X2},\mathrm{DX2}\right],'\mathrm{style}'='\mathrm{line}','\mathrm{title}'="First Derivative",'\mathrm{legend}'=\left["Real part","Imaginary part"\right],'\mathrm{color}'=\left['\mathrm{red}','\mathrm{blue}'\right]\right)$

Example 5

 • The Savitzky-Golay method can also be used to estimate the derivative:
 > $f≔\mathrm{sin}\left(t\right)+5{ⅇ}^{It}\mathrm{cos}\left(3t\right)+10$
 ${f}{≔}{\mathrm{sin}}{}\left({t}\right){+}{5}{}{{ⅇ}}^{{I}{}{t}}{}{\mathrm{cos}}{}\left({3}{}{t}\right){+}{10}$ (13)
 > $a≔0$
 ${a}{≔}{0}$ (14)
 > $b≔2\mathrm{Pi}$
 ${b}{≔}{2}{}{\mathrm{\pi }}$ (15)
 > $n≔250$
 ${n}{≔}{250}$ (16)
 > $\mathrm{dt},X≔\mathrm{GenerateSignal}\left(f,t=a..b,n,'\mathrm{includefinishtime}'='\mathrm{false}','\mathrm{output}'=\left['\mathrm{timestep}','\mathrm{signal}'\right]\right):$
 > $Y≔\mathrm{DifferentiateData}\left(X,1,'\mathrm{step}'=\mathrm{dt},'\mathrm{method}'='\mathrm{savitzkygolay}','\mathrm{frameradius}'=10,'\mathrm{extrapolation}'='\mathrm{periodic}','\mathrm{degree}'=3\right):$
 • Comparing with the actual derivative:
 > $Z≔\mathrm{GenerateSignal}\left(\frac{\partial }{\partial t}f,t=a..b,n,'\mathrm{includefinishtime}'='\mathrm{false}'\right):$
 > $\mathrm{RelativeRootMeanSquareError}\left(Y,Z\right)$
 ${0.00205478287629157685}$ (17)

Compatibility

 • Since internal commands are now compiled in external code, the compiled option is now deprecated. For backwards compatibility, the command can still be passed, but it will be ignored.
 • The SignalProcessing:-DifferentiateData command was introduced in Maple 2022.
 • For more information on Maple 2022 changes, see Updates in Maple 2022.
 • The SignalProcessing:-DifferentiateData command was updated in Maple 2023.
 • The frameradius option was introduced in Maple 2023.
 • The method and compiled options were updated in Maple 2023.
 • For more information on Maple 2023 changes, see Updates in Maple 2023.
user
The text passage is a detailed documentation of the `DifferentiateData` command in Maple, which is used to compute the derivative of a 1-D rtable of data. The passage includes a description of the command, its parameters, options, and several examples demonstrating its usage.

TYPE: NO_QUESTION

The passage does not contain any explicit mathematical questions or problems that require solving. It is primarily a reference document explaining how to use the `DifferentiateData` command in Maple.