I going to tap here if I may. Gravity inside a spherical object is linear with the distance from the object to center of the sphere. (assume more or less contant density).

So you do not need to use spherical coodenate in order to get the value of the gravity at any point inside the sphere.

all yo need is to now the magnitud of gravity on the surface, and the interpolate that value with the distance to the center.

somethin like this (pseudo code)

let G be the gravity
let R be the radius of the sphere
let P be the center of the sphere
lep Q be the point inside the sphere

distVector = substract (Q, P);
magOfdistVector = Magnitud (distVector)

gravDirVector = Normalize (distVector);
gravMag = G * (magOfdistVector / R)


this is valid in for any spherical object as long as the point is inside the sphere.

when the point is outside the it ovey Newton Gravitation Law

Newton