Binary Star Initial Speed 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.
You will always get a &quot;stable&quot; 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
$$v^2=GM/r$$
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 &quot;solar masses&quot;  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)