In most applications of numerical methods, as in Exercises 1619 , an exact
solution is unavailable to use as a benchmark. Therefore, it is natural to
ask, "How accurate is our numerical solution?" For example, how accurate are
the solutions obtained in Exercises 16-19 using the step size \(h=0.05\) ? This
exercise provides some insight.
Suppose we apply Heun's method or the modified Euler's method to the initial
value problem \(y^{\prime}=f(t, y), y\left(t_{0}\right)=y_{0}\) and we use a
step size \(h\). It can be shown, for most initial value problems and for \(h\)
sufficiently small, that the error at a fixed point \(t=t^{*}\) is proportional
to \(h^{2}\). That is, let \(n\) be a positive integer, let
\(h=\left(t^{*}-t_{0}\right) / n\), and let \(y_{n}\) denote the method's
approximation to \(y\left(t^{*}\right)\) using step size \(h\). Then
$$
\lim _{h \rightarrow 0 \atop t^{*} \text { fixed }}
\frac{y\left(t^{*}\right)-y_{n}}{h^{2}}=C, \quad C \neq 0
$$
As a consequence of this limit, reducing a sufficiently small step size by
\(\frac{1}{2}\) will reduce the error by approximately \(\frac{1}{4}\). In
particular, let \(\hat{y}_{2 n}\) denote the method's approximation to
\(y\left(t^{*}\right)\) using step size \(h / 2\). Then, for most initial value
problems, we expect that \(y\left(t^{*}\right)-\hat{y}_{2 n}
\approx\left[y\left(t^{*}\right)-y_{n}\right] / 4 .\) Rework Example 1 , using
Heun's method and step sizes of \(h=0.05, h=0.025\), and \(h=0.0125 .\)
(a) Compare the three numerical solutions at \(t=0.05,0.10,0.15, \ldots, 0.95
.\) Are the errors reduced by about \(\frac{1}{4}\) when the step size is reduced
by \(\frac{1}{2}\) ? (Since the solution becomes unbounded as \(t\) approaches 1
from the left, the expected error reduction may not materialize near \(t=1\).)
(b) Suppose the exact solution is not available. How can the Heun's method
solutions obtained using different step sizes be used to estimate the error?
[Hint: Assuming that
$$
y\left(t^{*}\right)-\hat{y}_{2 n} \approx
\frac{\left[y\left(t^{*}\right)-y_{n}\right]}{4}
$$
derive an expression for \(y\left(t^{*}\right)-\hat{y}_{2 n}\) that involves
only \(\hat{y}_{2 n}\) and \(\left.y_{n} .\right]\)
(c) Test the error monitor derived in part (b) on the initial value problem in
Example \(1 .\)