Alternative derivation
An alternative route to the difference formulae uses Taylor series expansions:
> restart;
> tayl:=convert(taylor(f(x),x=x0,4),polynom);
The error term is given by
> err:=(D@@4)(f)(xi(x))*(x-x0)^4/4!;
so that,
> f(x)=tayl+err;
We can then evaluate this expansion at the two neighbouring points:
> expr1:=f(xo+h)=subs(x=x0+h,tayl+err);
> expr2:=f(x0-h)=subs(x=x0-h,tayl+err);
We can eliminate the first derivative terms by adding both expressions together:
> lhs(expr1)+lhs(expr2)=rhs(expr1)+rhs(expr2);
which gives the the same centered three-point difference formula, but with a less complicated error term. Moreover, when
is continuous over
then the Intermediate Value Theorem says that
,
with
in the interval
.
Therefore, the three-point difference formula becomes:
.