Showing posts with label aviation. Show all posts
Showing posts with label aviation. Show all posts

Saturday, August 15, 2026

HP 48G Collection

 HP 48G Collection 


Contents: 

Intensity of Spherical Light Source 

Speed of Light in Dry Air 

Pressure of Air 

Earth's Gravity at a Specific Latitude 

Light of Sight: Altitude


Intensity of the Spherical Light Source



INTSP: 

<< '1_cm' * '1_m' CONVERT SQ 4 * π * →NUM SWAP '1_W' * SWAP / >>


I = P/(4π(r/100)^2)


Input: 

2: power in Watts (W) 

1: spherical radius in centimeters (cm) No need to enter units.

Output: 

1: intensity (W/m^2) with unit object attached



Example:

Input: 

2: 1368 (W) 1: 5 (cm)

Output: 

1: ≈ 43544.7924_W/m^2



Speed of Sound in Dry Air


CAIR: 

<< '1_°C' * '1_K' CONVERT 1.4 * 'R' CONST * '.289647_kg/mol' / UBASE √ >>


c_air = √(φR(T°C+273.15)/M_air) 

φ = 1.4, ideal adiabatic of air 

M_air = 0.289647 kg/mol, mole of air molecule 

R ≈ 8.314462 J/(mol K), ideal gas constant


Input: 

1: temperature in degrees Celsius (°C) No need to enter units


Output: 

1: speed of sound in air (m/s) with unit object attached


Example:


Input: 

1: 18 (°C)

Output: 

1: ≈ 342.0631_m/s


Pressure of Air


ρAIR (ρ character: [ α ] [ |→ ] [ R ]): 

<< '1_°C' * '1_K' CONVERT 287.05007 '1_J' * '1_kg' / '1_K'

* INV 'StdP' CONST '1_Pa' CONVERT * UBASE >>


ρ = P/(R*(T°C+273.15)) 

P = 101325 Pa, Standard temperature of pressure 

R = 287.05007 J/(kg K)


Input: 

1: temperature in degrees Celsius (°C) No need to enter units

Output: 

1: air pressure_J/(kg K) with unit object attached


Example:


Input: 

1: 18 (°C)

Output: 

1: ≈ 1.2124_kg/m^3


Earth's Gravity at a Specific Latitude


The true earth gravity force depends on several factors, such as latitude and altitude. This estimation takes the latitude (north/south) into account.

The constant 9.80665 m/s^2 is an accepted average, the true force varies.


gLAT: 

<< RAD HMS→ 90 / π * →NUM COS .026 * 9.806 SWAP - '1_m/s^2' * >>


g_Earth = g_45-(g_poles + g_equ) / 2 * cos(lat * π / 90 radians) 

Simplified: g_Earth = 9.806 – 0.026 * cos(lat * π / 90)

g_45 ≈ 9.806 m/s^2 

g_poles ≈ 9.832 m/s^2 

g_equ ≈ 9.78 m/s^2 Take the cosine of (latitude * π / 90) radians


Input: 

1: latitude in D.MMSS (degrees, minutes, seconds) No need to enter units

Output:

1: Earth's gravity at latitude_m/s^2 with unit object attached



Example:

