Showing posts with label algebra. Show all posts
Showing posts with label algebra. Show all posts

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.

Saturday, May 9, 2026

Solving Simple Arcsine and Arccosine Equations

 Solving Simple Arcsine and Arccosine Equations



Angle Measure

This document will focus on angle measurement in degrees. For radians and grads, please use the appropriate measurement.


90° = π/2 rad = 100 grad

180° = π rad = 200 grad



Simple Arcsine Equations


The calculator arcsine function gives: Domain: -1 ≤ x ≤ 1, Range: -90° ≤ Θ ≤ 90°


Note that for any angle x: sin(180° - x) = sin(x), sin(x) = sin(x ± 360°*z) (z is an integer)


Given n, solve for Θ:

n = sin(Θ) = sin(180° - Θ)


Base Solution 1:

n = sin(Θ)

⇒ Θ = arcsin(n)


Base Solution 2:

n = sin(180° - Θ)

arcsin(n) = 180° - Θ

⇒ Θ = 180° - arcsin(n)


Example:

0.67 = sin(Θ)

Base Solution 1: Θ = arcsin(0.67) ≈ 42.0670648025°

Base Solution 2: Θ = 180° - arcsin(0.67) ≈ 137.932935198°


Given n and α, solve for Θ:

n = sin(α + Θ)


Base Solution 1:

n = sin(α + Θ)

arcsin(n) = α + Θ

⇒ Θ = arcsin(n) – α


Base Solution 2:

n = sin(180° - (α + Θ))

n = sin(180° - α – Θ)

arcsin(n) = 180° - α – Θ

⇒ Θ = 180° - α – arcsin(n)


Example:

0.7757 = sin(Θ + 76°)

Base Solution 1: Θ = arcsin(0.7757) – 76° ≈ -25.1314549842°

Base Solution 2: Θ = 180° - 76° - arcsin(0.7757) = 104° - arcsin(0.7757) ≈ 53.131459842°


To get all the possible angles, add and subtract multiples of 360°.



Solving Simple Arccosine Equations


The calculator arccosine function gives: Domain: -1 ≤ x ≤ 1, Range: -90° ≤ Θ ≤ 90°


Note that for any angle x: cos(180° - x) = -cos(x), cos(x) = cos(x ± 360°*z) (z is an integer)


Given n, solve for Θ:

n = cos(Θ), n = cos(-Θ)


Base Solution 1:

n = cos(Θ)

⇒ Θ = arccos(n)


Base Solution 2:

n = cos(-Θ)

⇒ Θ = -arccos(n)


Example:

0.58 = cos(Θ)

Base Solution 1: Θ = arccos(0.58) ≈ 54.54945736°

Base Solution 2: Θ = -arccos(0.58) ≈ -54.54945736°


Given n and α, solve for Θ:

n = cos(α + Θ)


Base Solution 1:

n = cos(α + Θ)

arccos(n) = α + Θ

⇒ Θ = arccos(n) – α


Base Solution 2:

n = cos(-(α + Θ))

n = cos(-α – Θ)

arccos(n) = -α – Θ

-arccos(n) = α + Θ

⇒ Θ = -arccos(n) – α


Example:

0.6 = cos(35° + Θ)

Base Solution 1: Θ = arccos(0.6) – 35° ≈ 18.13012035°

Base Solution 2: Θ = -arccos(0.6) – 35° ≈ -88.13010235°



To get all the possible angles, add and subtract multiples of 360°.



I hope you find this useful and helpful,


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, 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.

Saturday, February 14, 2026

RPN: Absolute Value Equations with the HP 11C and DM41X

RPN: Absolute Value Equations with the HP 11C and DM41X



Introduction: Solving |z * w + y| = x


Today’s blog focuses on solving the absolute value equation:


|z * w + y| = x


for the variable w, and the values of z, y, and x are given and are on the Classic RPN stack.


For example, in the problem |5 * w + 7| = 2, the stack would be set up as:


t: (anything, it doesn’t matter)

z: 5

y: 7

x: 2


(This is why I set the variable as w instead of the usual x.)


One approach is to use memory registers and other uses only stack operations. Today’s algorithm focuses on the latter.


Caution: In the above equation, x will always be non-negative. The equation will never be valid if x is negative.



The Algebra


Solve for w:

|z * w + y| = x


This leads us to solve the two equations:


(I)

z * w + y = -x

z * w = -x – y

w = -x/z – y/z


Let w- = -x/z – y/z = (-x/z) + (-y/z)


(II)

z * w + y = x

z * w = x – y

w = x/z - y/z


Let w+ = x/z – y/z = (x/z) + (-y/z)


Then:


w- = -x/z – y/z

w- = (-x/z) + (-y/z)

w- = (-x/z) + (-y/z) + (-x/z) + (x/z)

w- = 2 * (-x/z) + (x/z) + (-y/z)

w- = 2 * (-x/z) + w+


RPN Code: HP 11C (adoptable for other RPN calculators)


LBL A

001

42, 21, 11

Program start

R↓

002

33


R↓

003

33


X<>Y

004

34


R↓

005

33


1/x

006

15


×

007

20


LST x

008

43, 36


X<>Y

009

34


R↓

010

33


×

011

20


LST x

012

43, 36


R↑

013

43, 33


X<>Y

014

34


R↓

015

33


X<>Y

016

34


CHS

017

16


X<>Y

018

34


+

019

40


ENTER

020

36


ENTER

021

36


LST x

022

43, 36


-

023

30


LST x

024

43, 36


-

025

30


RTN

026

43, 32

Program end


RPN Code: DM41X (HP 41C series, no module is required)


LBL “ASBEQ”

RDN

RDN

X<>Y

RDN


1/x

×

LAST X

X<>Y

RDN

×

LAST X

R↑

X<>Y


RDN


X<>Y

CHS

X<>Y


+

ENTER

ENTER

LAST X

-

LAST X

-


RTN



Notes:

* RDN is shown as R↓

* To enter R↑, press XEQ, ALPHA, R, SHIFT, ENTER, ALPHA



Subroutines Used


We used several techniques to manipulate the stack. They are presented below:


Rotate stack from X, Y, Z, T to Z, X, Y, T

R↓

R↓

X<>Y

R↓


Source:

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



Multiply Y and Z by 1/X. Stack: X, Y, Z, T → X, Y/X, Z/X, T


1/x

×

LAST X

X<>Y

R↓

×

LAST X

R↑

X<>Y


Change X, Y to Y+ X, Y – X


+

ENTER

ENTER

LAST X

-

LAST X

-


The resulting stack is:


z

z

y + x

y – x


Doing LAST X, -, twice is effectively subtracting whatever is in L register twice.



Examples


|4 * w – 6| = 5


Stack:

z: 4

y: -6

x: 5


Results:

y: 2.75

x: 0.25


|2 * w + 5| = 3


Stack:

z: 2

y: 5

x: 3


Results:

y: -1

x: -4




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.

Earth's Radius by Latitude

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