Showing posts with label RPN. Show all posts
Showing posts with label RPN. Show all posts

Saturday, October 17, 2026

HP 67 Collection: October 2026

HP 67 Collection: October 2026


All examples are done in FIX 4. (DSP 4)



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), in degrees-minutes-seconds, and latitude, in kilometers, into account.



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

g_s = 9.806 – 0.026 * cos(2 * φ)

g_h = g_s * (6378.1 / (6378.1 + h))



HP 67 Code:

LBL A: 001 31, 25, 11

DEG: 002 35, 41

H←: 003 31, 74

2 : 004 02

× : 005 71

COS: 006 31, 63

. : 007 83

0 : 008 00

2 : 009 02

6 : 010 06

× : 011 71

9 : 012 09

. : 013 83

8 : 014 08

0 : 015 00

6 : 016 06

x<>y: 017 35, 52

- : 018 51

x<>y: 019 35, 52

6 : 020 06

3 : 021 03

7 : 022 07

8 : 023 08

. : 024 83

1 : 025 01

+ : 026 61

LST x: 027 35, 82

x<>y: 028 35, 52

÷ : 029 81

× : 030 71

RTN : 031 35, 22



Inputs:

Y: h

X: φ



Examples:

Inputs: h = 0, φ = 2°33’: g ≈ 9.7801

Inputs: h = 0.762, φ = 52°17’: g ≈ 9.8114



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.



Triangulation



With angles α and ß:

base = dist * (1/tan α + 1/tan ß)

dist = base ÷ (1/tan α + 1/tan ß)



Labels:

LBL A: Enter angles α and ß in the current angle mode. Returns 1/tan α + 1/tan ß.

LBL B: Base. When a number is entered prior to pressing [ B ], the number is stored as a base. Otherwise, the program solves for a base.

LBL C: Distance (of a line that bisects the base). When a number is entered prior to pressing [ C ], the number is stored as a base. Otherwise, the program solves for a base.


HP 67 Code:

LBL A: 001 31, 25, 11 (enter the angles)

TAN: 002 31, 64

1/x: 003 35, 62

x<>y: 004 35, 52

TAN: 005 31, 64

1/x: 006 35, 62

+: 007 61

STO 5: 008 33, 05

RTN: 009 35, 22


LBL B: 010 31, 25, 12 (base)

STO 3: 011 33, 03

F? 3: 012 35, 71, 03

RTN: 013 35, 22

RCL 4: 014 34, 04

RCL 5: 015 34, 05

× : 016 71

STO 3: 017 33, 03

RTN: 018 35, 22


LBL C: 019 31, 25, 13 (distance)

STO 4: 020 33, 04

F? 3: 021 35, 71, 03

RTN: 022 35, 22

RCL 3: 023 34, 03

RCL 5: 024 34, 05

÷ : 025 81

STO 4: 026 33, 04

RTN: 027 35, 22


Examples:

α = 30°, ß = 65°

Set degree mode. 30 [ ENTER ] 65 [ A ]. Result: 2.1984

Distance = 24, solve for base. 24 [ C ] [ B ]. Result: 52.7606

Base = 24, solve for distance. 24 [ B ] [ C ]. Result: 10.9172


Source:

“Triangulation (surveying)” Wikipedia. https://en.wikipedia.org/wiki/Triangulation_(surveying) (last edited October 24, 2025). Retried March 17, 2026



Time of Runoff on Turf


t = 2.5 * (L / (S * I^2))^(1/3)


t: time of runoff (rain off) in minutes

2.5: turf constant

L: distance from remote area in feet

S: slope of the terrain

I: rain intensity in inches per hour


Input Stack:

Z: L

Y: S

X: I


Output Stack:

X: t


HP 67 Code:

LBL A: 001 31, 25, 11

x² : 002 32, 54

× : 003 71

÷ : 004 81

3 : 005 03

1/x: 006 35, 62

y^x: 007 35, 63

2 : 008 02

. : 009 83

5 : 010 05

× : 011 71

RTN: 012 35, 22


Examples:

Inputs: Z: 900 ft, Y: 0.11, X: 4 in/hr. Result: 19.9917 min

Inputs: Z: 650 ft, Y: 0.33, X: 0.06 in/hr. Result: 204.4744 min


Source


Texas Instruments. Slide Rule Calculator SR-50A Manual. 1975. Manual from datamath.org: http://www.datamath.net/Manuals/SR-50A_US.pdf pg. 59



Beamwidth of a Radio Telescope


This program calculates the beam width of a radio telescope in degree-minutes-seconds.


Θ = 67625 ÷ (D * f)

Θ = beam width

D = the diameter of a circular telescope in feet

f = observing frequency in MHz (megahertz)


Inputs:

Y: D

X: f

Outputs:

X: Θ


HP 67 Code:

LBL B: 001 31, 25, 12

