# A Comparison of Numeric Integration Schemes

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

## Magnetic pendulum revisited

The next test will deal with a magnetic pendulum simulation. The basic principles of the magnetic pendulum are explained in Video 1. The model used in this test is shown in Image 5. The simluation was solved with different integration schemes for a lot of different time step sizes. The results will then be compared and analysed with regard to time step sizes and accuracy.

But before we do so lets have a look at two sample points. The movement of the pendulum is chaotic but chaotic behavior doesnt mean you can't calculate it, it just means that the calculation error increases exponentially with time. So you can't calculate very much into the future because eventually even small variations in the initial conditions will grow and produce results that are totally different. The next test will investigate traces produced by different integration schemes. For this test the initial conditions of all integration schemes were identic so any error in the traces is the direct result of inaccuracies of the integration scheme. As you can see in image 8 There are some points in the simulation domain with virtually no difference between the edifferent results whilst there are other points were virtually every scheme produces a different result (Image 9).

### Simulation results

With this background it's interesting to see how a complete calculation will look like. First lets start with the resulting image. The following images were calculated with a time step size of h=0.015 s.

Large parts of the simulation domain show a chaotic behaviour, the central part and some structures are reproduceable regardless of the integration scheme. On a first glance all solutions look remarkably similar but maybe we should have a closer look how similar they are:

It is obvious that there are regions close to the magnets where most or all integration schemes yield the same end result. These are regions close to a magnet in which the pendulum doesn't really have much of a choice. If you get farther away from the centre (black regions) the results usually differ. Especially paths having many close encounters with Magnets exhibit strong chaotic behaviour. This is due to the force being proportional to the inverse square of the distance to the source. Consequently even small differences in the positions will have a dramatic effect on the path taken later on. And that is the very nature of chaotic behaviour.

Whatever you simulate in the future keep in mind that even the best integration scheme is always just an approximation of the truth. Using different simulation runs with slightly changed parameters and initial conditions can show you certain trends and provide statistic data on how reliable those trends are. This is usually done with so called Monte Carlo simulations but that is an entirely different topic.

You might also like: