Our past light cone, horizons and galaxies in the expanding universe, drawn three ways.
The spacetime diagram of our own universe, flat Lambda-CDM with Planck-like parameters. The program integrates the Friedmann equation once for cosmic time and conformal time as functions of the scale factor, and every curve follows from those two tables: galaxies sit at fixed comoving distance, our past light cone holds every event whose light reaches us now, the event horizon bounds the light that can still reach us someday, the particle horizon is how far light has come since the big bang, and the Hubble sphere is where the expansion carries things away at the speed of light. In proper distance the light cone is a teardrop, because light from the most distant galaxies was first carried away from us by the expansion before it could make headway; in comoving distance the galaxies stand still; in conformal time light travels at 45 degrees and the cones straighten out. Switching coordinates slides every point of every curve smoothly from one picture to the next.
Try it. Choose Proper, Comoving or Conformal (or press 1 to 3). Drag sideways to pick a galaxy and read when its light left, how far away it was then and is now, and its redshift. Drag the dashed now line, or press Up and Down, to see the universe from another epoch.
Paste this into Claude Code, Codex or any coding agent to get a simple version running, then take it wherever you like.
Build an interactive spacetime diagram of the expanding universe with JavaScript and the HTML canvas element. Put everything in a single index.html file with no libraries or build step, so I can open it directly in a browser.
Start simple:
- Make a canvas that fills the window and resizes with it, on a paper-colored background with clean ink lines and serif labels.
- Use a flat universe with H0 = 67.7 km/s/Mpc (0.0692 per billion years), matter 0.31 and dark energy 0.69, with distances in billion light years and times in billion years so c = 1.
- On a grid in log scale factor a, integrate the Friedmann equation H(a) = H0 sqrt(0.31 / a^3 + 0.69) for cosmic time (dt = d ln a / H) and conformal time (d eta = d ln a / (a H)). Check that today, a = 1, comes out near 13.8 billion years.
- Plot proper distance across against time up. Draw galaxies as worldlines a(t) chi for a few fixed comoving distances chi, and our past light cone, chi = eta_now - eta(a), on both sides. It should come out as a teardrop.
Once that works, make it beautiful:
- Add the Hubble sphere (c / H), the event horizon (eta at infinity minus eta(a)) and the particle horizon (eta(a)), each in its own color with a label along the curve.
- Add buttons to switch to comoving distance, and to comoving distance against conformal time, and animate the switch by interpolating every point of every curve between the two pictures.
- Let me drag sideways to pick a galaxy, and show where its light left, how far it was then and is now, and its redshift.
Explain the key ideas in short code comments. When you're done, tell me how to open it and suggest three directions I could take it next, such as moving the observer to another epoch, adding radiation for the early universe, or comparing universes with no dark energy.