Showing posts with label approximation. Show all posts
Showing posts with label approximation. Show all posts

Saturday, May 30, 2026

Numworks (Python): Determining Earth’s Acceleration of Gravity

Numworks (Python): Determining Earth’s Acceleration of Gravity



Introduction



Note: We will only be using SI units on this blog entry and program.



In general, the Earth’s acceleration constant, labeled with a lower case g, is conventionally defined to be 9.80665 m/s². Did you know that the gravitation acceleration on this planet actually varies (albeit slightly) depending on factors? For example, the gravity’s acceleration in Los Angeles, California, is about 9.796 m/s² (see Wikipedia article in the Source section).



On today’s blog, we will estimate the gravity of Earth based with two parameters: the latitude (North/South position on Earth’s grid) and elevation (in meters). This will give us a more accurate estimated on gravity, which in turn will give other physics calculations more accuracy.



For this program, I’m using a mix of formulas to estimate Earth’s gravitational acceleration:



Let Φ = latitude in radian measure:

Φ = (degrees + minutes ÷ 60 + seconds ÷ 3600) * π ÷ 180



For this calculation, consider the absolute value of the latitude. Gravity acceleration is the a given the northern latitude north and the corresponding southern latitude. (Example: gravity is about 9.79325 m/s² at 30° north and 30° south).



Gravity at the surface (0 m) is calculated as:

gs = (a * ga * (cos Φ)^2 + b * gb * (sin Φ)^2) ÷ √((a * cos(Φ))^2 + (b * sin(Φ))^2)

[Bilsin]



Where:

Φ = latitude in radians (see formula above)

a = 6378137 m (Earth’s radius at the equator)

ga = 9.70803253359 m/s² (gravity at the equator)

b = 6356752.3142 m (Earth’s radius at the poles)

gb = 9.8321849378 m/s² (gravity at the poles)

[Bilsin, Table 2]



Gravity at the selected elevation is estimated at:

ge = (100 * gs – 0.3086 * h ÷ 1000) ÷ 100

[Glover]



Where:

h = height in meters (m)



Note: The table on the Desk Ref list gravity as cm/s² and the original formula called for the height in kilometers (km).



To convert feet to meters, multiply by 0.3048.



Numworks Program: earthg.py


https://my.numworks.com/python/ews31415/earthg


Code:


from math import *

# Numworks, EWS, January 2026


# constants

# equator: radius, gravity

a=6378137

ga=9.7803253359

# poles: radius, gravity

b=6356721.3142

gb=9.8321849378


print("Latitude:","\nNorth or South")

d=eval(input("Decimal? "))

m=eval(input("Minutes? "))

s=eval(input("Seconds? "))

phi=radians(d+m/60+s/3600)


print("Height (m)?")

h=eval(input("? "))


gs=a*ga*cos(phi)**2+b*gb*sin(phi)**2

gs/=sqrt((a*cos(phi))**2+(b*sin(phi))**2)


print("Gravity on the surface:")

print(str(gs)," m/s**2")


print("At altitude: ",str(h)," m")

ge=(100*gs-0.3086*h/1000)/100

print(str(ge)," m/s**2")




Examples


Latitude

Elevation

g_surface

g_elevation

30°0’0”

0

9.793247191840559

9.793247191840559

40°0’0”

304.8

9.801696762579571

9.800756149779572

45°0’0”

762

9.806197665936962

9.803846133936961

12°5’13”

1219.2

9.782589588493437

9.778827137293437

34°26’44”

500

9.796866770553882

9.795323770553882


g_surface: gravity at surface level (0 m)

g_elevation: gravity at the selected elevation



Sources


Bislin, Walter. “Earth Gravity Calculator” September 1, 2018. https://walter.bislins.ch/bloge/index.asp?page=Earth+Gravity+Calculator Retrieved January 15, 2026.


Glover, Thomas J. and Richard A. Young Desk Ref Sequoia Publishing, Inc. Anchorage, AK. 4th Edition, 2022. Soft Cover ISBN 978-1-885071-60-6. pg. 587


“Gravity of Earth” Wikipedia. Last edited January 31, 2026. https://en.wikipedia.org/wiki/Gravity_of_Earth Retrieved February 1, 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.


Saturday, May 17, 2025

TI-84 Plus CE: Rafter Multipliers and Roof Area

TI-84 Plus CE: Rafter Multipliers and Roof Area



Introduction


Rafter multipliers are a quick way to calculate the area of a roof. All that is needed are three measurements:


(1) The width of a house

(2) The length of a house, including eaves and lengths of overhangs

(3) The pitch of the roof. The pitch the rise of the roof in inches over a run of 12 inches.


It is assumed that we have a simple roof and the area of the house is rectangular. Even in more complex cases, we can use the multipliers come up with a good approximation.



Pitch = rise in inches / 12 inches


The area of the roof depends on the width, length, and pitch.


The area is approximated by:

roof area ≈ length * width * rafter factor


The common values are shown here:


Pitch (n in 12”)

Pitch (decimal – 3 places)

Rafter Factor (decimal -3 places)

2 in 12

0.167

1.014

3 in 12

0.250

1.031

4 in 12

0.333

1.054

5 in 12

0.417

1.083

6 in 12

0.500

1.118

7 in 12

0.583

1.158

8 in 12

0.667

1.202

9 in 12

0.750

1.250*

10 in 12

0.833

1.302

11 in 12

0.917

1.357

12 in 12

1.000

1.413

13 in 12

1.083

1.474

14 in 12

1.167

1.537

15 in 12

1.250

1.601

16 in 12

1.333

1.667

17 in 12

1.417

1.734

18 in 12

1.500

1.803

19 in 12

1.583

1.875

20 in 12

1.667

1.948

21 in 12

1.750

2.010

22 in 12

1.833

2.083

23 in 12

1.917

2.167


* This was erroneously labeled as 1.357 on the Dewalt Construction Math Quick Check guide (see Sources). Several sources correctly has the value of 1.250.



Curve Fitting


What if I can fit a formula to the above data?


I used a TI-84 Plus CE to assist me with this.


First, we’ll use the quadratic regression with the data from the above table:


y = a * x^2 + b * x + c


The resulting coefficients:


a = 0.1867080745

b = 0.2897396951

c = 0.938

r^2 = 0.9992015789


That’s a pretty good fit.


What about the square root fit:


y = √(a * x^2 + b)


If we square both sides, we get:


y^2 = a * x^2 + b


This equation takes somewhat the form of the linear regression.


Let z = x^2 and t = y^2, then:


z = a * t + b


Pitch (n in 12”)

X = Pitch (decimal – 3 places)

Z = X^2 (approximate)

Rafter Factor (decimal -3 places)

T = Y^2 (approximate)

2 in 12

0.167

0.0278

1.014

1.0282

3 in 12

0.250

0.0625

1.031

1.063

4 in 12

0.333

0.1111

1.054

1.1109

5 in 12

0.417

0.1736

1.083

1.1729

6 in 12

0.500

0.25

1.118

1.2499

7 in 12

0.583

0.3403

1.158

1.341

8 in 12

0.667

0.4444

1.202

1.4448

9 in 12

0.750

0.5625

1.250*

1.5625

10 in 12

0.833

0.6944

1.302

1.6952

11 in 12

0.917

0.8403

1.357

1.8414

12 in 12

1.000

1

1.413

1.9966

13 in 12

1.083

1.1736

1.474

2.1727

14 in 12

1.167

1.3611

1.537

2.3624

15 in 12

1.250

1.5625

1.601

2.5632

16 in 12

1.333

1.7778

1.667

2.7789

17 in 12

1.417

2.0069

1.734

3.0068

18 in 12

1.500

2.25

1.803

3.2508

19 in 12

1.583

2.5069

1.875

3.5156

20 in 12

1.667

2.7778

1.948

3.7947

21 in 12

1.750

3.0625

2.010

4.0401

22 in 12

1.833

3.3611

2.083

4.3389

23 in 12

1.917

3.6736

2.167

4.6959


Running the linear regression calculation with (z, t) we get:


a = 1.000120031

b = 1.00008392

r^2 = 0.9999332927

More accurate that the quadratic regression.


z = 1.000120031 * t + 1.00008392

y^2 = 1.000120031 * x^2 + 1.00008392

y = √(1.000120031 * x^2 + 1.00008392)



Analysis


I suspect that the exact formula for the rafter factor is:

rafter factor = √( pitch^2 + 1 ), pitch as a decimal


And the roof area is:

roof area = length * width * √( pitch^2 + 1 ) [ in inches ]


Roof area in square feet = Roof area in square inches / 144



Example


Area: length = 18 feet 6 inches, width = 20 feet, pitch = 7/12

In inches, length = 222 inches, width = 240 inches


roof area = 222 * 240 * √((7/12)^2 + 1) ≈ 61682.45131 in^2 ≈ 428.3503 ft^2



Sources


Prince, Christopher DeWALT Construction Math Quick Check: Extreme Duty Edition. Delmar, Cengage Learning: Cliffon Park, NY. 2010


Elliot. “Roof Area Calculator * Surface Area Multiplied by Pitch”. sktechandcalc.com. October 20, 2017. https://www.calculator.net/roofing-calculator.html?acarea=176&acareaunit=feet&roofpitch=4&angle=25&eaves=0&eavesunit=feet&price=&priceunit=feet&ctype=pitch&tp=ar&x=Calculate


calculator.net. “Roofing Calculator” 2008 – 2024. Retrieved November 4, 2024. https://www.calculator.net/roofing-calculator.html?acarea=176&acareaunit=feet&roofpitch=4&angle=25&eaves=0&eavesunit=feet&price=&priceunit=feet&ctype=pitch&tp=ar&x=Calculate



Eddie


All original content copyright, © 2011-2025. 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.


-

Python in Numworks: Duplicating and Grayscale

Python in Numworks: Duplicating and Grayscale All three scripts presented today use the math, random, and the Numworks specific ...