Showing posts with label air density. Show all posts
Showing posts with label air density. Show all posts

Saturday, March 14, 2026

Commodore P50 Programs

Commodore P50 Programs



A collection of programs from the vintage Commodore P50 from 1978. Check out my review from last April: https://edspi31415.blogspot.com/2025/04/spotlight-commodore-p50.html.



Air Density


This equation calculates air density, in m/kg³ given the temperature of Celsius. The standard equations are used.


ρ = p ÷ (R * (T°C + 273.15)) ≈ 359.98728 ÷ (T°C + 273.15)

p = 101,325 Pa (absolute pressure)

R = 287.05 J/(kg * K) (specific gas constant)

p/R = 101325 / 287.05 ≈ 359.98728



With limited storage space of 24 steps, the equation had to be simplified.

(The step numbers are for reference, since steps cannot be reviewed on the P50.)



Start with temperature in the display. Press GOTO 00, R/S. The air density is displayed.

00 +

01 2

02 7

03 3

04 .

05 1

06 5

07 =

08 1/x

09 ×

10 3

11 5

12 2

13 .

14 9

15 8

16 7

17 2

18 8

19 =

20 r/s

21 GOTO

22 00


Examples:


Example 1: Input: 0°C, Output: 1.2922837 m/kg³

Example 2: Input: 15°C, Output: 1.2250123 m/kg³

Example 3: Input: 37.8°C, Output: 1.1351898 m/kg³



Speed of Sound



This equation calculates the speed of sound (in dry air) in m/s given the temperature of Celsius.

c_air ≈ 20.05 * √(273.15 + T°C)



Start with temperature in the display. Press GOTO 00, R/S. The speed of air is displayed.

00 +

01 2

02 7

03 3

04 .

05 1

06 5

07 =

08 √x

09 ×

10 2

11 0

12 .

13 0

14 5

15 =

16 r/s

17 GOTO

18 00


Examples:

Example 1: Input: 0°C, Output: 331.37137 m/s

Example 2: Input: 20°C, Output: 343.28856 m/s

Example 3: Input: 37.8°C, Output: 353.55718 m/s



Decibel Gain/Loss from Power Ratio



dB = 10 * log(power output ÷ power input)



Start with power output. Press GOTO 00, R/S. Then enter power input, press R/S. The decibel gain/loss is displayed.


00 ÷

01 r/s

02 =

03 log

04 ×

05 1

06 0

07 =

08 r/s

09 GOTO

10 00


Examples:

Example 1: power output = 25 W, power input = 5 W

Input: 25 GOTO 00 r/s, 5 r/s. Output: 6.9897 dB

Example 2: power output = 30 W, power input = 42 W

Input: 30 GOTO 00 r/s, 42 r/s. Output: -1.4612804 dB

Example 3: power output = 3 W, power input = 1 W

Input: 3 GOTO 00 r/s, 1 r/s. Output: 4.7712125 dB



“Radio Mathematics” ARRL. Retrieved November 1, 2025. https://www.arrl.org/files/file/ARRL%20Handbook%20Supplemental%20Files/2023%20Edition/Radio%20Supplement.pdf



Plus or Minus Operation



This program calculates a ± b (a + b and a – b). The program leaves a – b in the display and a + b in memory, which can be toggled by the memory exchange [ x ←→ M ] key.


The program uses the memory exchange key. Enter b (the term to both be added and subtracted first), then a.


00 STO

01 r/s

02 +

03 RCL

04 =

05 r/s

06 x ←→ M

07 ×

08 2

09 =

10 ±

11 +

12 RCL

13 =

14 r/s

15 GTO

16 00


Examples:

Remember, enter the second number (b) first.

Example 1: 5 ± 9

Input: 9 GOTO 00 r/s, 5, r/s. Output: 14 r/s -4

Example 2: 36 ± 20

Input: 20 GOTO 00 r/s, 36 r/s. Output: 56 r/s 16

Example 3: 310 ± 240

Input: 240 GOTO 00 r/s, 310 r/s. Output: 550 r/s 70



Combination



This is the combination function:



nCr = n! ÷ (r! * (n – r)!)



Due to only having one memory register and the factorial function does not distribute, one of the arguments (r) will need to be entered twice.



Input: n GOTO 00 r/s, r r/s, r r/s (again). Output: nCr.



00 STO

01 -

02 r/s

03 =

04 n!

05 1/x

06 ×

07 RCL

08 n!

09 ÷

10 r/s

11 n!

12 =

13 r/s

14 GOTO

15 00



Examples:

Example 1: 52 C 5

Input: 52 GOTO 00 r/s, 5 r/s, 5 r/s. Output: 2,598,960

Example 2: 34 C 12

Input: 34 GOTO 00 r/s, 12, r/s, 12 r/s. Output: 5.4835404 E 08

