Critical density of the universe calculator
The critical density of the universe calculator converts a positive Hubble constant from kilometres per second per megaparsec into inverse seconds, then evaluates three H squared over eight pi G.
Run — free
It returns the critical density in kilograms per cubic metre together with the converted Hubble constant, the gravitational constant, and the formula used. This transparent calculation is useful for cosmology lessons, quick model checks, scientific pipelines, and comparisons between measured matter density and the density associated with spatial flatness.
What critical density represents
Critical density is the reference mass-energy density associated with a spatially flat universe in the standard Friedmann description. For a specified present-day Hubble constant, it is defined here as rho_c = 3H0^2/(8 pi G), where H0 is the expansion rate and G is Newton's gravitational constant. The word critical does not mean dangerous or maximum. It identifies the dividing reference used to express cosmological density parameters: a component's density parameter is its density divided by critical density. When the total density parameter is one, the corresponding geometry is spatially flat under the assumptions of the cosmological model. Because the formula contains the square of H0, a percentage change in the Hubble constant produces approximately twice that percentage change in critical density for small differences. The calculator gives a mass-equivalent density in kilograms per cubic metre. It does not determine the actual matter, radiation, or dark-energy content of the universe, and it does not decide which measured value of H0 should be preferred.
How the unit conversion and calculation work
Enter the Hubble constant in kilometres per second per megaparsec, the conventional unit used in observational cosmology. That compound unit is an expansion rate divided by distance, so it can be converted to inverse seconds. The calculator multiplies kilometres by 1,000 metres and divides by 3.085677581491367e22 metres per megaparsec. It then squares the resulting H0 value in s^-1 and applies 3H0^2/(8 pi G), using G = 6.67430e-11 m^3 kg^-1 s^-2. The dimensional factors reduce to kilograms per cubic metre. The response includes the original Hubble constant, its inverse-second form, the density, G, the output unit, and a readable formula. Keeping these intermediate details makes automated results easier to audit. JavaScript floating-point arithmetic is used, which is appropriate for ordinary scientific estimates but is not arbitrary-precision arithmetic. Inputs must be finite and strictly positive; zero or negative expansion rates are rejected as outside this calculator's stated domain.
How to interpret and use the result
Use the result as a model-dependent reference tied to the exact Hubble constant you supplied. If you compare it with a measured matter density, ensure both values use compatible units and refer to the same epoch and cosmological convention. Dividing a component density by this critical density produces a dimensionless density parameter for that component. The calculator does not propagate uncertainty, so a scientific workflow should evaluate the lower and upper H0 bounds separately or apply an appropriate error analysis. It also does not include a redshift-dependent H(z), solve the Friedmann equations, convert density into energy density, or infer curvature from observations. Those tasks require additional parameters and assumptions. For reproducibility, retain the input H0 beside the output because critical-density values calculated from different expansion-rate estimates are not directly interchangeable. The deterministic implementation is suitable for browser checks and API pipelines: identical valid input produces identical output, with no network calls, stored state, time dependence, or random choices. Each API calculation costs $0.002, while the same arithmetic can run in the browser.
What you can do with it
Check a cosmology exercise
Verify the SI conversion and critical-density result for a given classroom value of the Hubble constant.
Compare observational assumptions
Calculate how different positive H0 estimates change the reference density used by a cosmological analysis.
Supply a reproducible pipeline value
Generate critical density from structured input and retain the converted rate, constant, formula, and unit with the result.
FAQ
What formula does the calculator use?
It uses rho_c = 3H0^2/(8 pi G), after converting H0 from km/s/Mpc to s^-1.
What value of G is used?
The calculation uses G = 6.67430e-11 m^3 kg^-1 s^-2.
What unit is the critical density returned in?
The result is returned in kilograms per cubic metre (kg/m^3).
Why must the Hubble constant be positive?
This capability is defined for a positive expansion-rate magnitude. Zero and negative values are rejected instead of being assigned a potentially misleading result.
How much does an API calculation cost?
Each API request costs $0.002. The 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/critical-density \
-H "Authorization: Bearer $KIT_KEY" \
-H "Content-Type: application/json" \
-d '{"hubble_constant_km_s_mpc":70}'const res = await fetch("https://api.kit.forhosting.com/astro/critical-density", {
method: "POST",
headers: {
"Authorization": `Bearer ${process.env.KIT_KEY}`,
"Content-Type": "application/json"
},
body: JSON.stringify({
"hubble_constant_km_s_mpc": 70
})
});
const { task_id } = await res.json();import os, requests
res = requests.post(
"https://api.kit.forhosting.com/astro/critical-density",
headers={"Authorization": f"Bearer {os.environ['KIT_KEY']}"},
json={
"hubble_constant_km_s_mpc": 70
},
)
task_id = res.json()["task_id"]<?php
$res = file_get_contents("https://api.kit.forhosting.com/astro/critical-density", false, stream_context_create([
"http" => [
"method" => "POST",
"header" => "Authorization: Bearer " . getenv("KIT_KEY") . "\r\nContent-Type: application/json",
"content" => '{"hubble_constant_km_s_mpc":70}',
],
]));
$task = json_decode($res, true);body := bytes.NewBufferString(`{"hubble_constant_km_s_mpc":70}`)
req, _ := http.NewRequest("POST", "https://api.kit.forhosting.com/astro/critical-density", body)
req.Header.Set("Authorization", "Bearer "+os.Getenv("KIT_KEY"))
req.Header.Set("Content-Type", "application/json")
res, _ := http.DefaultClient.Do(req)Example request
{
"hubble_constant_km_s_mpc": 70
}Example response
{
"task_id": "tsk_a1b2c3d4e5f6a1b2c3d4e5f6",
"type": "astro.critical_density",
"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. |