# Mistake in proof of virial theorem for gravity

I'm having trouble proving the virial theorem for gravity. I get an extraneous term, but I think my work is correct.

Starting with the Lagrangian: $$\frac{1}{2}m\dot{r}^2+\frac{1}{2}mr^2\dot{\theta}^2+\frac{GMm}{r}$$

I found $$L=mr^2\dot{\theta}^2\qquad\text{and}\qquad m\ddot{r}=mr\dot{\theta}^2-\frac{GMm}{r^2}.$$ Where $$L$$ is angular momentum.

From this I got Binet's equation $$\frac{1}{r}=\frac{GMm^2}{L^2}+B\cos{(\theta-\theta_0)}$$ Where $$B$$ is an as yet to be determined constant, but is related to the eccentricity of the orbit by geometric arguments.

I subbed $$A=\frac{GMm^2}{L^2}$$ for convenience and $$\theta_0=0$$ since it doesn't effect average values.

$$V=\frac{-GMm}{r}$$ so $$=-GMmA=\frac{-L^2A^2}{m}$$ since the cosine averages to zero over a full cycle.

Differentiating the expression for $$1/r$$ and subbing in the angular momentum, the result: $$\dot{r}=\frac{BL}{m}\sin{\theta}$$ and $$\frac{m}{2}\dot{r}^2=\frac{B^2L^2}{2m}\sin^2{\theta}$$ is the kinetic energy due to radial motion. There is also a kinetic energy term due to angular motion:

$$\frac{L^2}{2mr^2}=\frac{L^2}{2m}(A^2+2AB\cos{\theta}+B^2\cos^2{\theta})$$

So average kinetic energy $$=\frac{L^2(A^2+B^2)}{2m}.$$

So $$\frac{2}{}=\frac{-(A^2+B^2)}{A^2}.$$ The Virial Theorem says that ratio should be $$-1$$, but that's only the case if $$B=0$$, which implies circular and not elliptical motion.

It looks like I"m missing a term, but I'm not sure from where. Any thoughts?

The virial theorem $$\langle U\rangle_t =-2\langle T\rangle_t$$ is for time-averages $$\langle f\rangle_t=\frac{1}{T}\int_0^T\! \mathrm{d}t~f(t)$$, while OP considers angular averages $$\langle f\rangle_{\theta}=\frac{1}{2\pi}\int_0^{2\pi}\! \mathrm{d}\theta~f(\theta)$$. These averages will in general be different because of the larger (smaller) angular velocity at the perigee (apogee), respectively. Of course, when the eccentricity $$e\propto B$$ is zero, the angular velocity is constant, and the distinction doesn't matter.
The angular average for $$f(\theta)$$ is $$\langle f(\theta)\rangle_\theta= \frac{1}{2\pi}\int_0^{2\pi} f(\theta) d\theta$$. The time average of $$f(\theta)$$ is $$\langle f(\theta)\rangle_t=\frac{1}{\tau}\int_0^{2\pi} \frac{f(\theta)}{\dot{\theta}} d\theta$$.
Where $$1/\dot{\theta}=\frac{m}{L(A+B\cos{\theta})^2}$$ and $$\tau=\int_0^{2\pi} \frac{d\theta}{\dot{\theta}}$$.
This results in $$\langle\cos {\theta} \rangle=-\epsilon$$.
Relevant integrals can be evaluated by setting $$I=\int_0^{2\pi}\frac{d\theta}{A+B\cos{\theta}}=\int_\lambda \frac{-idz}{z[1+\epsilon(\frac{z+1/z}{2})]}$$ and using The Residue Theorem. Then the other integrals for calculating the averages can be determined by derivatives of I. Finally $$\langle \cos{\theta}\rangle=-\epsilon=-B/A$$. Ultimately this yields the expected result from the Virial Theorem, $$2\langle T\rangle/\langle V \rangle=-1.$$