Python – Earth’s Radius and Gravity in US Units
Introduction
The following script, gravus2.py, estimates the Earth’s gravity in ft/sec^2 given:
1. The observer’s latitude on Earth (North or South; you don’t have to enter negative numbers for South)
2. The elevation where the observer is in feet.
The Python script is made with a TI-84 Evo, but it should work with all platforms with Python.
Equation Used: With Everything Converted to U.S. Units:
Calculating g_0 at sea level with latitude φ:
g_0 = 32.17192 – 0.08530 * cos(2 * φ°) = 32.17192 – 0.08530 * cos(2 * φ * π ÷ 180)
Calculating g_h with height h:
g_h = g_0 * (erad ÷ (erad + h ÷ 5280))^2
Where (Earth’s radius at latitude φ):
erad = √((a^4 + b^4 * tan(φ)^2) ÷ (a^2+ b^2 * tan(φ)^2))
a = 3963.1905919
b = 3949.90276423189
Code: gravus2.py
'''
Earth's Gravity in US Units
EWS 05/26/2026
'''
from math import *
# title screen
print("Earth's Gravity")
print("Given Latitude and Elevation")
print("U.S./Imperial Units")
print("-----------------")
# angles must be converted to radians
print("Latitude in DMS:")
l1=eval(input("Whole Degrees? "))
l2=eval(input("Whole Minutes? "))
l3=eval(input("Seconds? "))
langle=l1+l2/60+l3/3600
# convert to radians
langle*=pi/180
# elevation
elev=eval(input("Elevation in feet? "))
# calculate radius
a=3963.1905919
b=3949.90276423189
erad=(a**4+b**4*(tan(langle))**2)
erad/=(a**2+b**2*(tan(langle))**2)
erad=sqrt(erad)
# calculation
g=32.17192-0.08530*cos(2*langle)
g*=(erad/(erad+elev/5280))**2
print("Earth's radius: {0:.5f} mi".format(erad))
print("Estimated Gravity: {0:.5f} ft/s**2".format(g))
Examples (Results are rounded to five decimal places)
Latitude (φ) |
Height (h ft) |
Earth’s Radius (mi) |
g_h (ft/s^2) |
34°03’00” |
500 |
3959.04875 |
32.13857 |
64°11’27” |
1650 |
3952.43868 |
32.21979 |
10°57’00” |
395 |
3962.71501 |
32.09156 |
Source
Grainger Engineering Office of Marketing and Communications. (answer written by Rebecca H.) (2016, November 21). “How gravitational force varies at different locations on Earth.” Illinois. https://van.physics.illinois.edu/ask/listing/64061. Retrieved March 10, 2026.
Planetcalc. “Earth Radius by Latitude (WGS 84)” Timur. 2021. https://planetcalc.com/7721/ Retrieved March 22, 2026.
Eddie
All original content copyright, © 2011-2026. Edward Shore. Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited. This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.