Introduction

Why Cosmology?

Cosmology is the study of the universe as a whole — its origin, evolution, large-scale structure, and ultimate fate. It is where general relativity, particle physics, thermodynamics, and quantum mechanics all converge on the grandest possible scale.

The universe began in a hot, dense state 13.8 billion years ago and has been expanding ever since. Today it is filled with galaxies, dark matter, and dark energy, all governed by a handful of elegant equations. The Friedmann equation describes the expansion. The Boltzmann equation describes the thermal history. The Jeans criterion explains why galaxies and stars form.

This course implements the core equations of cosmology in pure Python. No libraries — just the mathematics of an expanding universe expressed as functions. Each lesson introduces one concept, explains the physics, and asks you to write the formula as code.

You will implement:

  • Cosmic expansion — Hubble's law, the Friedmann equation, redshift, and distances
  • Thermal history — CMB temperature, critical density, matter-radiation equality, age of the universe
  • Structure formation — Jeans instability and the growth factor
  • Dark sector — dark energy, Planck units, and neutrino temperature

Let's start with Hubble's law.

Next →