]> 7.2 Round off Errors and the Derivative

## 7.2 Round off Errors and the Derivative

How can d being too small cause problems?

Usually computations on a calculator or computer or by hand are not performed to perfect accuracy. There are very small errors. Normally, these very small errors (called round off errors ) can be ignored because the "noise" they represent in your evaluation is extremely small compared to the signal, which consists of the value of f itself. (A notable exception occurs when your answer is 0; then the machine's answer will be only the error it has created.)

In general, if you take two very similar numbers, like $f ( x 0 + d )$ and $f ( x 0 )$ and take their difference, that difference will be very much smaller than either term and the information in the signal represented by the difference will therefore be much smaller than the signal represented by either, while the noise level usually remains about the same for the terms and the difference.

Taking the result of the subtraction and dividing by a very small $d$ (which is the same as multiplying by a huge $1 d$ ), amplifies the signal and noise together. The net result is that you get the expected answer plus a large amount of noise, and the smaller you make $d$ , the larger that noise will be, and the more this effect will make your computation inaccurate.

If you make $d$ smaller than the accuracy of your machine's computation, your answer will typically be off by more than 1, or your program will accuse you of dividing by 0 when you divide by $d$ .

The spreadsheet allows you to perform a very large number of calculations of this kind for a wide choice of $d$ values with essentially no more work than is involved in one such calculation. This usually gives you the power to look for yourself and see where round off error is causing significant error.

You will then be troubled by this effect only when the answer you are computing is too far from the correct answer for $d$ values at which this effect becomes noticeable. In consequence we try to make use of techniques that will allow us to get accurate estimates for as large $d$ values as possible.

How?

Set up a computation using one $d$ value on one line of the spreadsheet, then on the next line set $d = the old d 2$ , and copy the results downward as far as you like. You will get your computation repeated with $d$ replaced by $d 2$ , then $d 4$ then ,..., until the resulting value is so small your machine won't recognize it as other than 0.

If your estimate of the derivative were to home in on a value and stay there, that would probably be the derivative you seek. Alas this does not always happen. The estimates tend to home in then start to move away again, as the effects of round off error make themselves felt.
(Fortunately modern computers keep greater accuracy in their computations than they display on the screen, so that you can tolerate some amount of loss of accuracy due to round-off error, without even noticing it.)

However there is something much better that generally does home in on a value that is recognizable as the derivative you seek, and it takes no more work! Instead of computing $f ( x 0 + d ) − f ( x 0 ) d$ we form $f ( x 0 + d ) − f ( x 0 − d ) 2 d$ . Try this yourself.