get rid of unnecessary trig in gravitate function
This is a suggestion only, you may have your reasons for doing it the way you do. I have a suspicion that replacing three calls to trig functions with two divides might be slightly faster and potentially slightly more accurate.