Graphics Programs Reference
In-Depth Information
Errors in Finite Difference Approximations
Observethat in all finite difference expressions the sum of the coefficients iszero.
The effect on the roundoff error can be profound. If h is very small, the values of f ( x ),
f ( x
etc.will be approximately equal.When theyare multipliedbythe
coefficients in the finite difference formulas and added,severalsignificant figures can
be lost. On the other hand, wecannot make h too large, because then the truncation
error wouldbecomeexcessive. This unfortunate situation has no remedy, but wecan
obtain some relief by taking the following precautions:
±
h ), f ( x
±
2 h )
,
Use double-precisionarithmetic.
( h 2 ).
Employ finite difference formulasthat are accurate to atleast
O
=
e x at x
=
1
from the central difference formula, Eq. (5.2).Wecarry out the calculations with six-
and eight-digit precision, using different values of h . The results, shown in Table 5.4,
shouldbecomparedwith f (1)
To illustrate the errors, let uscompute the second derivativeof f ( x )
e 1
=
=
0
.
367 879 44.
h
6-digit precision
8-digit precision
.
.
.
0
64
0
380 610
0
380 60911
0
.
32
0
.
371 035
0
.
371 029 39
0
.
16
0
.
368 711
0
.
368 664 84
0
.
08
0
.
368 281
0
.
368 076 56
0
.
04
0
.
368 75
0
.
367 831 25
0
.
02
0
.
37
0
.
3679
.
.
.
0
01
0
38
0
3679
0
.
005
0
.
40
0
.
3676
0
.
0025
0
.
48
0
.
3680
0
.
00125
1
.
28
0
.
3712
Table 5.4. ( e x ) at x
=
1 from central finite difference
approximation
08, yielding a result
accurate to three significant figures. Hence three significant figures are lost dueto
a combination of truncation and roundoff errors.Aboveoptimal h , the dominant
erroris duetotruncation; belowit, the roundoff errorbecomes pronounced. The
best result obtainedwith the eight-digitcomputationis accurate to four significant
figures.Because the extra precisiondecreases the roundoff error, the optimal h is
smaller (about0
In the six-digitcomputations, the optimal valueof h is0
.
.
02)than in the six-figurecalculations.
Search WWH ::




Custom Search