I have a signal sampled at $\Delta t$: $f_i(t_i=i\Delta t)$ where $i = 0,\ldots,n-1$. I want to find the first and second derivative of the signal: $f'(t)$ and $f''(t)$.

My first thought was to estimate the derivatives by central differences:

\begin{align} f'(t_{i})&=\frac{f(t_{i+1})-f(t_{i-1})}{2\Delta t}\\ f''(t_{i})&=\frac{f(t_{i+1})-2f(t_{i})+f(t_{i-1})}{(\Delta t)^2} \end{align}

However the signal may have a lot of high frequency noise that may cause quick fluctuations in $f'$ and $f''$.

What would be the best way to find "smoothed" estimates of $f'$ and $f''$?


2 Answers 2


It probably depends more on your data. Just know, since differentiation is a linear operation, if you choose any linear filter to smooth f' and f'', it is equivalent to smoothing f using that same filter, then taking its derivatives.

Can you post some pictures or more information about the signal you want to differentiate? Probably what you're looking for is some sort of lowpass filter to smooth the signal. A couple really simple options include a single-pole recursive filter like $y(n) = a \cdot x(n) + (1-a) \cdot y(n-1)$, or a Hann filter, which is just convolving the signal with a Hann window. The Hann filter option is nice because it's linear-phase. If you know the frequency range you care about, you can just design a suitable lowpass filter in the frequency domain.

  • $\begingroup$ Thanks schnarf! So since smoothing followed by differentiation is equal to differentiation followed by smoothing; I may as well smooth the original signal by convolving with e.g. the Hann window? How about the simpler approach of using a finite difference over a larger span: f'(t)~=[f(t+10*Dt)-f(t-10*Dt)]/(20*Dt), would this give a quite good estimate of a smoothed derivative? $\endgroup$
    – Andy
    Dec 19, 2011 at 7:53

The Savitzky-Golay filter provides smooth estimates of the signal and first few derivatives.

A MATLAB implementation can be found here.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.