An Introduction to Numerical Methods in C++, Revised Edition

In this chapter we consider the arithmetical errors that arise in computing, certain basic theorems useful for error estimation and algorithm development, and some factors which affect the speed of computation.
Most computations are approximate. One of the most common approximations is the truncation of an iterative statement when some predetermined condition fails. We have seen an example of this in Newton's algorithm for the square root of a number A, where the condition
fabs(x*x - A) < tolerance
cuts off the iteration as soon as the difference between the square of the current approximate square root coincides with A to within the preset tolerance. To a large extent, the errors arising from truncation are within the user's control, but that does not mean that it is always easy to estimate their magnitude. In this case, however, it is easy enough. If we wish to calculate the square root of 10 to six significant decimal places, the truncation error must be less than ? = 5.10 ?7 and this implies that the tolerance ? < 2 ? x ? 3.10 ?6. The estimation of truncation errors in iteration resembles that of termination of infinite series. There will be many examples later in this book.
A quite different source of error results from the fact that floating point numbers are represented in a computer to high but limited precision. Owing to the fixed number of bytes associated...