Showing posts with label elevation. Show all posts
Showing posts with label elevation. Show all posts

Saturday, September 5, 2026

Python – Earth’s Radius and Gravity in US Units

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.


Sunday, May 19, 2013

HP35S Vertical Curve: Elevation at Peak and at End Point


HP35S Vertical Curve: Elevation at Peak and Length

Source: Fundamental of Engineering Supplied-Reference Handbook 8th Ed, 2nd Revision, 2011, NCEES

Calculator: HP 35S

Input
I = initial height
G = grade 1; entering the curve (in decimal form)
H = grade 2; exiting the curve (in decimal form)
L = horizontal length of the curve

G and H are the opposite signs

If G>0 and H<0 a="" and="" curve="" g="" h="" has="" if="" peak.="" similarity="" the="">0, the curve has a valley.

The program listed prompts for the inputs.

Output
1. Point where the curve reaches extreme elevation
2. Press R/S to get the elevation at the extreme point.
3. Press R/S once more to get the elevation at the end of the curve.

None of the outputs are stored.

Formula
A = (G - H)/(2L)
X_extrema = -G/(2A)
Equation of the Curve: y = I + G*x + A*x^2

Examples
Uphill curve:
I = 1,000 ft
G = 7% = 0.07
H = -4% = -0.04
L = 1,368 ft

Point at peak elevation is 870.545 ft into the curve at 1,030.469 ft. The elevation at the end of the curve is 1,020.520 ft.

Downhill curve:
I = 1,580 ft
G = -3% = -0.03
H = 4.2% = 0.042
L = 2.3 mi = 12,144 ft

Point at trough elevation occurs 5,060 ft into the curve at elevation 1,504.1 ft. The elevation at the end of the curve is at 1,652.864 ft.

Program
V001 LBL V
V002 INPUT I
V003 INPUT G
V004 INPUT H
V005 INPUT L
V006 RCL H
V007 RCL - G
V008 2
V009 ÷
V010 RCL ÷ L
V011 STO A
V012 RCL G
V013 x<>y
V014 ÷
V015 2
V016 ÷
V017 +/-
V018 R/S \\ shows point where extreme elevation occurs
V019 XEQ V024
V020 R/S \\ shows extreme elevation
V021 RCL L
V022 XEQ V024 \\ shows ending elevation
V023 RTN
V024 ENTER \\ calculate y subroutine
V025 RCL × A
V026 RCL + G
V027 ×
V028 RCL + I
V029 RTN



This blog is property of Edward Shore. 2013

HP 42S/DM42/Free 42: Two Functions Programmed Three Different Ways

HP 42S/DM42/Free 42: Two Functions Programmed Three Different Ways Introduction In 1979, Electro Scientific Industries (esi)...