Physically-uncoupled systems: the primordial power spectrum#
The primordial scalar power spectrum of single-field quadratic inflation, computed mode by mode. Each comoving wavenumber \(k\) obeys its own linear Mukhanov-Sasaki equation, coupled to no other mode, so the whole spectrum is an ensemble of independent ODEs – the same structure as the mode-by-mode linearised Einstein-Boltzmann solve in CMB codes such as CAMB and CLASS.
The script does two numerical solves:
the homogeneous inflationary background,
the Mukhanov-Sasaki perturbation equation for many independent Fourier modes, batched into one Tsit5 solve.
Each mode has its own start and stop e-fold, set by horizon crossing, so this is also a demonstration of an ensemble with per-trajectory integration intervals in a single call. From the result it extracts the scalar amplitude \(A_s\) and spectral index \(n_s\) and compares them with slow-roll estimates.
The power spectrum needs one mode function per wavenumber, but the same solutions are the bottleneck in predicting the primordial bispectrum, the leading probe of primordial non-Gaussianity. Beyond slow roll, or with features in the potential, the bispectrum has no closed form, and modal estimators sample it on a dense grid of wavenumber triangles – thousands of distinct wavenumbers per shape, repeated across the model’s parameter space. That is a massive ensemble of independent linear ODEs of exactly this form.
Run it with:
uv run python examples/mukhanov_sasaki/main.py
The modax solve runs as a Numba-CUDA kernel, so this needs a CUDA GPU.
The perturbation equations and slow-roll approximation follow the conventions in Daniel Baumann’s TASI lectures on inflation.
Result#
The default run resolves 41 wavenumbers spaced geometrically over \(k \in [10^{-4}, 1]\ \mathrm{Mpc}^{-1}\). The numerical spectrum gives \(A_s = 2.067 \times 10^{-9}\) and \(n_s = 0.9633\), within 0.3 per cent and 0.0006 of the slow-roll estimates \(A_s = 2.061 \times 10^{-9}\) and \(n_s = 0.9640\).
Solver-backend benchmark#
The mode solve can be timed across solver backends on identical right-hand-side
code with the --benchmark flag. The mode equation is non-stiff and strongly
oscillatory, so the comparison uses explicit solvers: modax Tsit5 and Diffrax
Tsit5 on the GPU, and scipy.integrate.solve_ivp RK45 on the CPU, each mode
integrated independently and the ensemble spread across every core.
# all three backends at 4096 modes, as in the paper
uv run python examples/mukhanov_sasaki/main.py --benchmark --n 4096
All three run at rtol = 1e-7, atol = 1e-9, and agree on the pivot amplitude
to five significant figures. The paper measures 4096 modes on an NVIDIA GeForce
RTX 4070 SUPER against an AMD Ryzen 9 7950X across all 32 hardware threads –
hardware of comparable price and power draw:
Backend |
Wall clock |
Per solve |
|---|---|---|
SciPy RK45 (CPU, 32 threads) |
53 s |
13,000 µs |
Diffrax Tsit5 (GPU) |
106 ms |
26 µs |
modax Tsit5 (GPU) |
9 ms |
2.3 µs |
That is roughly 5700× the parallel CPU baseline and 11× Diffrax.
Background Inflation#
The model is quadratic inflation in reduced Planck units, started at
\(\phi_0 = 17.5\) and integrated over \(N \in [0, 80]\) e-folds (2000 save points,
rtol = 1e-9, atol = 1e-11):
The mass \(m\) is chosen from a slow-roll estimate so that the scalar amplitude is close to the observed value
The background is evolved in e-fold time
with state
The script solves
The scalar field equation in an expanding FLRW universe is the homogeneous Klein-Gordon equation with Hubble friction:
Switching variables from cosmic time \(t\) to e-fold time \(N\) using
and
yields the e-fold-time background equation used in the script:
Inflation ends when
The pivot mode is defined to leave the horizon \(55\) e-folds before the end of inflation:
Background Tables#
After solving the background, the script builds interpolation tables for the quantities needed by the perturbation equation:
and
Here primes mean derivatives with respect to conformal time \(\tau\), but the script computes the needed combination in e-fold time as
That identity follows from
Mode Setup#
The script chooses \(N_{\rm MODES}\) comoving wavenumbers between
and
The pivot scale is
Internally, the physical \(k\) values are mapped into code units by enforcing horizon crossing at the pivot:
For each mode, the script starts the Mukhanov-Sasaki solve when the mode is deep inside the horizon:
and stops when it is far outside the horizon:
Mukhanov-Sasaki Equation#
The conformal-time Mukhanov-Sasaki equation is
The script solves the equivalent e-fold-time form:
Using
this becomes
Because \(v_k\) is complex and the solver uses real-valued states, the script stores
The real and imaginary parts obey the same real equation.
Initial Conditions#
Each mode starts in the Bunch-Davies vacuum while deep inside the horizon:
The script uses
and initializes at
With the chosen phase convention, it sets
and
Ensemble Solve#
Each \(k\)-mode is an independent ODE system. The script batches all modes into
one call to modax.solve(..., method=modax.Tsit5()).
Each mode has its own start and stop e-folds, so the script maps each trajectory to a normalized solver time
with
Therefore the right-hand side is multiplied by
Power Spectrum#
At the end of each mode solve, the curvature perturbation is
The dimensionless scalar power spectrum is
The script computes this for all sampled \(k\)-modes.
Extracting \(A_s\) and \(n_s\)#
The scalar amplitude is the power spectrum at the pivot:
The scalar spectral index is
The script estimates \(n_s\) by fitting a local straight line to
near the pivot.
Slow-Roll Comparison#
Slow roll is the approximation that the inflaton moves slowly enough for the potential energy to dominate the kinetic energy, and for the field acceleration to be small compared with Hubble friction. In cosmic time this means
and
Under these conditions the background equations reduce approximately to
and
The smallness of slow roll is usually measured by potential slow-roll parameters:
and
Slow roll requires
and
For the quadratic potential, these become
Large field values therefore correspond to slow roll. Inflation ends when the slow-roll approximation predicts
which gives
The number of e-folds remaining before the end of inflation is approximately
Equivalently, for quadratic inflation,
so at horizon exit
The script solves the full background ODE rather than imposing these approximations. The slow-roll formulas are used only to choose a sensible mass scale and to provide an analytical comparison for the numerical Mukhanov-Sasaki result. At the pivot, the approximate scalar amplitude is
and
It also prints the common compact approximation
Finally, it prints a table comparing the full numerical Mukhanov-Sasaki results with the slow-roll estimates.
References#
Daniel Baumann, “TASI Lectures on Inflation”, arXiv:0907.5424, https://arxiv.org/abs/0907.5424.
Andrew R. Liddle, “An Introduction to Cosmological Inflation”, section 5.5, “A worked example: polynomial chaotic inflation”, https://ned.ipac.caltech.edu/level5/Liddle/Liddle5_5.html.