What is the most accurate approximation you can write for $f'(x)$ using the values $f(x-2h)$, $f(x)$ and $f(x+4h)$? What is the order of this approximation?
Note: I know how to approximate $f'(x)$ with these given values by using Taylor expansion but I couldn't understand how to find the most accurate one.
Let's try to find the best linear approximation for $f'(x)$ using $f(x-2h)$, $f(x)$, $f(x+4h)$. It'll have the form $$\begin{align} f'(x) &\approx \frac{\alpha f(x-2h) + \beta f(x) + \gamma f(x+4h)}{h}\end{align}$$ We can use Taylor expansions to try to minimise the error $$\begin{align} f(x-2h)&= f(x) - 2hf'(x) + 2h^2f''(x) - \frac{4}{3}h^3f'''(x) + \mathcal{O}(h^4) \\ f(x)&= f(x) \\ f(x+4h)&= f(x)+4hf'(x) + 8h^2f''(x) + \frac{32}{3}h^3f'''(x) + \mathcal{O}(h^4)\end{align}$$ The numerator of the approximation is now $$\begin{align} (\alpha + \beta + \gamma)f(x)+(-2\alpha + 4\gamma)hf'(x)+(2\alpha+8\gamma)h^2 f''(x) + \left(-\frac{4}{3}\alpha + \frac{32}{3}\gamma\right)h^3 f'''(x) \end{align}$$ For the error to behave at all nicely as $h\to0$, we must have $\alpha+\beta+\gamma=0$. For the approximation to be accurate in the limit $h\to0$, we must have $-2\alpha + 4\gamma=1$. We still have one free parameter, since there are two equations and three unknowns, so let us say $2\alpha+8\gamma=0$ to make the approximation most accurate. Solving these three equations gives $$\alpha=-\frac{1}{3}, \quad \beta=\frac{1}{4}, \quad \gamma=\frac{1}{12}$$
Our approximation is $$\begin{align} f'(x) &\approx \frac{-\frac{1}{3} f(x-2h) + \frac{1}{4} f(x) + \frac{1}{12} f(x+4h)}{h}\end{align}$$
The approximation is second-order accurate, since the $h^2$ term disappears and the $h^3$ term doesn't.