I have a signal sampled at $\Delta t: fi(ti=i\Delta t)$ where i = 0..n-1. I want to find the first derivative of the signal: f'(t).
My first thought was to estimate this by a central difference:
$f'(t_i) =\frac{f(t_{i+1})−f(t_{i−1})}{2\Delta t}$
However the signal may have a lot of high frequency noise that may cause quick fluctuations in f'. I guess the proper thing might be to smooth the signal by convolving with a window function e.g., Hann and then find the derivative from the differences.
A colleague suggested a faster way of finding a smoothed estimate of the derivative: use a central difference over 2n samples, where n >> 1:
$f'(t_i) =\frac{f(t_{i+n})−f(t_{i−n})}{2n\Delta t}$
This would of course be computationally faster than first convolving with a window function but is it a good solution?
If we form the sum:
$S=2\Delta t[f'(t_{i-n+1})+f'(t_{i-n+2})+..+f'(t_{i+n-1})]$
and expand each derivative by the central difference with step $\Delta t$:
$S=f(t_{i-n+2})-f(t_{i-n})+f(t_{i-n+3})-f(t_{i-n+2})+..+f(t_{i+n})-f(t_{i+n-2})$
all terms except two cancels out:
$S=f(t_{i+n})-f(t_{i-n})=2n\Delta tf'(t_i)$
Therefore:
$f'(t_i)=\frac{1}{n}[f'(t_{i-n+1})+f'(t_{i-n+2})+..+f'(t_{i+n-1})]$
So taking the central difference over 2n samples is equivalent with first convolving by a rectangular window of size 2n - 2 and then taking a central difference over +/- 1 sample.
How "bad" is it to smooth with a rectangular window?
If we take the FFT this will cause "ringing", but we do not need to take the FFT.
Thanks in advance for any answers!