Let $f \in C[a,b]$ be a function whose derivative exists on $(a,b)$. Suppose $f$ is to be evaluated at $x_0$ in $(a,b)$, but instead of computing the actual value $f(x_0)$, the approximate value, $\tilde{f}(x_0)$, is the actual value of $f$ at $x_0 + \epsilon$, that is $\tilde{f}(x_0) = f(x_0 + \epsilon)$

a) Use the Mean Value Theorem to estimate the absolute error $|f(x_0) - \tilde{f}(x_0)|$ and the relative error $|f(x_0) - \tilde{f}(x_0)|/|f(x_0)|$, assuming that $f(x_0) \neq 0$.

b) If $\epsilon = 5 \cdot 10^{-6}$ and $x_0 = 1$, find bounds for the absolute and relative errors for

i. $f(x) = e^x$

ii. $f(x) = \sin x$

c) Repeat part (b) with $\epsilon = (5 \cdot 10^{-6}) x_0$ and $x_0 =10$

My work

Part a

There is some $c \in [x_0, x_0 + \epsilon]$ where $f'(c) = \frac{f(x_0 + \epsilon) - f(x_0)}{\epsilon} = \frac{\tilde{f}(x_0) - f(x_0)}{\epsilon}$

Absolute Error: $|f(x_0) - \tilde{f}(x_0)| = |f'(c) \cdot \epsilon|$

Relative Error $\frac{|f(x_0) - \tilde{f}(x_0)|}{|f(x_0)|} = \frac{|f'(c) \cdot \epsilon|}{|f(x_0)|}$

(Is this right? I'm suspicious this isn't the answer expected.)

Part b

Here, I simply calculate the absolute/relative error directly. I'm suspicious because I'm not using part (a) and I'm not calculating "bounds", I'm calculating error values.

i. $f(x) = e^x$

Absolute Error: $|f(1 + 5 \cdot 10^{-6}) - f(1)| = |e^{1 + 5 \cdot 10^{-6}} - e| \approx 1.359 \cdot 10^{-5}$

Relative Error: $|e^{1 + 5 \cdot 10^{-6}} - e|/e \approx 5.000 \cdot 10^{-6}$

ii. $f(x) = \sin x$

Absolute Error: $|f(1 + 5 \cdot 10^{-6}) - f(1)| = |\sin (1 + 5 \cdot 10^{-6}) - \sin 1| \approx 2.702 \cdot 10^{-6}$

Relative Error: $\frac{|\sin (1 + 5 \cdot 10^{-6}) - \sin 1|}{\sin 1} \approx 3.210 \cdot 10^{-6}$

Part c

Similar to (b)

i. $f(x) = e^x$

Absolute Error: $|f(10 + 5 \cdot 10^{-5}) - f(10)| = |e^{10 + 5 \cdot 10^{-5}} - e^10| \approx 1.101$

Relative Error: $|e^{10 + 5 \cdot 10^{-5}} - e^{10}|/e^{10} \approx 5.000 \cdot 10^{-5}$

ii. $f(x) = \sin x$

Absolute Error: $|f(10 + 5 \cdot 10^{-5}) - f(10)| = |\sin (10 + 5 \cdot 10^{-5}) - \sin 10| \approx -4.195 \cdot 10^{-5}$

Relative Error: $\frac{|\sin (10 + 5 \cdot 10^{-5}) - \sin 10|}{\sin 10} \approx 4.949 \cdot 10^{-6}$

  • $\begingroup$ Whilst it's excellent that you've put in so much effort, your post is too broad as it asks too many questions. $\endgroup$ – Shaun Sep 18 '17 at 22:19
  • $\begingroup$ @Shaun Actually, he only asks one question. Is this right? ... Everything after that should not be part of the question, as there are no questions. @OP: I suggest to edit this question, so that only your problem in part a) is asked. Then try to do b) and c) again. And if there are problems, open another question. $\endgroup$ – P. Siehr Sep 19 '17 at 12:58

Since that is the only question you asked, I will focus my answer on it.

(Is this right? I'm suspicious this isn't the answer expected.)

What you did is correct, but I would write the result slightly different.

\begin{align*}|f(x_0) - \tilde{f}(x_0)| &= |f'(c) \cdot \epsilon| \\ &= |f'(c)|\,|x_0-\tilde{x_0}|\leqslant \max_{c∈(a,b)}|f'(c)|\,|x_0-\tilde{x_0}|.\end{align*} Now you have an estimate in the form $$\text{"absolute error in the result"} = \text{constant}*\text{"absolute error in the data"},$$ which is better in the sense, that you explicitly see the connection of both errors. Also you don't know the value of $c$, because the Mean Value Theorem only states "There exists a $c$…". So the only thing you can evaluate numerically is $\underset{c}{\max}…$ .

For the relative error we can do the same \begin{align*}\frac{|f(x_0) - \tilde{f}(x_0)|}{|f(x_0)|} &= \frac{|f'(c) \cdot \epsilon|}{|f(x_0)|} \\ &= |f'(c)| \frac{|x_0|}{|f(x_0)|}\frac{|x_0-\tilde{x_0}|}{|x_0|} \\& \leqslant \max_{c∈(a,b)}|f'(c)| \frac{|x_0|}{|f(x_0)|}\frac{|x_0-\tilde{x_0}|}{|x_0|}.\end{align*} I think this answer also answers your not asked questions about b) and c).

It is nice to see, that that that factor resembles very much the condition number $$κ(x)=\frac{∂f(x)}{∂x}\frac{x}{f(x)}.$$ In fact, the condition number is a concept that describes how the relative error in the data connects to the relative error in the result (see here.) The reason, why we here get a different result is, that we used the Mean Value Theorem, while the condition number uses Taylor's expansion.


Not the answer you're looking for? Browse other questions tagged or ask your own question.