× : 002 71

1/x : 003 35, 62

6 : 004 06

7 : 005 07

6 : 006 06

2 : 007 02

5 : 008 05

× : 009 71

→H.MS: 10 32, 74

RTN: 11 35, 22


Examples:

Inputs: X: 1980 MHz, Y: 106 ft. Output: Θ: 0.1920 (19’20”)

Inputs: X: 1665 MHz, Y: 84 ft. Output: Θ: 0.2901 (29’01”)


Source


Ball, John A. Algorithms for RPN Calculators John Wiley & Sons: New York, NY. 1978. ISBN 0-471-03078-8. pg. 259



Fan Laws


p2 = (rpm2 ÷ rpm1)^n * p1

(p1 and p2 stand for various parameters, see the input syntax below)


Inputs:

1st law: (cfm: cubic feet per minute, rpm: revolutions per minute)

Calculate cfm2:

T: cfm1

Z: rpm2

Y: rpm1

X: 1


2nd Law: (sp: static pressure, rpm: revolutions per minute)

Calculate sp2:

T: sp1

Z: rpm2

Y: rpm1

X: 2


3rd Law: (hp: horsepower, rpm: revolutions per minute)

Calculate hp2:

T: hp1

Z: rpm2

Y: rpm1

X: 3


HP 67 Code:

LBL B: 001 31, 25, 12

R↓ : 002 35, 53

÷ : 003 81

R↑ : 004 35, 54

y^x: 005 35, 63

× : 006 71

RTN: 007 35, 22


Examples

1st Law: T: cfm1 = 2000, Z: rpm2 = 1100, Y: rpm1 = 950, X: n = 1

Result: cfm2 ≈ 2315.7895

2nd Law: T: sp1 = 0.5, Z: rpm2 = 1100, Y: rpm1 = 950, X: n = 2

Result: sp2 ≈ 0.6704

3rd Law: T: hp1 = 1.5, Z: rpm2 = 1100, Y: rpm1 = 950, X: n = 3

Result: hp2 ≈ 2.3286


Source

Gladstone, John. Air Conditioning Testing and Balancing: A Field Practice Manual A Van Nostrand Reinhhold Book. August 1976. pp. 24-32



More HP 67 goodness to come in November,


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, October 10, 2026

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) released the (rare) ESI Calcumeter 4100 which is a combination multimeter and RPN calculator. I’m going to focus on the calculator part.


The calculator is a standard RPN calculator with the following functions: x^2, √, 1/x, 10^x, e^x, LN, log, and y^x. Also present are the standard ↓ROLL (roll down) and x<>y (swap) functions. Then we have other unique function such as:


mx+b: Applies a linear regression model to a measurement, with m stored in memory and b is grabbed from the y-registered


dBV: Decibel measurement (volt): 20 * log(measurement ÷ memory) (measurement is probably in the X register)


%DEV: percent change of a measurement from the value stored in memory:

100 * (measurement – memory) ÷ memory


AVG: average of cumulative amount of measurements against the value stored in memory


xy/(x+y): calculates x * y ÷ (x + y)


xy/(x – y): calculates x * y ÷ (x – y)


Getting this multimeter combo was not inexpensive, it had a retail price of $399 in 1979.


Today’s blog will focus on two of these functions, particularly xy/(x+y) and xy/(x-y).



The Functions xy/(x+y) and xy/(x-y)


As I could gather from the calculator’s keyboard:


xy/(x+y): Multiply Over Plus*

MOP(x,y) = (x * y) ÷ (x + y) = 1/(1/y + 1/x)


xy/(x-y): Multiply Over Subtract*

MOP(x,y) = (x * y) ÷ (x - y) = 1/(1/y – 1/x)


* These are my names for these functions. I don’t have the manual. Here I am assuming that the stack is in the traditional order: X is the display, Y is the stack just above X, and the RPN works like any (HP) RPN calculator.


All programs are made using the Free42 app (42S/41C family).


Stage 1: The Long Way


This starts out by duplicating x and y first until we have the stack as follows: Y, X, Y, X.



00 { 19-Byte Prgm }

01▸LBL "MOP"

02 ENTER

03 ENTER

04 CLX

05 -

06 R↓

07 X<>Y

08 +

09 R↓

10 ×

11 R↑

12 ÷

13 RTN

14 END


00 { 19-Byte Prgm }

01▸LBL "MOS"

02 ENTER

03 ENTER

04 CLX

05 -

06 R↓

07 X<>Y

08 -

09 R↓

10 ×

11 R↑

12 ÷

13 RTN

14 END



Stage 2: What if we assume x and y are nonzero?


Let n = (x * y) ÷ (x ± y)

Then:

1/n = (x ± y) ÷ (x * y)

1/n = x ÷ (x * y) ± y ÷ (x * y)

