The early universe was nearly uniform, but tiny quantum-seeded density ripples (δρ/ρ ~ 10⁻⁵) grew under gravity. Regions slightly denser than average pull in more matter, becoming denser still — a runaway process. In the matter-dominated era, these perturbations grow as a power law of cosmic time, eventually going non-linear and collapsing into the galaxies and clusters we see today.
δ(t) ∝ t^(2/3) (linear growth, matter-dominated era)
F_i = G·Σ_j m_j (r_j − r_i) / (|r_j − r_i|² + ε²)^(3/2) (softened N-body force sum)
- Perturbation amplitude — how large the initial density ripples are; bigger seeds collapse faster into fewer, larger clumps.
- Particle count — resolution of the N-body simulation (fewer particles run faster, more particles resolve finer structure).
- Gravity strength — scales the force constant G, speeding up or slowing down collapse.
- Expansion toggle — includes/excludes cosmic expansion (Hubble drag) working against gravitational collapse.
- Restart — reseeds a fresh near-uniform field with new random perturbations.
Cosmological N-body codes like GADGET and cosmological surveys of the "cosmic web" both rely on exactly this gravitational-instability growth mechanism to explain large-scale structure.