Predictor-Corrector methods - Improved Euler

A way to improve on the Euler method is to invoke the rhs of the ODE at mid point during each time step. This was done in the mid-point method via the Euler method over a half time interval $dt/2$..

  

Another way to take into consideration the variation of the rhs over the time step is to average the rhs calculated at t and t+dt. The latter can be estimated based on a single Euler step to obtain the solution at t+dt. This leads to a prediction sub-step followed by a correction sub-step within each time step.

  

Solving

\begin{displaymath}
\frac{ d x}{d t } = f( x , t )
\end{displaymath}

leads to the scheme:
  1. Evaluate $f_{old}$, the rhs at $t=t_{old}$ (beginning of interval)

  2. Predict $x_{pred}=x_{old} + dt f_{old}$ (Euler step)

  3. Evaluate $f_{pred} = f(x_{pred},t+dt)$, the rhs at $t = t + dt$

  4. Correct $x_{new} = x_{old} + dt ( f_{old} + f_{pred} ) / 2$ (Euler step based on average of rhs at $t$ and $t+dt$

  

The Predictor-Corrector integrator step function using a function pointer is written as predictor_corrector_step.c

  

Exercise: Implement the 1D harmonic Oscillator in this scheme.

  



Michel Vallieres 2010-01-24