Example 3: 10 C 4

Input: 10 GOTO 00 r/s, 4 r/s, 4 r/s. Output: 210


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, October 8, 2023

TI-84 Plus CE: Using Matrices for "Tax Table" Calculations

TI-84 Plus CE:   Using Matrices for "Tax Table" Calculations


How The Matrix is Set Up


Each row represents a tier or a bracket.  


First column:  Lower Limit.  This is the test variable.  The first tier often will have the lower tier of 0.


Second and subsequent columns:    Variables that are associated with that tier.


Let's demonstrate this with an example.




Example Tax Bracket






This matrix has four brackets (four rows).  The algorithm starts with the last (bottom) row and tests whether the input is greater or equal to the test variable.  


According to the table, the tax rate changes at income level at $30,000, $90,000, and $270,000, with the top tax rate of 9% effective for all income excess of $270,000.


If the income is $29,999.99, the first tier of 3% is used.  If the income goes to $30,000.00, the next tier is activated.


The program ITAX, which uses this type of setup, goes "backwards".  It tests from the highest tier down.  


For example:  Income = $50,000


Start at tier 4 (bottom row). 

Is 50,000 > 270,000?  No, go to tier 3. (move one row up)

Is 50,000 > 90,000?  No, go to tier 2.  (move one row up) 

Is 50,000 > 30,000?  Yes, use the variables from tier 2.


Tax:  (50,000 - 30,000) × 5% + 900 = 20,000 × 5% + 900 = 1,900


Matrix wise:   (income - M[2,1]) * M[2,2] ÷ 100 + M[2,3]



Programs



There are two programs that illustrate this method:  


ITAX:  Income Tax Bracket.  Bracket is stored in Matrix [ A ] and has three columns:


Column 1:  lower limit of each bracket

Column 2:  tax rate for that bracket

Column 3:  additional "minimum" tax.   



BAROMET:  Calculates the air pressure and density based on height.  Scientific information is stored in Matrix [ J ].  


Column 1:  height in meters

Column 2:  mass density in kg/m^3

Column 3:  standard temperature in K

Column 4:  static pressure in Pa


If you are working in US Units, the height is converted to meters first.  After the calculation, the results are converted back into US units. 



You can download both programs here (zip file):  

https://drive.google.com/file/d/1ZCtMcJgZDLUGnrAHE6cPAkWBQQj1aHKc/view?usp=sharing



Source


"Barometric formula."  Wikipedia.  Last edited July 13, 2023.  Retrieved July 16, 2023.   https://en.wikipedia.org/wiki/Barometric_formula



Eddie



All original content copyright, © 2011-2023.  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, September 4, 2021

Sharp EL-5500III & PC-1403: Stairs and Air Density and Viscosity

 Sharp EL-5500III & PC-1403:  Stairs and Air Density and Viscosity


Stairs


Inputs:

RISE:  The floor-to-floor rise of the staircase. 

MAX RISER HGHT:  The maximum allowable rise height.

TREAD WIDTH:  The desired tread width of each stair.


Outputs:

N:  Number of Stairs

TRUE RH:  True riser height of the stair

# TREADS:  Number of treads

RUN:  Total theoretical run from the first stair to the top.

INCLINE:  Incline of the stair in degrees

STRINGER:  Length of the stringer


All amounts are assumed to be in inches and all amounts are precise (no rounding to the nearest 1/8th inch or 1/16 inch, etc).


Sharp EL-5500III/PC-1403 Program:  Stairs

RUN 300 (or whatever line you designate)


300 PRINT "STAIRS"

303 DEGREE

306 INPUT "RISE (IN)? "; R

309 INPUT "MAX RISER HGHT? "; H

312 INPUT "TREADWIDTH? "; W

315 N = INT (R/H) + 1

318 PRINT "N = "; N

321 T = R/N

324 PRINT "TRUE RH = "; T; " IN"

327 E = N-1

330 PRINT "# TREADS = "; E

333 U = E*W

336 PRINT "RUN = "; U; " IN"

339 A = ATN (T/W)

342 PRINT "INCLINE = "; A

345 S = (E*W)/(COS A)

348 PRINT "STRINGER = "; S; " IN"

351 END


Example


Inputs:

RISE:  150 in   (12 ft 6 in)

MAX RISER HGHT: 7.5 in 

TREAD WIDTH:  12 in


Results:

N = 21

TRUE RH = 7.142857143 IN

# TREADS = 20

RUN = 240 IN

INCLINE = 30.76271954

STRINGER = 279.2994151 IN


Air Density and Viscosity


Inputs:

AIR (F):  Temperature of the air in degrees Fahrenheit (°F)

PRESSURE:  Air pressure in pounds per square inch (psia)


Outputs:

DENSITY:  Air density  (lbm/ft^3)

VISCOSITY:  Estimate of air viscosity (ft^2/sec)


