# Finding or calculating orbital velocities of celestial bodies at periapsis/apoapsis?

I'm writing a solar system simulation that uses n-body physics. To plug in the celestial bodies in our solar system, I'm copying orbital values from wikipedia. For one example, the wikipedia page for Europa lists the periapsis distance, the apoapsis distance, the mean orbit radius and the average orbital speed. I'm currently plugging in the average orbital speed and mean orbit radius, as using either the periapsis or apoapsis in combination with the average orbital speed would result in inaccuracy for bodies that have eccentric orbits. Unfortunately this solution does not also seem to be especially correct, as the average orbital speed is not always the speed that a body travels at the semi-major axis.

I would rather starts the simulation with each body at it's periapsis or apoapsis and having the corresponding velocity. Is there an online service where I can fetch these orbital speeds, or is there a way to calculate them?

• This is of course a good question and deserves helpful answers However, so many variations of this question have been asked and answered here (and in [Astronomy SE]()) that perhaps we should start a canonical "How to simulate the solar system to various levels of accuracy for games, videos, media etc.?" question and answer it with a list of various specific questions and answers that cover it.
– uhoh
Apr 29, 2023 at 9:10
• In your case you are already doing n-body simulation and all you need is initial state vectors at some starting time. Use Horizons by either accessing the website interactively via browser or look for ways to do it via queries or Python, or use Python's Skyfield to get some initial starting state vectors, then enjoy running your n-bpdy simulator and watching it slowly drift away from reality :-)
– uhoh
Apr 29, 2023 at 9:13

In the two-body Keplerian-Newtonian simulation, orbital speed $$v$$ is calculable from the semi-major axis $$a$$, and the radial distance $$r$$ and the gravitational parameter $$\mu$$ by the vis-viva equation.
$$v = \sqrt{\mu\left(\frac{2}{r}-\frac{1}{a}\right)}$$
If $$r = a$$, this becomes the circular orbit speed equation: $$v = \sqrt{\frac{\mu}{r}}$$