1/n = 1/y ± 1/x

n = 1/(1/y ± 1/x)



00 { 14-Byte Prgm }

01▸LBL "MOAR"

02 1/X

03 X<>Y

04 1/X

05 +

06 1/X

07 RTN

08 END


00 { 15-Byte Prgm }

01▸LBL "MOSR"

02 X<>Y

03 1/X

04 X<>Y

05 1/X

06 -

07 1/X

08 RTN

09 .END.


Shorter.


Stage 3: Using Stack Storage Operations (41C/42S only)


The HP 41C and 42S families allow us to use stack levels (X, Y, Z, T, and L) as storage registers. Let's see if we can take advantage of this.



00 { 17-Byte Prgm }

01▸LBL "MOP42"

02 STO ST Z

03 X<>Y

04 STO× ST Z

05 +

06 ÷

07 RTN

08 END


00 { 17-Byte Prgm }

01▸LBL "MOS42"

02 STO ST Z

03 X<>Y

04 STO× ST Z

05 -

06 ÷

07 RTN

08 END


Sources


Electro Scientific Industries, Inc. “Calcumeter 4100” Ad/Pamphlet Micrometrics, Inc. Portland, OR. 1979


Sanden, Kees van der. “The ESI Calcumeter 4100” https://www.keesvandersanden.nl/calculators/esi4100.php Retrieved June 19, 2026.





I hope you enjoyed our deep dive. See you next time,


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, August 1, 2026

DM42 and HP 42S: Quadratic Equation, Characteristic Polynomial, and Eigenvalues

DM42 and HP 42S: Quadratic Equation, Characteristic Polynomial, and Eigenvalues




The programs are listed for the Swiss Micros DM42 and Hewlett Packard 42S.



All examples are on rounded to four decimal places and complex mode turned on (CPXRES).



Monic Quadratic Equation: quad2.raw



The program QUAD2 solves the equation for w:

w² + Y * w + X = 0

Y: contents of stack Y

X: contents of stack X



Code:

00 { 35-Byte Prgm }

01▸LBL "QUAD2"

02 X<>Y

03 ENTER

04 2

05 ÷

06 +/-

07 ENTER

08 X↑2

09 X<>Y

10 R↓

11 X<>Y

12 -

13 SQRT

14 R↑

15 X<>Y

16 ENTER

17 ENTER

18 R↑

19 ENTER

20 R↓

21 X<>Y

22 +

23 R↓

24 -

25 R↑

26 RTN

27 .END.



Example 1: w² + 7 * w + 5 = 0

Stack: Y: 7, X: 5

Results: -6.1926, -0.8074



Example 2: w² – 4 = 0

Stack: Y: 0, X: -4

Results: -2.0000, 2.0000



Characteristic Polynomial: char2.raw



The program CHAR2 find the coefficients of 2 x 2 matrix:

[ [ A, B ] [ C , D ] ]

Result: λ² – T1 * λ + T2 = 0 where

T1 = A + D

T2 = det([[ A, B ] [ C, D ]]) = A * D – C * B



The program provides prompts and results in messages.



Code:

00 { 81-Byte Prgm }

01▸LBL "CHAR2"

02 "[[A,B][C,D]]"

03 AVIEW

04 PSE

05 PSE

06 "L↑2-T1×L+T2=0"

07 AVIEW

08 PSE

09 PSE

10 INPUT "A"

11 ENTER

12 ENTER

13 INPUT "D"

14 ENTER

15 R↓

16 +

17 "T1= "

18 ARCL ST X

19 AVIEW

20 STOP

21 R↓

22 ×

23 INPUT "C"

24 INPUT "B"

25 ×

26 -

27 "T2= "

28 ARCL ST X

29 AVIEW

30 RTN

31 .END.



Example 1: [ [ -6, 4 ] [ 2, 3 ] ]

Results: T1: 3, T2: -26



Example 2: [ [ 5, 8 ] [ -1, 2 ] ]

Results: T1: 7, T2: 18



Eigenvalues of 2 x 2 Matrices: egn2.raw



The program EGNV2 calculates the eigenvalues of a 2 x 2 matrix:

[ [ A, B ] [ C , D ] ]



The program provides prompts and results in messages. The command CPXRES sets the calculator to accept complex number results.



Code:

00 { 106-Byte Prgm }

01▸LBL "EGNV2"

02 CPXRES

03 "[[A,B][C,D]]"

04 AVIEW

05 PSE

06 PSE

07 INPUT "A"

08 INPUT "B"

09 INPUT "C"

10 INPUT "D"

11 RCL "A"

12 RCL "D"

13 +

14 +/-

15 RCL "A"

16 RCL "D"

17 ×

18 RCL "B"

19 RCL "C"

20 ×

21 -

22 X<>Y

23 ENTER

24 2

25 ÷

26 +/-

27 ENTER

