---
title: "Measuring Motion with an Expanding Ruler"
description: "Separate cosmic expansion from peculiar motion, then convert comoving positions and canonical momenta into distances and velocities."
canonical_url: "https://sandboxphysics.com/stories/cosmic-web/coordinates-that-expand-with-the-universe/"
language: "en"
page_type: "story"
alternate_languages:
  zh-CN: "https://sandboxphysics.com/zh/stories/cosmic-web/coordinates-that-expand-with-the-universe/"
last_modified: "2026-11-12"
---

[From ripples to the cosmic web](https://sandboxphysics.com/stories/cosmic-web/)

From ripples to the cosmic web · L2

# Measuring Motion with an Expanding Ruler

Sandbox Physics · 2026-11-12

Putting the average expansion into the coordinate ruler lets us calculate motion relative to that ruler. A box can keep its displayed size as the physical distance it represents grows. Deciding whether matter approaches requires both changes.

## Before you begin

Start with How Gravity Builds the Cosmic Web. The existing cosmology chapter How Small Fluctuations Grow gives the linear-growth background. A vector lists directional components; a derivative describes a rate of change.

[Read the existing linear-growth derivation](https://sandboxphysics.com/stories/cosmology/linear-perturbations/)

## Let the ruler follow the expansion

Write physical position as $\boldsymbol r$ and comoving position, with length units, as $\boldsymbol x$. The scale factor $a$ records expansion relative to a reference epoch. For a comoving box of length $L=20\,\mathrm{Mpc}$, define dimensionless position $\boldsymbol y=\boldsymbol x/L$. Its displayed coordinates run from zero to one.

Matter following perfectly uniform expansion keeps the same $\boldsymbol y$ as its physical position changes. Comoving coordinates remove that shared expansion, exposing the migration relative to the average flow. A megaparsec is a length unit; the displayed box uses comoving lengths.

$$
\boldsymbol x=L\boldsymbol y,\qquad\boldsymbol r=aL\boldsymbol y
$$

Doubling the scale factor doubles the physical separation represented by a fixed comoving interval. The reference epoch fixes this teaching model’s units independently of a fit to today’s universe.

Reading: Springel (2005), The cosmological simulation code GADGET-2, astro-ph/0505010v1 · Original finite-mesh calculations and independent small-wave Python replay

## Two contributions to velocity

Differentiating physical position gives a term from the growing ruler and a term from motion along it. Define $H=\dot a/a$, with a dot denoting a cosmic-time derivative. The second term is the peculiar velocity $\boldsymbol v_{\rm pec}$, measured relative to the average expansion.

A particle can move inward in comoving coordinates and still move physically away from the chosen origin. Inward peculiar motion must overcome outward expansion before the physical separation starts shrinking. The same distinction applies to neighbouring pieces of matter.

$$
\dot{\boldsymbol r}=H\boldsymbol r+\boldsymbol v_{\rm pec},\qquad\boldsymbol v_{\rm pec}=aL\dot{\boldsymbol y}
$$

The origin follows the average expansion. These velocities are defined relative to it in a Newtonian box much smaller than the Hubble scale.

Reading: Springel (2005), The cosmological simulation code GADGET-2, astro-ph/0505010v1

## Why the saved momentum is not a speed

The saved $\boldsymbol u$ is dimensionless. Begin with canonical momentum per unit mass, $\boldsymbol p=a^2\dot{\boldsymbol x}=a\boldsymbol v_{\rm pec}$, then divide by the fixed velocity scale $H_\star L$. Canonical momentum is defined with the chosen coordinates and helps organise their equations of motion.

Our adopted $H_\star=70\,\mathrm{km}\,\mathrm{s}^{-1}\,\mathrm{Mpc}^{-1}$ and box length give $H_\star L=1400\,\mathrm{km}\,\mathrm{s}^{-1}$. The star marks a model reference value. Retaining both $a$ and $\boldsymbol u$ is enough to recover peculiar velocity at each epoch.

The extra factor of $a$ has a useful consequence. In the uniform-background limit with no peculiar gravitational force, peculiar velocity declines as $1/a$, but $\boldsymbol u$ stays constant. The variable has absorbed the expansion-dependent part of that change.

$$
\boldsymbol u=\frac{a\boldsymbol v_{\rm pec}}{H_\star L},\qquad\boldsymbol v_{\rm pec}=\frac{H_\star L}{a}\boldsymbol u
$$

Multiplying the stored momentum by the velocity scale is insufficient: divide by the current scale factor too. Momentum per unit mass is also distinct from the momentum obtained after multiplying by the particle mass.

Reading: Springel (2005), The cosmological simulation code GADGET-2, astro-ph/0505010v1 · Original finite-mesh calculations and independent small-wave Python replay

## Work through an inward-moving example

Consider a specified state at $a=0.5$: $y_x=0.25$ and $u_x=-0.2$ along a chosen axis. The negative sign points peculiar motion towards the origin. These are specified values for a conversion exercise.

The comoving distance is $20\times0.25=5\,\mathrm{Mpc}$. Multiplying by $0.5$ gives a physical distance of $2.5\,\mathrm{Mpc}$. Peculiar velocity is $1400\times(-0.2)/0.5=-560\,\mathrm{km}\,\mathrm{s}^{-1}$.

In the flat matter-only Einstein–de Sitter (EdS) background adopted here, $H(a)=H_\star a^{-3/2}$. At this epoch it is about $198\,\mathrm{km}\,\mathrm{s}^{-1}\,\mathrm{Mpc}^{-1}$, giving an outward expansion term near $495\,\mathrm{km}\,\mathrm{s}^{-1}$. The sum is approximately $-65\,\mathrm{km}\,\mathrm{s}^{-1}$: the physical distance to the origin is shrinking.

$$
\dot r_x\simeq(198)(2.5)-560=-65\quad\mathrm{km}\,\mathrm{s}^{-1}
$$

The first term uses physical distance times the Hubble rate. The second is peculiar velocity. Their sum determines whether physical separation grows or shrinks.

Reading: Original finite-mesh calculations and independent small-wave Python replay

## Use expansion as the clock

The model keeps expanding, so its monotonic $a$ can serve as an integration clock. Let $\phi$ be the physical peculiar potential, with units of speed squared, and define $U=a\phi/(H_\star^2L^2)$. The vector $\nabla_yU$ lists its rates of change along the three comoving directions; gravity points opposite to it.

Use $\dot a=aH=H_\star a^{-1/2}$ to change time derivatives into derivatives with respect to $a$ in Newton’s equation. This gives the following pair. Expansion is already accounted for by the canonical momentum variable.

$$
\frac{d\boldsymbol y}{da}=a^{-3/2}\boldsymbol u,\qquad\frac{d\boldsymbol u}{da}=a^{-1/2}(-\nabla_yU)
$$

These equations accompany an updated gravitational potential at every step. They assume the matter-only background, subhorizon Newtonian dynamics and collisionless particles.

Reading: Springel (2005), The cosmological simulation code GADGET-2, astro-ph/0505010v1 · Original finite-mesh calculations and independent small-wave Python replay

## A periodic face keeps the same particle

Opposite box faces connect. For display, subtract an integer from $y_x$ to put it back between zero and one. Exports retain continuous positions for following a particle across that face. Coordinates separated by an integer describe periodic copies.

Crossing the displayed boundary loses no mass and is not escape from gravity. Shell crossing, in the next chapter, instead means that different material streams overlap at one location.

Reading: Original finite-mesh calculations and independent small-wave Python replay

## Exercises and explained answers

1. If $\boldsymbol y$ stays fixed and $a$ doubles, what happens to physical separation and peculiar velocity?

   Read the explanation

   Physical separation $\boldsymbol r=aL\boldsymbol y$ doubles. Peculiar velocity is zero because $\dot{\boldsymbol y}=0$. All the changing physical separation comes from the average expansion.

2. With no peculiar gravitational force, $\boldsymbol u$ is constant. What happens to peculiar velocity between $a=0.5$ and $a=1$?

   Read the explanation

   It halves, since $\boldsymbol v_{\rm pec}=H_\star L\boldsymbol u/a$. Canonical momentum remains constant as peculiar speed declines.

3. Would the worked particle still physically approach the origin if $u_x=-0.1$?

   Read the explanation

   Its peculiar velocity becomes $-280\,\mathrm{km}\,\mathrm{s}^{-1}$. Adding expansion near $495\,\mathrm{km}\,\mathrm{s}^{-1}$ gives outward motion near $215\,\mathrm{km}\,\mathrm{s}^{-1}$, slower than pure expansion but still separating.

## Try the prediction

### [Convert an exported state into physical quantities](https://sandboxphysics.com/labs/cosmic-web-shell-crossing/)

1. Select an expansion factor near $0.5$, export the state and read its exact $a$ rather than treating the slider approximation as exact.
2. Choose one particle and convert its position and momentum with $\boldsymbol r=aL\boldsymbol y$ and $\boldsymbol v_{\rm pec}=1400\boldsymbol u/a$, obtaining megaparsecs and kilometres per second.
3. Inspect a particle near a periodic face and explain why its continuous and displayed positions can differ by one box length.

[Previous: How Gravity Builds the Cosmic Web](https://sandboxphysics.com/stories/cosmic-web/why-matter-forms-a-web/) [Next: Why One Position Can Have Several Velocities](https://sandboxphysics.com/stories/cosmic-web/when-one-position-has-several-velocities/)

## Sources and calculation scope

1. [Springel (2005), The cosmological simulation code GADGET-2, astro-ph/0505010v1](https://arxiv.org/abs/astro-ph/0505010v1)

   Focused reading: Section 2.1, equations 1–3; Section 3.2/3.2.1, equations 20–23; Section 4.1, equations 26–31, with original pages 3 and 11 viewed. Supplies cosmological momentum, PM windows and time-integration context. The teaching calculation specifies its own cutoff and finite gradient and adds no short-range tree force.

2. [Original finite-mesh calculations and independent small-wave Python replay](https://sandboxphysics.com/stories/cosmic-web/materials/cosmic-web-replay-v1.zip)

   Original accepted kernel/linear, nonlinear and five-preset F64 calculations support the teaching figures and calibration. This small public ZIP contains only an exact current-state small-wave fixture, an independent NumPy/SciPy trajectory replay and expected output. The fixture was generated through the frozen model and canonical serializer in Node, not downloaded in a browser. Large raw preset archives remain separately retained; no Engine or source paper is included.
