Mass ratio from barycenter calculator
Read the mass ratio of two orbiting bodies straight from their distances to the shared centre of mass: distances of 1,500,000,000 and 450,000,000,000 give a ratio of 300. Any length unit works. Free in your browser.
- Free
- Runs in your browser
- No sign-up
- Your data stays on your device
Run — free
Worked example
- R1
- 1,500,000,000
- R2
- 450,000,000,000
- Mass ratio
- 300
- Mass ratio inverse
- 0.0033333333
Two bodies in mutual orbit share a barycenter—the centre of mass on the line that joins them. The heavier body sits closer to that point and the lighter body farther out, so the product of each mass and its barycenter distance is the same. Negative distances are rejected as non-physical.
What the barycenter mass ratio means
The result is dimensionless: kilometres, astronomical units, or light-seconds cancel, so you only need both distances in the same unit. When either distance is exactly zero the algebraic ratio would require a division by zero—physically, a body sitting on the barycenter while the companion remains at finite range is only consistent with an infinite mass ratio, which this calculator refuses to invent as a finite number. Negative lengths have no meaning as radial distances to a barycenter and are rejected.
This page intentionally returns only the pure ratio from the two distances; absolute masses in kilograms, orbital periods, or Keplerian semi-major axes are separate search intents and separate landings.
Where a barycenter mass-ratio calculator earns its keep
Introductory astronomy and two-body mechanics courses assign barycenter ratio drills long before students meet full Keplerian solvers; a trusted oracle that only divides the two distances speeds grading and demo setup. Binary-star and exoplanet tutorial tracks often publish angular or linear separations from the centre of light or mass and ask only for m1 over m2, not absolute solar masses. Science communicators convert textbook Sun–planet and double-star cases into quick ratios for slides without opening a computer-algebra system.
Game and simulation authors seed toy two-body systems with transparent ground-truth mass ratios from placed barycenter offsets. If you later need orbital period from semi-major axis, gravitational force between two masses, centre-of-mass velocity of a particle list, or Roche tidal limits, treat those as separate search intents and landings rather than overloading this mass ratio from barycenter page.
What you can do with it
Binary-star and two-body labs
Turn measured or assigned radial offsets from the centre of mass into a dimensionless mass ratio without solving for absolute masses.
FAQ
How do I get a mass ratio from the barycenter?
Divide the second body's distance from the barycenter by the first body's distance. That gives the first mass over the second, because each mass times its distance is the same for both bodies.
Which body is heavier?
The one closer to the barycenter. The heavier body sits near the shared centre of mass and the lighter one swings farther out, so the shorter distance always belongs to the larger mass.
Do both distances need the same unit?
Yes, but any unit works: kilometres, astronomical units or light-seconds. The unit cancels out, so the result is a pure number with no unit attached.
Why is a distance of zero not accepted?
A body sitting exactly on the barycenter while its companion stays at a distance would need an infinitely larger mass. Rather than invent a finite number, the calculator asks for two distances greater than zero.
Related tools
For developers — API access
Everything on this page is available programmatically. This section is for teams who want to wire it into their own systems; everyone else can just use the tool above.
API endpoint
Prefer to automate it? One authenticated POST creates the task; the result comes back by webhook or a signed link. The same capability also runs here on the web, by email and from Telegram — and soon from our app too.
Call it from your stack
curl -X POST https://api.kit.forhosting.com/astro/mass-ratio-from-barycenter \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"r1":1500000000,"r2":450000000000}'const res = await fetch("https://api.kit.forhosting.com/astro/mass-ratio-from-barycenter", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"r1": 1500000000,
"r2": 450000000000
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/astro/mass-ratio-from-barycenter",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"r1": 1500000000,
"r2": 450000000000
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/astro/mass-ratio-from-barycenter", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"r1":1500000000,"r2":450000000000}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"r1":1500000000,"r2":450000000000}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/astro/mass-ratio-from-barycenter", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"r1": 1500000000,
"r2": 450000000000
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "astro.mass_ratio_from_barycenter",
"status": "queued",
"_links": {
"result": "/tasks/tsk_…/result"
}
}The API is asynchronous: the call returns a task_id immediately and the result arrives by webhook. Polling is capped at 1 req/s per task.
Pricing
Published price — no tokens, no invented credits. A failed task is never charged.
Errors
| HTTP | Code | Meaning |
|---|---|---|
401 | unauthorized | Missing or invalid API key. |
402 | insufficient_balance | Your balance doesn't cover the task price. |
404 | unknown_type | That task type doesn't exist. |
429 | rate_limited | Too many requests. Use the webhook instead of polling. |
Technical notes
This mass ratio from barycenter calculator accepts two strictly positive finite distances in any consistent length unit, returns m1/m2 and m2/m1 with a short formula string, and fails with invalid_input when either distance is zero so a silent Infinity never escapes into a gradebook or pipeline.
Input contract, response shape, and error behaviour
Values are rounded to twelve significant figures for stable goldens across runtimes. Classic checks include equal distances recovering mass ratio one, and a Sun–Earth style case where the Sun–barycenter distance is about one and a half million kilometres and the Earth–barycenter distance is about one hundred fifty million kilometres, recovering a mass ratio near one hundred. Pair the free browser form for classroom drills with the same contract from scripts when you need bulk answer keys. Each field may arrive as a JSON number or as a numeric string; missing fields, empty strings, non-numeric values, NaN, and Infinity fail with invalid_input naming the field and are not billed. Successful API calls use the published base price of $0.002 per item; validation failures do not consume prepaid balance.
Where a barycenter mass-ratio calculator earns its keep
Because this capability is a pure parse engine, API pricing is the published base of $0.002 per successful item and failed validation does not consume balance.
Integration use cases
Homework and exam answer keys
Compute m1/m2 = r2/r1 from two barycenter distances so students and auto-graders share one closed-form ground truth.
Curriculum widgets and demos
Drive planetarium or LMS widgets with the same pure ratio the API returns, including clear rejection of zero distances.
Technical questions
How do I get the mass ratio from barycenter distances?
Send finite positive r1 and r2 (distances of body 1 and body 2 to the shared barycenter). The API returns mass_ratio = m1/m2 = r2/r1 and mass_ratio_inverse = m2/m1 = r1/r2.
What happens if a distance is zero?
The task fails with invalid_input. A zero distance would divide by zero in m1/m2 = r2/r1 or its inverse; the calculator never returns Infinity or NaN for that case.
Must r1 and r2 use the same units?
Yes. Any consistent length unit works (m, km, AU, etc.) because the ratio is dimensionless. Mixing units without conversion yields a wrong number.
Does equal distance mean equal mass?
Yes. When r1 equals r2 the barycenter sits halfway between the bodies and mass_ratio is exactly 1 (equal masses).
What does the mass ratio from barycenter calculator cost?
The browser tool is free. API requests use prepaid KIT balance at $0.002 per successful call; invalid input is not billed.