# A Comparison of Numeric Integration Schemes

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

## Introduction

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 chosen 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:

## Accuracy of an integration scheme

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. Image 1: Total error as the of the sum of round off error and method error.

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 time-step. 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
• Round off error ( ~ 1/h)
• Global error (~ h^p)
• Calculation time (~1/h)
• Numerical stability

Image 1 now shows the total error as the sum of round off 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: