# Math Help - Numerical Differentiation Formulas

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:

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

What is $O(h) \$?

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

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

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

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

$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

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

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

I am knowing that

$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:

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

and

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

so

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

rearranging gives

$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

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

Also, using Taylor expansion

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

and I now knowing

$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

$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 $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 $O(h).

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

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

I get

$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:

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

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

$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

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

so

$f'(x)=\frac{f(x+h) - f(x)}{h}-\frac{O(h^2)}{h}$
$\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:

$f(x+h) = f(x) + h*f'(x) + \frac{h^2}{2}*f''(x) + O(h^3)$
If we just have that $f$ is twice differentiable then the final term is little-o $h^2$ not big-O $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

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

$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

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

$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:

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

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

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

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

and $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.