Input:
1: 20.2214 (20°22'14")

Output: 

1: ≈ 9.7863_m/s^2

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.



Light of Sight: Altitude

The program calculates altitude required for an airplane to receive a signal from an airplane.


Program LOSALT: 

<< '1_nmi' * 3 ROLLD '1_ft' * '1_nmi' CONVERT '3440_nmi' + SQ 3 ROLLD '1_ft' * '1_nmi' CONVERT '3440_nmi' + SQ DUP 4 ROLL SWAP - √ 3 ROLL SWAP - SQ + √ '3440_nmi' - '1_ft' CONVERT >>


Inputs: 

3: height of the antenna in feet 

2: average height of the terrain between the airplane and antenna 

1: horizontal distance from airplane to antenna in nautical miles

Enter numbers only, no need to attach units.


Output: 

1: required height in feet, _ft unit object attached


Example: 


height of antenna: 426 ft 

average terrain height: 846 ft 

horizontal distance: 57 nautical mi

required altitude: ≈1519.7282 ft

Note: An average Earth radius is 3440 nautical miles is used. Results will vary since Earth is a spheroid.


Formulas Used:

R_ter: terrain height, Rt = radius_Earth + R_ter 

R_atn: antenna height, Ra = radius_Earth + R_atn 

D: distance to antenna 

R_alt: altitude 1 nmi ≈ 6076.1155 ft R_alt = √(Ra^2 + (D - √(Ra^2 - Rt^2))^2) – radius_Earth



This is a partial adaption of the line of sight distance program of the HP 67.

Source: Hewlett Packard. "Line of Sight Distance" HP-67/HP-97 User's Library Solutions: Avigation. Corvallis, OR. Rev. E. April 1979. pp. 18-22


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 18, 2024

HP 15C and Python: Calculating The Speed of Sound in Air

 HP 15C and Python: Calculating The Speed of Sound in Air



How fast does Sound Travel?


We can calculate the speed of sound in air which depends on temperature.


The speed of sound in air can be approximated by:

c ≈ √( γ * R * T / M)


where:


R = molar gas constant = 8.314 4625 618 153 J/(K * mol)

R = 8.314 4625 618 153 (kg * m^2)/(s^2 * K * mol)


M = molar mass of air = 0.02897 kg/mol


γ = adiabatic index of air

The index of air varies between 1.3991 and 1.403. For calculations, Wikipedia uses an average value of γ = 1.4. (see Source). For reference, an adiabatic process is a thermodynamic process that does not use heat.


A joule is a composite unit, 1 J = 1 (kg * m^2)/s^2


T = temperature in Kelvin.


Convert temperatures to Kelvin:


Fahrenheit to Kelvin:

T = 5/9 * (°F – 32) + 273.15


Celsius to Kelvin:

T = °C + 273.15


A formula to calculate the speed of sound in air is:


C = √( γ * R * T / M)


Entering the three numerical constants for γ, R, M:


γ * R / M ≈ 401.8035093 m^2/(s^2 * K)


Then:


C ≈ √(401.8035093 * T)

≈ 20.04503702 * √T


A popular version of the formula can be achieved by multiplying by 273.15/273.15 (essentially multiplying by 1):


C ≈ √(401.8035093 * 273.15 * T / 273.15)

≈ √(401.8035093 * 273.15) * √(T / 273.15)

≈ 331.2893427 * √(T / 273.15)


Let °C be the temperature in degrees Celsius. Then:

≈ 331.2893427 * √((°C + 273.15) / 273.15)

≈ 331.2893427 * √(°C / 273.15 + 1)


The Wikipedia formula rounds the constant to 331.3. (see Source) Other formulas use 331.


However, we can use the formula


C ≈ 20.04503702 * √T


and be in the ballpark. Note we’ll have to convert the temperature to Kelvin before using this formula.




HP 15C (Collector’s Edition) Program: Speed of Sound


Instructions:


To calculate the speed of sound when the temperature is in Fahrenheit (°F), press [ f ] { A } or [ GSB ] { A } [ R/S ].


To calculate the speed of sound when the temperature is in Celsius (°C), press [ f ] { B } or [ GSB ] { B } [ R/S ].


To calculate the speed of sound when the temperature is in Kevin (K), press [ f ] { C } or [ GSB ] { C } [ R/S ].


Code


Step

Key Code

Key

Notes

001

42, 21, 11

LBL A

Enter °F, convert to °C

002

3

3


003

2

2


004

30

-


005

5

5


006

20

×


007

9

9


008

10

÷


009

42, 22, 12

LBL B

Enter °C, convert to K

010

2

2


011

7

7


012

3

3


013

48

.


014

1

1


015

5

5


016

40

+


017

42, 22, 13

LBL C

Enter K

018

11

√

Calculate Speed of Sound

019

2

2


020

0

0


021

48

.


022

0

0


023

4

4


024

5

5


025

0

0


026

3

3


027

7

7


028

0

0


029

2

2


030

20

×


031

36

ENTER


032

36

ENTER


033

2

2


034

48

.


035

2

2


036

3

3


037

6

6


038

9

9


039

3

3


040

6

6


041

20

×


042

34

X<>Y


043

43, 32

RTN

End of the program


Python Code: spsound.py


Programmed on a TI-84 Plus CE Python.


print("Speed Of Sound\n")

print("1. Fahrenheit")

print("2. Celsius")

print("3. Kelvin")


# type of temperature

# choice var must be an integer

# ch is used in an element call

ch=int(input("? "))

if ch==1:

t0=eval(input("deg F? "))

t=5/9*(t0-32)+273.15

elif ch==2:

t0=eval(input("deg C? "))

t=t0+273.15

elif ch==3:

t0=eval(input("K? "))

t=t0

else:

print("Not a valid choice")

# force an error to stop the script

1/0


# calculation

s1=20.04503702*t**0.5

s2=s1*2.236936

print(str(s1)+" m/s")

print(str(s2)+" mi/hr")




Example Calculations (rounded to 5 decimal places)


Temperature

Speed of Sound (m/s)

Speed of Sound (mi/hr)

68 °F

343.20358

767.72445

35 °C

351.87462

787.83024

280 K

335.41762

750.30776

0 °C

331.28934

741.07306

96 °F

352.19167

787.83024



Source


“Speed of Sound” Wikipedia. Last Edited March 27, 2024. https://en.wikipedia.org/wiki/Speed_of_sound Retrieved April 7, 2024



Until next time,


Eddie


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