Pavel Holoborodko Applied mathematics and beyond Home MPFR C++ Numerical Methods QuickLaTeX Image Processing About Central Differences The most common way of computing numerical derivative of a function at any point is to approximate by some polynomial in the neighborhood of . It is expected that if selected neighborhood of is sufficiently small then approximates near well and we can assume that . Let’s consider this approach in details (or go directly to the table of formulas). At first, we sample at the ( is odd) equidistant points around : , where is some step. Then we interpolate points by polynomial of degree: . Its coefficients are found as a solution of system of linear equations: By our assumption can be approximated by the derivative of the constructed interpolating polynomial: To illustrate the process let’s consider case when for simplicity): . Here interpolating parabola are defined by the system (we assume After subtracting first equation from the last we get final result: In the same way we can obtain expressions for any . Formulas for are listed below: These expressions are very widely used in numerical analysis and commonly refered as central(finite) differences. As it can be clearly seen they have simple anti-symmetric structure and in general difference of -th order can be written as: , where are coefficients derived by procedure described above. It is easy to see that if is a polynomial of a degree , then central differences of order give precise values for derivative at any point. This follows from the fact that central differences are result of approximating by polynomial. If is a polynomial itself then approximation is exact and differences give absolutely precise answer. To differentiate a digital signal we need to use h=1/SamplingRate and replace case derivative of a signal is found by Frequency response of central differences is: Magnitude responses for are drawn below: by in the expressions above. In this Red dashed line is the magnitude response of an ideal differentiator differentiator response (by increasing tangency order with at . As grows moves closer to ideal ). In practice there is no need for ideal differentiators because usually signals contain noise at high frequencies which should be suppresed. This means that response of practical differentiator should be close to on some passband interval and should tend to zero in the upper part of Nyquist interval . From the plot we can see that central differences don’t resemble such behavior, all they care about is to get as closer as possible to the response of ideal differentiator, without supression of noisy high frequencies. As a consequence they perform well only on exact values, which contain no noise. Different technique is needed for robust derivative estimation of noisy signals. Such approaches are considered in the next sections: Savitzky-Golay/Low-noise Lanczos differentiators Smooth noise-robust differentiators (28 votes, average: 4.68) 80 Comments Kem Posted February 19, 2009 at 8:32 pm | # Hi Pavel, great tutorial! How can this be done for the second derivatives f”(x) and also for the 2D case , especially how can we approximate d^2 f(x,y) / dxdy with different orders of approximation Thank you! Reply Pavel Holoborodko Posted February 20, 2009 at 5:42 pm | # Thanks, Kem.