A LOW-ORDER PREDICTOR-CORRECTOR ALGORITHM
373
which has the solution
Y(x)
=
1/(1
+
x).
The results in Table
6.8
are for
stepsizes
h =
.25
and 2h =
.5.
The last column
is
the error estimate (6.5.27), and
it is an accurate estimator of the true error
Y(x)-
yh(x).
6.6 A Low-Order Predictor-Corrector Algorithm
In this section, a fairly simple algorithm is described for solving the initial value
problem
(6.0.1).
It
uses
the trapezoidal method (6.5.2), and it controls the size of
the local error by varying the stepsize
h. The method is not practical because of
its low order of convergence, but it demonstrates some of the ideas and
techniques involved
in
constructing a variable-stepsize predictor-corrector al-
gorithm.
It
is
also simpler to understand than algorithms based on higher order
methods.
Each step from xn
to
xn+
1
will consist of constructing
Yn+
1
from
Yn
and
Yn-
1
,
and
Yn+
1
will be an approximate solution of (6.5.2) based on using some iterate
from
(6.5.3). A regular step has xn+
1
-
xn
=
xn-
xn_
1
=
h,
the midpoint
predictor (6.5.15)
is
used, and the local error is predicted using the difference of
the predictor and corrector formulas. When the stepsize is being changed, the
Euler predictor (6.5.12)
is
used.
The user of the algorithm
will
have to specify several parameters in addition to
those defining the differential equation problem (6.0.1). The stepsize
h will vary,
and the user must specify values
h min and h max that limit the size of h. The user
should also specify an initial value for
h; and the value should be one for which
ihfy(x
0
,
y
0
)
is
sufficiently less than 1 in magnitude, say less than 0.1. This
quantity
will
determine the speed of convergence of the iteration in (6.5.3) and
is
discussed later in the section, following the numerical example. An error toler-
ance
t:
must be given, and the stepsize h
is
so chosen that the local error trunc
satisfies
(6.6.1)
at
each step. This
is
called controlling the error
per
unit stepsize. Its significance is
discussed near the end of the section.
The notation of the preceding section
is
continued. The function
un(x)
is the
solution of
y'
=
f(x,
y)
that passes through
(xn,
Yn). The local error to be
estimated and controlled
is
(6.5.11), which
is
the error in obtaining un(xn+
1
)
using the trapezoidal method:
h =
Xn+
1
-
Xn
(6.6.2)
If
Yn
is sufficiently close to Y(xn), then this is a good approximation to the
closely related truncation error in (6.5.1):