The dynamic viscosity (μ) for air is estimated by the equation to three significant digits:


μ ≈ 5.550736842 * 10^-10 * F + 3.04406316 * 10^-7 


Table of viscosity values:  https://www.engineeringtoolbox.com/air-absolute-kinematic-viscosity-d_601.html


Sharp EL-5500III/PC-1403 Program:  Air Density and Viscosity

RUN 400 (or whatever line you designate)


400 PRINT "AIR DENSITY/VISC (US)"

403 INPUT "AIR (F)? "; F

406 INPUT "PRESSURE (PSIA)? ";R

409 D = (144*R) / (53.3533 * (F+459.67))

412 REM MU - 3 DEC APPROX

415 M = 5.550736842E-10*F + 3.404406316E-7

418 REM NEED 9 PLACES SINCE MU IS TO -6TH POWER

421 M = INT (M*TEN 9) / TEN 9

424 V = M*32.1740464/D

427 PRINT "DENSITY = ": PRINT D; " LBM/FT^3"

430 PRINT "VISCOSITY = ": RINT V; "FT^2/SEC"

433 END


Example


Inputs:

AIR (F):  78 °F

PRESSURE:  82 psia


Outputs:

DENSITY:  4.116226392E-01 LBM/FT^3

VISCOSITY:  2.993678821E-05 FT^2/SEC


Sources


"Air - Dynamic and Kinematic Viscosity".  The Engineering Toolbox   

https://www.engineeringtoolbox.com/air-absolute-kinematic-viscosity-d_601.html

Retrieved July 8, 2021


Lindeburg, Michael R. PE Practice Problems for the Civil Engineering PE Exam: A Companion to the Civil Engineering Reference Manual  Thirteenth Edition Professional Publications, Inc: Belmont, CA  2012


Eddie


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

HP 35S: Air Density & Density Altitude (Metric-US Conversion Factors included)

HP 35S: Air Density & Density Altitude (7 Digit Accuracy*)

*You can use 4 or 5 digits for the HP 15C and other RPN calculators on which each number takes a step. Slightly less accuracy but smaller program.

Source: Shelquist Engineering web page: http://wahiduddin.net/calc/density_altitude.htm

Formulas

Air Density:

D = P ÷ (R * T)
D = density in kg/m^3
P = pressure in Pascals (Pa)
T = temperature in Kelvins
R = specific gas constant = 287.05 J/(kg*°K)

Air Density Altitude: (where the plane/vehicle thinks it is)
H = 44.3307692 - 42.2665143 * D^0.2349695

H = air density in km

U.S.-SI Conversion Factors
Pressure: (convert and store in P)
1 inHg = 2275.5477799 lb/(ft*s^2) = 3386.3881579 Pa

Temperature Conversion Formula: (convert and store in T)
°K = 5/9 * (°F - 32) + 273.15

Length:
1 km = 3280.8398950 ft

Program
D001 LBL D
D002 INPUT P
D003 287.05
D004 INPUT T
D005 *
D006 ÷
D007 STO D
D008 VIEW D \\ display air density in kg/m^3
D009 0.2349696 \\ dimensionless constant
D010 y^x
D011 42.2665143
D012 *
D013 +/-
D014 44.3307692
D015 +
D016 STO H
D017 RTN \\ display density altitude


I chose to use SI units because the constants are much smaller than the formula would be in US units.

This blog is property of Edward Shore. 2013

Thursday, March 15, 2012

Projectiles - A Realistic Point of View (Linear Drag)

Projectile Motion

This blog is about projectile motion. Most resources give an introductory treatment of projectile motion. And yes, I will present the non-air resistance model in this section. But I am also going to present a more realistic model, taking into account air resistance, size of the projectile, and temperature.

All amounts are presented in SI (kilograms, meters, seconds) units.

Quick Conversions
1 ft = 3.280839895 m
1 lb = 0.4535924 kg

Simple Projectile Motion

A perfect projectile can be described by the following equations:

x(t) = v0 t cos θ
y(t) = v0 t sin θ - 0.5 g t^2

Where
v0 = initial velocity
θ = Intial angle, in degrees
g = gravitational acceleration constant = 9.80665 m/s^2 = 32.17404856 ft/s^2
And we assume the starting height is zero (on the ground)

Note that air resistence, features of the object, and other outside objects are ignored.

Example: Hitting a Golf Ball

Use the simplistic model to plot a trajectory with an initial velocity of 150 mph (67.056 m/s) at a 35° angle.

The trajectory lasts for approximately 7.844 seconds, with a range of approximately 430.86 meters and a height of approximately 75.4 meters.

A More Realisitc View of Projectile Motion

The equations above describe simple projectile motion. However, if we want a realistic picture, we have to consider factors such as temperature, air pressure, and the size of the projectile.

