Central Difference Approximations Hi Guys I was going through the different approximations which can be used for differentiation such as the forward difference, the backward difference and lastly the central difference approximations. I am currently looking into the finite difference method which is used to solve differential equations and i cam across the following.
The different central difference approximations for the first four derivatives as shown :
$$y'_ = \frac{y_{i+1} - y_{i-1}}{2h}$$
$$y''_i = \frac{y_{i+1} - 2y_i + y_{i-1}}{h^2}$$
$$y'''_i = \frac{y_{i+2} -2y_{i+1} + 2y_{i-1}- y_{i-2}}{2h^3}$$
$$y''''_i = \frac{y_{i+2} -4y_{i+1} + 6y_i - 4y_{i-1} + y_{i-2}}{h^4}$$
I was attempting to understand the derivation of the methods by use of the taylor series:
$$f(x+h) = f(x) +hf'(x)+h^2f''(x)/2!+h^3f'''(x)/3!+h^4f''''(x)/4!$$ + ...
$$f(x_h) = f(x) -hf'(x)+h^2f''(x)/2!-h^3f'''(x)/3!+h^4f''''(x)/4!$$ - ...
Therefore considering f'''(x) and trying to obtain the expressions as shown above this is my evaluation:
$$f(x+h)-f(x-h) = 2hf'(x) + \frac{2h^3f'''(x)}{3!}$$
Rearranging gives the following
$$3![\frac{f(x+h)-2hf'(x)-f(x-h)}{2h^3}] = f'''(x)$$
I know that f'(x) can be used as 
$$y'_i = \frac{y_{i+1} - y_{i-1}}{2h}$$
When i substitute this into the above equation it goes to zero and im confused as to how they get the expression for f'''(x)
Can anyone help me with the derivation for f'''(x) as to how it is obtained and I am trying to evaluate f'''''(x) (5th) derivative does anyone know what this central difference approximation will be ?
 A: Consider a function that is smooth in a neighborhood of a point $x$. Then, we can approximate its derivatives using values of the function at specified mesh points. Suppose the mesh spacing is $h$, then the mesh points are $...,x-3h,x-2h,x-h,x,x+h,x+2h,x+3h,...$ . Using Taylor's theorem we derive the first, second, third, and fourth order central approximation formulas. 
First Order Central Difference: Starting from
$$f(x+h) = f(x)+hf'(x)+\frac1{2}f''(\xi_2)h^2,$$
subtract
$$f(x-h) = f(x)-hf'(x)+\frac1{2}f''(\xi_2')h^2,$$
and then divide by $2h$ to form
$$f'(x)\approx \frac{f(x+h)-f(x-h)}{2h}.$$
Second Order Central Difference: Starting from
$$f(x+h) = f(x) + f'(x)h + \frac1{2}f''(x)h^2 +\frac1{6}f'''(\xi_3)h^3$$
add
$$f(x-h) = f(x) - f'(x)h + \frac1{2}f''(x)h^2 -\frac1{6}f'''(\xi'_3)h^3,$$
and then divide by $h^2$ to form
$$f''(x)\approx\frac{f(x-h)-2f(x)+f(x+h)}{h^2}.$$
Third Order Central Difference: Starting from
$$
\begin{align}
f(x+h) & = f(x) + f'(x)h+f''(x)\dfrac{h^2}{2}+ f'''(x)\dfrac{h^3}{6} + f^{(4)}(x)\dfrac{h^4}{24} + f^{(5)}(\xi_5)\dfrac{h^5}{120},\\
f(x-h) & = f(x) - f'(x)h+f''(x)\dfrac{h^2}{2}- f'''(x)\dfrac{h^3}{6} + f^{(4)}(x)\dfrac{h^4}{24} - f^{(5)}(\xi_5')\dfrac{h^5}{120},\\
f(x+2h) & = f(x) + f'(x)2h+f''(x)2h^2+ f'''(x)\dfrac{4h^3}{3} + f^{(4)}(x)\dfrac{2h^4}{3} + f^{(5)}(\xi_5'')\dfrac{4h^5}{15},\\
f(x-2h) & = f(x) - f'(x)2h+f''(x)2h^2- f'''(x)\dfrac{4h^3}{3} + f^{(4)}(x)\dfrac{2h^4}{3} - f^{(5)}(\xi_5''')\dfrac{4h^5}{15},\\
\end{align}$$
calculate
$$f(x+2h)-f(x-2h)-2\left(f(x+h)-f(x-h)\right),$$
where
$$f(x+2h)-f(x-2h)=4hf'(x)+\frac{8h^3}{3}f'''(x)+f^{(5)}(\tilde{\xi_5})\dfrac{2h^5}{120},$$
$$2\left(f(x+h)-f(x-h)\right)=4hf'(x)+\frac{4h^3}{6}f'''(x)+f^{(5)}(\tilde{\tilde{\xi_5}})\dfrac{8h^5}{15},$$
to form
$$f(x+2h)-f(x-2h)-2\left(f(x+h)-f(x-h)\right)=2h^3f'''(x)-f^{(5)}(\tilde{\tilde{\tilde{\xi_5}}})\dfrac{31h^5}{60},$$
therefore dividing by $2h^3$ forms
$$f'''(x)\approx\frac{f(x+2h)-2f(x+h)+2f(x-h)-f(x-2h)}{2h^3}.$$
Fourth Order Central Difference: Calculate
$$f(x+2h)+f(x-2h)-4\left(f(x+h)+f(x-h)\right)+6f(x),$$
where
$$f(x+2h)+f(x-2h)=2f(x)+4h^2f''(x)+\frac{4h^4}{3}f^{(4)}(x)+f^{(6)}(\xi_6)\dfrac{8h^6}{45},$$
$$-4\left(f(x+h)+f(x-h)\right)=-8f(x)-4h^2f''(x)-\frac{h^4}{3}f^{(4)}(x)-f^{(6)}(\xi_6')\dfrac{h^6}{90},$$
to form
$$f(x+2h)+f(x-2h)-4\left(f(x+h)+f(x-h)\right)+6f(x)=h^4f^{(4)}(x)+f^{(6)}(\xi_6'')\dfrac{h^6}{6},$$
therefore dividing by $h^4$ forms
$$f^{(4)}(x)\approx\frac{f(x+2h)-4f(x+h)+6f(x)-4f(x-h)+f(x-2h)}{h^4}.$$
As an alternative to Taylor series expansions, one can use the method of undetermined coefficients to derive higher order approximations.
A: Let $f:\mathbb{R}\rightarrow\mathbb{R}$ be a smooth function in a neighborhood of $x_0$.  Define $g(x) = f(x+x_0) - f(x_0)$.  Then $g^{(n)}(0) = f^{(n)}(x_0)$ for $n \ge 1$ and $g(0)=0$.  If we approximate $g(x)$ with a degree $n+1$ polynomial $p(x) = \sum_{i=0}^{n+1} a_i x^{n+1-i}$ by setting $p(jh) = g(jh)$ for $j=-\lceil n/2\rceil, -\lceil n/2\rceil+1, \dots \lceil n/2\rceil$ and solve this linear system of equations for the coefficients $a_i$, the central difference approximation for $g^{(n)}(0) = f^{(n)}(x_0)$ will be $p^{(n)}(0)=n!a_1$.  For $n=5$,
$$
p(x)=a_0x^6 + a_1x^5 + a_2x^4 + a_3x^3 + a_4x^2 + a_5x
$$
with $a_6=0$ since $p(0) = g(0) = 0$.  The linear system of equations is:
$$
  \begin{pmatrix}
  243h^5 & 81h^4 & 27h^3 & 9h^2 & 3h & 1 \\ 
  32h^5 & 16h^4 & 8h^3 & 4h^2 & 2h & 1 \\
  h^5 & h^4 & h^3 & h^2 & h & 1 \\
  h^5 & -h^4 & h^3 & -h^2 & h & -1 \\
  32h^5 & -16h^4 & 8h^3 & -4h^2 & 2h & -1 \\
  243h^5 & -81h^4 & 27h^3 & -9h^2 & 3h & -1
  \end{pmatrix}
  \begin{pmatrix}
  a_0\\
  a_1\\
  a_2\\
  a_3\\
  a_4\\
  a_5
  \end{pmatrix}
  =
  \begin{pmatrix}
  g(3h) / (3h) \\
  g(2h) / (2h) \\
  g(h) / h \\
  g(-h) / h \\
  g(-2h) / (2h) \\
  g(-3h) / (3h)
  \end{pmatrix}.
$$
The system of equations can be easily reduced to 
$$
  \begin{pmatrix}
  1 & 9h^2 & 81h^4 \\
  1 & 4h^2 & 16h^4 \\
  1 & h^2 & h^4
  \end{pmatrix}
  \begin{pmatrix}
  a_5\\
  a_3\\
  a_1
  \end{pmatrix}
  =
  \begin{pmatrix}
  d_1\\
  d_2\\
  d_3
  \end{pmatrix}
  =
  \begin{pmatrix}
  (g(3h) - g(-3h))/(6h) \\
  (g(2h) - g(-2h))/(4h) \\
  (g(h) - g(-h))/(2h)
  \end{pmatrix}.
$$
Gaussian elimination shows that 
$$
p^{(5)}(0) = 120a_1 = (3d_1 - 8d_2 + 5d_3)/h^4.
$$
So the 5th order derivative central difference approximation is
$$
  f^{(5)}(x_0) \approx \frac{f(x_0+3h) - f(x_0-3h) - 4(f(x_0+2h) - f(x_0-2h)) + 5(f(x_0+h) - f(x_0-h))}{2h^5}
$$
since $g(jh) - g(-jh) = f(x_0+jh) - f(x_0-jh)$.
