G is a constant, right? I'm honestly not sure of a few of your steps.

Differentiate g(r) with respect to r:

g(r) = GM(r)/r^3

Well, we have a function of r divided by a function of r and you want to differentiate so via the quotient rule:

g'(r) = (GM'(r)r^3 - 3GM(r)r^2)/r^6

= (rGM'(r) - 3GM(r))/r^4

So what is M'(r)?

The Fundamental Theorem of Calculus says,

4Piq(r)r^2 (I used q instead of p to avoid confusion with Pi)

Substituting:

(4PiGq(r)r^5 3GM(r))/r^4 = 4rPiGq(r) 3GM(r)/r^4

I do not think that our answers are equivalent. Granted, I havent slept in a long time so maybe Im just drowsy. Do you see a mistake from either one of us?

M(r) is mass at radius r. As you go down, r = R-d (Radius of earth - depth dug).

g(r)=GM(r)/r^3

subst M(r) = Integral limits r and 0(4pi*rho(r)*r^2 dr

g(r)=4*pi*G/r^2*integral(rho(r)*r^2)

are we OK to there?

As last time, I am confused about how you canceled out an r in the last line. How the denominator went from r^3 to r^2 is for some reason slipping me. I have a little work to do now but when I finish I will just grab a pen and paper and work it out for myself. Sometimes simple things can slip (and then you lose an r) when you're doing all of this in your head and not writing it down.

Ah, okay. That changes everything. Okay, I think that should clear up everything (although I didn't diligently check because I'm pretty sure that should take care of the r that was bothering me). It's an interesting result that I'd never really thought about.

When you put some rough density figures in, it transpires that g goes up to about 10.2 and then decreases after that

I understand the math but am not sure about the physics because I actually never took physics after high school (and I learned almost nothing about physics in my high school physics class). It simply has to do with gravitational pull being directly proportional to mass and the obvious relation between mass and density (since density is mass per volume)?

That's basically it. The calculation is to work out how much mass is below you as you dig down. The gravitational attraction varies proportional to mass/r^2. So if you are currently in a sparse layer, with denser material below you, the mass will not change much for a given depth (r), and the 'pull' actually increases. If you are moving through dense stuff then the mass decreases rapidly as r decreases and the pull goes down.

The equation shows the balance point - if the density of the current layer is 2/3rds of the average density or more then as you dig the pull decreases. If it is less then g increases as you go down.

I've been reading physics text books lately because my job has been giving me quite a bit of spare time and I'm trying to learn physics better (and exercise my brain). We learned quite a bit in my high school physics class (that teacher was probably the best teacher that I ever had) but physics wasn't really much of what we learned (ironic, right?). These kinds of exercises are fun. If I look at an example, it's usually much easier for me to understand the math than to understand what is going on because my background is far more math oriented (my favorite math classes are mathematical analysis (which is just pure math with not a lot of physical application) and partial differential equations (which does have a lot of physical applications but you don't have to know that much physics if you're just looking at the math)).

I did get a copy of the Feynman Lectures on Physics. Unfortunately, there's no way that I could watch the videos because my internet is awful right now and won't be improving anytime soon.

Along with the Feynman Lectures, I got a few subject specific textbooks (such as right now I'm working on a relativity book because I'm interested in the math there and next I may start on an electricity book).

I do know the maths quite well. Unfortunately, when I was in college, there was a huge divide (from my understanding most universities are like this) between the pure maths and the applied maths. I was in the pure maths camp until my last year and I absolutely did not want to see any application (ergo I didn't take physics). I would have my physics or applied friend set up a problem and I'd do the differential equations or linear algebra or whatever to solve it. Around my last year I got really interested in differential equations and then wished I had double majored in physics and maths but it was too late so now I know the maths and I learn the physics just because I'm interested in it.

If I decide to go to grad school in the future, I will see if there's some sort of applied physical maths program that I can take ergo I'm studying the physics now just in case.