Cosmology studies the universe on its largest scales. It connects observations of galaxies, light, and matter with a mathematical description of how space changes with time. The standard Big Bang model says that the observable universe evolved from an earlier state that was much hotter and denser than it is now. It does not describe matter exploding from one special point into pre-existing empty space. In the model, space itself expands, and no ordinary location is selected as the centre of that expansion.
This distinction matters. An observer in almost any unbound galaxy sees distant galaxies recede on average. That observation does not put the observer at the centre, just as every dot on the surface of an inflating balloon sees other dots move away. The balloon is only an analogy: its two-dimensional surface stands for three-dimensional space, and its surrounding room is not part of the cosmological model.
Cosmologists represent the changing size of large-scale spatial separations with the scale factor \(a(t)\). It is conventional to set its present value to \(a(t_0)=1\). If two galaxies simply follow the large-scale expansion, their proper separation at a chosen cosmic time is proportional to \(a(t)\). Local systems such as atoms, people, planets, and gravitationally bound galaxies do not expand with this rule: electromagnetic and gravitational binding dominates on those scales.
Expansion stretches freely travelling light. If a photon was emitted when the scale factor was \(a_{\mathrm{em}}\) and observed today, its cosmological redshift is
\[1+z=\frac{\lambda_{\mathrm{obs}}}{\lambda_{\mathrm{em}}}=\frac{a(t_0)}{a(t_{\mathrm{em}})}\]Here \(z\) is dimensionless. A positive value means the observed wavelength is longer than the emitted wavelength. At cosmological distances, this scale-factor interpretation is more useful than treating the entire shift as an ordinary Doppler effect through static space.
rest_wavelength_nm, observed_wavelength_nm = 656.3, 984.45
redshift = observed_wavelength_nm / rest_wavelength_nm - 1
emission_scale_factor = 1 / (1 + redshift)
print("Illustrative line redshift:", redshift)
print("Emission scale factor with a_today=1:", emission_scale_factor)
The spectral line must be identified correctly, and the instrument calibration and measurement uncertainty must be retained. The final line also assumes the present-day normalization \(a(t_0)=1\).
The fractional expansion rate is the Hubble parameter,
\[H(t)=\frac{\dot a(t)}{a(t)}\]where the dot means a derivative with respect to cosmic time. For a nearby galaxy that follows the smooth expansion, the recession speed is approximately
\[v\approx H_0d\]where \(H_0\) is the present value of the Hubble parameter and \(d\) is an appropriate nearby distance. This is a low-redshift approximation. At large redshift, recession speed and distance are not uniquely defined without specifying a cosmological model and a distance convention.
The units provide a quick check. If \(H_0\) is expressed as speed per distance, multiplying it by distance gives speed. Doubling \(d\) therefore doubles the predicted local recession speed. The linear relation does not imply that every galaxy has only this motion: galaxies also have local or peculiar velocities caused by nearby gravitational fields.
General relativity relates expansion to the contents and spatial geometry of the universe. For a homogeneous and isotropic model, one central equation is
\[H^2=\left(\frac{\dot a}{a}\right)^2=\frac{8\pi G}{3}\rho-\frac{kc^2}{a^2}+\frac{\Lambda c^2}{3}\]The density \(\rho\) includes the relevant forms of mass-energy. The constant \(G\) is Newton's gravitational constant, \(c\) is the speed of light, \(k\) represents spatial curvature, and \(\Lambda\) is the cosmological constant. The equation does not predict a unique history until the components, their evolution, and initial or measured parameters are supplied.
Read the equation as an accounting rule rather than as a wall of symbols:
import numpy as np
# Illustrative flat matter + cosmological-constant model, not a data fit.
H0_km_s_mpc, omega_m, omega_lambda = 70.0, 0.3, 0.7
H0_per_s = H0_km_s_mpc * 1000 / 3.085677581e22
def hubble(z):
return H0_per_s * np.sqrt(omega_m * (1 + z) ** 3 + omega_lambda)
print("Hubble rate at z=0.5 (1/s):", hubble(0.5))
This Python exposes the sign of the curvature term and prevents silently taking the square root of a negative result. In practical calculations, each energy component has its own density evolution. Nonrelativistic matter dilutes approximately as \(a^{-3}\) because volume grows as \(a^3\). Radiation dilutes approximately as \(a^{-4}\): three powers come from volume and one more from wavelength stretching.
Density parameters compare each contribution with a critical density. With a consistent sign convention they can be summarized at a chosen epoch by
\[\Omega_{\mathrm{m}}+\Omega_{\mathrm{r}}+\Omega_{\Lambda}+\Omega_{\mathrm{k}}=1\]The subscripts denote matter, radiation, cosmological-constant-like dark energy, and curvature. Numerical values inferred from observations depend on the chosen model, datasets, calibrations, and analysis assumptions; they should not be treated as source-free constants.
Running the expansion model backward leads to hotter, denser conditions. The name “Big Bang” refers to this evolving early state, not to a conventional explosion. The well-tested hot Big Bang account covers a sequence of physical eras:
These stages join nuclear physics, atomic physics, thermodynamics, gravity, and observational astronomy. Their times and temperatures are model-dependent, so a timeline should label its assumptions rather than display unjustified precision.
The expanding hot-universe model is supported by several observations that test different parts of the account. Galaxy redshifts and distance indicators reveal the large-scale expansion. The cosmic microwave background has an extremely thermal spectrum and small directional variations that preserve information about the early universe. Measured abundances of light elements test nuclear reactions in a hot early phase. The distribution and evolution of large-scale structure test how density variations grew.
No single item should be presented as the whole case. Agreement across independent measurements is powerful because changing a model to fit one dataset may spoil its fit to another. Conversely, disagreement can point to underestimated systematic error, incorrect parameter assumptions, or missing physics.
Dark matter is introduced because luminous matter alone does not explain several gravitational observations and the observed growth of structure. Dark energy is the name for the component or modification used to account for accelerated cosmic expansion. These labels describe inferred roles; the simple cosmological model does not by itself identify the microscopic nature of either one.
In an expanding universe, “the distance to a galaxy” can mean several different quantities. Proper distance compares positions at a selected cosmic time. Comoving distance factors out expansion and assigns expansion-following galaxies fixed coordinates. Luminosity distance is defined through observed brightness, while angular-diameter distance connects physical size with apparent angle. These distances agree approximately for nearby objects but differ at large redshift.
Lookback time is how long the observed light has travelled according to the model. It can be computed from
\[\frac{dt}{dz}=-\frac{1}{(1+z)H(z)}\]The minus sign says that larger redshift corresponds to earlier cosmic time. A numerical integral can accumulate positive lookback time in small redshift steps:
z = np.linspace(0, 0.5, 10001)
lookback_seconds = np.trapezoid(1 / ((1 + z) * hubble(z)), z)
seconds_per_gigayear = 1e9 * 365.25 * 24 * 3600
print(f"Model lookback time: {lookback_seconds/seconds_per_gigayear:.3f} billion years")
The calculation should be repeated with smaller steps. If the answer changes materially, the original discretization was too coarse. Model uncertainty and parameter uncertainty are separate from numerical integration error and should be reported separately.
Because light has a finite speed and the universe has a finite expansion history, we can observe only a limited region. The observable universe is therefore not necessarily the whole universe. A horizon is a limit on causal contact or observation under a specified cosmological history; it is not a physical wall. Very distant galaxies can have recession rates greater than
\(c\)without locally moving through space faster than light. Special relativity still limits the speed measured between nearby observers; cosmological recession over a changing geometry is a different comparison.
Inflation is a proposed period of very rapid early expansion that helps explain features such as large-scale uniformity and the origin of primordial fluctuations. Its broad observational consequences are studied seriously, but the underlying mechanism and detailed model are not settled by the elementary Big Bang account. Likewise, extrapolating the Friedmann equation to a classical singularity signals the limit of the theory rather than a complete physical description of an absolute beginning.
A careful cosmological conclusion therefore includes scope. State the assumed geometry and contents, define the distance and time quantities, preserve parameter uncertainties, and distinguish observed evidence from theoretical extrapolation. The equations provide a coherent history of an expanding, cooling universe; they do not remove the need to test each part of that history against independent data.
Inspect an illustrative flat matter-plus-cosmological-constant expansion model. The question for this calculation is precise: how does expansion rate divided by H0 change when we change redshift, while keeping the other choices fixed? The earlier sections explain the physical relationship. Here we turn one part of that relationship into a calculation that you can run, inspect, and change in Google Colab.
The density fractions are chosen example parameters and radiation is neglected over this redshift range. Keep that sentence beside the results. A formula can return a number outside its useful range, and a plotting library will usually draw that number without asking whether the physical assumptions still hold. The selected interval is from 0 to 3 dimensionless. It gives us a specific domain to discuss instead of leaving the graph's range to a software default.
Use the notebook link above the lesson, run the setup cell, and then run the cells in order. The code below is also included there. NumPy handles the arrays of numerical values, SymPy keeps the equation symbolic, and Matplotlib draws the results. If these libraries or notebook cells are unfamiliar, start with Your first physics notebook.
In this small example, q stands for redshift, expressed in dimensionless. The output is
expansion rate divided by H0, expressed in dimensionless. The equation below uses the numerical values in those
units. Any fixed coefficients therefore carry the units needed to make the relation
consistent. A value supplied in another unit must be converted before it enters this
expression.
This is a function of one changing input. It is not a statement that the physical system has only one variable. We deliberately hold the other inputs fixed so that one cause of variation is visible. Changing several inputs at once would make it harder to tell which change produced the output difference. Write down the held-fixed choices before trying a different experiment.
At 0.5 dimensionless, the expression gives 1.30863 dimensionless. This is our reference calculation. It is a prediction of the stated example, not a new measurement. Its displayed digits help us compare implementations. They should not be read as a claim that physical inputs are known to six significant figures.
import numpy as np
import sympy as sp
import matplotlib.pyplot as plt
q = sp.Symbol("q", real=True)
expression = sp.sympify("sqrt(0.3*(1+q)**3+0.7)", locals={"q": q})
reference_input = 0.5
reference_output = float(expression.subs(q, reference_input))
print("Input:", reference_input, "dimensionless")
print("Predicted expansion rate divided by H0:", reference_output, "dimensionless")
sp.Symbol declares a mathematical symbol. It does not assign a numerical measurement
to that symbol. subs then replaces the symbol with our chosen input, and float
converts the resulting symbolic number into a standard Python numerical value.
Keeping these steps separate lets us inspect the equation before numerical substitution.
It also prevents a later plot from becoming the only surviving record of the model.
Before drawing hundreds of points, calculate three. The lower endpoint gives 1 dimensionless. The midpoint, at 1.5 dimensionless, gives 2.3211 dimensionless. The upper endpoint gives 4.46094 dimensionless. Read these together with the assumptions: they describe different choices of redshift within the same example, with the other inputs held fixed.
These three values are a useful first check, but they do not establish the shape between them. Two endpoints can be equal even when the curve bends or oscillates in between. Likewise, a large change between endpoints does not tell us whether the relationship is linear. We need the equation and intermediate samples to answer those questions.
evaluate = sp.lambdify(q, expression, modules="numpy")
inputs = np.array([0.0, 1.5, 3.0])
outputs = np.asarray(evaluate(inputs), dtype=float)
outputs = np.broadcast_to(outputs, inputs.shape)
for input_value, output_value in zip(inputs, outputs):
print(f"{input_value:.6g} dimensionless -> {output_value:.6g} dimensionless")
assert np.all(np.isfinite(outputs))
lambdify turns the symbolic expression into a numerical function. We explicitly select
NumPy as its numerical backend so it can accept an array. The same expression now has
two useful forms: one for algebra and one for calculating many cases. The assertion
checks that the chosen inputs produce finite outputs. It would catch an infinity or an
undefined numerical result, but a finite value can still be physically inappropriate.
The horizontal axis shows redshift; the vertical axis shows expansion rate divided by H0. Every plotted point is a prediction of the same expression. We mark the reference case separately so that a reader can connect the earlier printed value to its place on the curve. The axis labels include units because a shape without a scale cannot tell us the size of a physical effect.
input_grid = np.linspace(0.0, 3.0, 301)
output_grid = np.asarray(evaluate(input_grid), dtype=float)
output_grid = np.broadcast_to(output_grid, input_grid.shape)
fig, ax = plt.subplots(figsize=(7, 4))
ax.plot(input_grid, output_grid, label="Stated model")
ax.scatter([reference_input], [reference_output], label="Reference case", zorder=3)
ax.set_xlabel("Redshift (dimensionless)")
ax.set_ylabel("Expansion rate divided by h0 (dimensionless)")
ax.legend()
ax.grid(alpha=0.25)
fig.tight_layout()
plt.show()
Look for a sign change, a turning point, or a region where the curve becomes steep. Connect each feature to the expression rather than to the colour of the line. If the curve has a minimum or maximum, changing the input in opposite directions may have similar effects on the output near that point. If it is nearly straight over a short interval, a local linear approximation may be useful even when the complete expression is nonlinear.
Increasing the number of samples makes the line smoother and may reveal features that a coarse grid missed. It does not improve the physical inputs or enlarge the model's validity range. For quantities that can take only discrete values, use the line as a guide to the relationship and interpret only the allowed input values. A plotting function does not enforce such restrictions for you.
A derivative asks a more specific question than the whole graph: how quickly does expansion rate divided by H0 change near the reference input? Its units are the output unit divided by the input unit. For this calculation, the derivative at 0.5 dimensionless is 0.773713 in those ratio units. Locally, the output increases as the input increases. This statement is local; the sign or size of the slope can be different elsewhere on the curve.
\[f'(q) = \frac{0.45 \left(q + 1\right)^{2}}{\sqrt{0.3 \left(q + 1\right)^{3} + 0.7}}\]For a small input change, multiply the derivative by that change to estimate the output change. Then compare that estimate with a fresh evaluation of the full expression. The distinction between these two calculations matters: the derivative gives a tangent approximation, while substitution evaluates the chosen expression at the new point.
slope_expression = sp.diff(expression, q)
slope_at_reference = float(slope_expression.subs(q, reference_input))
changed_input = 0.515
linear_prediction = reference_output + slope_at_reference * (
changed_input - reference_input
)
full_prediction = float(evaluate(changed_input))
print("Symbolic derivative:", slope_expression)
print("Tangent prediction:", linear_prediction, "dimensionless")
print("Full expression:", full_prediction, "dimensionless")
print("Approximation difference:", full_prediction - linear_prediction, "dimensionless")
Here the changed input is 0.515 dimensionless. The tangent estimate is 1.32023 dimensionless, while the full expression gives 1.3203 dimensionless. If the two values are close, it means the chosen input change is small enough for this local approximation at this point. It does not mean the entire model is linear. If the slope is zero, a quadratic or higher-order term may supply the leading change instead.
This is also the beginning of uncertainty propagation. If the input has a small stated standard uncertainty, the magnitude of the slope times that uncertainty estimates one contribution to output uncertainty. Do not automatically use the same rule for a wide interval, a discontinuity, a turning point with zero first derivative, or several correlated uncertain inputs. Those situations need more of the model than one slope.
We can estimate the same slope from values on either side of the reference point. Subtract the lower output from the upper output and divide by twice the input step. Parentheses are essential: the entire output difference must be divided by the entire input interval. Without them, Python can execute a different mathematical expression while still producing a plausible number.
The calculation below uses three decreasing step sizes. Each estimate is compared with the symbolic derivative, so the reference is independent of the numerical difference formula. Near an endpoint, it is acceptable here to evaluate a small extension only because the displayed mathematical expression is smooth there; such a check does not assert that extrapolated values describe additional physical cases.
input_span = 3.0
for fraction in [1e-2, 1e-3, 1e-4]:
step = input_span * fraction
upper = float(evaluate(reference_input + step))
lower = float(evaluate(reference_input - step))
numerical_slope = (upper - lower) / (2 * step)
difference = numerical_slope - slope_at_reference
print(f"step={step:.6g}: slope={numerical_slope:.6g}, difference={difference:.6g}")
For a smooth function, reducing the step often reduces the approximation error at first. Very small steps can eventually make subtraction of nearly equal floating-point values less reliable. Therefore “smaller” is not an unlimited guarantee of “better.” Compare the observed behaviour over a useful range of steps instead of choosing the smallest number the computer can represent.
An absolute slope difference is useful when the expected slope is near zero. A relative difference would divide by a very small reference and could look enormous even when the absolute discrepancy is tiny. Away from zero, a relative difference can help compare quantities with very different scales. The tolerance should reflect the question and the numerical method, rather than a universal decimal threshold copied into every test.
Make one copy of the reference calculation before editing it. Choose a second value of redshift inside the stated interval, predict whether expansion rate divided by H0 will rise or fall, and then evaluate the expression. Place the prediction and the result in a text cell. If they disagree, identify whether the mistake was in the sign, the unit conversion, the algebra, or the assumption about how the curve behaves.
Next choose a shorter plotting interval around the reference point. Compare the local curve with its tangent approximation. Then widen the interval again. The difference shows why a useful local estimate need not describe the whole range. Keep the axis labels and numerical scale visible when comparing the plots; automatic axis limits can make two different effects appear equally large.
Finally, return to the physical limit stated at the start: The density fractions are chosen example parameters and radiation is neglected over this redshift range. Describe one change to the setup that would violate that limit. State what new input, equation, or observation would be needed before trusting an answer in the changed situation. This last step connects the Python experiment to the physics instead of treating successful execution as the only criterion for a useful result.
Before saving, restart the runtime and run all cells in order. A result that depends on an earlier, now-deleted input cell is not reproducible from the saved notebook. Keep unrounded values for later calculations, round only the reported output, and label any new data as measured, assumed, or generated. The graph and printed values should remain traceable to the same expression and the same choices of inputs.
There is another way to check that the expression and its derivative describe the same relationship. Add up the small output changes predicted by the slope across the chosen input interval. In the continuous limit, this integral equals the output at the upper endpoint minus the output at the lower endpoint. The result has units of dimensionless: the input unit in the integration cancels the input unit in the denominator of the slope.
This statement is about the mathematics of this particular relationship. It does not assign a new physical meaning to an arbitrary area under a graph. For example, an area under force versus distance represents work, while an area under a different pair of quantities may represent something else or have no standard name. Always carry the axis units through the calculation before naming an integral.
slope_function = sp.lambdify(q, slope_expression, modules="numpy")
endpoint_change = float(evaluate(3.0) - evaluate(0.0))
for points in [101, 201, 401]:
grid = np.linspace(0.0, 3.0, points)
slopes = np.asarray(slope_function(grid), dtype=float)
slopes = np.broadcast_to(slopes, grid.shape)
integrated_change = np.trapezoid(slopes, grid)
print(
points,
"integrated change:",
integrated_change,
"endpoint change:",
endpoint_change,
)
The trapezoidal rule joins neighbouring slope samples with straight segments and adds their signed areas. A negative contribution remains negative; replacing every slope by its magnitude would calculate a different quantity. Increasing the sample count provides a practical refinement check. If the values do not settle toward the endpoint difference, first inspect the interval, singularities, and array ordering.
Do not conclude that two agreeing calculations prove the model is physically complete. Both use the same selected relationship, so an omitted effect would be omitted from both. Their agreement is evidence that the numerical tools implement that relationship consistently. Comparing with an independent experiment or a more appropriate physical model is a separate test.
Keep this comparison in the notebook when you change the expression. It is particularly useful after adding a coefficient, changing a sign convention, or converting an input unit. A code cell that produces a smooth graph can conceal these mistakes; a second calculation of the same output change gives you another place to notice them.