Mukhanov-Sasaki Example¶
This example computes the primordial scalar power spectrum from single-field quadratic inflation by doing two numerical solves:
- the homogeneous inflationary background,
- the Mukhanov-Sasaki perturbation equation for many independent Fourier modes.
It then extracts the scalar amplitude \(A_s\) and scalar spectral index \(n_s\), and compares them to approximate slow-roll estimates.
Run it with:
The modax solve runs as a Numba-CUDA kernel, so this needs a CUDA GPU.
The scipy backend below is the CPU-only path.
The perturbation equations and slow-roll approximation follow the conventions in Daniel Baumann's TASI lectures on inflation.
Solver-backend benchmark¶
The mode solve can be timed across solver backends on identical right-hand-side
code with the --benchmark flag. Because the mode equation is non-stiff and
oscillatory, the comparison uses explicit solvers: modax Tsit5 (GPU), Diffrax
Tsit5 (GPU), and scipy.solve_ivp RK45 (serial CPU baseline).
# all three backends at 64 modes (scipy is the slow one)
uv run python examples/mukhanov_sasaki/main.py --benchmark --n 64
# GPU backends at a saturating ensemble size
uv run python examples/mukhanov_sasaki/main.py --benchmark --backends modax diffrax --n 4096
Background Inflation¶
The model is quadratic inflation in reduced Planck units:
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 tsit5_solve(...) from 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.