<p>You should avoid using <span class="math-container">$G$</span> (when possible), since its value is only known to around 5 digits. From <a href="https://en.wikipedia.org/wiki/Gravitational_constant" rel="nofollow noreferrer">Wikipedia</a>,
<span class="math-container">$$G \approx 6.67430(15)×10^{-11}\,\rm{N\,m^2\cdot kg^{-2}}$$</span></p>
<p>That means there's an uncertainty of <span class="math-container">$15$</span> in the last two digits (<span class="math-container">$30$</span>). In this notation, the uncertainty is one <a href="https://en.wikipedia.org/wiki/Standard_deviation" rel="nofollow noreferrer">standard deviation</a>, so the probability is around <span class="math-container">$68\%$</span> that the true value is between <span class="math-container">$6.67415×10^{-11}$</span> and <span class="math-container">$6.67445×10^{-11}$</span>. There are more details on this notation <a href="https://physics.stackexchange.com/a/563879/123208">here</a>.</p>
<p>With modern technology, we can make very precise measurements of orbital periods and distances in the Solar System. This allows us to use the orbital period equation or the <a href="https://en.wikipedia.org/wiki/Vis-viva_equation" rel="nofollow noreferrer">vis-viva equation</a> to make very good calculations of <span class="math-container">$GM$</span> for the major bodies of the Solar System, especially if they have satellites. But to calculate the masses of the bodies involves dividing <span class="math-container">$GM$</span> by <span class="math-container">$G$</span>. So any values you see for the masses of astronomical bodies that are given in mass units like kilograms are limited by our poor <span class="math-container">$G$</span> value.</p>
<p>One way to work around this problem is to use mass ratios. That is, you state the mass as a number of Earth masses or solar masses. A better way is to simply use the value of <span class="math-container">$GM$</span> itself. This value is known as the <a href="https://en.wikipedia.org/wiki/Standard_gravitational_parameter" rel="nofollow noreferrer">standard gravitational parameter</a>, and sometimes written using the Greek letter <span class="math-container">$\mu$</span> (mu), although that can be a little confusing because <span class="math-container">$\mu$</span> is also used for the <a href="https://en.wikipedia.org/wiki/Reduced_mass" rel="nofollow noreferrer">reduced mass</a>.</p>
<p>That Wikipedia article has a table of <span class="math-container">$GM$</span> values for the Solar System, but I prefer to use the values given by JPL in the body data files produced by <a href="https://ssd.jpl.nasa.gov/horizons/" rel="nofollow noreferrer">Horizons</a>. You can get that data using this script: <a href="https://sagecell.sagemath.org/?z=eJw1j0FLxDAQhe_5FXFY2BZKei8ErG4XUboV1ounEjeJm6VNYjIVdel_NxGcwxw-5s17z8zeBaRBfSwqYiRLmCincEb0sanrGCW7-IlZEQV7d5-18KY-u2B-nI2jNpNiiQC5NRZVECckUmk6Fm9OfnOAsiE0jdHUOqQZNskKl2D_-GmWyUwDALnZbI7DnvTtUzd2zw9dzw8DuR_6vj3s-PaapeuWDHeP4659aflrdyRZlr_4kMyL_wbMu4hFqlFJgYJfQbswC4QGUH0hrFUOHRM31i8JF5BSQJVWuZYs35S_aOFYGg==&amp;lang=sage" rel="nofollow noreferrer">Horizons object data</a>. It can be used for any body that Horizons knows, either by name or ID number. If the body name is ambiguous, Horizons will print a list of matching bodies, with their ID numbers. Please see the <a href="https://ssd.jpl.nasa.gov/horizons/manual.html" rel="nofollow noreferrer">Horizons manual</a> for further details.</p>
<p>Here are some <span class="math-container">$GM$</span> values from Horizons. The units are <span class="math-container">$\rm{km^3/s^2}$</span>.</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th style="text-align: left;">Body</th>
<th style="text-align: right;">GM</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">Sun</td>
<td style="text-align: right;">132712440041.93938</td>
</tr>
<tr>
<td style="text-align: left;">Earth</td>
<td style="text-align: right;">398600.435436</td>
</tr>
<tr>
<td style="text-align: left;">Moon</td>
<td style="text-align: right;">4902.800066</td>
</tr>
</tbody>
</table>
</div>
<p>To convert those values to <span class="math-container">$\rm{m^3/s^2}$</span>, multiply by <span class="math-container">$10^9$</span>.</p>
<p>Using that data, <span class="math-container">$1$</span> solar mass equals <span class="math-container">$332946.048834$</span> Earth masses.</p>
<p>The JPL <a href="https://ssd.jpl.nasa.gov/astro_par.html" rel="nofollow noreferrer">Astrodynamic Parameters</a> lists newer <span class="math-container">$GM$</span> values, which come from <a href="https://doi.org/10.3847/1538-3881/abd414" rel="nofollow noreferrer">The JPL Planetary and Lunar Ephemerides DE440 and DE441</a>, Ryan S. Park et al (2021). The value given there for the Sun is <span class="math-container">$132712440041.279419 \, \rm{km^3/s^2}$</span>, which differs at the 13th digit from the value given earlier.</p>
<p>Since 2012, the <a href="https://en.wikipedia.org/wiki/Astronomical_unit" rel="nofollow noreferrer">astronomical unit</a> has been defined to be exactly <span class="math-container">$149597870700$</span> metres. Working in kilometres, we can do your period calculation using this pseudocode:</p>
<pre><code>au = 149597870.7
period = 2 * pi * sqrt((a * au)^3 / (M1 * GMsun + M2 * GMearth))
</code></pre>
<p>where <code>period</code> is in seconds, <code>M1</code> is in solar masses and <code>M2</code> is in Earth masses, and <code>a</code> is in AU.</p>
<p>Using <span class="math-container">$a=1$</span> AU in that formula, and standard double-precision arithmetic, the Earth's orbital period is <span class="math-container">$365.256349805$</span> days. That's quite close to the true <a href="https://en.wikipedia.org/wiki/Sidereal_year" rel="nofollow noreferrer">sidereal year</a>, which is approximately <span class="math-container">$365.256 363 004$</span> days.</p>
<p>Incidentally, in units of astronomical units and Julian years, <span class="math-container">$GM$</span> of the Sun is approximately <span class="math-container">$4\pi^2$</span>. Using the value from Park et al, we get <span class="math-container">$GM = 39.47692642117668951 \, \rm{au^3/y^2}$</span>. A Julian year is exactly <span class="math-container">$365.25$</span> days of <span class="math-container">$86400$</span> SI seconds.</p>

