# Density at the centre of the sun

Hello, here is the question I have to answer;

Calculate the total gravitational potential energy $U$ of a gravitating sphere of mass $M$ with a density profile $\rho(r)$ given by

$\rho(r)=\rho_{center}\left(1-\frac{r}{R_{star}}\right)$​

where $R_{star}$ is the radius of the star and $\rho_{center}$ is the density at $r=0$. First give an expression for the center density $\rho_{center}$ in terms of $R_{star}$ and $M$, then compute a value for the sun. Calculate the total gravitational potential energy of the sun.
I am aware that the gravitational energy of one layer of thickness dr is
$dU=-\frac{GM(r)dm}{r}$​
and that ultimately I will have to integrate this over all radii but I am unclear about the expression for $\rho_{center}$. The only thing that springs to mind is
$\rho=\frac{M}{\frac{4}{3}\pi R^3}$​
but this must be for an average density over the whole star. Can anyone point me in the direction of how to establish an expression for $\rho_{center}$?

Thanks a lot

Related Advanced Physics Homework Help News on Phys.org
jedishrfu
Mentor
It says in the problem that it is the density at the center ie r=0 its just a constant scalar.

so you must construct a function M(r) using p(r) for the shell.

However the question says "give an expression for $\rho_{center}$, so presumably I have to calculate the value of $\rho_{center}$ from scratch rather than looking it up. For example I know that the value for the center density quoted from many sources is $1.622\times10^5\textrm{ kg m}^{-3}$ however it is clear from the question I cannot simply use this value but I need to form an expression and then set r=0, but anything I try always ends up with r in the denominator thus resulting in infinity.