Numerical approximation of differentiation

67 Views Asked by At

I have the following task to solve:

Let $b>x$ be defined, determine $w_0,w_1$ and $w_2$ in dependency of $b$ such that the approximation $f''(x) \approx w_0 f(x-h) + w_1 f(x) +w_2f(b)=D^2_{x,h}(f)$ is accurate for polynomials with high degree.

I did this so far: \begin{align} f''(x) &\approx \frac{f'(x+\frac{h}{2})-f'(x-\frac{h}{2})}{h}\\ &\approx \frac{\frac{f(x+h)-f(x)}{h} - \frac{f(x)-f(x-h)}{h}}{h}\\ &\approx \frac{f(x+h)-2f(x) + f(x-h)}{h^2}\\ &\approx \frac{1}{h^2}f(x-h) - \frac{2}{h^2}f(x) + \frac{1}{h^2}f(b) \end{align} I'm not sure if this is the right way. But now I don't know how to go on further with $b$. I mean if $b \ne x-h$ but for example $b = x$, then the equation seems to be false.

Thanks for your help.

1

There are 1 best solutions below

0
On BEST ANSWER

You could start with Taylor expansion on each term: $$f(x-h)=f(x)+f'(x)(-h)+\frac{1}{2!}f''(x)(-h)^2+O(h^3)\\ f(x)=f(x)\\ f(b)=f(x)+f'(x)(b-x)+\frac{1}{2!}f''(x)(b-x)^2+O((b-x)^3)$$

Then add three equations with weights $w_0,w_1,w_2$:

$$w_0f(x-h)+w_1f(x)+w_2f(b)=w_0f(x)+w_1f(x)+w_2f(x)+w_0f'(x)(-h)+w_2 f'(x)(b-x)+w_0 \frac{1}{2!}f''(x)(-h)^2 + w_2 \frac{1}{2!}f''(x)(b-x)^2+O((b-x)^3)$$

Since you want the right hand side to be $f''(x) + $ error terms, set

$$w_0+w_1+w_2=0\\ w_0(-h)+w_2(b-x)=0\\ \frac{1}{2}w_0(-h)^2+\frac{1}{2}w_2(b-x)^2=1$$

If you simplify the notation with $b=x+ah$, so $b-x=ah$, then through some algebra you can get $w_0,w_1,w_2$ in terms of $a$, and that's also in terms of $b$ and $x$.

If you plug $a=1$, which means $b=x+h$, it actually gives you the central difference formula.