From the FLRW metric to the dynamics of the scale factor a(t), with analytic solutions, the age of the universe, deceleration and cosmological distances.
Write the FLRW metric and relate the scale factor to the redshift.
Derive the Friedmann equations (Newtonian and relativistic versions) and the fluid equation.
Solve analytically the radiation, matter, Λ and Milne universes, and numerically the general case.
Compute the age, the deceleration parameter and the comoving, luminosity and angular-diameter distances.
Motivation: a single function for the whole cosmic history
All of background cosmology fits into one function of one variable, the scale factor a(t). From it follow the age of the
universe (13.787 ± 0.020 Gyr according to Planck 2018), its fate (eternal expansion or recollapse), the redshift of every
galaxy and the distances with which supernovae and the cosmic background are measured. This lesson derives the equation that governs
a(t) from general relativity, solves it in the cases that admit a closed-form solution and integrates it numerically
in the general case, with the Planck 2018 parameters as the working example.
1. The FLRW metric
The cosmological principle postulates that, on scales larger than about 100 Mpc, the universe is homogeneous and
isotropic. The only compatible spatial geometries are those of constant curvature, and the most general
metric (Friedmann–Lemaître–Robertson–Walker) is
where t is the cosmic time (the one measured by an observer at rest with respect to the cosmic fluid), r the
radial comoving distance, dΩ2=dθ2+sin2θdϕ2, k the sign of the spatial
curvature, R0 the present radius of curvature and a(t) the scale factor, normalized to a(t0)=1
today (t0).
The proper distance between two comoving galaxies is dp(t)=a(t)r, so that
d˙p=(a˙/a)dp: this is the Hubble lawv=Hdp with H(t)≡a˙/a and
H0=H(t0). A photon (ds=0) emitted at te and received at t0 satisfies
∫tet0cdt/a=r; comparing two successive crests one obtains
1+z=λeλ0=a(te)1.
2. Newtonian motivation
Consider a sphere of radius R(t)=a(t)rs expanding with the fluid, of uniform density
ρ(t) and constant mass M=34πR3ρ. By Newton’s shell theorem, a test particle
on its surface feels only the interior mass. Its mechanical energy per unit mass is conserved:
21R˙2−RGM=U⟹(aa˙)2=38πGρ+rs2a22U.
This is exactly the form of the first Friedmann equation, with the energy U playing the role of the
curvature: U<0 (bound) corresponds to a closed universe that recollapses, U>0 to an open one.
The argument has serious limitations: it presupposes a center, ignores pressure as a source of gravity and does not
explain what the “curvature” is. General relativity fixes all three.
3. The Friedmann equations in general relativity
With the FLRW metric and a perfect fluid of energy density ε=ρc2 and pressure P,
Tμν=diag(−ε,P,P,P), the Einstein equations
Gμν+Λgμν=(8πG/c4)Tμν reduce to two independent equations.
The 00 component gives the first Friedmann equation:
H2=(aa˙)2=3c28πGε−R02a2kc2+3Λc2.
The trace of the spatial components, combined with the previous one, gives the acceleration equation:
aa¨=−3c24πG(ε+3P)+3Λc2.
Pressure gravitates: a fluid with P>−ε/3 slows the expansion down; one with P<−ε/3
accelerates it.
Fluid equation
The conservation law ∇μTμν=0 (or, equivalently, the first law of thermodynamics
dE+PdV=0 applied to a comoving volume V∝a3) gives
ε˙+3aa˙(ε+P)=0.
Differentiating the first equation with respect to t and substituting the fluid equation recovers the acceleration
equation: of the three equations only two are independent.
Equations of state
For P=wε with constant w, the fluid equation integrates immediately:
εdε=−3(1+w)ada⟹εw(a)=εw,0a−3(1+w).
Component
w
ε∝
Non-relativistic matter (baryons + dark matter)
0
a−3
Radiation (photons, relativistic neutrinos)
1/3
a−4
Cosmological constant / vacuum energy
−1
constant
Curvature (formal)
−1/3
a−2
4. Density parameters
The critical density is the one that makes k=0 with Λ=0:
εc=3c2H2/(8πG). We define, today,
The Planck 2018 values (TT,TE,EE+lowE+lensing) are H0=67.66 km s⁻¹ Mpc⁻¹, Ωm=0.3111,
ΩΛ=0.6889 (Planck Collaboration 2020, table 2); Ωr≈9×10−5 includes
photons and neutrinos.
5. Analytic solutions
Writing τ=H0t, the first equation is (da/dτ)2=a2E(a)2. With a single dominant
component it integrates by separation of variables:
Radiation (Ωr=1): ada=dτ⇒a(t)=(2H0t)1/2, age t0=1/(2H0).
Λ, de Sitter (ΩΛ=1): da/a=dτ⇒a(t)=eH0(t−t0); there is no Big Bang.
Empty, Milne (Ωk=1): da=dτ⇒a(t)=H0t, t0=1/H0. It is Minkowski space in hyperbolic coordinates.
Matter + positive curvature (Ωm>1, ΩΛ=0): parametric solution (cycloid)
a(η)=2(Ωm−1)Ωm(1−cosη),t(η)=2H0(Ωm−1)3/2Ωm(η−sinη),
with maximum amax=Ωm/(Ωm−1) at η=π and Big Crunch at η=2π.
The integrand may have integrable singularities (∝a1/2 near a=0, ∝(a∗−a)−1/2
near a turning point a∗). The library removes them with the substitution a=Asin2θ before
applying Simpson’s rule. For Planck 2018 the result is t0=13.79 Gyr, in agreement with the published value
13.787±0.020 Gyr.
The universe recollapses if P(a)≡a2E2 vanishes for some a>1 (there a˙=0 and a¨<0),
and it had no Big Bang (bounce) if it vanishes for some 0<a<1. The boundaries in the (Ωm,ΩΛ) plane
have closed form (Carroll, Press & Turner 1992):
(with cos and arccos in the second one for Ωm>21). The deceleration parameter
q0≡−a˙2a¨at0=Ωr+21Ωm−ΩΛ
is q0≈−0.53 for Planck 2018: the expansion is accelerating today (the line ΩΛ=Ωm/2 in the plane).
Numerical integration
To draw a(t) in any model, src/lib/math/friedmann.ts integrates with RK4 the second-order form
d2a/dτ2=−Ωra−3−21Ωma−2+ΩΛa from a=1, da/dτ=1. The
first-order form a˙=±P(a) is useless at a turning point (the sign changes and P is not Lipschitz),
whereas the second-order form is regular there. The step is adapted as h=η/s, with
s=max(∣a˙∣/a,∣a¨/a∣), and the constraint a˙2=P(a) serves as a check: its relative error is
<10−6 in all the predefined models.
determines the angular-diameter distanceDA=DM/(1+z) (size ℓ=DAθ) and the
luminosity distanceDL=(1+z)DM (flux F=L/4πDL2). Etherington’s reciprocity relation
DL=(1+z)2DA holds. The lookback time is tL(z)=H0−1∫0zdz′/[(1+z′)E(z′)].
Error analysis
Quadrature of the age. The substitution a=Asin2θ turns the integrable singularities (a−1/2 at the origin,
(a∗−a)−1/2 at a turning point) into bounded integrands, and Simpson’s rule recovers its order h4: with n=4000 the error
of t0 against the closed formula of flat ΛCDM is below 10−9 relative (friedmann.test.ts). Without the change of
variable, the integrand ∝a−1/2 degrades Simpson’s rule to order h3/2.
Integration of a(t). RK4 with step h=η/s is of order 4 in η (problem 6); the constraint a˙2=P(a) acts as
a control invariant, with relative error <10−6 in all the predefined models.
Parameters.t0∝1/H0 to first order: the 0.6 % uncertainty in H0 (Planck 2018, 67.66±0.42) translates into
±0.09 Gyr, while ∂t0/∂Ωm≈−0.6tH in flat models gives ±0.05 Gyr for δΩm=0.0056;
combined (anticorrelated in Planck) they reproduce the published ±0.020 Gyr only if the correlation is included.
Problems
1. (Proof) From the fluid equation to the acceleration equation. Differentiate the first Friedmann equation
(with Λ=0) with respect to time and, using the fluid equation, prove the acceleration equation.
Proof
2HH˙=3c28πGε˙+R02a22kc2H. With ε˙=−3H(ε+P) and H˙=a¨/a−H2, dividing by
2H: a¨/a−H2=−c24πG(ε+P)+R02a2kc2. Substituting H2 from the first equation, the curvature
term cancels and what remains is a¨/a=−3c24πG(ε+3P). With Λ, the term Λc2/3 is constant and
carries through unchanged. ■
2. (Proof) Age of flat ΛCDM. Prove that for Ωm+ΩΛ=1 (Ωr=0)
t0=3H0ΩΛ2arsinhΩΛ/Ωm and evaluate it for H0=70, Ωm=0.3 and for Planck 2018.
Proof
With u=a3/2, du=23a1/2da:
∫01Ωm+ΩΛa3a1/2da=32∫01Ωm+ΩΛu2du=3ΩΛ2arsinhΩΛ/Ωm.
For H0=70 (tH=13.97 Gyr), Ωm=0.3: t0=13.97×3×0.83672×arsinh(1.5275)=13.97×0.7968×1.2099=13.47 Gyr.
For Planck (tH=14.45 Gyr, Ωm=0.3111): 13.80 Gyr; radiation lowers it to 13.786. ■
3. Cycloid. Verify that the parametric solution of section 5 satisfies (da/dt)2=H02(Ωm/a+1−Ωm) and
deduce the total lifetime ttot=πΩm/[H0(Ωm−1)3/2]. Evaluate it for Ωm=3 and H0=67.66 and compare it with
vidaTotal in the simulator.
Show solution
With A=Ωm/[2(Ωm−1)] and B=Ωm/[2H0(Ωm−1)3/2]: da/dt=(da/dη)/(dt/dη)=Asinη/[B(1−cosη)], hence
(da/dt)2=B2A2(1−cosη)2sin2η=B2A21−cosη1+cosη. On the other hand Ωm/a+1−Ωm=1−cosη2(Ωm−1)−(Ωm−1)=(Ωm−1)1−cosη1+cosη,
and A2/B2=H02(Ωm−1): they agree. The Big Crunch is at η=2π: ttot=2πB=πΩm/[H0(Ωm−1)3/2]. For Ωm=3:
ttot=3π/23/2tH=3.332×14.45=48.2 Gyr.
4. (Proof) Milne. Prove that in the Milne universe DL=DHz(1+z/2).
Proof
E=1+z, so DC=DHln(1+z); with Ωk=1, DM=DHsinhln(1+z)=DH2(1+z)(1+z)2−1 and DL=(1+z)DM=DHz(1+z/2).
It is the same formula that special relativity gives for an explosion of free particles in Minkowski space. ■
5. (Proof) Bounce. For Ωm=Ωr=0, prove that there is a bounce if and only if ΩΛ>1, with
amin=(ΩΛ−1)/ΩΛ. Explain why the observation of quasars at z>2 excludes ΩΛ>9/8 in that family.
Proof
P(a)=Ωk+ΩΛa2=(1−ΩΛ)+ΩΛa2. It vanishes at a2=(ΩΛ−1)/ΩΛ, which is positive and less than 1 if and only if
ΩΛ>1; for a smaller than amin, P is negative (forbidden region): the universe contracted down to amin and bounced. An object at
z=2 is observed at a=1/3, so we need amin<1/3, that is (ΩΛ−1)/ΩΛ<1/9 ⇒ ΩΛ<9/8. Quasars at
z>7 push the bound to ΩΛ<64/63. ■
6. (Computational) Order of convergence. The step of evolucionar is h=η/s. Measure the error of the Big Bang instant
obtained by RK4 against the integral edadUniverso for η=0.016,0.008,0.004 in the Planck model and check
the order-4 convergence. Why does the adapted step not destroy that order near the Big Bang?
Outline and explanation
import { PLANCK18 } from '@/lib/math/cosmology';import { edadUniverso, evolucionar } from '@/lib/math/friedmann';const t0 = edadUniverso(PLANCK18);for (const eta of [0.016, 0.008, 0.004]) { const ev = evolucionar(PLANCK18, { eta }); console.log(eta, Math.abs(-ev.bigBang! - t0) / t0);}
The relative errors should drop by ≈16 when η is halved. Near a→0 the solution is a∝t1/2 and
the characteristic time 1/s≈1/H∝t; the step h∝t keeps the local relative error per step constant
(∝(h/t)5), and the number of steps grows only logarithmically, so the global error still scales as η4.
The analytic tail a∝∣t−ts∣p removes the last stretch, where any integrator would fail.
7. Fate and acceleration. With fronteraRecolapso and fronteraRebote, draw in the (Ωm,ΩΛ) plane the regions of
recollapse, bounce and eternal expansion, the line q0=0 and the flat line Ωm+ΩΛ=1. Place Planck 2018 and the approximate
contours of Perlmutter et al. (1999), 0.8Ωm−0.6ΩΛ≈−0.2±0.1. Which combination of data fixes the position along
the Perlmutter line?
Show solution
The supernova line is almost perpendicular to the flat line of the CMB (θ∗ fixes Ωm+ΩΛ≈1); their intersection
is (0.3,0.7). Planck alone (without BAO or supernovae) already breaks the degeneracy through lensing and the heights of the peaks.
All the recollapse and bounce regions lie more than 10 σ away.
✦ Self-assessment
Answer all the questions to check.
Further reading
Ryden, B. (2017). Introduction to Cosmology, 2nd ed., chs. 3–6: metric, dynamics, single- and multi-component models, measures.
Weinberg, S. (2008). Cosmology, ch. 1: complete relativistic derivation of the Friedmann equations and of the distances.
Carroll, Press & Turner (1992), ARA&A 30, 499: the (Ωm,ΩΛ) plane and the analytic boundaries the library uses.
Hairer, E., Lubich, C. & Wanner, G. (2006). Geometric Numerical Integration, ch. II: order and step control in RK4.
🍎 Teacher guide
Time
2 classes of 90 min
Learning outcome
By the end, the student derives the Friedmann and fluid equations, solves the single-component models, computes the age and the fate of an arbitrary model with control of the numerical error and places the Planck 2018 data in the (Ω_m, Ω_Λ) plane.
Evidence of learning
Submission of problem 6 (order of convergence of RK4 with adapted step) and of problem 7 (plane of models with the Planck and supernova contours).
Materials
Simulator universo-friedmann
Python 3 with NumPy or the library src/lib/math/friedmann.ts
Table 2 of Planck 2018 VI
Figure 7 of Perlmutter et al. 1999 (Ω_m–Ω_Λ plane)
Suggested sequence
Class 1. Metric and redshift (§1), Newtonian motivation and its limits (§2), Friedmann equations, fluid equation and
equations of state (§§3–4). Analytic solutions (§5) as a group exercise: one model per group.
Class 2. Age, fate and the (Ωm,ΩΛ) plane (§6) with the simulator; distances (§7) as a bridge to the next lesson.
Lab: problems 6 and 7.
Common mistakes
Thinking that the Big Bang was an explosion at a point in space: the FLRW metric describes the expansion of space itself, with no center.
Mistaking the Newtonian argument for a derivation: it explains neither the curvature nor the fact that pressure gravitates.
Believing that the cosmological constant “pushes outward”: it accelerates because its negative pressure makes the source ε + 3P negative.
Integrating ȧ = √P(a) and being surprised that it fails at the turning points.
Key terms in this lesson (12)
Glossary terms that appear in the text. Each one links to its full entry.
Friedmann equationsThe equations that say how the size of the universe changes with time according to what it contains: matter, radiation and dark energy. They are general relativity applied to the whole universe.
Scale factorIn a scale model, the number real sizes are divided by (1 : 1 billion for the Solar System on a sports field). In cosmology, the number that says how much the universe has stretched: it equals 1 today and was 0.5 when all distances were half as large.
Big BangThe beginning of the expansion of the universe, 13.8 billion years ago, when everything was unimaginably hot and dense. It was not an explosion "in" space: it was space itself starting to stretch.
LuminosityThe total energy a star emits every second, like the "power" of a light bulb. It does not depend on the distance you look at it from.
General relativityEinstein's theory (1915), according to which gravity is not a force but the curvature of space and time caused by mass. The planets follow the "straightest" possible path in a space curved by the Sun.
RedshiftThe light from distant galaxies arrives "stretched" toward the red because the universe expands while it travels. The farther the galaxy, the larger the redshift.
Hubble–Lemaître lawThe farther away a galaxy is, the faster it moves away from us. It is not that we are at the center: all of space is stretching, like dots painted on a balloon being inflated.
Luminosity distanceThe distance deduced from how faint an object looks when we know its true brightness (a "standard candle", such as a Type Ia supernova). In an expanding universe it gives values larger than the actual distance.
Runge–Kutta methodAn improvement on Euler's method that "samples" the slope at several intermediate points of each step and averages them. The fourth-order version (RK4) is thousands of times more accurate for the same step size.
SupernovaThe explosion of a star, so bright that for weeks it can outshine its entire galaxy. It scatters into space the elements the star made.
GalaxyA city of stars: hundreds of billions of them, with gas, dust and dark matter, bound together by gravity. Ours is the Milky Way; the largest neighbor, Andromeda.
Cosmic microwave backgroundThe oldest light in the universe: it set out when the universe was 380 000 years old and today arrives from every direction, cooled to 2.7 degrees above absolute zero. It is the "baby picture" of the cosmos.