Solution (source code)

= Solution

The four <stellar structure equations> are
$$
\frac{dm_r}{dr}=4\pi r^2\rho,
\qquad
\frac{dP}{dr}=-\frac{Gm_r\rho}{r^2},
$$
$$
\frac{dL_r}{dr}=4\pi r^2\rho\epsilon,
\qquad
\frac{dT}{dr}=-\frac{3\kappa\rho L_r}{16\pi a_{
m rad}c,r^2T^3},
$$
together with the perfect-gas <equation of state>
$$
P=\frac{\rho k_BT}{\mu m_u}.
$$
Here $a_{\rm rad}$ is the <radiation constant>, $\epsilon$ is the specific <stellar energy-generation rate>, and $\kappa$ is the <opacity>.

Put $x=r/R$. Integrating the prescribed density gives the <enclosed mass>
$$
m_r=4\pi\rho_c\left(\frac{r^3}{3}-\frac{r^4}{4R}\right).
$$
Since $m_R=M$,
$$
\boxed{\rho_c=\frac{3M}{\pi R^3}},
\qquad
\boxed{m_r=Mx^3(4-3x)}.
$$
Integrating <hydrostatic equilibrium> inward from $P(R)=0$ gives
$$
\boxed{
P(r)=\frac{GM\rho_c}{R}
\left(\frac5{12}-2x^2+\frac73x^3-\frac34x^4\right)}.
$$
The ideal-gas law then gives
$$
\boxed{
T(r)=\frac{\mu m_uGM}{k_BR}
\frac{(1-x)(5+10x-9x^2)}{12}}.
$$
In particular,
$$
\boxed{P_c=\frac{5GM^2}{4\pi R^4}},
\qquad
\boxed{T_c=\frac{5\mu m_uGM}{12k_BR}}.
$$