28 X↑2

29 X<>Y

30 R↓

31 X<>Y

32 -

33 SQRT

34 R↑

35 X<>Y

36 ENTER

37 ENTER

38 R↑

39 ENTER

40 R↓

41 X<>Y

42 +

43 "E1="

44 ARCL ST X

45 AVIEW

46 PSE

47 PSE

48 R↓

49 -

50 "E2="

51 ARCL ST X

52 AVIEW

53 PSE

54 PSE

55 R↑

56 RTN

57 .END.



Example 1: [ [ -6, 4 ] [ 2, 3 ] ]

Results: 3.8151, - 6.8151



Example 2: [ [ 5, 8 ] [ -1, 2 ] ]

Results: 3.5 ± 2.37792 i


You can download the three programs here: https://drive.google.com/file/d/1SKcVIhKYHnnuhrvBJxfOmwsV8sRTSj0X/view?usp=sharing





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, June 27, 2026

HP 32SII: Volume of a Square Frustum (Three Approaches in RPN)

HP 32SII: Volume of a Square Frustum (Three Approaches in RPN)







The volume of a square frustum is:


v = height ÷ 3 × (s1^2 + s2^2 + √(s1^2 × s2^2))


which is based off the formula for the volume of general frustum:


v = height ÷ 3 × (base_area_1 + base_area_2 + √(base_area_1 × base_area_2))



Here are three approaches, which were all done with a HP 32SII calculator. The beauty of RPN is on display here. The three programs are labeled A, C, and D.


s1, s2: side of the square base h: height

Stack: Z: s1 Y: s2 X: h



Program A: (24 steps, 36 bytes) 

V = h/3 * (s1^2 + s2^2 + √(s1^2 * s2^2))


LBL A

STO H

R↓

x²

x<>y

x²

ENTER

ENTER

CLx

-

R↓

x<>y

R↓

×

√

R↓

+

R↑

+

RCL H

×

3

÷

RTN


Program C: (17 steps, 25.5 bytes)

Note: √(s1^2 * s2^2) = s1 * s2

V = h/3 * (s1^2 + s2^2 + (s1 * s2))


LBL C

ENTER

3

÷

R↓

×

LST x

x<>y

R↓

x²

x<>y

x²

+

R↑

+

×

RTN



Program D: (15 steps, 22.5 bytes) 

Note: s1^2 + s2^2 + s1 * s2 = s1^2 + s2^2 + 2 * s1 * s2 – s1 *s2 = (s1 + s2)^2 - s1*s2 

V = h/3 * ((s1 + s2)^2 - s1 * s2)



LBL D

3

÷

R↓

×

LST x

x<>y

R↓

+

x²

R↑

-

×

RTN



Examples



Example 1:

s1: 24

s2: 30

h: 5.8

Result: 4245.6



Example 2:

s1: 2.54

s2: 12.15

h: 10

Result: ≈ 616.4503





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, June 6, 2026

RPN: Solving T * w + Z = Y * w + X (featuring DM42, HP 67)

RPN:   Solving T * w + Z = Y * w + X  (featuring DM42, HP 67)


Introduction and Code



This is inspired in part by the new Casio fx-92 being released where it has added the linear equation:

ax + b = cx + d



( https://tiplanet.org/forum/viewtopic.php?p=280173&sid=2174c3a99692ac8898ff3957db84031a#p280173 (in French), retrieved February 6, 2026)



Solve the equation for w:

T * w + Z = Y * w + X


where the solution is w = (Z – X) ÷ (Y – T)


The values for T, Z, Y, and X are taken directly from the four-level classic RPN stack.



HP 42S/DM42/HP 41C (programmed with a DM42) Code


LBL “TZYX1”

x<>y

R↓

-

R↓

-

R↑

x<>y

÷

RTN



HP 67 Code


001: LBL A; 31, 25, 11

002: x<>y; 35, 52

003: R↓; 35, 53

004: -; 51

005: R↓; 35, 53

006: -; 51

007: R↑; 35, 54

008: x<>y; 35, 52

009: ÷; 81

010: RTN; 35, 52



Stack Results:


Start

Finish

T

Z - X

Z

Z - X

Y

Y

X

(Z – X) ÷ (Y – T) = W (solution)



Examples


Example 1: 5 * w + 20 = 10 * w + 30


T: 5

Z: 20

Y: 10

X: 30


Solution: w = -2




Example 2: 3 * w – 18 = -2 * w + 16


T: 3

Z: -18

Y: -2

X: 16


Solution: w = 6.8




Example 3: 5 * w + 3 = w + 2


T: 5

Z: 3

Y: 1

X: 2


Solution: w = -0.25




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.

Python: Drawing a Ring of Circles

Python: Drawing a Ring of Circles The goal: Draw a number of circles that revolve around the origin (0,0). The center of each circle i...