The order of calculating velocity and position alters the solution?

Join the discussion
Registration is free. Start your own thread to ask a follow-up.
31 replies · 5K views
TachyonLord said:
Thank you so much for your suggestion. I appreciate it a lot ! :) By the way, what is the maximum error for this algorithm ?
But I still kinda want to know about the reason for energy having these little disturbances. Thanks again :)
For this scheme, the error is going to be on the order of ##(\Delta t)^2##, compared to ##\Delta t## for the forward Euler scheme.

The explicit difference equations are going to be $$v(t+\Delta t)=\frac{1-(\pi \Delta t)^2}{1+(\pi \Delta t)^2}v(t)-\frac{4\pi^2\Delta t}{1+(\pi \Delta t)^2}x(t)$$
$$x(t+\Delta t)=\frac{\Delta t }{1+(\pi \Delta t)^2}v(t)+\frac{1-(\pi \Delta t)^2}{1+(\pi \Delta t)^2}x(t)$$

Try it. You'll like it.
 
  • Like
Likes   Reactions: TachyonLord
Physics news on Phys.org
Have you tried this difference scheme yet? You will find that it exactly conserves energy with no discretization error (and only tiny roundoff error). You will also find that this scheme is much more accurate than forward Euler, for equal values of the time step.