A siren sounds higher as it comes toward you and lower as it goes away: the Doppler effect. Light does the same. With spectral lines as precise markers, astronomers can measure how fast any star or galaxy is moving toward or away from us, from its light alone.
Why it works
A source moving away from us emits each wave crest from a little farther away than the last, so the crests arrive stretched apart: longer wavelengths, a redshift. A source moving toward us squeezes the crests together: a blueshift. In one wave period $T$ the source moves $vT$, so the wavelength changes by $\Delta\lambda = vT$ while the wavelength itself is $\lambda = cT$. Dividing, $$\frac{\Delta\lambda}{\lambda} = \frac{v}{c}.$$ This holds for speeds much less than $c$, and it measures only the radial velocity, the motion along our line of sight; sideways motion does not shift the lines.
Key idea
$\dfrac{\Delta\lambda}{\lambda_0} = \dfrac{v}{c}$. Lines shifted to longer wavelengths (redshift) mean the source is moving away; shorter (blueshift) means toward us.
Worked examples
Worked example: A receding star
Hydrogen's red line, at $656.3$ nm in the lab, appears at $656.5$ nm in a star's spectrum. Find the star's radial velocity.
- $\Delta\lambda = 656.5 - 656.3 = 0.2$ nm (longer, so a redshift).
- $v = c\,\frac{\Delta\lambda}{\lambda_0} = 3.00 \times 10^{5} \times \frac{0.2}{656.3} = 91$ km/s.
- The star is moving away from us at about $91$ km/s.
Answer: About $91$ km/s, away from us.
Worked example: An approaching galaxy
The Andromeda Galaxy moves toward us at about $300$ km/s. Where does its hydrogen-alpha line appear?
- $\Delta\lambda = \lambda_0\,\frac{v}{c} = 656.3 \times \frac{300}{3.00 \times 10^{5}} = 0.66$ nm.
- Toward us, so shorter: $656.3 - 0.66 = 655.6$ nm.
Answer: About $655.6$ nm, a blueshift.
Common mistake
A redshifted star does not look red. A star moving away at $30$ km/s shifts its lines by $\frac{30}{300{,}000} = 0.01\%$; a $500$ nm line moves to $500.05$ nm, far too little for any eye. The color of a star comes from its temperature; redshift is measured by comparing the positions of its dark lines with lab wavelengths. Check: if redshift changed colors noticeably, half the stars in the sky would look red and half blue.