......
··-···
...
---------
...
...
.. j
EULER'S METHOD 351
Usually rounding error
is
not a serious problem. However, if the desired
accuracy
is
close to the best that can be attained because of the computer word
length, then greater attention must be given to the effects due to rounding.
On an
IBM mainframe computer (see Table 1.1) with double precision arithmetic, if
h
~
.001, then the maximum of
ujh
is
2.2
X
10-
13
, where u
is
the unit round.
Thus the rounding error
will
usually not present a significant problem unless very
small error tolerances are desired. But in single precision with the same restric-
tion
on
h, the maximum of
ujh
is
0.5 X 10-4,
and
with
an
error tolerance of this
magnitude (not an unreasonable one), the rounding error will be a more signifi-
cant
factor.
Example We solve the problem
y'=
-y+2cos(x)
y(O)
= 1
whose true solution
is
Y(x)
=sin
(x)
+ cos(x). We solve it using Euler's method,
with three different forms
of
arithmetic: (1) fqur-digit decimal floating-point
arithmetic with chopping; (2) four-digit decimal floating-point arithmetic with
rounding; and (3) exact,
or
very high-precision, arithmetic.
In
the first two cases,
the unit rounding errors are
u =
.001
and u = .0005, respectiYely. The bound
(6.2.32) applies to
cas_es
1 and
2,
whereas case 3 satisfies the theoretical bound
(6.2.24). The errors for the three forms of Euler's method are given in Table 6.3.
The errors for the answers obtained using decimal arithmetic are based on the
true answers
Y(
x)
rounded to four digits.
For
the case of chopped decimal arithmetic, the errors are beginning to be
affected with
h = .02; with h =
.01,
the chopping error has a significant effect
on
Table
6.3 Example
of
rounding effects in Euler's
method
Chopped
Rounded
Exact
h
X
Decimal
Decimal
Arithmetic
.04
1
-l.OOE-2
-1.70E-
2
-1.70E-
2
2
-1.17E-
2
1.83E-
2
-1.83E-
2
3
-1.20E-
3
-2.80E-
3
-2.78E-
3
4
l.OOE- 2
1.60E-
2
1.53E-
2
5
1.13E-
2
1.96E-
2
1.94E-
2
.02
1
7.00E-
3
-9.00E-
3
-8.46E-
3
2
4.00E-
3
-9.10E-
3
-9.13E-3
3
2.30E-
3
-1.40E-
3
-1.40E-
3
4
-6.00E-
3
8.00E-
3
7.62E-
3
5
-6.00E-
3
8.50E-
3
9.63E-
3
.01
1
2.80E-
2
-3.00E-
3
-4.22E-
3
2
2.28E-
2
-4.30E-
3
-4.56E-
3
3
7.40E-
3
-4.00E-
4
-7.03E-
4
4
-2.30E-
2
3.00E-
3
3.80E-
3
5
-2.41E-
2 4.60E
-3
4.81E-
3