We now want to analyze the error of a numerical method applied to an initial value problem of the form

Before introducing the general concept, we recall the crucial points in the error analysis that we have performed in Section ??.
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 .

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

This inequality is of the same type as the inequality in first line in (??) — one just has to replace the first by . Hence we can repeat the estimate in (??) and obtain Since we have proved the following result.
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;
 
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’)

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.


PIC

Figure 1: The global discretization error (marked by ) and its bound given in (??) (marked by ) for the step size .

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

on the interval . Again we consider Euler’s method. The crucial tool for the computation of the local error is a Taylor expansion of the solution combined with the fact that the derivatives of can be written in terms of the function by the differential equation. Using this idea we expand up to second order by
with an appropriate . Substitution into the expression for the local error leads to
Hence, choosing a constant by we find that for all if we set

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 , then

As an example of (??) we approximate the solution of the initial value problem

on the interval . Here and therefore From the ODE we see that the solution is monotonically increasing and thus we find that Therefore we can choose for any such that . In particular, we have confirmed the result we have previously obtained, see (??).

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:

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 (??))

The aim is to find a step size such that Euler’s method is approximating the solution on the interval up to a global discretization error smaller than . By Proposition ?? this can be guaranteed if is chosen so that For this example , since

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;
 
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’)

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).


PIC

Figure 2: The numerical solution obtained by Euler’s method for the step size .

Exercises

Determine the function which belongs to the fourth order Runge-Kutta method.

In Exercises ?? – ?? find an estimate for the constant of the form where is the solution of the specified initial value problem on and .

where .
where .
Set and the step size . Use MATLAB to compute the global discretization error and its bound in (??) on the interval . Compare the result with the ones obtained in Figures ?? and ??.