A Naive Variable Step Size Method

This demonstration illustrates the prinicpals behind automatic step size adjustment using a fairly crude, but easy to understand algorithm. It generates an approximate solution to the initial value problem

  1. y'=exp( -8(t-.5)**2 )
  2. y(0)= exp(-2)
Here is an outline of the algorithm. For the details see this. It first does one step of Euler's method using a trial step size h. Call the answer A1. It also does two steps of Euler method's with step size h/2. Call the answer A2. The local truncation error introduced in A1 is Kh**2 +O(h**3). The local truncation error introduced in A2 is Kh**2/2 +O(h**3)=A1-A2+O(h**3). If the error per unit advance in t, |A1-A2|/h, is smaller than the user specified error rate, the result A2 is accepted and the procedure moves on to the next step. Otherwise it repeats the current step with trial step size h'= .9*2*(error rate)/K.

THIS DEMONSTRATION USES A LARGE WINDOW. SCROLL AND RESIZE YOUR BROWSER WINDOW SO THAT YOU CAN SEE THE WHOLE WINDOW.

To execute one step click the "next" button. The upper window gives the approximate solution constructed to date. The lower window gives a blown up view of the current step. To start over at t=0 click the "restart" button. The demonstration provides a running commentary which at each step tells you what computations were done.

The demonstration below is an applet. Google Chrome, Firefox, Safari and Microsoft Edge no longer execute applets natively because of security issues with NPAPI plugins. However applets can be played in the Google Chrome browser by using the CheerpJ Applet Runner extension.