I am writing a 2D simulation for binary stars orbiting each other. Currently, the initial position of the stars are on opposite sides of the screen with the left star having a velocity up the page and the right star having an equivalent velocity down the page.

The question I have is there a formula for calculating what that initial speed should be so that the stars remain in a stable orbit? Optimally, the formula would take into account the mass of the stars (which are equivalent), the distance apart, and G.

My apologies if this question would be better directed elsewhere or if I overlooked the answer in my own research.

Thank you for your help.


2 Answers 2


You will always get a "stable" orbit if the stars have less than escape velocity relative to each other. (unless you are modelling the stars as having non-zero radii so they can collide) The stars will enter into elliptical orbits around a barycentre.

But I guess you want a circular orbit. For a circular orbit the speed $v$ is given by


where r is the orbit radius (from the centre of mass), G is Newtons gravitational constant, and M is the reduced mass $$M= \frac{m_1m_2}{m_1+m_2}$$ for stars of mass $m_1$ and $m_2$.

You will find it convenient to use astronomical units (not SI units), so distance in AU, time in years, mass in "solar masses" In these units $G=(2\pi)^{2}$ and you avoid difficulties with very large and very small values. (in these units the speed of the Earth is $2\pi$ AU/year which makes sense)


To generalise from James K's answer, which gives the condition for a circular orbit...

The condition for the binary to remain bound is that the total energy of the system, which is the sum of the potential energy $V$ and the kinetic energy $T$ (as evaluated in a centre-of-momentum frame) is less than zero.

$$T+V < 0$$

Considering the system as two point masses obeying Newtonian gravity, the gravitational potential energy $V$ is given by:

$$V = -\frac{G m_1 m_2}{\left\| \vec{r_2} - \vec{r_1} \right\|}$$

where $m_1$ and $m_2$ are the masses, $\vec{r_1}$ and $\vec{r_2}$ are the position vectors of the masses, and $G$ is the gravitational constant.

The kinetic energy is given by:

$$T = \tfrac{1}{2} m_1 \left\| \vec{v_1} \right\|^2 + \tfrac{1}{2} m_2 \left\| \vec{v_2} \right\|^2$$

Where $\vec{v_1} = \dot{\vec{r_1}}$ and $\vec{v_2} = \dot{\vec{r_2}}$ are the velocity vectors of the two masses.

Using the definition of the centre-of-momentum frame $m_1 \vec{v_1} + m_2 \vec{v_2} = \vec{0}$, and expressing in terms of the relative positions and velocities

$$r = \left\| \vec{r_2} - \vec{r_1} \right\| \\ v = \left\| \vec{v_2} - \vec{v_1} \right\|$$

and the reduced mass

$$\mu = \frac{m_1 m_2}{m_1 + m_2}$$

the condition can be written:

$$\tfrac{1}{2} \mu v^2 - \frac{G m_1 m_2}{r} < 0$$

Which can be rearranged to give

$$v^2 < \frac{2 G \left( m_1 + m_2 \right)}{r}$$

An easy way to initialize a simulation is to initialise the primary stationary at the origin, pick the secondary's position and velocity to match this condition, then subtract the centre-of-mass velocity from the individual velocities to ensure your system doesn't go wandering off the screen.

What about cases not meeting the condition? If the total energy is exactly zero (i.e. replace the less-than sign with equality), the orbit will be parabolic. If the energy exceeds zero, the orbit will be hyperbolic.

If the relative velocity and relative position vectors are co-linear (or the velocity vector is zero) then the motion will be linear: if the total energy is less than zero then the masses will collide, if the total energy is greater than zero and the velocities directed outwards then they will escape to infinity.

  • 1
    $\begingroup$ This lists all the cases nicely and gives the fundamental equations for it in an easily-comprehensible form. Nice answer! $\endgroup$ Commented Jul 31, 2020 at 11:26

You must log in to answer this question.

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