Next: DOUBLE PRECISION
Up: Numeric Applications
Previous: Numeric Applications

Rounding Errors

There's not much to add to the discussion of roundoff error in section 11.1 of the text except to let you run a demonstration similar to the one in the book. Take a look at ``roundoff1.f'' in your ``examples'' directory (or view it directly).

This program reads in a value for ``N''. If N, for example, is 6, it then performs the following calculation.

SQRT(6/5) * SQRT(4/3) * SQRT(2/1) * SQRT(5/6) * SQRT(3/4) * SQRT(1/2)

As you can see, it multiplies together the square roots of a sequence of fractions, and then multiplies in the square roots of a sequence consisting of the inverses of the original fractions. So mathematically speaking, the result of computing this product, no matter how large N is, should be 1. (Make sure that you believe that before you go on.)

Now compile and run the program for various values of N. What do you observe?

Click here for the answer

Roundoff error like this can become an extremely serious problem in programs that do extensive numerical calculations. The error that this program produces may not seem like much to you, but it all depends upon the application. You must always be aware of the possibility.


Next: DOUBLE PRECISION
Up: Numeric Applications
Previous: Numeric Applications

Hamlet Project
hamlet@cs.utah.edu