Numerical Exercise - January 13

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

  1. 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).

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

  3. 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.

  4. 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).

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

  6. Is the error truncation error or roundoff error or some of both?

  7. 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).

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

  9. 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.