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.