Now manipulate these two equations to obtain the two desired expressions for $f'(a)$ and $f''(a)$. Verify with the chosen values of $a$, $h$, and $f$, we have $f'(\pi/6) = 0.87$ and $f''(\pi/6) = 0.50$.

To derive more terms, here is a general process for a difference scheme that uses the values of the function at $x - 2h$, $x-h$, $x$, and $x + h$. Writing \[ af(x - 2h) + bf(x - h) + cf(x) + df(x + h), \]

then we wish to find the values of $\{a, b, c, d\}$ such that the linear combination gives us $f'(x)$ with as small error terms as we can force it.

Taylor expanding the left hand side gives \begin{multline*} af(x - 2h) + bf(x - h) + cf(x) + df(x + h) \\ = (a + b + c + d)f(x) + hf'(x)(d-b - 2a) \\ + \frac{h^2 f''(x)}{2} (d + b + 4a) + \frac{h^3 f'''(x)}{3!} (d - b -8a) \\ + \frac{h^4 f''''(x)}{4!} (d + b + 16a) + \max(a,b,d) O(h^5) \end{multline*}

Effectively, we want to chose $a + b + c + d = 0$ in order for the $f(x)$ term on the right to disappear; then we choose $d - b - 2a$ to give a coefficient of $1$ on the $f'(x)$ term. At this point, we have the freedom to impose two additional constraints, so we can zero out the coefficients of the $O(h^2)$ and the $O(h^3)$ term. This is a system of four equations for four unknowns.

Solving everything gives \[ f'(x) = \frac{f(x - 2h) - 6f(x-h) + 3f(x) + 2f(x + h)}{6h} + O(h^3 f''''(x)), \]

which is more accurate than the formula we have. This process can be continued in general to higher orders to obtain more accurate derivatives.