Solution (source code)

= Solution

For an isolated final system with isotropic one-dimensional <velocity dispersion> $\sigma$, the random <kinetic energy> is $K=\tfrac12M\langle v^2\rangle=\tfrac32M\sigma^2$. The <virial theorem> gives $W=-2K$ and total energy $E_f=K+W=-K$. Starting from a diffuse, almost unbound gas reservoir with $E_i\simeq0$, <conservation of energy> therefore requires the <radiative energy of virialized gravitational collapse>
$$
\boxed{E_{\rm rad}\simeq E_i-E_f\simeq\frac32M\sigma^2\simeq1\times10^{52}\,\mathrm J}.
$$
It is the decrease in total energy, not the whole final magnitude $|W|$, that is lost; half of the binding-energy magnitude remains as <kinetic energy>. Assuming radiation carries most of this loss, the average <luminosity> during the nominal <galactic dynamical time> is
$$
\boxed{\langle L\rangle\simeq\frac{1.2\times10^{52}}{1.75\times10^{15}}
\simeq7\times10^{36}\,\mathrm W\simeq2\times10^{10}L_\odot},
$$
using $L_\odot\simeq4\times10^{26}\,\mathrm W$. This is comparable in order of magnitude to the stellar <luminosity> of a characteristic $L_*$ <galaxy> in the <Schechter function>, often of order $10^{10}L_\odot$ with a band-dependent definition. The equality is an energy-scale comparison: ordinary present starlight is powered mainly by <stellar nucleosynthesis>, whereas this estimate concerns gravitational energy lost during formation. Appreciable initial binding energy, mass loss or external stresses alter the coefficient, and the finite-boundary <singular isothermal sphere> cannot be used as an isolated exact <virial equilibrium> without its boundary term.