How to develop a numerical differentiation formula using Taylor expansion/series?

374 Views Asked by At

I have a problem understanding a numerical differentiation problem, using Taylor series.

It's an exercise and we should develop a 2nd order approximation formula, which uses just $f(x), f(x-h)$ and $f(x+3h)$. As help, the professor gave us a tip in the exercice, that we should start with:

$$f'(x) = \frac{af(x+3h) + bf(x) + cf(x-h) }h $$

Attached here is the problem AND the solution (which I think is wrong, or he made something wrong, at least I hope), and a legend for my questions.

exercise

I found other results, and here are my 3 questions:

  1. For point 1 (marked 1 on the screenshot), I found $27/6$ as factor there, not $9/2$
  2. My 2. question (marked 2 in screenshot) concerns the last term in the result. Shouldn't we multiply that big term with $h^3$?
  3. 3rd question (marked 3 in screenshot): Let's say the professor is right, and there are no typos or calculating errors. If we are dividing by $h$, these $h$'s on the nominator will get eliminated by 1 power. So the term (middle term), that he says should be 1, is multiplied by $h$, and if we divide by $h$ there won't be any $h$ anymore there. For the term after if, which is multiplied by $h^2$, and we are dividing by $h$, it will be then just $h$, which makes our formula of 1st order. Or did I understand something wrong?

Thank you for any help! Exam is tomorrow, and I am really freaking out about this.

2

There are 2 best solutions below

0
On

More generally, suppose you want to find $f'(x) \approx \dfrac{af(x+uh) + bf(x+vh) + cf(x+wh) }h $.

$f(x+rh) =f(x)+rhf'(x)+r^2h^2f''(x)/2+r^3h^3f'''(x)/6+O(h^4) $ so

$\begin{array}\\ af(x+uh) + bf(x+vh) + cf(x+wh) &=(a+b+c)f(x)+(au+bv+cw)hf'(x)\\ &\quad +(au^2+bv^2+cw^2)h^2f''(x)/2+(au^3+bv^3+cw^3)h^3f'''(x)/6\\ &\quad+O(h^4)\\ \end{array} $

Therefore you want $0=a+b+c, 1=au+bv+cw, 0=au^2+bv^2+cw^2 $ and the error is $(au^3+bv^3+cw^3)h^2f'''(x)/6 +O(h^3) $.

This leads to Vandermonde determinants.

Your case is $u=3, v=0, w=-1$, so $0=a+b+c, 1=3a-c, 0=9a+c $.

Adding the second and third, $a=1/12$, so $c = -9a =-3/4$.

From the first, $b = -a-c =-1/12+3/4 =2/3 $.

The error coefficient is $au^3+bv^3+cw^3 =27/12-3/4 =15/12 =5/4 $ so the error is $(5/4)h^2f'''(x)/6+O(h^3) =(5/24)h^2f'''(x)+O(h^3) $.

2
On

1) $\frac {27}{6} = \frac 92$

2) yes there should be an $h^3$ factor multiplying that term. However, that term ultimately gets dropped (actually becomes the error estimate). And is not relevant for finding optimal values of $a, b, c$

3) yes the $h's$ cancel. That is kind of the point.

$\frac 1h [(a+b+c)f(x) + (3a+c)f'(x)h + (\frac 92 a + \frac 12 c) f''(x)h^2+\epsilon h^3] = f'(x)$

Which can only be true if

$(a+b+c) = 0$ and $(3a+c) = 1$

as for $\frac 92 a + \frac 12 c = 0$ This makes your error term decrease at quadratic speed rather than linear speed.