Runge Kutta vs. Euler - On the Influence of time step sizes on the accuracy of numerical simulations

In this article i will use two real world examples in order to illustrate how the proper selection of time steps will influence the result of a numerical simulation. I got the idea for this article after finishing the magnetic pendulum simulation. The problem solved there is chaotic and i always wanted to know how reliable the result is and how different it would have been looked like had i choosen to use another integration scheme. Moreover i wanted to know if it is possible to find points in such a simulation where from a set of different integrators every single one of them converges to a different magnet. This article will answer both questions and in addition it will shed some light on the importance of choosing the right integration scheme and time step size with focus on the balance between accuracy and calculation speed.

In order to understand this article I recommend basic knowledge of numerical integration schemes. Having heard about *Euler*, *Runge-Kutta* and *Adams-Bashforth* integration schemes would certainly help since i will not explain them in detail here. If you do not know about *Runge-Kutta* I recommend the following article:

- Integration basics

An introduction to the RK4 scheme by Glenn Fiedler

The accuracy of an integration scheme is described by the local and the global error. The local error is the error made at a single integration step. The global error is the sum of local errors for many integration steps. Usually the big O notation is used to describe the local and global error of an integration scheme. The maximum global error of an integration scheme of order *p* (for small step sizes) is a function proportional to h^p or in big O notation: *O(h^p)*. The general rule is: The higher the order p, the better is the integration scheme.

Singlestep methods | |||
---|---|---|---|

Method name | Abbreviation | Local error | Global error |

Euler | Euler | O(h^2) | O(h) |

Modified Euler | Euler mod. | O(h^3) | O(h^2) |

Heun Method | Heun | O(h^3) | O(h^2) |

Runge-Kutta 3th order | RK3 | O(h^4) | O(h^3) |

Runge-Kutta 4th order | RK4 | O(h^5) | O(h^4) |

Runge-Kutta 5th order | RK5 | O(h^6) | O(h^5) |

Multistep methods | |||

Method name | Abbreviation | Local error | Global error |

Adams-Bashforth (2 Steps) | ADB2 | O(h^3) | O(h^2) |

Adams-Bashforth (3 Steps) | ADB3 | O(h^4) | O(h^3) |

Adams-Bashforth (4 Steps) | ADB4 | O(h^5) | O(h^4) |

Adams-Bashforth (5 Steps) | ADB5 | O(h^6) | O(h^5) |

Adams-Bashforth (6 Steps) | ADB6 | O(h^7) | O(h^6) |

The ultimate goal of every simulation is getting accurate results in a reasonable amount of time. You have the choice of the integration scheme and once you select it you have to use it with a suitable timestep. The general Problem is that an accurate high order scheme will require more evaluations making it slower but on the other side it will work with larger step sizes making it faster. So your choice is either using an accurate scheme with large time steps or an not so accurate scheme with smaller time steps. But be carefull: One of the misconceptions is that if you choose your time step small enough even a bad integration scheme like Euler will produce the right result. That is wrong! To find out why lets have a closer look at the global error of a numerical scheme. The following properties of the integration scheme are directly linked to the time step size:

- Accuracy of the solution
- Roundoff error ( ~ 1/h)
- Global error (~ h^p)

- Calculation time (~1/h)
- Numerical stability

Image 1 now shows the total error as the sum of roundoff error and method error plotted on a logarithmic scale. As you can see there is a step width for which the global error has a minimum. Every numerical scheme has an optimal time step size for which the total error is minimized. The consequence is that if you select your time step size too small your result will get worse not better! So much for the theory but can we actually observe this in a example? Lets find that out on the next page.

You might also like: