Simpson’s rule using Taylor polynomial

simpsons rule

From a proof of Simpson's rule using Taylor polynomial where $f\in[x_{0},x_{2}]$ and, for
$$x_{1}=x_{0}+h$$
where
$$h=\frac{x_{2}-x_{0}}{2}$$,
it got:
$$\int_{x_{0}}^{x_{2}}f(x)dx\cong2hf(x_{1})+h^{3}\frac{f''(x_{1})}{3}+h^{5}\frac{f^{(4)}(\xi)}{60}$$
and then, it changed $f''(x_{1})$ by
$$\frac{f(x_{0})-2f(x_{1})+f(x_{2})}{h^{2}}$$
And I don't know from where it came.

Best Answer

The author of the proof replaces $f''(x_1)$ with its second-order central finite difference formula. Given a small $h>0$ which represents the difference between grid points $x_j$ and $x_{j-1}$, the formula can be derived by adding the two Taylor expansions

$$f(x-h)=f(x)-hf'(x)+\frac{h^2f''(x)}{2!}-\frac{h^3f'''(x)}{3!}+\mathcal{O}(h^4)$$ and $$f(x+h)=f(x)+hf'(x)+\frac{h^2f''(x)}{2!}+\frac{h^3f'''(x)}{3!}+\mathcal{O}(h^4)$$

to form

$$f(x-h)+f(x+h)=2f(x)+h^2f''(x)+\mathcal{O}(h^4)$$

which after subtracting $2f(x)$ and dividing by $h^2$ produces

$$f''(x)\approx \frac{f(x-h)-2f(x)+f(x-h)}{h^2}$$

in your case the grid points are $x=x_1$, $x-h=x_0$, and $x+h=x_2$ therefore

$$f''(x_1)\approx \frac{f(x_0)-2f(x_1)+f(x_2)}{h^2}$$