1. ## Numerical Differentiation Formulas

Hello to everyone

I have a question with many parts that i am needing to do.

(a)Derive the 2point formula, for numerical differentiation:

$\displaystyle f'(x) = \frac{f(x + h) - f(x)}{h} + O(h)$

What is $\displaystyle O(h) \$?

(b) Derive the same formula as (b) witht 3points formula

$\displaystyle f'(x) = \frac{f(x + h) - f(x-h)}{2h} + O(h^2).$

(c) Discretisation error in (a) and (b) is

$\displaystyle E_2(h) = |f'(x) - \frac{f(x + h) - f(x)}{h} |$

$\displaystyle E_3(h) = |f'(x) - \frac{f(x + h) - f(x-h)}{h^2} |$

Prove that discretisation error for f'(1), where f(x) = exp(x) is

$\displaystyle E_2(h) = e|1 - \frac{e^h - 1}{h}| = e\frac{h}{2} + O(h^2)$

$\displaystyle E_3(h) = e|1 - \frac{e^h - e^-h}{2h}| = e\frac{h^2}{6} + O(h^3)$

I am knowing that

$\displaystyle f'(x) = \lim_{h \to 0} ~ \frac{f(x + h) - f(x)}{h}$

but I cannot realise how to do these parts? Can someone please showing me how to prove?

2. I'll give you some thought on part (b). Part (a) is done in a similar way.

Using Taylor expansion:

$\displaystyle f(x+h) = f(x) + h*f'(x) + \frac{h^2}{2}*f''(x) + O(h^3)$

and

$\displaystyle f(x-h) = f(x) - h*f'(x) + \frac{h^2}{2}*f''(x) + O(h^3)$

so

$\displaystyle f(x+h) - f(x-h) = 2*h*f'(x) + O(h^3)$

rearranging gives

$\displaystyle f'(x) = \frac{f(x+h)-f(x-h)+O(h^3)}{2h}= \frac{f(x+h)-f(x-h)}{2h}+O(h^2)$

3. Thank you very much, I understand what you show, but I am now a small amount confused because I found

$\displaystyle f'(x) = \frac{f(x + h) - f(x - h)}{2h} - \frac{h^2}{6}f'''(c)$ where $\displaystyle (x - h) \ < \ c \ < \ (x +h)$ for 3-point centered-difference formula.

Also, using Taylor expansion

$\displaystyle f'(x + h) = f(x) + hf'(x) + \frac{h^2}{2} f''(c)$ where $\displaystyle x \ < \ c \ < \ (x +h)$

and I now knowing

$\displaystyle f'(x) = \frac{f(x + h) - f(x)}{h} - \frac{h}{2}f''(c)$ for 2-point forward difference formula but I do not understand how they got there(being very tired).

So is

$\displaystyle O(h) = - \frac{h}{2}f''(c)$ or am I wrong?

4. ## Big O notation

You need to find out about "Big O" notation.

The big O notation gives an idea of the size of something and is used to put an upper bound on the error term in your integration formulas (and lots of other areas of math, science and computer prog.).

When we write $\displaystyle O(h^n)$ we mean that for any value of k (even any really big finite value) then it is still possible to find a value of h sufficiently small so that $\displaystyle O(h)<k*h^n$.

This isn't a good explanation but a web search for "big O notation" should turn up something helpful.

5. I now understand what big O notation is. Thank-you for helping me know this.

But I have spent much time on trying to derive the 2point formula

$\displaystyle f'(x) = \frac{f(x + h) - f(x)}{h} + O(h)$ using the same method as you doing for deriving $\displaystyle f'(x) = \frac{f(x + h) - f(x-h)}{2h} + O(h^2)$ but I can not find the answer.

I get

$\displaystyle f'(x) = \frac{f(x+h) - f(x) - \frac{h^2}{2}f''(x)}{h} + O(h^2)$

of course which is not right. What am I doing wrong?
Can someone please showing me because I can not see why, and I have used great time amounts trying to get it.

6. The following three statements are all true:

$\displaystyle f(x+h) = f(x) + h*f'(x) + \frac{h^2}{2}*f''(x) + \frac{h^3}{6}*f'''(x) + O(h^4)$

$\displaystyle f(x+h) = f(x) + h*f'(x) + \frac{h^2}{2}*f''(x) + O(h^3)$

$\displaystyle f(x+h) = f(x) + h*f'(x) + O(h^2)$

You used the second option for the central difference equation. You need to use the third option for the forward difference.

Therefore

$\displaystyle f(x+h) - f(x)= h*f'(x) + O(h^2)$

so

$\displaystyle f'(x)=\frac{f(x+h) - f(x)}{h}-\frac{O(h^2)}{h}$
$\displaystyle \therefore f'(x)=\frac{f(x+h) - f(x)}{h}+O(h)$

7. Now I understand.....thank-you again. Now that I have seen it I understand how easy it is. I can see the silly mistake I make. You are fantastic

8. Originally Posted by Kiwi_Dave
I'll give you some thought on part (b). Part (a) is done in a similar way.

Using Taylor expansion:

$\displaystyle f(x+h) = f(x) + h*f'(x) + \frac{h^2}{2}*f''(x) + O(h^3)$
If we just have that $\displaystyle f$ is twice differentiable then the final term is little-o $\displaystyle h^2$ not big-O $\displaystyle h^3$.

(Not that it makes any difference to the argument)

RonL

9. Originally Posted by funnyinga
(1) Derive the 2point formula, for numerical differentiation:

What is ?

(3) Discretisation error in (a) and (b) is

$\displaystyle E_2(h) = |f'(x) - \frac{f(x + h) - f(x)}{h} |$

$\displaystyle E_3(h) = |f'(x) - \frac{f(x + h) - f(x-h)}{h^2} |$

Prove that discretisation error for f'(1), where f(x) = exp(x) is

$\displaystyle E_2(h) = e|1 - \frac{e^h - 1}{h}| = e\frac{h}{2} + O(h^2)$

$\displaystyle E_3(h) = e|1 - \frac{e^h - e^-h}{2h}| = e\frac{h^2}{6} + O(h^3)$
Now I am having hard time with this part. My thinking is this, but I am confused:

$\displaystyle \frac{\mathrm{d}}{\mathrm{d}x} e^x = e^x$

and $\displaystyle E_2(h) = |f'(x) - \frac{f(x + h) - f(x)}{h} |$

so for $\displaystyle f(x) = e^x$

$\displaystyle E_2(h) = |e^x - \frac{e^{x+h} - e^x}{h} |$

and $\displaystyle E_3(h) = |e^x - \frac{e^{x+h} - e^{x-h}}{h} |$.

This is all I have. Can someone please showing me how finish this? I have spent great hours on this question and I am almost ready to leave it.