CC BY-SA 4.0
2022-02-22T21:17:04.293Z
FWIW, here's a bookmark for the Horizons body data: `javascript:(function(){let%20s=prompt('Body');if(s)location.href='https://ssd.jpl.nasa.gov/api/horizons.api?format=text&OBJ_DATA=YES&MAKE_EPHEM=NO&COMMAND='+encodeURIComponent(s)})()`  If the body name string contains spaces or commas, you *must* enclose it in single quotes.
PM 2Ring
CC BY-SA 4.0
2024-02-22T07:30:54.473Z
Note that `M2` in your pseudocode should be about 1.0123 rather than one because of the Moon, which is about 0.0123 Earth masses. Also, the Earth-Moon system orbits at slightly more than one au due to the prior definition of the au, which is a particle of negligible mass that would orbit the Sun alone in one sidereal year. Gauss used a slightly different value for a year in what would become the Gaussian gravitation constant than you did. It's not coincidental at all that $GM_{\odot}$ is $4\pi^2$ in units of astronomical units and years. It's how the astronomical unit was originally defined.
David Hammen
CC BY-SA 4.0
2024-02-22T10:54:47.020Z
@David Good points. To get the year length we really should use the Earth-Moon barycentre. OTOH, the OP wants a formula for a simple binary system in terms of solar & Earth masses, so that's what I wrote. And I gave mu for the Moon in case the reader wants to do an EMB calculation. Of course, that also needs a suitably precise value for the semi-major axis of the EMB. And the calculated period ought to be the anomalistic year, but in my answer I didn't want to go too deeply down the astronomical year rabbit-hole. FWIW, here's an EMB calculation. It's still not quite right...
PM 2Ring
CC BY-SA 4.0
2024-02-22T10:55:42.903Z
https://sagecell.sagemath.org/?z=eJxNULtOxDAQ7P0Vq9AkEPn8Co6RKEC68ipES2RdLJEitrFjCf6e9eUO0VjrnZmd2b2DlxhT%2DIbj6RWiS0uYKbz7ZctPsLotudxDdufg50yILfAMXJnB6FEzqp0kiOUJddNsfxAUCu5BPjJGyFreiq98KTQXSjGmOBXaKG6cQfRo0%5FaJuDQj8qmSw8D0BTmFUIXKMEFHxjgfsU3yaid31VwyjExITJDw%5F4eRmBa%5FtQ02mh4SHMCWHhpbmq4mQuoe6wFuAWpVDcm%2DfN0BV4gL9W2HRf5KW5s%2DJE5aS3cbv3PR4So6wP87oCG%2DGS1%5FAZ4YZEc=&lang=sage
PM 2Ring
CC BY-SA 4.0
2024-02-22T20:11:12.727Z
Oh, and I didn't intend to imply that it's a coincidence that $\mu \approx 4\pi^2$ in natural units. I said "incidentally", not "coincidentally". ;)
PM 2Ring
CC BY-SA 4.0
2024-02-24T17:29:17.413Z
"Incidentally", the Gaussian gravitational constant still exists, in a hidden way, in JPL's Development Ephemerides. $\left(\frac{0.0172020989500}{86400 \operatorname{TDB seconds}}\right)^2 \ast (1 \operatorname{au})^3$ is **the** value that JPL uses to this day for the TDB solar mass parameter.
David Hammen
CC BY-SA 4.0
2024-02-24T19:41:44.190Z
@David That may be true of the older DEs, and it's certainly true of the GM_Sun value in that table from Horizons, but I don't think it applies to DE 440/441. According to  Ryan S. Park et al (2021), that slightly lower value was estimated from DE 440. Here's a comparison.
PM 2Ring
CC BY-SA 4.0
2024-02-24T19:43:16.873Z
https://sagecell.sagemath.org/?z=eJxtj09Lw0AQxe%5FzKR71sisSN5ttNxvwpjmIqLRHsRDJBkL%2DaZpFSul3d1IDXpzLwLzfm3lzhcfXJ9w%5FYBd6dAFFX6Khj3o64A4bQ9uc%2D9YXbV77thSzIInK4sjjdGOUoiIkM5KL2Li1s6lVkZXYIyHqwktbLmKibawNG0wcucQlqWT52X%5F%5FI2vrTOwkNbtpcatIxVYrrVzq1krNCXyFbhhEIzOMfgpjD9HgFpxM7jWuwbF%2DqaY4ii78YYevceIBs4xIJtlCVA3j%5FH7d4%2D2ylk%5FLG1wemBsHfc8IXJ9j3U%2DiWp26kEVpdUaG03LivOJgP3fwWsM=&lang=sage
PM 2Ring
CC BY-SA 4.0
2024-02-24T22:43:36.807Z
Those numbers for GM_Sun all agree with one another to 11 digits. Everything beyond that is fiction. We don't yet know GM_Sun to 12 digits, let alone 18 digits (the DE 440/441 value you used). Even though the Sun is estimated to lose about $10^{-13}$ solar masses per year, JPL has yet to represent GM_Sun as a time-varying parameter in their ephemerides computations because the variations remain in the noise.
David Hammen
CC BY-SA 4.0
2024-02-24T22:56:33.980Z
*"We don't yet know GM_Sun to 12 digits"*. Ah. Ok. Thanks, @David
PM 2Ring
CC BY-SA 4.0
2022-02-22T20:50:12.343Z
2024-02-04T21:48:24.757Z
2024-02-04T21:48:24.757Z
PM 2Ring
<p>If the masses are in solar masses, <span class="math-container">$a$</span> is in AU and T is in years, then just use <span class="math-container">$G=(2 \pi)^2$</span>. (hat tip to PM2Ring)</p>
<p><span class="math-container">$$T/year = \sqrt{\frac{(a/AU)^3}{(M_1+M_2)/M_{Sun}}} $$</span></p>
<p>This won’t be absolutely exact because of the ways that years, AUs and solar masses are defined, but we don’t know <span class="math-container">$G$</span> that well either!</p>

