# Approximation of derivative of discrete function

I have a function of which I only know the value of at some discrete points. Now I want to calculate the derivative of this function. The approximation of taking the difference of two consecutive values is not good enough for my purpose. In a book about my field of study they propose the formula

$\Delta f(x) = (\sum_{l=-L}^L l * f(x+l)) / (\sum_{l=-L}^L l^2)$

to calculate a better approximation of the derivative. They approximate the discrete function by a polynomial in an interval of $2L+1$ discrete steps. L usually takes a value between 1 and 3 in this case. Indeed this formula archives better results but I would like to know a bit more about this formula. How do we arrive there? Does it have a name? Are there other approximations that are better/worse? Unluckily I was not able to find this formula or a similar one on-line.

This looks just as the solution of the equation for the least-square problem for the model $$y=a x$$ based on $n$ data points ($x_i,y_i$) $$a=\frac{\sum_{i=1}^n{x_i y_i}}{\sum_{i=1}^n{x_i ^2}}$$ I am sure you see the analogy.
• @balea: I don't like this formula very much as it gives greater emphasis to data points far from the evaluation point. I think a weighting that decreases smoothly would be better, like that given by the convolution with the derivative of Gaussian, $-\xi e^{-\xi^2/2\sigma^2}/\sqrt{2\pi}\sigma^3$ (Gaussian derivative). – Yves Daoust Jul 29 '15 at 10:24