Solution (source code)

= Solution

With the <polytropic equation of state> and substitutions
$$
P=K\rho_c^{1+1/n}\theta^{n+1},
\qquad
\rho=\rho_c\theta^n,
\qquad
r=a\xi,
$$
we have
$$
\frac1\rho\frac{dP}{dr}
=(n+1)K\rho_c^{1/n}\frac{d\theta}{dr}.
$$
The pressure-support equation therefore becomes
$$
(n+1)K\rho_c^{1/n}\frac1{r^2}
\frac d{dr}\left(r^2\frac{d\theta}{dr}\right)
=-4\pi G\rho_c\theta^n.
$$
Choose
$$
\boxed{a^2=\frac{(n+1)K}{4\pi G}\rho_c^{(1-n)/n}.}
$$
Changing from $r$ to $\xi$ then yields the <Lane-Emden equation>
$$
\boxed{\frac1{\xi^2}\frac d{d\xi}
\left(\xi^2\frac{d\theta}{d\xi}\right)=-\theta^n.}
$$
These are the <Lane-Emden variables for a stellar polytrope>.