Suppose you want to simulate the dynamics of a particle subject to Newton's laws of motion. We could just fix a discretization of the time dt and solve approximate differential equations like


and so on for the other coordinates. If we are unsatisfied with the accuracy we could make dt smaller or use higher order approximation methods, at the cost of slowing the simulation and this would reduce the error, but the error can still sum up and become big in after a long time.

Now my point is: suppose that you want to run the simulation for long time so you don't mind short run accuracy but you want the system to preserve long run properties such as conservation laws.

Concrete example: suppose the particle is subject to gravity with the acceleration ay constantly equal to g. We have the conservation law 1/2 m v^2 + m g h =constant.

Now after the approximation step I could compute the energy and discover it is slightly changed, and this lead to a degeneration after long times (for example it can lead to overflow errors or particle slowing down). At each step I could then adjust v and h in order to make the energy conserved, but I have a lot of choice here... how do I decide for the better in this constrained choice?

In general what is the best way to deal with situation where you can sacrifice short time accuracy to save speed and preserve the long time behavior?

  • \$\begingroup\$ How do you quantify "short time accuracy" and "the long time behavior"? \$\endgroup\$
    – Steve H
    Commented Aug 10, 2013 at 11:15
  • 1
    \$\begingroup\$ Welcome to Physical Chemistry. \$\endgroup\$
    – mobo
    Commented Aug 10, 2013 at 16:11
  • \$\begingroup\$ All answers provided to your question offer some well known bits of valuable information. The real question is: have you tried an integrator already and found it to "suck" a lot? Verlet and semi-implicit Euler are both symplectic (and conserve the energy or area in phase space - which is what you need). If you increase dt you'll eventually run into stability issues. You can't have it all. There's no perfect integrator that is, at the same time, symplectic, stable, accurate and fast. If you aim for a sim scenario, the speed factor should be of a lower priority.Or are you using it 'for games'? \$\endgroup\$
    – teodron
    Commented Aug 11, 2013 at 12:18
  • \$\begingroup\$ I tried both (1) semi-implicit-Euler and (2) Verlet. It seems to me that (1) has larger oscillations for the energy than (2) but also more symmetric oscillations around 0. Also it seems that the bouncing ball symulations is stable with Euler and not with Verlet, but this may be due to my opproximation of the collision with the floor. \$\endgroup\$ Commented Aug 19, 2013 at 7:58

3 Answers 3


You're mentioning a very good point! The simple answer is: In some cases simple Euler integration is not good enough, and no increase in accuracy will help.

Clearly, you have to distinguish the goal of your particular simulation. If you're simulating a whole bunch particles bouncing, interacting with each other and/or fields and gravity en masse, then the Euler method should be good enough. Your system might diverge from the "real" solution, but for all practical purposes no one will notice.

That being said, there are cut cases where one intuitively knows the solution or some property of it. If you have a plane orbiting a star, it should do so on an elliptical orbit. If you have a weight attached to a spring, the elongation of the spring should be sinusoidal (without dampening). Then simple Euler integration will not just produce some inaccuracy, it will produce a solution that completely diverges from the closed path. The spring will get ridiculously elongated overtime, a planet will be escape the solar system...

When decreasing the timestep of an Euler integration, it will take longer time for the divergence to become noticeable, but if the system is prone to it, it will always occur.

There are other integrations scheme that inherently perform much better in conservative systems. Most notable are the Verlet integration and the Runge-Kutta methods. Verlet is much easier to understand and already quite good, especially in systems with conservation of energy. The Runge-Kutta method is usually the best in accuracy, but it is quite complicated and it has some inherit dampening which most of the time helps it to converge, but you might find a case where it performs worse.

Here is a nice comparison I just found: http://codeflow.org/entries/2010/aug/28/integration-by-example-euler-vs-verlet-vs-runge-kutta/

Sorry, for not providing implementations to compare. You should be able to find plenty when searching for these keywords.


Pretty sure you can just use symplectic euler integration and call it good. Over time numerical accuracies should be insignificant enough it won't matter.

Often times in a physics simulation you'll have a simple way of measuring error, and add energy back into the system. However with just simple particle dynamics conserving energy like this usually isn't necessary. Usually particle dynamics is only done to animate tons and tons of particles in an efficient manner, whereas accuracy isn't really the goal.

  • \$\begingroup\$ Ok, thank you very much. The point is that if I have tons of interacting particles and due to errors the total energy is shrinking or exploding then the dynamics will degenerate. \$\endgroup\$ Commented Aug 10, 2013 at 11:23
  • \$\begingroup\$ @Marco Welcome to the world of physics simulation. We take what we can get. I don't think you understand when I say "symplectic euler is accurate enough". Perhaps you should try putting this sort of thing into practice instead of theorizing about errors. \$\endgroup\$
    – RandyGaul
    Commented Aug 10, 2013 at 20:27
  • 2
    \$\begingroup\$ @Marco The symplectic Euler method is explicitly designed to be better at energy conservation than the basic Euler method that you posted, which often tends to add energy over time. \$\endgroup\$ Commented Aug 11, 2013 at 1:33


where you can sacrifice short time accuracy to save speed and preserve the long time behavior?

from the request is nonsensical as it stands. As you extend the simulation, and particularly if you do not carefully guard and preserve the accuracy of every result, you will end up with the rounding error of your calculations accumulating to overwhelm everything else.

The only way to preserve long-term accuracy is to ensure even greater accuracy at every shorter interval.

  • 1
    \$\begingroup\$ I think by "long-time behavior" he means something more along the lines of preserving invariants like total energy/momentum etc., than accuracy of raw predictions. For instance a simulated planet in orbit should remain in orbit, not crash into the star or escape the solar system, even if after a long time its predicted position diverges from its real one. \$\endgroup\$ Commented Aug 11, 2013 at 4:04
  • \$\begingroup\$ @NathanReed: Without an explanation of the purpose of the simulation it is difficult to say. \$\endgroup\$ Commented Aug 11, 2013 at 4:17
  • \$\begingroup\$ My point is this: there are dynamical systems which show asymptotic behaviors when t->infinity. For example: particles in a gas should expand to fill the available volume, planets should keep a bounded distance from the sun, conservative bouncing balls should have heights which oscillate between 0 and a fixed maximum... one important thing is that you will not notice accumulation of small errors if they don't lead to implausible long term behavior. So it may be important to preserve them even with bigger short term errors. \$\endgroup\$ Commented Aug 11, 2013 at 7:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .