This section is about methods of calculation derivative numerically. Description covers classic central differences, Savitzky-Golay (or Lanczos) filters for noisy data and original smooth differentiators.
This section is about methods of calculation derivative numerically. Description covers classic central differences, Savitzky-Golay (or Lanczos) filters for noisy data and original smooth differentiators.
6 Comments
Pavel,
I like your neat website, but I have one comment regarding your smooth noise-robust differentiation formulas. In the attached Excel spreadsheet I compare your formula for first-order differentiation for N = 5 with that for central differencing, either using no input noise (as when used in optimizing software) or with noisy input data. I use a highly nonlinear test function, F(x) = x20, with a simple x0-value, x0 = 1.234, and plot the results as the negative 10-based logarithm (“p”, as in pH) of the absolute error (“E”) as a function of the negative logarithm of the step amplitude h.
(Some notes on nomenclature. In the spreadsheet I use j instead of your N (which in statistical data analysis usually refers to the number of data or samples taken), and d (for distance) instead of your h (for height). My pE is sometimes called LRE, for logarithm of the relative error, but here it is the negative logarithm of the absolute error. The added noise is from Excel’s Random number generator, under Tools > Data analysis, and I have used a small relative error in x0.)
The interesting result is that central differencing is superior (as long as one can find the optimum step size, for which I recently published an algorithm, see http://www.ias.ac.in/chemsci/Pdf-Sep2009/935.pdf for noise-free data, but that they become equivalent with almost any realistic amount of external noise (which I here distinguish from the cancellation noise generated “internally” by the computer). Your formulas do have a small advantage at very small d-values, where the cancellation noise is reduced because your formulas in general use smaller coefficients, in the example illustrated –1, –2, 0, 2, 1 versus 1, –8, 0, 8, –1, while the tables are turned in the region of large d-values (small pd). But in the broad region where the external noise dominates, the results appear to be identical.
I did not test the Lanczos formula, but it appears to be rather equivalent to yours in these respects.
Am I missing something?
Bob
Dear Robert,
Thank you very much for your feedback.
I am sorry for the late answer.
Let me make some comments on your comparisons.
1. Case when input data contain no noise.
Central difference formula (-1,-8,0,8,1) has approximation order of .
Whereas noise robust differentiator (NRD) your are comparing to has only .
So, it is only natural that difference outperforms NRD in such unfair conditions.
It would be fair to compare noise robust differentiators from the second table with the same approximating property as central difference (-1,-8,0,8,1) has.
For example, please try this one: (-5,-12,-39,0,39,12,5).
Or it would be fair to compare (-1,-2,0,2,1) with difference (-1,0,1) which also has error term.
2. Case when input data contain noise.
NRD filter (-1,-2,0,2,1) has the weakest noise suppression capability of all family of smooth differentiators. It just suppresses high frequency noise near . If data contain noise in lower frequencies than longer NRD filters should be used to suppress it.
That is the beauty of NRD filters – they can be selected flexibly based on data properties.
As longer NRD filters as stronger noise suppression.
To see this clearly please try longer filter like :
where
NRD filters uses their degrees of freedom to balance between approximation order and noise suppression. Central differences uses all coefficients to attain maximum approximation order.
This is a little confusing but allows great flexibility. For instance, we have only one central
difference which produce exact derivative for : (-1,-8,0,8,1).
Whereas we have the whole family of noise robust differentiators of such approximation order, ranging from ones with weak noise suppression(short filters) to filters with any desired noise suppression capability (long filters).
Hope this could be of some help.
Dear Avel
I like this website, and i am performing one study about electronic properties of low-dimensional structures. May be the central differences method could be emplpyed to calculate my problems. However my mathematical programm ability is poor. Could you provide some examples about solving 3 D shrodinger equation in this website. I think most peopole will like them.
Hi Pavel,
I just started using you QuickLatex plugin and it’s great. The plugin works great, but I wanted to know how I could get my latex to display as sharp as it does on your website. It may be the theme I am using (Tarski), but I am not sure. Here is my web page with some latex on it
http://kennychowdhary.me/
As you can see, the latex works fine, but the sharpness is so much nicer on your web page. Any thoughts?
Thanks,
Kenny
Dear Pavel,
I found your website very interesting and helpful for me in solving an engineering problem (honestly, it is the only website
providing me direct help.)
I will cite your website in a manuscript correspondingly.
Unfortunately, I cannot rederive all of the proposed equations but will compare the numerical derivatives
with suitable analytical derivatives.
My question concerns:
(a) your approximation of (posted on February 20, 2009);
your expression is valid for .
Can you eventually provide me also with the corresponding derivative for
?
(b) Amins expressions for and , posted
on March 31, 2012, are of interest for me.
You answered, that ‘at first glance’ this formulas seems to be all right.
Can you confirm the correctness of the derivatives? Your own third-order derivatives employ at least 5 points,
Amins expression does only employ 3 points (which must not be incorrect, of course).
I want to implement this in my application (calculation of combined uncertainties for highly nonlinear functions).
Thus, a confirmation or 5-point approximation would be very helpful.
Many thanks in advance
Olaf
Dear Olaf,
(a). Just use in denominator instead of .
(b). I think Amin’s expression is correct.
Sorry for delayed reply.
Pavel.