What is the mathematical formulae for gravity?
When dealing with a uniform shell of mass (and planets can be thought of as just a bunch of concentric uniform shells of mass), the gravity, for all points outside the shell, is the same as it would be if all the mass were concentrated at the center.
I was somewhat in error. Density does matter in that the more dense an object is the smaller the radius. This website has a good treatment of the subject.
http://www.geocities.com/nickemarkov/ExpansionAndGravitation.html
Gmn = -(8pG/c2)Tmn
ds2 = c2(1-2MG/c2r)dt2 - dr2/(1-2MG/c2r) - r2(dq2+sin2qdf2).
dt = (1-2MG/c2r)1/2dt
dt1/dt2 = (1-2MG/c2r1)1/2/(1-2MG/c2r2)1/2
rc = 2MG/c2
dt1/dt2 = (1-MG/c2R)(1+MG/c2(R+h)) = 1 - (MG/c2)[1/R - 1/(R+h)]
1-dt1/dt2 = (MG/c2)(h/R2)
(n2-n1)/n2 = (MG/c2)(h/R2)