Appendix E: A Detailed Look at f 245

This approximation took about twice as long as the approximation in i 3 or i 2. In this case, the algorithm had to evaluate the function at about twice as many sample points as before in order to achieve an approximation of acceptable accuracy. Note, however, that you received a reward for your patience: the accuracy of this approximation is better, by almost two digits, than the accuracy of the approximation calculated using half the number of sample points.

The preceding examples show that repeating the approximation of an integral in a different display format sometimes will give you a more accurate answer, but sometimes it will not. Whether or not the accuracy is changed depends on the particular function, and generally can be determined only by trying it.

Furthermore, if you do get a more accurate answer, it will come at the cost of about double the calculation time. This unavoidable trade-off between accuracy and calculation time is important to keep in mind if you are considering decreasing the uncertainty in hopes of obtaining a more accurate answer.

The time required to calculate the integral of a given function depends not only on the number of digits specified in the display format, but also, to a certain extent on the limits of integration. When the calculation of an integral requires an excessive amount of time, the width of the interval of integration (that is, the difference of the limits) may be too large compared with certain features of the function being integrated. For most problems, however, you need not be concerned about the effects of the limits of integration on the calculation time. These conditions, as well as techniques for dealing with such situations, will be discussed later in this appendix.

Uncertainty and the Display Format

Because of round-off error, the subroutine you write for evaluating f(x) cannot calculate f(x) exactly, but rather calculates

ˆ = ± δ

f (x) f (x) 1(x),

where δ1 (x) is the uncertainty of f(x) caused by round-off error. If f(x) relates to a physical situation, then the function you would like to integrate is not f(x) but rather