Skip to main content
Sandbox Physics

M047 · Energy averages

Virial Theorem Observatory

When does the virial theorem actually hold? Only for bound motion, and only after a long time. Over any finite stretch, twice the average kinetic energy differs from the average radial-force term by a boundary term: the change in position times momentum, divided by the elapsed time. That gap is real physics, not numerical error. A bound orbit keeps it finite, so it fades as time grows; an escaping one need not.

Follow bound and escaping orbits in power-law and logarithmic potentials. Compare the running averages of kinetic energy and of the radial-force term, keep the boundary term that a finite time window leaves, and check the relation again from raw sensor readings.

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}

Physics tutorial

Finite-time virial, before the limit

BackgroundIn this Lab the force always points along the radius, and the chosen source sets how its strength changes with distance.

Why it mattersLink what you see in the scene to the computed trajectory and to sensor readings taken separately.

Start with the essentials

Focus question
When does the virial theorem actually hold?
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−W,W=−r⋅F\frac{d(\mathbf r\cdot\mathbf p)}{dt}=2K-W,\qquad W=-\mathbf r\cdot\mathbf F

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=(r⋅p)(T)−(r⋅p)(0)T2\langle K\rangle_T-\langle W\rangle_T=\frac{(\mathbf r\cdot\mathbf p)(T)-(\mathbf r\cdot\mathbf p)(0)}{T}

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

What the model assumes

Typical misconceptionAn ideal model like this automatically describes a real planet or a relaxed star cluster.

Better mental modelThe source is fixed in advance, the test particle does not pull back on it, and the effects left out are listed.

Run the experiment

  1. 01

    Compare potentials

    Try Kepler ellipse, Harmonic well, Quartic confinement and Logarithmic potential.

    What to observe: When the force law changes, the running averages change with it.
  2. 02

    Keep the boundary term

    Compare Short observation with a longer duration, and drag the selected time.

    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

    Acquire the computed trajectory, look at the raw estimates, then halve the integration step.

    What to observe: Resampling and sensor noise affect the raw estimate, separately from the numerical average taken at every step.
FeedbackSomething 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