How would the density of a sphere of uniform composition vary with depth due to gravity? Let's say we have a planet-sized sphere of some uniform material floating isolated in space, not rotating, with the only significant gravity acting on it coming from its own mass. How would the density vary with depth? Would it be linear, quadratic, cubic, or something else?
For example, say the sphere is composed of iron, with a density at the surface of 7874 kg/m$^3$, and a total mass equivalent to the Earth at 5.972 × 10$^{24}$ kg. How dense would it be, say, at the core, or halfway between the core and the surface? If density were constant such a sphere would have a radius of approximately 5657 km, instead of Earth's own 6357-6371, but due to gravity we would expect the outer mass of the sphere to contract and compress the inner material. I want to know how this gravitational compression affects the density.
 A: Conceptually, the density increases until a pressure gradient is formed which balances the force of gravity, leading to hydrostatic equilibrium. This depends on how the pressure and density are related. A common approximation is to treat the pressure-density relationship as a polytrope. As a result, the answer to your question depends on which assumptions you make. Treating the Earth as an n=0 polytrope is instructive, but as a result one would simply say the density is basically constant, because rock/iron don't compress very well.
See here for more detailed theoretical treatments:
https://en.wikipedia.org/wiki/Polytrope
https://en.wikipedia.org/wiki/Lane%E2%80%93Emden_equation
Solutions to the Lane-Emden equation are usually more complicated than linear/quadratic/cubic.
In practice, the density of the Earth can be directly measured. If you trust the data here: http://hyperphysics.phy-astr.gsu.edu/hbase/Geophys/earthstruct.html then the core has a density of 13, 1/2 out has a density of 10, and the crust has a density of 2.
