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
y+=vy*dt;
vy+=ay*dt;
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?
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\$