Solution (source code)

= Solution

The <virial theorem> for a stationary isolated system with inverse-square gravity is
$$
\boxed{2\langle K\rangle+\langle W\rangle=0,}
$$
where $K$ is total kinetic energy in the system's <centre-of-mass frame> and $W$ is its negative gravitational potential energy. The brackets denote a suitable time or ensemble average. Surface pressure, rapid evolution or mass fluxes add terms, so equilibrium and an appropriate boundary are substantive assumptions.