Solution (source code)

= Solution

For a gas-pressure-supported <stellar core> of fixed <mass> and composition, neglect boundary terms for the illustrative whole-core estimate. The <virial theorem> gives $E=U+\Omega=-U$, and the <monatomic gas> gives $U=3M_ck_B\overline T/(2\mu m_u)$. Thus the effective <heat capacity> along the equilibrium sequence is
$$
\boxed{\frac{dE}{d\overline T}=-\frac{3M_ck_B}{2\mu m_u}<0.}
$$
This <negative heat capacity of a virialized gravitational system> means that net <energy> loss makes a self-gravitating core contract and heat. It is different from the positive local material <specific heat capacity>. On the <main sequence>, <hydrogen burning> supplies most of the radiated <energy>, so rapid contraction is arrested. Hydrogen depletion increases the <mean molecular weight>; slow structural readjustment usually raises the central <temperature> rather than making it fall.

After core hydrogen exhaustion, a massive <stellar core> contracts and heats more rapidly until a later nuclear fuel ignites. There is no general reversal to cooling simply upon leaving the <main sequence>. If <radiation pressure> becomes dominant, the <internal energy> becomes $U=U_{\rm gas}+U_{\rm rad}$ with $3\int P\,dV=2U_{\rm gas}+U_{\rm rad}$. The <virial theorem> therefore gives $E=-U_{\rm gas}$; the radiation-dominated limit is marginally bound and its effective <adiabatic index> approaches $4/3$.

Quasistatic contraction can still maintain <virial equilibrium>. It fails dynamically only when sufficient support is lost, for example if pair creation reduces the effective <adiabatic index> below $4/3$, or when an iron core undergoes <electron capture> and photodisintegration. A fixed-composition gas-dominated contracting core with $T\propto1/R$ is already a counterexample to any assertion that leaving the <main sequence> alone reverses the heating or destroys <virial equilibrium>.