Fourth order accurate approx

numerical methods

Prove that the following is a fourth order accurate approximation of the second derivative of a function $f$: $$f''(x_0) = \frac{-f(x_0+2h)+16f(x_0+h)-30f(x_0)+16(x_0-h)-f(x_0-2h)}{12h^2} + O(h^4)$$ Find the leading order error term.

Here are my workings below,
1. Are they correct?
2. How do I find the leading order error term? looking for some help with this

Using taylor expansion:

$$
f(x_0+h) =
f(x_0) + h f'(x_0) + \frac{h^2}{2} f''(x_0)
+ \frac{h^3}{6} f'''(x_0)
+ O(h^4)
$$

$$
f(x_0-h) =
f(x_0) – h f'(x_0) + \frac{h^2}{2} f''(x_0)
– \frac{h^3}{6} f'''(x_0)
+ O(h^4)
$$

$$
f(x_0+2h) =
f(x_0) + 2h f'(x_0) + 2 h^2 f''(x_0)
+ \frac{4 h^3}{3} f'''(x_0) + O(h^4)
$$

$$
f(x_0-2h) =
f(x_0) – 2h f'(x_0) + 2 h^2 f''(x_0)
– \frac{4 h^3}{3} f'''(x_0)
+ O(h^4)
$$

Calculate:
$$
-f(x_0 + 2h) + 16f(x_0 + h) – 30f(x_0) + 16f(x_0 – h) – f(x_0 -2h)
$$

Which is
$$
\begin{aligned}
&
– \left[
f(x_0) + 2h f'(x_0) + 2 h^2 f''(x_0)
+ \frac{4 h^3}{3} f'''(x_0)
\right]
\\
&
+16
\left[
f(x_0) + h f'(x_0) + \frac{h^2}{2} f''(x_0)
+ \frac{h^3}{6} f'''(x_0)
\right]
\\
&
-30
f(x_0)
\\
&
+16
\left[
f(x_0) – h f'(x_0) + \frac{h^2}{2} f''(x_0)
– \frac{h^3}{6} f'''(x_0)
\right]
\\
&

\left[
f(x_0) – 2h f'(x_0) + 2 h^2 f''(x_0)
– \frac{4 h^3}{3} f'''(x_0)
\right]
\\
&
+ O(h^4)
\end{aligned}
$$

Which evaluates to
$
12 h^2
$

to give the required result.

Best Answer

No, your expression evaluates to $12h^2\color{red}{f''(x_0)+O(h^4)}$, not $12h^2$, which doesn't give you the error estimate $+O(h^4)$ (only $+O(h^2)$) after you divide by the denominator $12h^2$.

To get the explicit $O(h^4)$ term means you need to expand to order (at least) 6. To save space, I'll note that since the numerator $$S:=-f(x_0+2h)+16 f(x_0+h)-30 f(x_0)+16 f(x_0-h)-f(x_0-2h)$$ is even in $h$ only the even-order derivatives appear. Writing $[h^n]F$ for the coefficient of $h^n$ in the Taylor series expansion of a (sufficiently smooth) function $F(h)$, we have \begin{align} [h^n](f(x_0+mh))&=[h^n]\left(\sum_{j=0}^n f^{(j)}(x_0)\frac{(mh)^j}{j!}+o(h^n)\right)\\ &=\frac{f^{(n)}(x_0)}{n!}m^n \end{align} so $$ \boxed{\color{blue}{[h^n]S=\frac{f^{(n)}(x_0)}{n!}\bigg[-(2)^n+16(1)^n-30(0)^n+16(-1)^n-(-2)^n\bigg]}} $$ For even $n>0$, $$ -(2)^n+16(1)^n-30(0)^n+16(-1)^n-(-2)^n =-2(2^n-16) $$ So we can write down the coefficients immediately \begin{align} [1]S&=0\\ [h^2]S&=\frac{-2(2^2-16)}{2!}f^{(2)}(x_0)=12f''(x_0)\\ [h^4]S&=0\\ [h^6]S&=\frac{-2(2^6-16)}{6!}f^{(6)}(x_0)=-\frac{2}{15}f^{(6)}(x_0). \end{align} Hence $$ S=12f''(x_0)h^2-\frac{2}{15}h^6f^{(6)}(x_0)+o(h^6), $$ which rearranges to $$ f''(x_0)=\frac{S}{12h^2}+\left(\frac{1}{90}f^{(6)}(x_0)+o(1)\right)h^4. $$ I.e., the leading order error term is $\frac{1}{90}f^{(6)}(x_0)h^4$.