Skip to main content

Exercises 12.6 Homework

1.

Find the order of error of the formula (12.3.2) (theoretical exercise).

2.

Rewrite the formula

\begin{equation*} \frac{\sqrt{9 + x^4} - 3}{\sin(x^4)} \end{equation*}

to avoid the loss of significance when \(x\) is close to \(0\text{.}\) Evaluate both the original and rewritten formulas when \(x = 10^{-4}\text{.}\) How different are the results?

3.

A function \(f\) has been evaluated at the points \(0, 0.1, 0.2, \dots, 1\) (in Matlab notation, x = 0:0.1:1). Its values are

y = [1, 0.99, 0.96, 0.91, 0.85, 0.78, 0.7, 0.61, 0.53, 0.44, 0.37]

Write a script which plots this function together with its first derivative \(f'\) and its second derivative \(f''\text{.}\) Use symmetric difference formulas with \(h=0.1\text{.}\)

Hint

Expressions like y(3:end) - y(1:end-2) will be useful. Note that while the values of \(f\) can be plotted against the given vector x, the derivatives need to be plotted against x(2:end-1) because the symmetric formulas do not apply at the endpoints. Recall we can combine several functions in one plot command like plot(x, y, xx, yy).