In my last post I was investigating what would happen if you jumped into a hole that went through the Earth, and to make the maths easier I made the assumption that the Earth was made up of a material with homogeneous density. That's just plain wrong. As we all know the Earth's surface is mainly water, therefore its density is about 1000 kg per cubic meter, whereas the core of the planet is molten metal, which has a significantly larger density. The point is however, the density of Earth varies with depth and there are couple of different models to account for this.
Using these models I plan to run a couple of simple numerical simulations to see how the results differ as the models become more authentic. To make the simulations more accurate I need to be able to calculate the mass of a spherical shell that has a linearly varying radial density. With this I can take any spherical symmetric object with a varying density, break it into layers and calculate the object's total mass. Using the shell theorem, we can see that the gravitational field of this body outside of the sphere would be exactly the same as a body with all of the mass concentrated at a point in the centre of the sphere. Calculating the acceleration at different positions within the sphere becomes easy.
The following document shows how to derive an expression for the mass of a spherical shell with an inner radius r0 and an outer radius r1, with a linearly varying density from the inner to the outer shell of p0 to p1.