Hubble constant from velocity and distance calculator
This calculator estimates the Hubble constant from one galaxy's recession velocity and distance by applying the rearranged Hubble law, H0 = v / d.
Run — free
Enter velocity in kilometres per second and distance in megaparsecs to receive the ratio in kilometres per second per megaparsec. It is useful for classroom exercises, quick observational checks, and transparent comparisons of measured galaxy data. The calculation is deterministic and rejects a zero or negative distance because division by such a distance is not meaningful for this input model.
Enter velocity and distance in the stated units
Provide the galaxy's recession velocity in kilometres per second and its distance in megaparsecs. The calculator does not perform unit conversion, so both values must already use those units if you want the reported Hubble constant to have the standard unit km/s/Mpc. Recession velocity is commonly inferred from a measured redshift, while distance may come from a standard candle, a distance ladder method, or another independent observation. Use the values from the same galaxy and the same reference frame. The distance must be greater than zero; a zero or negative distance cannot represent the denominator in this calculation and produces an input error. Both fields must also be finite numbers, so missing values, text, NaN, and infinity are rejected instead of producing a misleading result. A negative velocity is accepted mathematically and produces a negative ratio, although it usually describes an approaching object rather than the receding galaxies for which the simple Hubble relation is intended. Check the sign and provenance of your velocity before interpreting the answer physically.
Understand the ratio being calculated
The algorithm uses the linear Hubble relation v = H0 × d and rearranges it to H0 = v / d. It divides the supplied recession velocity by the supplied distance exactly once, then returns the result in kilometres per second per megaparsec. For example, a velocity of 7,000 km/s and a distance of 100 Mpc give 70 km/s/Mpc. The unit describes how much recession velocity the linear model associates with each megaparsec of distance. The output also repeats the validated inputs and states the formula, making the result easy to audit or save with a calculation record. This is a direct ratio, not a statistical fit: one galaxy supplies one estimate. It does not combine a sample, weight measurement uncertainties, correct peculiar motion, convert redshift into velocity, or fit cosmological parameters. Stable numeric formatting keeps equivalent results consistent across the API and browser implementation while preserving enough significant digits for ordinary exercises and data checks. If you need a survey-quality estimate, calculate a regression from a suitable collection of independently measured galaxies instead.
Interpret the estimate with the limits of Hubble's law
Treat the returned value as an estimate derived from the two numbers you supplied, not automatically as a definitive measurement of the present cosmic expansion rate. Nearby galaxies can have substantial peculiar velocities caused by local gravitational motion, so their observed recession velocity may not follow the smooth expansion relation closely. At very large distances, the elementary linear relation and a simple velocity interpretation of redshift become inadequate; a cosmological model is then needed to relate redshift, distance, and expansion history. Distance measurements also carry method-dependent uncertainty, and because distance is the denominator, that uncertainty directly affects the calculated ratio. The calculator intentionally does not hide these issues behind extra assumptions. It gives the transparent arithmetic needed for teaching, reproducing a worked example, checking a row of observational data, or comparing how different distance estimates change H0. Record the source, uncertainty, frame, and units of each input when the result will be cited. Multiple well-selected galaxies and a documented fitting method are more informative than treating a single ratio as universal.
What you can do with it
Check an astronomy exercise
Verify a worked Hubble-law problem from a galaxy velocity and distance without rearranging the formula by hand.
Compare distance estimates
See how two independently derived galaxy distances change the implied Hubble constant while holding velocity fixed.
Audit an observation table
Recalculate the per-galaxy H0 ratio for a row of observational data before performing a broader statistical fit.
FAQ
What formula does the calculator use?
It rearranges the linear Hubble law v = H0 × d and calculates H0 = v / d.
Which units should I enter?
Enter recession velocity in kilometres per second and distance in megaparsecs. The result is kilometres per second per megaparsec.
Why must distance be greater than zero?
Distance is the denominator of the ratio. Zero would make division undefined, and a negative galaxy distance is outside this input model.
Does one galaxy give a definitive Hubble constant?
No. A single ratio is sensitive to peculiar velocity and measurement uncertainty. Scientific estimates generally use carefully selected samples and statistical fitting.
Does the calculator convert redshift to recession velocity?
No. Supply an already determined recession velocity in km/s; this capability only calculates its ratio to distance.
What does an API calculation cost?
Each API request costs $0.002. The same deterministic calculation can also run in the browser.
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/hubble-constant-from-velocity \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"recession_velocity":7000,"distance":100}'const res = await fetch("https://api.kit.forhosting.com/astro/hubble-constant-from-velocity", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"recession_velocity": 7000,
"distance": 100
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/astro/hubble-constant-from-velocity",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"recession_velocity": 7000,
"distance": 100
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/astro/hubble-constant-from-velocity", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"recession_velocity":7000,"distance":100}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"recession_velocity":7000,"distance":100}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/astro/hubble-constant-from-velocity", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"recession_velocity": 7000,
"distance": 100
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "astro.hubble_constant_from_velocity",
"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. |