Is there any generalized way to calculate numerical differentiation using a certain number of points? I have found 2-point and 5-point methods, but could not find information about using any other number of points. I am interested in doing 3-point, but am not sure if this would be practical or possible.
Asked
Active
Viewed 1.5k times
6
-
4Something like $\frac{3f(x)-4f(x-h)+f(x-2h)}{2h}=f'(x)+O(h^2)$ is used for boundary conditions. – Lutz Lehmann Oct 27 '15 at 15:10
-
2Here is a table: https://en.wikipedia.org/wiki/Finite_difference_coefficients#Forward_and_backward_finite_difference – gammatester Oct 27 '15 at 15:12
1 Answers
9
The general method is as follows.
- Decide which points you want to use: maybe $x-2h$, $x+h$ and $x+3h$ for some reason. Here $x$ refers to the point at which I want to compute the derivative.
- Write down Taylor expansions for those points, centered at $x$. Use as many terms as you have points: $$f(x-2h) = f(x) - 2h f'(x) + 2h^2 f''(x)+O(h^3) $$ $$f(x+h) = f(x) + h f'(x) + 0.5 h^2 f''(x)+O(h^3) $$ $$f(x+3h) = f(x) + 3h f'(x) + 4.5 h^2 f''(x)+O(h^3) $$
- Find a linear combination of these lines that eliminates all derivatives except the one you want, and makes the coefficient of that derivative $1$. This means solving a linear system of $3$ equations with $3$ unknowns, in the above case. If $f'(x)$ is desired, the combination is $$ -\frac{4}{15h}f(x-2h) + \frac1{6h} f(x+h) + \frac{1}{10h} f(x+3h) = f'(x) +O(h^2) $$