### Numerical Exercise - January 13

Let f(x) = 1 - cos(x).

- Compute f(0.023) and round the result to 4 significant digits (leading
0s are not significant digits). Your answer is the best one could hope
for on a 4-digit computer (one that can only hold 4 significant digits - base 10).

- Find the relative error in approximating f(0.023) by the rounded
answer.

- Observe that your relative error is less than or equal to 0.5 times
10
^{-4}. As we'll see later the maximum relative error is always
related to the number of significant digits in the rounding process.

- Compute f(0.023) using 4-digit arithmetic. That is, after each operation
round to 4 significant digits then use the rounded result to continue
(so in this case compute cos(0.023) and round the result to 4 significant
digits then subtract the result from 1).

- Compute the
*absolute error* and the *relative error*
in the result from part (d) taking your answer from (a) as the "true" value.

- Is the error truncation error or roundoff error or some of both?

- Find an expression that is equivalent to 1 - cos(x) (use a well-known
"trick" of multiplying numerator and denominator by the same expression
and use a well-known trig identity to simplify the numerator).

- Now compute the value of your equivalent expression for x = 0.023 using
4-digit arithmetic.

- What is the error in this case (absolute and relative)?

**MORAL: **Two expressions can be algebraically equivalent but not
numerically equivalent.

**Question: **In "real life" we don't know the true answer ahead of time.
Is there a way to know which expression would be best or to anticipate
an error in an expression?

**Answer:** Yes, that is one of the things we'll learn this semester.

The expression you found above should have been equivalent to the original,
not an approximation. Now we'll find an approximation.

- Use the Taylor series for cos(x) to find a polynomial approximation
to f(x) (don't get carried away -- keep it simple).
- Evaluate your approximation for x = 0.023 using 4-digit arithmetic.
- How good is the approximation? That is what are the absolute and
relative errors in the approximation?
- Use your polynomial to approximate f(2.3). (You may do this
to the precision of your calculator rather than 4-digit.)
- How good is the approximation? How does it compare to the approximation
of f(0.023) using the same polynomial? If one approximation is better
than the other, why? Could you have predicted that would be the case?