0

I had to calculate the truncation error, but the error gave me $0$. Then the question asked what is the order of accuracy, however since the error is $0$ should it be infinity?


We use this difference formula:

$$Q(h) = \frac{f(x-2h) - 8f(x-h) + 8f(x+h) -f(x+2h)}{12h}$$

And with the following Taylor expansions around $x$:

$\begin{align} f(x-2h) &= f(x) - 2hf'(x) + 2h^2f''(x) - \frac{4}{3}h^3f'''(x) + \mathcal{O}(h^4)\\ f(x-h) &= f(x) - hf'(x) + \frac{1}{2}h^2f''(x) - \frac{1}{6}h^3f'''(x) + \mathcal{O}(h^4)\\ f(x-h) &= f(x) + hf'(x) + \frac{1}{2}h^2f''(x) + \frac{1}{6}h^3f'''(x) + \mathcal{O}(h^4)\\ f(x+2h) &= f(x) + 2hf'(x) + 2h^2f''(x) + \frac{4}{3}h^3f'''(x) + \mathcal{O}(h^4)\\ \end{align}$

Then we find the truncation error:

$\begin{align} |f'(x) - Q(h)| &= |f'(x) - f(x)\cdot\left(\frac{1}{12h}-\frac{8}{12h}+\frac{8}{12h}-\frac{1}{12h}\right)\\ &- f'(x)\cdot\left(-\frac{1}{6}+\frac{2}{3}+\frac{2}{3}-\frac{1}{6}\right)\\ &- f''(x)\cdot\left(\frac{h}{6}-\frac{h}{3}+\frac{h}{3}-\frac{h}{6}\right)\\ &- f'''(x)\cdot\left(-\frac{h^2}{9}+\frac{h^2}{9}+\frac{h^2}{9}-\frac{h^2}{9}\right)| \end{align}$

As you can see, all the orders cancel out except for the first derivative

Therefore $|f'(x) - Q(h)| = |f'(x) - f'(x)| = 0$

  • 2
    If the error is actually $0$, then $\infty$ seems a reasonable choice for the order of accuracy. –  Nov 08 '21 at 09:37
  • Could you please share exactly what you've been doing? It usually doesn't make sense for a truncation error to be $0$. If you were to truncate for example the Taylor series of $x^2$ at order $3$, than this error is indeed zero, but we can agree that it doesn't make much sense to do so. – Gábor Pálovics Nov 08 '21 at 09:55
  • @GáborPálovics I updated the question to show what I did – Jorge Correa Merlino Nov 08 '21 at 10:18
  • 2
    Your approximation of the derivative was construted in a manner that your error would be of order $h^5$. Your truncation error comes from the the things you are considering to be negligible: $\mathcal{O}(h^4)$. You should estimate those terms and give an upperbound which would be your truncation error. – Gábor Pálovics Nov 08 '21 at 10:24
  • Oh okay, I thought it would be true for the rest of the terms so I did not calculate the rest since we do not usually need to get to order 5. Thanks! – Jorge Correa Merlino Nov 08 '21 at 10:39

2 Answers2

1

You can't cancel the orders out. Remember that each Taylor expansion has an error of $\frac{h^4}{24} f^{(4)}(\eta_i)$, and $\eta_i$ might vary for each case.

pablich
  • 50
  • Yeah I calculated order 4 and they also cancelled out so I gave up thinking that the rest would cancel out. Gave up too soon! – Jorge Correa Merlino Nov 08 '21 at 10:38
  • It is a normal mistake to make, but since $\eta_i$ is just some number in the interval between x and the limit of your Taylor expansion, $\eta_1 \in [x-2h, x]$, $\eta_2 \in [x-h, x]$, and so on, $f^{(4)}(\eta_i)$ is likely different in each case. Therefore, $\mathcal{O}$ can't usually be cancelled, unless you continue the expansion. I'm glad this helped! – pablich Nov 09 '21 at 11:18
0

Although having no error means that the accuracy is maximum, I would personally use a more elegant way of measuring accuracy, because infinity means that the scale of real numbers until there is all available for accuracies. As in, 200...10^5, etc.

Perhaps, use 100% (much more clear and easy to write and process).

Another option, of you want to see it as "efficiency", make it 1.

If you want to be fine, use complete accuracy.

AndrewFNAF
  • 23
  • 7