TITLE: How to obtain (prove) 5-stencil formula for 2nd derivative?
QUESTION [5 upvotes]: My question seems pretty easy. Prove the correctness of the following approximation:
$$f(x)''= \frac{-f(x-2h)+16f(x-h)-30f(x)+16f(x-h)-f(x+2h)}{12h^2}$$
I rendered myself deeply saddened upon stumbling on this and being seemingly unable solve it by my own. I also failed to find proof anywhere online. Only final answer.
The way I tried to it is via pretty common Taylor series expansion:
$$f(x+h) = f(x) + f'(x)h+\frac{1}{2!}f''(x)h^2+\frac{1}{3!}f^{(3)}(x)h^3 + \sum_{n=4}^\infty \frac{1}{n!}f^{(n)}(x)h^n\quad (1)$$
I cut it off after $f^{(3)}$.
I use this formula to get rest of the points to have 5-stencils, simply by substituting $h$ with $\{-h; 2h; -2h\}$ Thus I get:
$$f(x-h) = f(x) - f'(x)h+\frac{1}{2!}f''(x)h^2-\frac{1}{3!}f^{(3)}(x)h^3\quad (2)$$ 
$$f(x+2h) = f(x) + 2f'(x)h+\frac{4}{2!}f''(x)h^2+\frac{8}{3!}f^{(3)}(x)h^3\quad (3)$$
$$f(x-2h) = f(x) - 2f'(x)h+\frac{4}{2!}f''(x)h^2-\frac{8}{3!}f^{(3)}(x)h^3\quad (4)$$ 
When I use equations $(1)$ and $(2)$, and add them by sides, I can get the 3-point formula:
$$f(x+h) + f(x-h) = 2f(x) + f''(x)h^2\quad (5)$$
$$f''(x) = \frac{f(x-h) - f(2x) + f(x+h)}{h^2}$$
However when I try to do this with all the equations $(1)$-$(4)$ I get:
$$f(x+h) + f(x-h) = 2f(x) + f''(x)h^2 \quad (6)$$
$$f(x+2h) + f(x-2h) = 2f(x) +4f''(x)h^2\quad (7)$$ 
Then I can try subtracting $(6)$ from $(7)$ and I get:
$$f(x+h) + f(x-h) - f(x+2h) - f(x-2h) = 3 f''(x)h^2\quad (8)$$
which gives
$$f''(x) = \frac{f(x+h) + f(x-h) - f(x+2h) - f(x-2h) } {3 h^2} \quad(9)$$
This is clearly different from what I am expecting. Also doing $(6)$+$(7)$ doesn't seem to yield correct coefficients, even though it preserves $f(x)$ term.
Could you point out flaw in the approach and provide correct reasoning or any materials? All I found were very general or final answers with no explicit transformations. I feel kinda stupid being unable to get it right but I can't spot the flaw.

REPLY [3 votes]: You are on the right track, but you need to take the Taylor series up to the term in $h^4$. Add the series for $f(x+h)$ to the one for $f(x-h)$, which cancels the terms in $h$ and $h^3$, to obtain an expression involving only even powers of $h$. Do the same for the series for $f(x+2h)$ and $f(x-2h)$ to get another expression involving $h^2$ and $h^4$. Now take $16$ times the first expression from the latter one to eliminate $h^4$, and rearrange algebraically to get the required result.
This method shows that the result is accurate up to the fourth order of Taylor approximation. You could get the same result by choosing suitable linear combinations of the second-order approximations, but that wouldn't demonstrate that the accuracy is any better than second-order.