Recently, I've implemented and compared a number of basic integrators for my physics engine. The 3 that gave me the best results are RK4, Symplectic Euler, and Verlet Velocity, but I think I need something a little more advanced. I've done many Google and StackExchange searches but haven't found what I'm looking for.

I'm looking for something that combines the strengths of those integrators without their weaknesses. I'm only concerned about orbital mechanics. Drag and other similar forces will not be put through the integrator because it's not important that I get perfect answers for those other forces, but (near) perfect answers are very important for my orbital mechanics. Computationally expensive algorithms (within reason) are not as much of a concern as accuracy is.

My thoughts and primary concerns are as follows:

  • RK4 Pros: Very accurate.
  • RK4 Cons: Loses energy over the long term. This sim needs to be able to run for a VERY long time, so experiencing this kind of "orbital decay" is quite undesirable.
  • Symplectic Euler and Verlet Velocity Pros: Symplectic/Don't lose energy.
  • Symplectic Euler and Verlet Velocity Cons: Much less accurate. Highly eccentric orbits make this apparent very quickly...even with a simple massless-satellite-orbiting-a-massive-object scenario, the satellite's orbit "rotates" around the parent object over longer periods of time. This is extremely undesirable behavior.

For my purposes, I cannot resort to orbits "on rails".

TLDR: I am looking for an algorithm that gives me the accuracy of RK4 without the slow decay. Computational expense is not a major concern.

Thanks in advance for the help!

Update 1: I found a similar question here: https://stackoverflow.com/questions/3680136/help-with-symplectic-integrators

There might be good answers in the accepted answer, but after several hours of study, I have only determined that they are very difficult to understand. I will keep studying the accepted answer's linked paper and source code and post an answer if I get results. However, I suspect that while the algorithm is not much more complicated than RK4, the symbology and style of the linked explanations/source code are making it very difficult for anyone without a heavy math/physics background to understand. Unfortunately, as a comment noted, the OP accepted that answer, but never came back and gave a clearer explanation himself. I'll leave this question open and keep studying myself. Hopefully, together we can come up with a clearer answer for future searchers!

  • \$\begingroup\$ Have you tried wikipedia's article on (4th-order) Symplectic Integration? It's got a handful of further links for you too. \$\endgroup\$ Commented Sep 17, 2015 at 1:27
  • 1
    \$\begingroup\$ Why does it need to be so accurate? Is the player going to notice / care? We often give up accuracy in game design if it means getting the job done quickly - a million other design aspects are vying for your time. \$\endgroup\$
    – Engineer
    Commented Oct 18, 2015 at 7:56
  • \$\begingroup\$ Thanks for the response! That is along the lines of what I'm looking for, but a few months ago when I asked this question I spent a while studying that article and related ones, and was still clueless on how to convert that description into an algorithm. The math and "c" symbols sort of made sense for first/second order examples that I already knew how to do anyway, but my best efforts failed to decipher the math/symbol meanings thoroughly enough to apply the wiki equations to a 4th order algorithm. \$\endgroup\$
    – MindSeeker
    Commented Dec 18, 2015 at 23:02
  • \$\begingroup\$ @MindSeeker - you might find this page useful if you are a programmer learning to read formal math (github.com/Jam3/math-as-code) \$\endgroup\$ Commented Feb 29, 2016 at 3:53

1 Answer 1


I suggest using Cartesain Orbit Elements , with rk4 in real time simulation. Switch to kepler Orbit Elements (orbit as a function of time) when you augment timestep. Try this answer of mine as reference

Another example schenario: when your orbital body is subject to only gravity force , use kepler Orbit Elements , whe you turn on body engine (to add/decrease prograde speed), swith to Cartesain Orbit Elements (with rk4) , at the end of acceleration proces (when turno of engines) swith back to kepler Orbit Elements (on rails).

The approach I described suffers if there are more than two objects , in this case you may integrate considering Sphere of influence.

  • \$\begingroup\$ Upvoted for some excellent info that might help others who are looking at this question. Unfortunately, in my case, there is often more than one massive object, and I've ruled out spheres of influence as a solution in my case (a lot of massive objects potentially close together interacting, rather than a space ship/solar system simulator like Kerbal Space Program). So I can't accept your solution, but it does really add some great info to this question that could potentially help others. Thanks for your time and contribution! \$\endgroup\$
    – MindSeeker
    Commented Dec 18, 2015 at 22:58

You must log in to answer this question.

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