So of the variables we will consider are the drag coefficient, the density of air, and the object's terminal velocity.

Note: Linear drag is assumed. This is best for objects moving at slow speeds. No lift is used.

Drag Coefficient

The drag coefficient is a dimensionless quantity that quantifies the resistance of an objects's movement, taking into consideration factors such as the object's size, shape, and smoothness.

Approximate Drag Coefficients:
Perfect Smooth Baseball: 0.1
Baseball: 0.3
Golf Ball: 0.4
Tennis Ball: 0.6

Density of Air

The density of air can be determined using the Ideal Gas Law:

P V = N R T

where
P = absolute pressure = 101325 kPa
R = Specific Gas Constant = 287.058 J/kg K
T = temperature in Kelvins
N = number of moles (mass)
V = volume of the gas
ρ = air density = N/V in kg/m^3

Solving for ρ gives:

ρ = P / (R T) ≈ 352.9774471/T

Note: To convert degrees Celsius to Kevlins, add 273.15.

Terminal Velocity

When an object falls, it reaches a terminal velocity when the drag becomes equal to the object's weight. At terminal velocity, the object no longer accelerates.

Terminal Velocity is measured by:

V = √ ( ( 2 × mass of object × g ) / ( drag coefficient × ρ × surface area of object ) )


TROJECT
Calculator: CASIO fx-CG10 (Prizm)

Note: Let [triangle] be the symbol for the "stop and display triangle"


{.3, .6, .4} → List "C"
{.145, .057, .045} → List "M"
{.041043, .003318, .001385} → List "S"
Deg
ClrText
"Init Velocity="?→ V
"Init Angle="? → θ
9.80665 → G
Menu "Object","Baseball",1,"Tennis Ball",2,"Golf Ball",3
Lbl 1: 1 → I : Goto Y
Lbl 2 : 2 → I : Goto Y
Lbl 3 : 3 → I : Goto Y
Lbl Y
Menu "Temperature","104°F/40°C",A,"95°F/35°C",B,
"86°F/30°C",C,"77°F/25°C",D,
"68°F/20°C",E,"59°F/15°C",F,
"50°F/10°C",G,"41°F/5°C",H,
"32°F/0°C",I
Lbl A : 1.1839 → P : Goto Z
Lbl B : 1.2041 → P : Goto Z
Lbl C : 1.2250 → P : Goto Z
Lbl D : 1.2466 → P : Goto Z
Lbl E : 1.2690 → P : Goto Z
Lbl F : 1.2920 → P : Goto Z
Lbl G : 1.3163 → P : Goto Z
Lbl H : 1.3413 → P : Goto Z
Lbl I : 1.3943 → P : Goto Z
Lbl Z
List "M"[I] → M
√ (( 2 × M × G) ÷ (List "C"[I] × P × List "S"[I])) → W
M × G ÷ W → K
Solve(-MGX ÷ K + M ÷ K × ( 1 - e^(-KX ÷ M)),100) → E
MV cos θ ÷ K × ( 1 - e^(-KE ÷ M)) → R
"Range="
R [triangle]
-M ÷ K × ln ((MG) ÷ K × (V sin θ + MG ÷ K)^-1) → F
-MGF ÷ K + M ÷ K × (V sin θ + MG ÷ K) × (1 - e^(-KF ÷ M)) → H
"Height="
H [triangle]
ClrGraph
ViewWindow -.5, R + .5, 1, -1, H+1, 1, 0, E, .05
θ → A
ParamType
G SelOff
G SelOn 1
"MV cos A ÷ K × (1 - e^(-KT ÷ M))" → Xt1
"-MGT ÷ K + M ÷ K × (V sin A + MG ÷ K) × (1 - e^(-KT ÷ M))" → Yt1
DrawGraph

-----------

Variables:

M = mass of object, in grams
V = initial velocity, in metes/seconds
A = θ = initial angle, in degrees
C = drag coefficient
S = radius of the object
P = gas density
K = terminal velocity

Revisiting the Example: The Golf Ball

Use the proposed model to plot a trajectory with an initial velocity of 150 mph (67.056 m/s) at a 35° angle. Assume it is 77°F outside (25°C).

The trajectory has a range of approximately 163.46 meters and a height of approximately 45.02 meters. It lasts about 6.177 seconds.


References:

Article: Erlichson, Herman. "Maximum Projectile range with drag and lift, with particular application to golf." The College of Staten Island, 1982

From:

Armenti, Angelo Jr. (editor) The Physics of Sports American Institute of Physics 1983 pg. 71-78

Reference Links:

Terminal Velocity (NASA.gov)

Drag Coefficient (NASA.gov)

Drag on a Baseball (NASA.gov)

Air Pressure


Earth's Radius by Latitude

Earth's Radius by Latitude Introduction: Calculating the Earth’s Radius In quick, general calculations, we assume that the...