Step-size Adjustment

Another way to use the error information is to estimate the error and use that estimate to choose the step size so that the desired accuracy is achieved. For example, in the Euler method the local truncation error is

Yet the second derivative can be evaluated using the difference formulas as

Thus by monitoring the difference between the right-hand side from one time-step to another one obtains an estimate of the truncation error. This error can be reduced by reducing t. If the user specifies a criterion for the largest local error estimate, then t is reduced to meet that criterion. Also, t is increased to as large a value as possible, since this shortens the computation time. If the local truncation error has been achieved (and estimated) using a step size t1

and the desired error is e, to be achieved using a step size t2

then the next step size t2 is taken from

Generally, it is necessary not to change things too often or too drastically. Thus one may choose not to increase t by more than a factor (such as 2) or to increase t more than once every so many steps (such as 5) [Rice, 1983]. In the most sophisticated codes the alternative exists to change the order of the method as well. In this case, the truncation error of the orders one greater and one less than the current one are estimated, and a choice is made depending on the expected step-size and work.

To summarize, we have two ways of estimating the error in the numerical solution depending on the method we use. The first alternative is the most common and is the one we use with MATLAB. In this case we use a method with a variable stepsize, t, which is chosen by the method to give an estimated error smaller than a tolerance we specify. With this method we cannot use the extrapolation method, since the t keeps changing and we have no control over it; we only control the tolerance. Thus to assess the accuracy of the solution it is necessary to solve the problem at least twice with different tolerances. If the solution does not change (to our standards), then the problem is

solved accurately enough. We could also use two different methods, of different order. For example, ode45 and ode23 are both Runge-Kutta codes, one fifth order and one third order. Thus comparison of results from both would give some idea of the accuracy, too. Thus with MATLAB, it is imperative that we solve the problem at least two times to verify the accuracy. That doesn't mean we have to solve every case two times, since we may be making small changes in some of the parameters and redoing the calculations. We do, however, have to make this test at least once per problem.

In the second alternative, we write a code ourselves to use a fixed, specified t. We might do this in MATLAB, or in EXCEL, for example. Then we apply the method three times and verify that the solution is within the region in which the error terms are followed. Then we extrapolate to zero t to get the accurate answer. Figure 2 shows that the method used there is O(t), and the extrapolation is then done with the first order formula,

Note that we have to plot the numerical solution versus t to some power, since we don't have the exact solution for comparison. If we write our own code to solve differential equations, this test is essential to verify the answer.

Take Home Message: The ODE solvers usually adjust the time step to try to achieve a user-specified accuracy. However, at least two solutions must be found to verify the accuracy.