First derivative 3 point forward difference formula

fonseh
Messages
521
Reaction score
2

Homework Statement


Can someone explain why for the first derivative 3 point forward difference formula is 4f(x-h) - f(x-2h) ??

Homework Equations

The Attempt at a Solution


Why it's not f(x-h) - f(x-2h) ?
Is there anything wrong with the notes ?
 

Attachments

  • sdfdfs.jpg
    sdfdfs.jpg
    59.2 KB · Views: 825
Physics news on Phys.org
fonseh said:

Homework Statement


Can someone explain why for the first derivative 3 point forward difference formula is 4f(x-h) - f(x-2h) ??

Homework Equations

The Attempt at a Solution


Why it's not f(x-h) - f(x-2h) ?
Is there anything wrong with the notes ?

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.
 
  • Like
Likes fonseh
Ray Vickson said:
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.
please refer to the circled part ... it's really ##4 f(x-h)-f(x-2h)##
 
Ray Vickson said:
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.
here's the full notes
 

Attachments

  • 543.jpg
    543.jpg
    42.1 KB · Views: 817
  • 544.jpg
    544.jpg
    59.2 KB · Views: 1,559
fonseh said:
please refer to the circled part ... it's really ##4 f(x-h)-f(x-2h)##
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:
  • Like
Likes fonseh
fonseh said:

Homework Statement


Can someone explain why for the first derivative 3 point forward difference formula is 4f(x-h) - f(x-2h) ??

Homework Equations

The Attempt at a Solution


Why it's not f(x-h) - f(x-2h) ?
Is there anything wrong with the notes ?
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.
 
Ray Vickson said:
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?
No , i get the same as the notes , my question is why should we use 4f(x-h) ? why can't we use f(x-h) ?
 
Chestermiller said:
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.
Can you explain further ? I still didnt get it
 
fonseh said:
Can you explain further ? I still didnt get it
In my judgment, it is well explained in the visual you provided.
 
  • #10
Chestermiller said:
In my judgment, it is well explained in the visual you provided.
Why we should use 4f(x-h) ? It's not explained in the notes
 
  • #11
fonseh said:
No , i get the same as the notes , my question is why should we use 4f(x-h) ? why can't we use f(x-h) ?

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.
 
  • Like
Likes fonseh
  • #12
fonseh said:
Why we should use 4f(x-h) ? It's not explained in the notes
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
Chestermiller said:
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.
why there is a need to eliminate f'' from the equation ?
 
  • #14
Ray Vickson said:
(a+b+c)f(x)+Bhf′(x)+Ch2f′′(x)+O(h3),(a+b+c)f(x)+Bhf′(x)+Ch2f″(x)+O(h3),(a+b+c) f(x) + B h f'(x) + C h^2 f''(x) + O(h^3),
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
fonseh said:
why there is a need to eliminate f'' from the equation ?
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
fonseh said:
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

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.
 
  • Like
Likes fonseh
  • #17
Ray Vickson said:
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.
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
fonseh said:
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) + ...

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.
 
Back
Top