Virial theorem on a Kepler ellipse (source code)

= Virial theorem on a Kepler ellipse
{title2=$\langle K\rangle=\kappa/(2a),\quad\langle U\rangle=-\kappa/a$}

Consider the exact <two-body problem> with <masses> $m_1,m_2$. In the inertial <centre of mass> frame, its internal <kinetic energy> is $K=m|\dot{\mathbf r}|^2/2$, where $\mathbf r$ is their relative <position>, $m=m_1m_2/(m_1+m_2)$ is the <reduced mass>, and $U=-\kappa/r$ with $\kappa=G_{\!N}m_1m_2$. Take a noncollision <elliptic Kepler orbit> with <semi-major axis> $a$ and <orbital eccentricity> $0<e<1$. Write $\eta$ for <eccentric anomaly>, to avoid confusing it with total <energy> $E$. With <mean motion> $n=\sqrt{\kappa/(ma^3)}$ and <orbital period> $P=2\pi/n$, <Kepler's equation> and the <orbit> geometry give
$$
nt=\eta-e\sin\eta,\qquad r=a(1-e\cos\eta),\qquad
K=\frac{\kappa}{r}-\frac{\kappa}{2a},\qquad U=-\frac{\kappa}{r},\qquad E=-\frac{\kappa}{2a}.
$$
The <time> origin is <periapsis>. Since $dt=(1-e\cos\eta)\,d\eta/n$, the <time> average of $1/r$ over one <orbital period> is exactly $1/a$. Therefore $\langle K\rangle_P=\kappa/(2a)$ and $\langle U\rangle_P=-\kappa/a$, independently of <orbital eccentricity>. Equal steps in <eccentric anomaly> are not equal <time> steps; unweighted averaging of a drawing of the <ellipse> gives the wrong answer.

\Image[/virial-kepler-ellipse-energy-time-averages.png]
{title=Instantaneous <kinetic energy> and <potential energy>, their <orbital period> averages, and the finite-window virial residual on an eccentric <Kepler orbit>}
{id=virial-kepler-ellipse-energy-time-averages}

The original dimensionless example in both diagrams has $m=a=\kappa=1$ and $e=0.6$. At <periapsis>, $r=0.4$, $K=2$, $U=-2.5$; at <apoapsis>, $r=1.6$, $K=0.125$, $U=-0.625$. Both have $E=-0.5$, but $2K+U$ is respectively $1.5$ and $-0.375$. Only the <orbital period> averages are $\langle K\rangle_P=0.5$ and $\langle U\rangle_P=-1$. The instantaneous zero of $2K+U$ occurs at $r=a$, not at every point of the <orbit>.

\Image[/virial-kepler-ellipse-orbit-configuration.png]
{title=Relative <orbit> of the same <two-body problem>, with equal-<time> markers, the attracting focus, and <periapsis> and <apoapsis> <energies>}
{id=virial-kepler-ellipse-orbit-configuration}

The endpoint term can also be evaluated exactly: $G=m\mathbf r\cdot\dot{\mathbf r}=mna^2e\sin\eta$. Starting at <periapsis>, a window ending at <eccentric anomaly> $\eta$ has
$$
2\langle K\rangle_T+\langle U\rangle_T
=\frac{\kappa}{a}\frac{e\sin\eta}{\eta-e\sin\eta}.
$$
At $T=P/4$, <Kepler's equation> gives $\eta\simeq2.09133$ and a positive residual $\simeq0.3314\kappa/a$. At $T=P/2$ or $P$, $G$ returns to zero and the residual vanishes exactly. The lower panel shows the running residual and its endpoint expression coinciding; the shaded quarter-<orbital period> window explains why a short observation need not satisfy the infinite-<time> theorem.