Sunday, May 3, 2026

HP 65 Programs: Triangulation, Percentile, Roots of Unity, Partial Fractions

 HP 65 Programs: Triangulation, Percentile, Roots of Unity, Partial Fractions


Triangulation

(done with HP-65 Emulator for Windows, Bernhard Emese)



Given:

Side angle α

Side angle ß

r = Length of base

Find:

h = height which crosses the base line at right angles



Code:

23: LBL

12: B

35: g

41: DEG

33 01: STO 1

35 08: R↓

41: ENTER

41: ENTER

44: CLX

51: -

31: f

04: SIN

35 09: R↑

31: f

04: SIN

71: *

33: STO

71: *

01: 1

35 08: R↓

61: +

31: f

04: SIN

33: STO

81: ÷

01: 1

34 01: RCL 1

24: RTN



Example: ß = 50°, α = 30°, r = 10

Result: h ≈ 3.89


Source:

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


Percentile in a Range


The program calculates the percentile of x in the range [a, b].


percentile = (x – a) ÷ (b – a) * 100%


Stack:

Z: x

Y: a

X: b


23: LBL

11: B

35 07: x<>y

51: -

35 00: LSTx

35 07: R↓

51: -

35 09: R↑

81: ÷

02: 2

32: f^-1

08: LOG (10^x)

71: ×

24: RTN


Example: The range: [210, 470], x = 376

Stack: Z: 376, Y: 210, X: 470

Result: 63.85



Roots of Unity

(done with HP-65 Emulator for Windows, Bernhard Emese)


w^n = 1

Registers used: R1 = n, R8 = n (counter)


n [ A ]


Cycle:

root # [ R/S ]

real part [ R/S ]

imaginary part [ R/S ] (the cycle starts again)


Repeat the cycle until the display is flashing zeros (forced 1/0 error). Hit [ CLx ] to stop the flashing.


This program switches the mode to radians angle measurement.



Code:

23: LBL

11: A

33 01: STO 1

33 08: STO 8

35: g

42: RAD

23: LBL

00: 0 (LBL 0 - subroutine)

34 08: RCL 8

84: R/S (show root #)

35: g

02: π

71: ×

02: 2

71: ×

34 01: RCL 1

81: ÷

01: 1

32: f^-1

01: R->P (->rect)

84: R/S (show real part)

35 07: x<>y

84: R/S (show imaginary part)

35: g

83: DSZ (decrement R8 by 1)

22: GTO

00: 0 (GOTO LBL 0)

34 08: RCL 8

35: g

04: 1/x

24: RTN


Example (FIX 4):

w^3 = 1

#; R/S; real part; R/S; imaginary part

3; 1.0000; -0.0000

2; -0.5000; -0.8660

1; -0.5000; 0.8660

(flashing zeroes)




Partial Fractions

(w is the variable, and T, Z, Y, and X are the stack contents)

(Tw+Z) ÷ ((w+Y)(w+X)) → B÷(w+Y) + A÷(w+X)

Input Stack: T, Z, Y, X 

Output Stack: B, A


Code: 

23: LBL 

11: A 

35, 07: x<>y 

51: - 

35, 00: LST x 

35, 09: R↑ 

71: × 

35, 00: LST x 

35, 07: x<>y 

35, 09: R↑ 

35, 07: x<>y 

51: - 

35, 09: R↑ 

81: ÷ 

41: ENTER 

35, 08: R↓ 

51: - 

35, 09: R↑ 

35, 07: x<>y 

24: RTN



Example 1: 

(12*w + 28) ÷ ((w+2) * (w+3)) = 4 ÷ (w+2) + 8 ÷ (w+3) 

Input Stack: T: 12, Z: 28, Y: 2, X: 3 press [ A ] 

Output Stack: Y (B): 4, X (A): 8



Example 2: 

(33) ÷ ((w-5) * (w+6)) = 3 ÷ (w-5) + -3 ÷ (w+6) 

Input Stack: T: 0, Z: 33, Y: -5, X: 6 press [ A ] 

Output Stack: Y (B): 3, X (A): -3



Example 3: 

(2*w - 3) ÷ ((w-1) * (w+4)) = -0.2 ÷ (w-1) + 0.2 ÷ (w+4) 

Input Stack: T: 2, Z: -3, Y: -1, X: 4 press [ A ] 

Output Stack: Y (B): -0.2, X (A): 0.2





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.