Error Estimation and step size control

Error Estimates

If we want to have reliable code it needs to have some way to estimate how much error it makes at each step. There are a number of tricks for this:

Estimate the terms in the error estaimate directly e.g. estimate y''[t].

Run two different solvers.  Use the accurate one to estimate the solution and the difference between it and the less accurate one to estimate the error.

Run the same solver but with multiple smaller steps.  Use the smallest step one (and any other information you have gleaned) to estimate the solution and the differences between your solutions to estaimate the error.

Step Size Control

Assume we can estimate the error and have some understanding of the expression for the Local Truncation Error (LTE) then we can understand a couple of things about the step size.

If our step was good we can guess how much bigger a step we could have taken and try that step size next time.  The standard thing to do is guess that the constants in the LTE expression do not change too much.

If our step was bad (but not too bad) we can guess how big a step would have met our error criteria. The standard thing to do is guess that the constants in the LTE expression do not change too much.

Butcher Tables

The standard way to present Runge Kutta schemes is in a Butcher Tableau.  Yes it is the Butcher from our book.

Quick Order Computation of BS Scheme

ODE23[y_,f_,h_]:= Module[
{k1,k2,k3,k4},
k1=f[y];
k2=f[y+ 1/2 h k1];
k3=f[y+3/4 h k2];
yNew=y + h ( 2/9 k1 + 1/3 k2 + 4/9 k3);
k4=f[yNew];
zNew=y +h*(7/24 k1 + 1/4 k2 + 1/3 k3 + 1/8 k4);
{yNew, zNew}]

Need to add all the derivative formulae to the substitution list.

LTE=Series[
y[h]-ODE23[y0,f,h],
{h,0,2}]/.{
y[0]->y0
}