Skip to article frontmatterSkip to article content

Lab 4: Exploring Cosmological Parameters with Functions

Objective:

This Lab will help you develop and practice your ability to write Python functions in the context of cosmology.

Background: Hubble’s Law

Hubble’s Law describes the relationship between the velocity of a galaxy and its distance from us:

v=H0×dv = H_0 \times d

where vv is is the recession velocity of a galaxy (in km/s), H0H_0 is the Hubble constant (in km/s/Mpc, assume 70 km/s/Mpc), and dd is the distance of the galaxy (in Mpc). H0H_0 is the present-day expansion rate of the universe. In general, we cannot measure direct distances to very distant galaxies, and so we measure the recessional velocity vv and can use that to find dd. The fact that this correlation exists is a consequence of the fact that our universe is expanding.

Questions 5-6 above get at a core concept in Python: vectorization. In Python, it will essentially always be faster to carry out an operation over a vector (array) simultaneously (part 5) as opposed to using a loop (part 4). This might not matter for small datasets but will become increasingly relevant as your dataset grows.

Now, we can make it even more sophisticated! We will now build subsequent functions that expand upon the one above. This incremental function-building is a core component of research, since you rarely write a single function that does everything you want.

Background: The Cosmic Critical Density

The cosmic critical density is the average density of matter and energy needed for the universe to be flat. If the actual density is higher, the universe is “closed” may eventually collapse; if the density is lower, the universe is “open” and will expand forever. It can be calculated from the Hubble Constant via

ρc=3H028πG\rho_c = \frac{3H_0^2}{8\pi G}

Background: The Age of the Universe

Because the universe has been continuously expanding since the origin of the universe, the present-day expansion rate can be used to approximate the age of the universe. Put explicitly, the age of the universe can be estimated roughly as

t=1H0t = \frac{1}{H_0}

(but you need to be careful about units: you need to first convert H0H_0 to units of inverse seconds for this to work.