I am writing a 3D solar system simulator that features planets, asteroids, comets and Trans-Neptunian objects. It also includes daily "Close Approach" bodies from the Jet Propulsion Laboratory database. I am calculating planets positions using the “Keplerian Elements for Approximate Positions of the Major Planets” document from JPL/Caltech with formulas valid for the 3000 BC to 3000 AD range. It looks like the calculations give me a position that is not accurate enough when dealing with close approach objects: In the simulation, the time of closest distance between earth and an object doesn’t match the theoretical time.

I also tried formulas for the 1800 AD to 2050 AD range (which are supposed to be more accurate) with no significant difference.

My question is: Is there a more accurate method to calculate planets positions than the method I am using.

  • $\begingroup$ I assume you are familiar with this: ssd.jpl.nasa.gov/?ephemerides#planets $\endgroup$
    – Vince 49
    Commented Jan 13, 2018 at 23:19
  • $\begingroup$ How accurate would be enough for your goals,? Do you really need +/- thousands of years or would tens or hundreds be OK? $\endgroup$
    – uhoh
    Commented Jan 14, 2018 at 2:50
  • 1
    $\begingroup$ About accuracy, right now, when I download the orbital elements of a body that is supposed to be at its closest to earth that day, it is not. It may be closer a day before, or a day after. I am assuming that the error comes from the approximation in the calculation of earth's orbital elements from the formulas since the author of the paper label the calculations as "lower accuracy". $\endgroup$
    – ChuckM
    Commented Jan 14, 2018 at 5:52
  • $\begingroup$ @ChuckM OK for that I would recommend you ask a new question, and include a complete, specific example (links, numerical values) showing clearly the numerical disagreement. There are several people here who may be able to help you with that, but the more you document the specific problem/question, the more likely people will help. There seems to be no limit to the number of good quality questions you can ask here. Also include a link back to this question for reference. $\endgroup$
    – uhoh
    Commented Jan 14, 2018 at 6:04
  • 1
    $\begingroup$ @jumpjack, thanks for this. Really helpful to have all the parameters figured out. $\endgroup$
    – ChuckM
    Commented Feb 14, 2021 at 1:24

1 Answer 1


The "more accurate method" will be to either numerically integrate orbital motion to make your own approximate ephemeris (see this and this answer) or as @Vince49 points out, download and interpolate existing ephemerides, in this case for a very large number of minor bodies! Neither is a pretty or elegant solution but because gravity is long ranged and "everything pulls on everything", Keplerian orbits won't do here.

Realistic solar system orbits are only approximately Keplerian.

I'll mention that integrating yourself is fun and educational if you really enjoy that kind of challenge, but doing it right is much more complicated than shown in those linked answers. I was able to match the JPL ephemerides to 1 km over 1 year for a dozen large bodies, but without correctly addressing the tidal effects between the Earth and Moon, the Earth's position will continue to degrade each year. You would need to do a more sophisticated calculation than the approximation shown there.

For smaller bodies, non-gravitational forces such as radiation from the sun and by the body itself, as well as outgassing when near the sun are also important. Those can be approximated as I've described in this question and in this answer.

So I think it is likely that sooner or later you will probably decide to use existing ephemerides. If you like to program in C, there should be documentation out there to use things like the Spice toolkit to interpolate JPL kernels. Once you get good at it you may decide to construct less accurate much smaller tables to interpolate, considering you may need to do thousands or tens of thousands of minor bodies.

@RoryAlsop's excellent answer includes several helpful links, including a Python library jplephem that interpolates Spice kernels. This might be particularly helpful to you.

The Python package Skyfield is already set up to automatically download and interpolate the JPL Developmental Ephemerides, but these are only for the major solar system bodies. Since you are already using Python, I'd guess you would really enjoy reading through that package. It's a joy to use.

Also, the Python package PyEphem performs a wider range of orbit functionality for you. I'm less familliar with it so you'll have to investigate yourself. It's been around quite a long time, and I have found out is based on XEphem and VSOP87 (and see also).

The Python packages SkyField and PyEphem are both supported by the same person.

  • $\begingroup$ It's a really cool software package you have on Github! I'll take a look this coming week. $\endgroup$
    – uhoh
    Commented Jan 14, 2018 at 6:00
  • $\begingroup$ @MarkAdler I really think you should undelete your answer. The two complement each other - mine is sort-of a Smörgåsbord, yours gets to the point, and so it's better for future readers to see both of them. An answer direct from NASA is golden! $\endgroup$
    – uhoh
    Commented Jan 16, 2018 at 13:45
  • 1
    $\begingroup$ Actually I retired from NASA about eight months ago. $\endgroup$
    – Mark Adler
    Commented Jan 16, 2018 at 16:51
  • $\begingroup$ @MarkAdler Congratulations, but the NASA luster (and expertise) never wear off :-) $\endgroup$
    – uhoh
    Commented Jan 17, 2018 at 1:33

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.