Skip to main content
Sandbox Physics

Virial Theorem Observatory

When does the virial theorem actually hold? If the particle’s position and momentum stay bounded and its energy averages exist, the virial relation holds in the long-time limit. At finite times an endpoint term sets the gap: it is zero on a circular orbit or over a complete period, and can persist or decay on an escaping orbit.

Follow bound and escaping orbits. Compare running energy averages with the finite-time boundary term to see when the virial relation settles.

Interactive modelVirial Theorem Observatory
Mean potential energyReady\text{Ready}
Selected timeReady\text{Ready}
Particle radiusReady\text{Ready}
Particle speedReady\text{Ready}
Kinetic energyReady\text{Ready}
Potential energyReady\text{Ready}
Twice mean kinetic energyReady\text{Ready}
Mean radial virialReady\text{Ready}
Finite-window boundary termReady\text{Ready}
Finite-window identity residualReady\text{Ready}
Characteristic clockReady\text{Ready}
Maximum energy errorReady\text{Ready}
Maximum angular momentum errorReady\text{Ready}
Endpoint refinement differenceReady\text{Ready}
Raw-record identity residualReady\text{Ready}
Initial binding conditionReady\text{Ready}
Acquired trajectory stationsReady\text{Ready}

Why energy averages need a long observation

BackgroundA particle on a bound orbit speeds up near the centre and slows farther out. Its kinetic and potential energies keep changing while their time averages can settle.

Why it mattersCompare a short stretch of an orbit with many revolutions, then launch a particle fast enough to escape.

One-sentence intuition
Over a finite time, the boundary term is real physics, not numerical error.

Core mathematical model

Attractive radial potentials

U(r)=An(rr0)n(n≠0)Ulog⁡(r)=Aln⁡(rr0)\begin{aligned}U(r)&=\frac A n\left(\frac r{r_0}\right)^n\\&\quad(n\ne0)\\U_{\log}(r)&=A\ln\left(\frac r{r_0}\right)\end{aligned}

The logarithmic potential is a separate choice, and the energy zero of the power-law potentials is not shifted to match it. The test mass is one kilogram.

The virial identity at each instant

d(r⋅p)dt=2K−WW=−r⋅F\begin{aligned}\frac{d(\mathbf r\cdot\mathbf p)}{dt}&=2K-W\\W&=-\mathbf r\cdot\mathbf F\end{aligned}

The signs follow from a radius that points outward and a force that points inward.

The identity averaged over a finite time

2⟨K⟩T−⟨W⟩T=BTBT=C(T)−C(0)TC(t)=r(t)⋅p(t)\begin{gathered}2\langle K\rangle_T-\langle W\rangle_T=B_T\\B_T=\frac{C(T)-C(0)}T\\C(t)=\mathbf r(t)\cdot\mathbf p(t)\end{gathered}

Over a short interval the physical boundary term can be large, and the identity still holds accurately.

The virial term for each potential

W=nU(n≠0)Wlog⁡=A\begin{aligned}W&=nU\quad(n\ne0)\\W_{\log}&=A\end{aligned}

The familiar long-time energy relation follows only when the boundary term goes to zero.

Conserved quantities

E=12m∣v∣2+U(r)Ly=m(zvx−xvz)\begin{aligned}E&=\frac12m|\mathbf v|^2+U(r)\\L_y&=m(zv_x-xv_z)\end{aligned}

The orbit lies in the horizontal plane. Errors in energy and angular momentum are reported separately from the virial residual.

Common difficulties

A short interval leaves a physical remainder

Typical misconceptionAny gap in the average-energy relation is an integration error.

Better mental modelEven exact motion leaves an endpoint term over a finite interval. Subtract that term before judging numerical error. The fixed radial source models a test particle, not a self-gravitating star cluster.

Run the experiment

  1. 01

    Compare potentials

    Try Kepler ellipse, Harmonic well, Quartic confinement and Logarithmic potential. Drag the violet launch arrow to change its radial and tangential components.

    What to observe: Both mean kinetic and mean potential energy change when the force law or launch changes.
  2. 02

    Keep the boundary term

    Choose Short observation, increase Observation window and drag Selected time or the gold particle.

    What to observe: The gap between the averages tracks the physical boundary term. What remains after subtracting it measures numerical error.
  3. 03

    Test the assumption

    Raise the Kepler launch speed above escape speed and watch the boundary term.

    What to observe: An escaping particle breaks the assumption of bounded motion, and observing for longer need not restore the relation.
  4. 04

    Take readings, then refine the step

    Expand Scales, resolution and sensors, acquire the trajectory and inspect Raw records and numerical checks. Halve the integration step and acquire again.

    What to observe: Resampling and sensor noise affect the raw estimate, separately from the numerical average taken at every step.
Something broken, confusing, or missing on this page?Tell us
What kind of feedback?

Sent with this page’s address, its Lab ID, the site language and your device type. Please leave out personal details. Feedback is kept for up to 12 months.Privacy policy