CC BY-SA 4.0
2022-02-23T01:21:45.043Z
If anyone is wondering how on Earth this works out - remember that ~1 AU is the distance at which a body in orbit around a ~1 solar-mass body has an orbital period of ~1 year.
TLW
CC BY-SA 4.0
2022-02-23T20:18:26.610Z
...and, put another way, we can see this explicitly by simply converting units (ie, there's nothing exotic going on).  $G=6.67x10^{-11} N.m^2.kg^{-2} = 6.67x10^{-11} m^3.s^{-2}.kg^{-1}$.  With the unit conversions above, that turns directly into $39.47 AU^3.yr^{-2}.Msun^{-1}$.  Lovely: I'd never thought of $G=(2\pi)^2$ in the _right_ units (of course, it's also G=1 in the _other_ right units...)
Norman Gray
CC BY-SA 4.0
2022-02-24T18:50:04.390Z
This is more exact than using SI units, since $GM_{Sun}$ is much more precisely known than either $G$ or $M_{Sun}$.
Walter
CC BY-SA 4.0
2022-02-24T23:40:43.450Z
@Walter *potentially*, but an AU is defined by the speed of light and the second and not Earth's semi-major axis, and year is based on a second which is based on "transition between the hyperfine levels of the unperturbed ground state of the 133Cs atom" and not Earth's period, so I'm not sure in the end which one is is going to turn out to be closer. Because of all the perturbations from Venus and Jupiter et al. I'm not sure how periodic Earth's orbit even is.
uhoh
CC BY-SA 4.0
2024-02-24T14:54:41.927Z
@uhoh That's how the au is defined since 2012. The astronomic unit formerly was defined as the distance from the Sun at which a particle of negligible mass would have an unperturbed circular orbit about the Sun with a mean motion of  0.0172020989500 radians per day, or $2\pi$ radians per 365.256898326 days, the value that astronomers at the start of the 19th century thought to be the length of a sidereal year. (The currently accepted value is 365.256363004 days.) Note that 0.0172020989500 **is** the numerical value of the Gaussian gravitational constant.
David Hammen
CC BY-SA 4.0
2022-02-22T13:12:27.693Z
2022-02-22T22:07:49.193Z
2022-02-22T22:07:49.193Z
uhoh
<p>You can figure it out by looking at the equation and using simple dimensional analysis.</p>
<p><span class="math-container">$$T_{binary} = 2 \pi \sqrt{\frac{a^3}{G (M_1+M_2)}} $$</span></p>
<p>We know that <span class="math-container">$T_{binary}$</span> needs to be time, <span class="math-container">$a$</span> is a unit of distance, and <span class="math-container">$M_1$</span> / <span class="math-container">$M_2$</span> are units of mass. We can easily look up <span class="math-container">$G$</span> to find that it has units of <span class="math-container">$\frac{m^3}{kg\cdot s^2}$</span>, which are distance cubed over mass and time squared.</p>
<p>Plug that into the equation and get:</p>
<p><span class="math-container">$$\text{time} \propto \sqrt{\frac{\text{distance}^3}{\frac{\text{distance}^3}{\text{mass}\cdot\text{time}^2} (\text{mass+mass})}}$$</span></p>
<p>From here, it's pretty clear that the sum of masses cancels with the mass from <span class="math-container">$G$</span>, the distances cancel from <span class="math-container">$a$</span> to <span class="math-container">$G$</span>, and you're left with the root of the square of time, hence why you end up with a unit of time.</p>
<p>If you want to add solar masses to Earth masses, you'll have to convert one of them. Let <span class="math-container">$k=\frac{\text{solar mass}}{\text{Earth mass}}\approx 333000$</span>, then we can turn the sum into <span class="math-container">$(kM_1+M_2)$</span>. The result of the sum will be Earth masses, so we need the mass in <span class="math-container">$G$</span> to be Earth masses.</p>
<p>A standard definition is <span class="math-container">$G=6.67408\cdot10^{-11} \frac{m^3}{kg\cdot s^2}$</span>, so we need to multiply by an appropriate factor to convert from <span class="math-container">$\frac{1}{kg}$</span> to <span class="math-container">$\frac{1}{\text{Earth mass}}$</span>.</p>
<p><span class="math-container">$1\text{ Earth mass}= 5.9736\cdot 10^{24} kg$</span> <span class="math-container">$\rightarrow 1=\frac{5.9736\cdot 10^{24} kg}{1 \text{ Earth mass}}$</span>.</p>
<p>Next, you want <span class="math-container">$a$</span> in AU, so we need to convert that. <span class="math-container">$1\text{ AU}=149,597,870,700 m$</span>, which gives us <span class="math-container">$1=\frac{1\text{ AU}}{149,597,870,700 m}$</span>.</p>
<p>Finally, we need a factor for time. Given the other units, I'm thinking days or years would be appropriate temporal units. Let's say we want days, then <span class="math-container">$1\text{ day}=86400 s$</span>, giving <span class="math-container">$1=\frac{86400 s}{1\text{ day}}$</span>.</p>
<p>Now we just need to multiply<br />
<span class="math-container">$\require{cancel}G\cdot\text{ratio}_{mass}\cdot{\text{ratio}_{distance}}^3\cdot{\text{ratio}_{time}}^2$</span>.<br />
<span class="math-container">$=6.67408\cdot10^{-11} \frac{\cancel{m}^3}{\cancel{kg}\cdot \cancel{s}^2}$</span> <span class="math-container">$\cdot\frac{5.9736\cdot 10^{24} \cancel{kg}}{1 \text{ Earth mass}}$</span> <span class="math-container">$\cdot\left(\frac{1\text{ AU}}{149,597,870,700 \cancel{m}}\right)^3$</span> <span class="math-container">$\cdot\left(\frac{86400 \cancel{s}}{1\text{ day}}\right)^2$</span><br />
<span class="math-container">$=\frac{6.67408\cdot10^{-11}\cdot 5.9736\cdot 10^{24}\cdot 86400^2}{149,597,870,700^3}$</span> <span class="math-container">$\cdot\frac{\text{AU}^3}{\text{Earth mass}\cdot\text{days}^2}$</span><br />
=<span class="math-container">$8.8895\cdot10^{-10}$</span> <span class="math-container">$\cdot\frac{\text{AU}^3}{\text{Earth masses}\cdot\text{days}^2}$</span></p>
<p>We can plug this into a computer program or calculator using:<br />
<span class="math-container">$a$</span> is the semi-major axis, in AU.<br />
<span class="math-container">$M_1$</span> is the large body mass, in <span class="math-container">$M_☉$</span>.<br />
<span class="math-container">$M_2$</span> is the small body mass, in <span class="math-container">$M_$</span>.<br />
<span class="math-container">$T$</span> is the orbital period, in Earth days.<br />
<span class="math-container">$T=2\pi\sqrt{\frac{a^3}{8.8895\cdot10^{-10}(333000\cdot M_1+M_2)}}$</span></p>
<p>We can bring the numeric portion of <span class="math-container">$G$</span> out if we want, for:<br />
<span class="math-container">$T=2.1074\cdot 10^5\sqrt{\frac{a^3}{333000\cdot M_1+M_2}}$</span></p>
<p>Voila! We now have an equation that uses custom units. You can do the same thing for any units you want, including made-up units like &quot;the mass of an average Klingon spit-wad&quot;, as long as you can convert it to something standardized.</p>
<p>We can sanity check the equation with:<br />
<span class="math-container">$a=1$</span> AU.<br />
<span class="math-container">$M_1=1M_☉$</span>.<br />
<span class="math-container">$M_2=1M_$</span>.<br />
<span class="math-container">$T=2.1074\cdot 10^5\sqrt{\frac{1^3}{333000\cdot 1+1}}$</span><br />
<span class="math-container">$=2.1074\cdot 10^5 \cdot 1.7329 \cdot 10^{-3}$</span><br />
<span class="math-container">$=365.19$</span> days.</p>
<p>Which is quite close to the 365.242-ish days in a real year.</p>
<p>Obviously, accuracy will depend greatly on how good your source numbers are.</p>

CC BY-SA 4.0
2022-02-25T09:25:30.727Z
The first part of this answer is excellent. But you lose a lot of precision by using G instead of GM. FWIW, more precise values of your constants are 8.88769244512e-10 and 210758.626456 (see my answer for a more precise Sun/Earth mass ratio).
PM 2Ring
CC BY-SA 4.0
2022-02-23T18:39:48.647Z
2022-02-23T18:39:48.647Z
MichaelS
<p>You need to use the same units for both masses, M<span class="math-container">$_1$</span> and M<span class="math-container">$_2$</span>.</p>
<p>If you use SI units for all values, then you answer will be in seconds. This means using kg for mass and m for distance. As an example...</p>
<p>The orbital period is given by:</p>
<p><span class="math-container">$\displaystyle T = 2 \pi \sqrt{\frac{a^3}{G (M_1 + M_2)}} $</span></p>
<p>Rough values for Earth/Sun mass and orbital separation:</p>
<p>Semi-major axis = 1 AU = <span class="math-container">$1.5 \times 10^{11}$</span> m <br />
M<span class="math-container">$_1$</span> = 1 Earth mass = <span class="math-container">$6 \times 10^{24}$</span> kg <br />
M<span class="math-container">$_2$</span> = 1 Solar mass = <span class="math-container">$2 \times 10^{30}$</span> kg</p>
<p>Plugging these into the equation gives:</p>
<p><span class="math-container">$\displaystyle T = 2 \pi \sqrt{\frac{(1.5 \times 10^{11})^3}{(6.67 \times 10^{-11}) ((6 \times 10^{24}) + (2 \times 10^{30})) }} $</span></p>
<p><span class="math-container">$\displaystyle T \approx 3.16 \times 10^7$</span> seconds</p>
<p><span class="math-container">$\displaystyle T \approx 1.002$</span> years</p>

CC BY-SA 4.0
2022-02-22T12:50:34.777Z
2022-02-22T12:50:34.777Z
lucas
<p>Using this site for binary system orbital period calculations: <a href="https://www.omnicalculator.com/physics/orbital-period" rel="noreferrer">https://www.omnicalculator.com/physics/orbital-period</a></p>
<p>The formula given there is</p>
<p><span class="math-container">$$T_{binary} = 2 \pi \sqrt{\frac{a^3}{G (M_1+M_2)}} $$</span></p>
<p>Entering numbers into the calculator on that page works fine, but I'm having trouble reproducing the above formula on my (physical) calculator as I'm not sure which of the units allowed on that page should be used. Ideally I'd want to use solar masses for M1, earth masses for M2, and AU for a. However I'm not getting anything resembling the right answers. I'm also entering G as 0.0000000000667408.</p>
<p>So my question is: is the formula as stated above correct, and if so which units are used?</p>
<p>I'm a total layman with this kind of thing, so apologies if this question seems dumb.</p>

CC BY-SA 4.0
2022-02-22T12:32:07.753Z
You have to use the same units everywhere. You cannot directly use solar masses for M1 and earth masses for M2; they have to be in the same units. The calculator on that page is obviously converting everything to the same set of units behind the scenes (e.g., both M1 and M2 are probably converted to kg, the SI version of G is used, and then the resulting period in seconds is converted to days + hours).
Peter Erwin
CC BY-SA 4.0
2022-02-22T19:18:57.543Z
You should avoid using G (when possible), since its value is only known to around 5 digits. See https://en.wikipedia.org/wiki/Gravitational_constant & https://astronomy.stackexchange.com/q/13587/16685
PM 2Ring
<orbit><gravity>
Units for orbital period and gravitational constant
Hemlyn
# Units for orbital period and gravitational constant

(Asked by: username_0 on 2022-02-22)

Using this site for binary system orbital period calculations: <https://www.omnicalculator.com/physics/orbital-period>

The formula given there is

$$T\_{binary} = 2 \pi \sqrt{\frac{a^3}{G (M\_1+M\_2)}} $$

Entering numbers into the calculator on that page works fine, but I'm having trouble reproducing the above formula on my (physical) calculator as I'm not sure which of the units allowed on that page should be used. Ideally I'd want to use solar masses for M1, earth masses for M2, and AU for a. However I'm not getting anything resembling the right answers. I'm also entering G as 0.0000000000667408.

So my question is: is the formula as stated above correct, and if so which units are used?

I'm a total layman with this kind of thing, so apologies if this question seems dumb.

**Tags:** orbit, gravity
> **Comments:**
> **username_1**: You have to use the same units everywhere. You cannot directly use solar masses for M1 and earth masses for M2; they have to be in the same units. The calculator on that page is obviously converting everything to the same set of units behind the scenes (e.g., both M1 and M2 are probably converted to kg, the SI version of G is used, and then the resulting period in seconds is converted to days + hours).  
> **username_2**: You should avoid using G (when possible), since its value is only known to around 5 digits. See https://en.wikipedia.org/wiki/Gravitational_constant & https://astronomy.stackexchange.com/q/13587/16685  

---

## 4 answers

### Answer by username_9 on 2022-02-22. Score: 9 | Accepted answer

You need to use the same units for both masses, M$\_1$ and M$\_2$.

If you use SI units for all values, then you answer will be in seconds. This means using kg for mass and m for distance. As an example...

The orbital period is given by:

$\displaystyle T = 2 \pi \sqrt{\frac{a^3}{G (M\_1 + M\_2)}} $

Rough values for Earth/Sun mass and orbital separation:

Semi-major axis = 1 AU = $1.5 \times 10^{11}$ m   
M$\_1$ = 1 Earth mass = $6 \times 10^{24}$ kg   
M$\_2$ = 1 Solar mass = $2 \times 10^{30}$ kg

Plugging these into the equation gives:

$\displaystyle T = 2 \pi \sqrt{\frac{(1.5 \times 10^{11})^3}{(6.67 \times 10^{-11}) ((6 \times 10^{24}) + (2 \times 10^{30})) }} $

$\displaystyle T \approx 3.16 \times 10^7$ seconds

$\displaystyle T \approx 1.002$ years


---

### Answer by username_2 on 2022-02-22. Score: 9

You should avoid using $G$ (when possible), since its value is only known to around 5 digits. From Wikipedia,
$$G \approx 6.67430(15)×10^{-11}\,\rm{N\,m^2\cdot kg^{-2}}$$
That means there's an uncertainty of $15$ in the last two digits ($30$). In this notation, the uncertainty is one standard deviation, so the probability is around $68\%$ that the true value is between $6.67415×10^{-11}$ and $6.67445×10^{-11}$. There are more details on this notation here.
With modern technology, we can make very precise measurements of orbital periods and distances in the Solar System. This allows us to use the orbital period equation or the vis-viva equation to make very good calculations of $GM$ for the major bodies of the Solar System, especially if they have satellites. But to calculate the masses of the bodies involves dividing $GM$ by $G$. So any values you see for the masses of astronomical bodies that are given in mass units like kilograms are limited by our poor $G$ value.
One way to work around this problem is to use mass ratios. That is, you state the mass as a number of Earth masses or solar masses. A better way is to simply use the value of $GM$ itself. This value is known as the standard gravitational parameter, and sometimes written using the Greek letter $\mu$ (mu), although that can be a little confusing because $\mu$ is also used for the reduced mass.
That Wikipedia article has a table of $GM$ values for the Solar System, but I prefer to use the values given by JPL in the body data files produced by Horizons. You can get that data using this script: Horizons object data. It can be used for any body that Horizons knows, either by name or ID number. If the body name is ambiguous, Horizons will print a list of matching bodies, with their ID numbers. Please see the Horizons manual for further details.
Here are some $GM$ values from Horizons. The units are $\rm{km^3/s^2}$.




Body
GM




Sun
132712440041.93938


Earth
398600.435436


Moon
4902.800066




To convert those values to $\rm{m^3/s^2}$, multiply by $10^9$.
Using that data, $1$ solar mass equals $332946.048834$ Earth masses.
The JPL Astrodynamic Parameters lists newer $GM$ values, which come from The JPL Planetary and Lunar Ephemerides DE440 and DE441, Ryan S. Park et al (2021). The value given there for the Sun is $132712440041.279419 \, \rm{km^3/s^2}$, which differs at the 13th digit from the value given earlier.
Since 2012, the astronomical unit has been defined to be exactly $149597870700$ metres. Working in kilometres, we can do your period calculation using this pseudocode:
au = 149597870.7
period = 2 * pi * sqrt((a * au)^3 / (M1 * GMsun + M2 * GMearth))

where period is in seconds, M1 is in solar masses and M2 is in Earth masses, and a is in AU.
Using $a=1$ AU in that formula, and standard double-precision arithmetic, the Earth's orbital period is $365.256349805$ days. That's quite close to the true sidereal year, which is approximately $365.256 363 004$ days.
Incidentally, in units of astronomical units and Julian years, $GM$ of the Sun is approximately $4\pi^2$. Using the value from Park et al, we get $GM = 39.47692642117668951 \, \rm{au^3/y^2}$. A Julian year is exactly $365.25$ days of $86400$ SI seconds.

> **Comments:**
> **username_2**: FWIW, here's a bookmark for the Horizons body data: `javascript:(function(){let%20s=prompt('Body');if(s)location.href='https://ssd.jpl.nasa.gov/api/horizons.api?format=text&OBJ_DATA=YES&MAKE_EPHEM=NO&COMMAND='+encodeURIComponent(s)})()`  If the body name string contains spaces or commas, you *must* enclose it in single quotes.  
> **username_3**: Note that `M2` in your pseudocode should be about 1.0123 rather than one because of the Moon, which is about 0.0123 Earth masses. Also, the Earth-Moon system orbits at slightly more than one au due to the prior definition of the au, which is a particle of negligible mass that would orbit the Sun alone in one sidereal year. Gauss used a slightly different value for a year in what would become the Gaussian gravitation constant than you did. It's not coincidental at all that $GM_{\odot}$ is $4\pi^2$ in units of astronomical units and years. It's how the astronomical unit was originally defined.  
> **username_2**: @David Good points. To get the year length we really should use the Earth-Moon barycentre. OTOH, the OP wants a formula for a simple binary system in terms of solar & Earth masses, so that's what I wrote. And I gave mu for the Moon in case the reader wants to do an EMB calculation. Of course, that also needs a suitably precise value for the semi-major axis of the EMB. And the calculated period ought to be the anomalistic year, but in my answer I didn't want to go too deeply down the astronomical year rabbit-hole. FWIW, here's an EMB calculation. It's still not quite right...  
> **username_2**: https://sagecell.sagemath.org/?z=eJxNULtOxDAQ7P0Vq9AkEPn8Co6RKEC68ipES2RdLJEitrFjCf6e9eUO0VjrnZmd2b2DlxhT%2DIbj6RWiS0uYKbz7ZctPsLotudxDdufg50yILfAMXJnB6FEzqp0kiOUJddNsfxAUCu5BPjJGyFreiq98KTQXSjGmOBXaKG6cQfRo0%5FaJuDQj8qmSw8D0BTmFUIXKMEFHxjgfsU3yaid31VwyjExITJDw%5F4eRmBa%5FtQ02mh4SHMCWHhpbmq4mQuoe6wFuAWpVDcm%2DfN0BV4gL9W2HRf5KW5s%2DJE5aS3cbv3PR4So6wP87oCG%2DGS1%5FAZ4YZEc=&lang=sage  
> **username_2**: Oh, and I didn't intend to imply that it's a coincidence that $\mu \approx 4\pi^2$ in natural units. I said "incidentally", not "coincidentally". ;)  
> **username_3**: "Incidentally", the Gaussian gravitational constant still exists, in a hidden way, in JPL's Development Ephemerides. $\left(\frac{0.0172020989500}{86400 \operatorname{TDB seconds}}\right)^2 \ast (1 \operatorname{au})^3$ is **the** value that JPL uses to this day for the TDB solar mass parameter.  
> **username_2**: @David That may be true of the older DEs, and it's certainly true of the GM_Sun value in that table from Horizons, but I don't think it applies to DE 440/441. According to  Ryan S. Park et al (2021), that slightly lower value was estimated from DE 440. Here's a comparison.  
> **username_2**: https://sagecell.sagemath.org/?z=eJxtj09Lw0AQxe%5FzKR71sisSN5ttNxvwpjmIqLRHsRDJBkL%2DaZpFSul3d1IDXpzLwLzfm3lzhcfXJ9w%5FYBd6dAFFX6Khj3o64A4bQ9uc%2D9YXbV77thSzIInK4sjjdGOUoiIkM5KL2Li1s6lVkZXYIyHqwktbLmKibawNG0wcucQlqWT52X%5F%5FI2vrTOwkNbtpcatIxVYrrVzq1krNCXyFbhhEIzOMfgpjD9HgFpxM7jWuwbF%2DqaY4ii78YYevceIBs4xIJtlCVA3j%5FH7d4%2D2ylk%5FLG1wemBsHfc8IXJ9j3U%2DiWp26kEVpdUaG03LivOJgP3fwWsM=&lang=sage  
> **username_3**: Those numbers for GM_Sun all agree with one another to 11 digits. Everything beyond that is fiction. We don't yet know GM_Sun to 12 digits, let alone 18 digits (the DE 440/441 value you used). Even though the Sun is estimated to lose about $10^{-13}$ solar masses per year, JPL has yet to represent GM_Sun as a time-varying parameter in their ephemerides computations because the variations remain in the noise.  
> **username_2**: *"We don't yet know GM_Sun to 12 digits"*. Ah. Ok. Thanks, @David  

---

### Answer by username_4 on 2022-02-22. Score: 7

If the masses are in solar masses, $a$ is in AU and T is in years, then just use $G=(2 \pi)^2$. (hat tip to PM2Ring)

$$T/year = \sqrt{\frac{(a/AU)^3}{(M\_1+M\_2)/M\_{Sun}}} $$

This won’t be absolutely exact because of the ways that years, AUs and solar masses are defined, but we don’t know $G$ that well either!

> **Comments:**
> **username_5**: If anyone is wondering how on Earth this works out - remember that ~1 AU is the distance at which a body in orbit around a ~1 solar-mass body has an orbital period of ~1 year.  
> **username_6**: ...and, put another way, we can see this explicitly by simply converting units (ie, there's nothing exotic going on).  $G=6.67x10^{-11} N.m^2.kg^{-2} = 6.67x10^{-11} m^3.s^{-2}.kg^{-1}$.  With the unit conversions above, that turns directly into $39.47 AU^3.yr^{-2}.Msun^{-1}$.  Lovely: I'd never thought of $G=(2\pi)^2$ in the _right_ units (of course, it's also G=1 in the _other_ right units...)  
> **username_7**: This is more exact than using SI units, since $GM_{Sun}$ is much more precisely known than either $G$ or $M_{Sun}$.  
> **username_4**: @Walter *potentially*, but an AU is defined by the speed of light and the second and not Earth's semi-major axis, and year is based on a second which is based on "transition between the hyperfine levels of the unperturbed ground state of the 133Cs atom" and not Earth's period, so I'm not sure in the end which one is is going to turn out to be closer. Because of all the perturbations from Venus and Jupiter et al. I'm not sure how periodic Earth's orbit even is.  
> **username_3**: @uhoh That's how the au is defined since 2012. The astronomic unit formerly was defined as the distance from the Sun at which a particle of negligible mass would have an unperturbed circular orbit about the Sun with a mean motion of  0.0172020989500 radians per day, or $2\pi$ radians per 365.256898326 days, the value that astronomers at the start of the 19th century thought to be the length of a sidereal year. (The currently accepted value is 365.256363004 days.) Note that 0.0172020989500 **is** the numerical value of the Gaussian gravitational constant.  

---

### Answer by username_8 on 2022-02-23. Score: 3

You can figure it out by looking at the equation and using simple dimensional analysis.

$$T\_{binary} = 2 \pi \sqrt{\frac{a^3}{G (M\_1+M\_2)}} $$

We know that $T\_{binary}$ needs to be time, $a$ is a unit of distance, and $M\_1$ / $M\_2$ are units of mass. We can easily look up $G$ to find that it has units of $\frac{m^3}{kg\cdot s^2}$, which are distance cubed over mass and time squared.

Plug that into the equation and get:

$$\text{time} \propto \sqrt{\frac{\text{distance}^3}{\frac{\text{distance}^3}{\text{mass}\cdot\text{time}^2} (\text{mass+mass})}}$$

From here, it's pretty clear that the sum of masses cancels with the mass from $G$, the distances cancel from $a$ to $G$, and you're left with the root of the square of time, hence why you end up with a unit of time.

If you want to add solar masses to Earth masses, you'll have to convert one of them. Let $k=\frac{\text{solar mass}}{\text{Earth mass}}\approx 333000$, then we can turn the sum into $(kM\_1+M\_2)$. The result of the sum will be Earth masses, so we need the mass in $G$ to be Earth masses.

A standard definition is $G=6.67408\cdot10^{-11} \frac{m^3}{kg\cdot s^2}$, so we need to multiply by an appropriate factor to convert from $\frac{1}{kg}$ to $\frac{1}{\text{Earth mass}}$.

$1\text{ Earth mass}= 5.9736\cdot 10^{24} kg$ $\rightarrow 1=\frac{5.9736\cdot 10^{24} kg}{1 \text{ Earth mass}}$.

Next, you want $a$ in AU, so we need to convert that. $1\text{ AU}=149,597,870,700 m$, which gives us $1=\frac{1\text{ AU}}{149,597,870,700 m}$.

Finally, we need a factor for time. Given the other units, I'm thinking days or years would be appropriate temporal units. Let's say we want days, then $1\text{ day}=86400 s$, giving $1=\frac{86400 s}{1\text{ day}}$.

Now we just need to multiply  
$\require{cancel}G\cdot\text{ratio}\_{mass}\cdot{\text{ratio}\_{distance}}^3\cdot{\text{ratio}\_{time}}^2$.  
$=6.67408\cdot10^{-11} \frac{\cancel{m}^3}{\cancel{kg}\cdot \cancel{s}^2}$ $\cdot\frac{5.9736\cdot 10^{24} \cancel{kg}}{1 \text{ Earth mass}}$ $\cdot\left(\frac{1\text{ AU}}{149,597,870,700 \cancel{m}}\right)^3$ $\cdot\left(\frac{86400 \cancel{s}}{1\text{ day}}\right)^2$  
$=\frac{6.67408\cdot10^{-11}\cdot 5.9736\cdot 10^{24}\cdot 86400^2}{149,597,870,700^3}$ $\cdot\frac{\text{AU}^3}{\text{Earth mass}\cdot\text{days}^2}$  
=$8.8895\cdot10^{-10}$ $\cdot\frac{\text{AU}^3}{\text{Earth masses}\cdot\text{days}^2}$

We can plug this into a computer program or calculator using:  
$a$ is the semi-major axis, in AU.  
$M\_1$ is the large body mass, in $M\_☉$.  
$M\_2$ is the small body mass, in $M\_$.  
$T$ is the orbital period, in Earth days.  
$T=2\pi\sqrt{\frac{a^3}{8.8895\cdot10^{-10}(333000\cdot M\_1+M\_2)}}$

We can bring the numeric portion of $G$ out if we want, for:  
$T=2.1074\cdot 10^5\sqrt{\frac{a^3}{333000\cdot M\_1+M\_2}}$

Voila! We now have an equation that uses custom units. You can do the same thing for any units you want, including made-up units like "the mass of an average Klingon spit-wad", as long as you can convert it to something standardized.

We can sanity check the equation with:  
$a=1$ AU.  
$M\_1=1M\_☉$.  
$M\_2=1M\_$.  
$T=2.1074\cdot 10^5\sqrt{\frac{1^3}{333000\cdot 1+1}}$  
$=2.1074\cdot 10^5 \cdot 1.7329 \cdot 10^{-3}$  
$=365.19$ days.

Which is quite close to the 365.242-ish days in a real year.

Obviously, accuracy will depend greatly on how good your source numbers are.

> **Comments:**
> **username_2**: The first part of this answer is excellent. But you lose a lot of precision by using G instead of GM. FWIW, more precise values of your constants are 8.88769244512e-10 and 210758.626456 (see my answer for a more precise Sun/Earth mass ratio).  

---

