Redshift and Hubble’s law calculator
From a shifted spectral line to a speed and a distance.
How do I calculate redshift?
z = (observed wavelength − emitted wavelength) ÷ emitted wavelength. If a hydrogen line that a lab measures at 656.3 nm shows up at 700 nm in a galaxy’s spectrum, z = (700 − 656.3) ÷ 656.3 = 0.0666. Use the same unit for both wavelengths; the unit cancels.
How do I get the speed from z?
For small z, v = c × z. For larger z, the relativistic Doppler formula 1 + z = √((1 + β) ÷ (1 − β)), with β = v ÷ c, gives β = ((1 + z)² − 1) ÷ ((1 + z)² + 1). At z = 0.05 the two give 14,990 km/s and 14,615 km/s; the simple form overstates the speed by about 2.6%. At z = 4.5 the simple form would give 4.5 times the speed of light, which is impossible, while the relativistic one gives β = 0.936.
What is Hubble’s law?
v = H0 × d: the farther away a galaxy is, the faster it recedes, in proportion. H0 is the Hubble constant, usually written in kilometers per second per megaparsec. A megaparsec is 3.26 million light-years. OpenStax Astronomy 2e writes the constant as about 22 km/s for each million light-years.
What value of the Hubble constant should I use?
It is under active dispute. The Planck 2018 analysis of the cosmic microwave background gives 67.4 ± 0.5 km/s/Mpc (assuming the standard ΛCDM model). The SH0ES team, using Cepheid variables and supernovae, reported 73.04 ± 1.04 in 2022, about five standard deviations higher. This “Hubble tension” has no accepted explanation yet. OpenStax University Physics uses 70, and OpenStax Astronomy’s 22 km/s per million light-years is about 72 in Mpc units. The calculator lets you pick any of them or type your own.
How much does the choice of H0 change the answer?
For a galaxy at z = 0.05 (speed 14,615 km/s), H0 = 67.4 gives 217 Mpc, which is 707 million light-years, and H0 = 73.04 gives 200 Mpc, or 653 million light-years: a difference of about 8%.
Is the distance the light-travel time?
Only roughly, and only for small z. Space expands while the light travels, so the distance now, the distance when the light left and the distance the light covered are three different numbers. For z below about 0.1 they are close enough to the Hubble-law distance for rough work. For large z you need a cosmological model, not a one-line formula.
Why does a blueshift give no distance?
Hubble’s law describes the average expansion. Nearby galaxies also move through space under each other’s gravity. OpenStax Astronomy notes that most galaxies approaching us belong to our own local group, whose motion differs from the general expansion. A negative z therefore tells you about local motion, not distance.
From a spectrum to a distance
An astronomer finds a known spectral line, such as hydrogen-alpha at 656.3 nm, shifted to a longer wavelength and calls the fractional shift z. That z then converts to a speed with the Doppler formula, and the speed to a distance with Hubble’s law. For z = 0.05 the relativistic speed is 14,615 km/s (4.88% of the speed of light), which gives 217 Mpc at H0 = 67.4. The same chain (z, then speed, then distance) is the one used in OpenStax University Physics, section 11.6.
Worked example: the textbook galaxy at z = 4.5
OpenStax University Physics, Example 11.8, takes a redshift of 4.5. The relativistic formula gives β = 0.94, a speed of 280,606 km/s, and with H0 = 73.8 km/s/Mpc the distance is 3,802 Mpc (the book rounds to 3.8 × 10³ Mpc). With a 67.4 constant the same speed gives 4,163 Mpc. A galaxy at that redshift is so far that the distance depends on the model of the universe, so read the answer as the textbook’s illustration of the method, not as the true distance.
Limits of this method
First, Hubble’s law is linear only for the nearby universe, where H is nearly constant. OpenStax Astronomy notes that H changes over the history of the universe, since the expansion has been accelerating, so accurate distances to remote galaxies need a model of how it changed. Second, cosmological redshift is really a stretching of space rather than a Doppler shift through it, so the “recession speed” of a distant galaxy is a convention for a number, not a speed you could clock with a radar. Third, OpenStax Astronomy notes that Hubble’s law holds for all galaxies except a few of the nearest, which have their own motions; for those a redshift gives no reliable distance.
Common mistakes
Mixing up the direction of the subtraction gives a negative z and a nonsense distance: observed minus emitted, not the reverse. Entering one wavelength in nanometers and the other in angstroms is the other classic error; both must be in the same unit. People also apply v = cz at z of 1 or more, where it gives speeds above that of light. And the Hubble constant is written in different units in different books: kilometers per second per megaparsec, or per million light-years. The two differ by a factor of 3.26.
Sources: OpenStax University Physics, Volume 3, section 11.6 “The Big Bang” (Hubble’s law, equation 11.12, redshift definition, Example 11.8); OpenStax Astronomy 2e, section 26.5 “The Expanding Universe”; Planck Collaboration, “Planck 2018 results. VI. Cosmological parameters,” arXiv:1807.06209 (H0 = 67.4 ± 0.5 km/s/Mpc); A. Riess et al., “A comprehensive measurement of the local value of the Hubble constant…” (2022), arXiv:2112.04510 (73.04 ± 1.04). One megaparsec is 648,000/π × 10⁶ astronomical units (the parsec definition quoted in a footnote to IAU 2015 Resolution B2). Related: Doppler effect calculator, time dilation calculator, Schwarzschild radius calculator, star magnitude calculator.