We now want to analyze the error of a numerical method applied to an initial value problem of the form
Error Analysis From Section ??
We introduced two different types of error: the local discretization error and the global discretization error .
For Euler’s method, the local error is bounded by where is a constant depending on the length of the interval on which the solution is approximated, see (??). (For example, .) In particular, on the interval , the local error goes to zero at least as fast as a quadratic function in the step size .
For Euler’s method the global error is bounded by with a constant that again just depends on , see (??). Hence the global error tends to zero at least as fast as a linear function in the step size . Roughly speaking, one power is lost going from the local to the global error, and this power is lost while going through the estimate in (??). The same phenomenon occurs in the general error analysis.
A General Form for a Numerical Method
Let be the solution of the initial value problem. From now on we represent an explicit numerical method by a function as follows: for we have , , and
In Euler’s method (??) In particular, in this case, does not depend on the step size . In the modified Euler method (??)
A General Form for Errors
Next we introduce the two different types of error for a numerical method given by .
- The local discretization error is defined as where .
- The global discretization error is given by where .
A Theorem on Global Discretization Errors
The purpose is to find a bound on the global error by the same technique as in Section ??. For this we need two assumptions:
- In the error estimates for Euler’s method it was very convenient to use a bound for the local error that is independent of the actual step . Hence we assume that there is a constant such that In concrete examples this fact can be guaranteed by the differentiability of the right hand side in the initial value problem.
- We also need an additional assumption on the function : we assume that there is a constant such that for all For Euler’s method and therefore (??) is satisfied if is (globally) Lipschitz continuous in .
We are now in the position to derive a bound for the global discretization error proceeding completely analogous to Section ??. Observe that by Definition ??(a) On the other hand, the numerical method can be written as Subtracting these two equations from each other and using (??), (??) we obtain
An Example Using Euler’s Method
The estimate (??) indicates that the constant plays an important role for the size of the global discretization error. Indeed, let us illustrate this fact by applying Euler’s method to the initial value problem
on the interval . In this case since for Euler’s method Moreover, since we know the exact solution we may compute for this case as follows: we have and since we obtain (see also (??)) Therefore we can choose In fact, observe that for we recover (??).Proceeding as in Section ?? we set and compute the global discretization error and its bound in (??) by MATLAB on the interval for the step size . Concretely we type
h = 0.1;The result is shown in Figure ??. A comparison with Figure ?? shows that the error is indeed significantly bigger reflecting the fact that here whereas in the example in Section ?? this constant was one.
L = 2;
t(1) = 0;
x(1) = 1;
err(1) = 0;
est(1) = 0;
K = 1/h;
for k = 1:K
t(k+1) = t(k)+h;
x(k+1) = (1+L*h)*x(k);
err(k+1) = exp(L*t(k+1))-x(k+1);
est(k+1) = exp(L)*(exp(L*k*h)-1)*L*h/2;
end
plot(t,err,’+’)
hold on
plot(t,est,’x’)
A Bound on Local Discretization Errors
It remains to demonstrate how to determine a bound on the local discretization error for a given numerical method applied to the initial value problem
Since the solution of the initial value problem is in general not known, it is more appropriate to find a bound for the constant directly from the right hand side in the differential equation. We now outline a procedure how this can be accomplished.
We have and it follows
Hence if a solution has to be computed for , and the values of the solution certainly are in the range , thenAs an example of (??) we approximate the solution of the initial value problem
The computation of the local discretization error using Taylor expansions is quite tedious. Therefore we just remark here that for the modified Euler method the local error can be bounded by a function of the form and for the fourth order Runge-Kutta method the local discretization error is bounded by Here and are positive constants.
A Bound on Global Discretization Errors
Once the local discretization error is bounded we can use Theorem ?? to obtain a bound on global discretization error. In particular, we can prove:
- Euler’s method is bounded by
- the modified Euler method is bounded by
- the fourth order Runge-Kutta method is bounded by
In view of this proposition it is clear that the fourth order Runge-Kutta method is much better than Euler’s method or the modified Euler method: the reason is that for small step sizes the value of is much smaller than or even itself. Hence the global discretization error of the fourth order Runge-Kutta method is, for reasonably small step sizes, much smaller than for the other two methods. In addition, it is also evident how the fourth order Runge-Kutta method got its name.
Specifying the Tolerance
In principle, we can use Proposition ?? to find a step size for which the global discretization error is not bigger than a specified tolerance. To illustrate this point, consider the initial value problem (see also (??))
We now find a bound for the constant . We compute We see from the ODE that the solution is monotonically increasing. Suppose that we know that for the solution is bounded by from above. Using (??) we obtain an estimate for by Since , we can choose an such that Indeed, computing a solution with MATLAB by
h = 0.0007;we obtain the result in Figure ??. (The MATLAB command round rounds a number towards the nearest integer.) The outcome cannot be distinguished from the exact solution shown in Figure ??(b).
t(1) = 1;
x(1) = 2;
K = round(2/h);
for k = 1:K
t(k+1) = t(k)+h;
x(k+1) = x(k)+h*(x(k)+t(k));
end
plot(t,x)
xlabel(’t’)
ylabel(’x’)
Exercises
In Exercises ?? – ?? find an estimate for the constant of the form where is the solution of the specified initial value problem on and .