10.10 Introduction to Chemical Engineering

NMM Chapter 5: Unavoidable Errors in Computing

Significant Figures, Roundoff, and Truncation Errors

Chapter 5 of NMM discusses two of the most important sources of numerical errors in computations: roundoff errors related to the fact that the computer only keeps track of a finite number of significant figures for each number, and truncation errors due to the fact that continuous functions are represented by discrete numbers on the computer.

Computers typically only keep track of about 7 or 16 significant figures (depending on whether the program uses the default or special “double precision” representation of floating point numbers; the technical details are explained in NMM Section 5.1). So it is extremely difficult to output the result of any computation accurate to more than 16 significant figures. This is not usually a problem, as we seldom know the inputs to more than a few significant figures, so there is no way we could expect to know the output more precisely: “Garbage In, Garbage Out”. Unfortunately, many computer programs “lose” significant figures in the course of the computations due to roundoff, and it is not difficult to find cases where the output may only have one or zero significant figures even if the inputs are all known quite accurately.

This is a good time to review significant figures (see the 10.10 Web page), which are extremely important in all aspects of engineering. The most important thing to remember for programming is that when two numbers of very different magnitudes are added or subtracted, one can lose many (or all!) of the significant figures of the smaller number. Examples 5.3 and 5.4 in the beginning of NMM section 5.2 are worth reading carefully, and the rest of Section 5.2 is also very important. In engineering, we usually are most concerned with relative errors (i.e. percent errors, relate to the number of significant figures) rather than absolute errors (which have units), so we usually try to set our convergence criteria (section 5.2.5) so that the relative tolerance in NMM Eq. 5.13 is larger than the absolute tolerance.

The computer can only represent functions at discrete points; to bridge the gaps between these points we usually use Taylor Series expansions (NMM 5.3, 5.3.1), usually chopping off, or truncating, the series after the first few terms. Neglecting all the rest of the terms leads to truncation errors, which sometimes propagate throughout the calculations in very bad ways, similar to what happens with roundoff errors. However, truncation errors are more controllable: if you are worried about them, you could rewrite the program to include the next couple of terms in the series. Truncation errors can be analyzed mathematically, and it is frequently possible to prove mathematical bounds on how much these errors can contribute to the final result of a computation. However, to understand these mathematical arguments about the bounds, you will need to understand the “order” notation explained in detail in NMM 5.3.2.
 


Next Chapter: Root Finding
Back to Study Guide
Back to 10.10 home page
last updated: August 28, 2002