# Numerical methods

1. Jan 24, 2006

### stunner5000pt

given five points of a function one can approximate the derivate of the function at some point. The standard five point formula is

Derive an O(h^4) five point formula to approximate f'(x0) that uses
$f(x_{0}-h), f(x_{0}), f(x_{0} +h),f(x_{0} +2h),f(x_{0} +3h)$.

(Hint:Consider the expression $Af(x_{0} -h) + Bf(x_{0} +h) + Cf(x_{0} + 2h) + Df(x_{0} + 3h)$. Expand in fourth Taylor polynomials and choose A,B,C and D appropriately.)

im not sure how they expect me to expand that polynomial they gave because it would be a total mess!
how would one go about deriving this formula?
my idea is using taylor polynomials
$$f'(x_{0}) = \frac{f(x_{0}) - f(x_{0} -h)}{h} + \frac{f''(x_{0}}{2} h - \frac{f^{(3)}(x_{0})}{6} h^2 + \frac{f^{(4)}(x_{0})}{24} h^3 + O(h^4)$$
but im not sure how ot proceed
what to subsitute... i know its gonna take some algebraic gymnastics to get the answer...

Last edited: Jan 24, 2006
2. Jan 24, 2006

### StatusX

I've never done this type of problem before, but the way I'd approach it, given the hint you have, would be to write:

\begin{align*} A f(x_0&-h)+B f(x_0+h)+ C f(x_0+2h) + D f(x_0+3h) = \\ & f(x_0) (A+B+C+D) +\\ & h f'(x_0) (-A+B+2C+3D)+\\ & \frac{1}{2}h^2 f''(x_0) (A+B+4C+9D)+... \end{align*}

Up to the fourth order, and then solve for a set of (A,B,C,D) that makes all the coefficients on the right side vanish except for the coefficient of f'(x_0). This will give you an O(h^4) approximation of f'(x_0).

Last edited: Jan 24, 2006
3. Jan 24, 2006

### stunner5000pt

hmmm... seems there is no one who is in numerical methods on this site... strange that .. or maybe they just dont like to help on homework?
well anyway... did some googling and got these equations
1)
$$f'(x) = \frac{f(x_{0}) - f((x_{0}-h)}{h} + \frac{f''(x_{0}}{2}h - \frac{f^{(3)}(x_{0})}{6}h^2 + \frac{f^{(4)}(x_{0})}{24}h^3 +O(h^4)$$
replace h with -h
2) $$f'(x) = \frac{-f(x_{0}) + f((x_{0}+h)}{h} - \frac{f''(x_{0})}{2}h - \frac{f^{(3)}(x_{0})}{6}h^2 - \frac{f^{(4)}(x_{0})}{24}h^3 +O(h^4)$$
in 2 replace h with 2h
3) $$f'(x) = \frac{-f(x_{0}) + f(x_{0}+2h)}{2h} - \frac{f''(x_{0})}{2}2h - \frac{f^{(3)}(x_{0})}{3}2h^2 - \frac{f^{(4)}(x_{0})}{3}h^3 +O(h^4)$$
so now the aim is simply to eliminate the second, third nad fourth order derivatives
after a lot of fun (ya right)
$$f'(x_{0}) = \frac{ -2f(x_{0} -h) + 6f(x_{0} +h) -11f(x_{0}) - f(x_{0}+2h)}{2h} + \frac{f^{(4)}(x_{0})}{4}h^3 + O(h^4}$$
all i need to do now is get rid of the fourth order derivative
im not sure what to subtract from this equation... any ideas?

Last edited: Jan 24, 2006