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 ?
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.