# First derivative 3 point forward difference formula

1. Jan 21, 2017

### fonseh

1. The problem statement, all variables and given/known data
Can someone explain why for the first derivative 3 point forward difference formula is 4f(x-h) - f(x-2h) ??

2. Relevant equations

3. The attempt at a solution
Why it's not f(x-h) - f(x-2h) ?
Is there anything wrong with the notes ?

#### Attached Files:

• ###### sdfdfs.jpg
File size:
61.5 KB
Views:
43
2. Jan 21, 2017

### Ray Vickson

The formula is not $4 f(x-h)-f(x-2h)$, and the notes make no such claim. Please try again with a correct question.

Anyway, as far as I can see the notes explain things in a perfectly clear way, using the Taylor expansion.

3. Jan 21, 2017

### fonseh

please refer to the circled part .... it's really $4 f(x-h)-f(x-2h)$

4. Jan 21, 2017

### fonseh

here's the full notes

#### Attached Files:

File size:
49.9 KB
Views:
126
• ###### 544.jpg
File size:
61.5 KB
Views:
204
5. Jan 21, 2017

### Ray Vickson

OK, but your first message said nothing about the "circled part"---that makes a difference. So, I have a question for you: have you taken the Taylor expansions for $f(x-h)$ and $f(x-2h)$ and performed the calculation of $4f(x-h) - f(x-2h)?$ Did you get a different answer from that in the notes?

Last edited: Jan 21, 2017
6. Jan 21, 2017

### Staff: Mentor

The reason that your equation is not correct is that this is a first order accurate approximation, and the result they are trying to obtain is supposed to be accurate to terms of 2nd order in h.

7. Jan 21, 2017

### fonseh

No , i get the same as the notes , my question is why should we use 4f(x-h) ? why cant we use f(x-h) ???

8. Jan 21, 2017

### fonseh

Can you explain further ? I still didnt get it

9. Jan 21, 2017

### Staff: Mentor

In my judgment, it is well explained in the visual you provided.

10. Jan 21, 2017

### fonseh

Why we should use 4f(x-h) ? It's not explained in the notes

11. Jan 21, 2017

### Ray Vickson

You can use what works, and 4f(x-h) works. Try it for yourself, without the "4", and see what happens.

In fact, suppose you want a finite-difference formula of the form
$$f'(x) \approx \frac{1}{h} [ a f(x) + b f(x-h) + c f(x-2h)].$$
Expand out the numerator as a series in small $h$ and you will get something of the form $(a+b+c) f(x) + B h f'(x) + C h^2 f''(x) + O(h^3),$
where $B$ and $C$ are some expressions in $a,b,c$. You want a numerator expression of the form $0 f(x) + 1 h f'(x) + O(h^2)$ (so that the ratio is $f'(x)$ to first order in $h$). In other words, you want $a+b+c=0$ and $B = 1$. After evaluating $B$ in terms of $a,b,c$ you will have two equations in the three unknowns $a,b,c$, and can solve for $b,c$ in terms of $a$. If you make different choices for $a$ you will get different "finite-difference" formulas for $f'(x)$. See if you can figure out what value of $a$ gives you $1 f(x-h)$ in your finite-difference formula.

12. Jan 21, 2017

### Staff: Mentor

What they do is eliminate the term involving f'' from the two equations, and solve for f'. This results in a finite difference approximation that is accurate to terms if h2.

13. Jan 21, 2017

### fonseh

why there is a need to eliminate f'' from the equation ?

14. Jan 21, 2017

### fonseh

I tried f(x-h) - f(x-2h) , i get -h'f(x) + (3 /2!) (f"(x) h^2) + (3/3!)(f"'(x)h^3) + ......

I didnt get (a+b+c)f(x)+Bhf′(x)+Ch2f′′(x)+O(h3) though

15. Jan 21, 2017

### Staff: Mentor

Because otherwise you would find that the final finite difference equation would only be first order in h. Try any other linear combination of the two equations and see what you get for f'

16. Jan 21, 2017

### Ray Vickson

That is because you ignored what I wrote. I wrote $a f(x) + b f(x-h) + c f(x-2h)$. I suggest you do the same, then tell us what you obtain.

17. Jan 22, 2017

### fonseh

Do you mean f(x) + f(x-h) - f(x-2h) ?
If so , i get f(x) -h'f(x) + (3 /2!) (f"(x) h^2) + (3/3!)(f"'(x)h^3) + ......

18. Jan 22, 2017

### Ray Vickson

Why would you ask that? Since when does $a f(x) + b f(x-h) + c f(x-2h)$ suddenly become $f(x)+f(x-h)-f(x-2h)?$ (Ok, it would happen in the one case where we choose $a=1, b=1, c=-1$, but I said no such thing.) I left $a,b,c$ as unevaluated constants, because I thought you wanted to see why certain choices are made and others rejected. The first step is to actually write down what you would get with general $a,b,c.$

I am now quitting this thread.