Showing posts with label HP 11C. Show all posts
Showing posts with label HP 11C. Show all posts

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.

Saturday, January 31, 2026

RPN: HP 11C: Transferring Between Bases (Common/Natural)

RPN: HP 11C: Transferring Between Bases (Common/Natural)



All algorithms were tested with the HP 11C.



Between the Exponential Function and Common-Antilog


e^α = 10^ß


Given α, what is ß?


ß = log(e^α)


RPN:

<input α>

e^x

LOG


Examples (Fix 6):

e^1.05 = 10^ß

ß ≈ 0.456009


e^(-2.2) = 10^ß

ß ≈ -0.955448


Given ß, what is α?


α = ln(10^ß)


RPN:

<input ß>

10^x

LN


Examples (Fix 6):

e^α = 10^5.4

α ≈ 12.433960


e^α = 10^0.366

α ≈ 0.842746


Between the Natural Logarithm and Common Logarithm


log α = ln ß


Given α, what is ß?

ẞ = exp(log α)


RPN:

<input α>

LOG

e^x


Examples (Fix 6):

log 17 = ln ß

ß ≈ 3.422766


log 317 = ln ß

ß ≈ 12.195405



Given ß, what is α?

α = 10^(ln ß)



RPN:

<input ß>

LN

10^x



Examples (Fix 6):

log α = ln 425

α ≈ 1,127,428.915



log α = ln 9.81

α ≈ 192.044677




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, January 24, 2026

RPN: HP 11C: Surface Gravity and Escape Velocity

RPN: HP 11C: Surface Gravity and Escape Velocity


EQUATIONS


The surface gravity constant of a celestial object (planet, dwarf planet, star, etc.):


g_p = G * M ÷ R²


The escape velocity of a celestial object:


v_esc = √(2 * G * M ÷ R)


where (using SI units):

g_p: surface gravity (m/s)

v_esc: escape velocity (m/s)

M: (measured) mass of the object (kg)

R: (average) radius of the object (m)

G: Universal Gravitational Constant (G ≈ 6.6743 * 10^-11 N m²/kg² (or m³/(s² kg))


The value of G is the 2022 CODATA value (https://physics.nist.gov/cgi-bin/cuu/Value?bg)



Determining Surface Gravity and Escape Velocity



DERIVATION - Determine the surface gravity constant in terms of escape velocity.


Start with the escape velocity:


v_esc = √(2 * G * M ÷ R)

(v_esc)² = 2 * G * M ÷ R


dividing both sides by 2 (we'll see why this important in a bit):


(v_esc)² ÷ 2 = G * M ÷ R

(v_esc)² * 1/2 = G * M * 1/R


Then insert the square of escape velocity in the equation for the surface velocity:


g_p = G * M ÷ R²

g_p = G * M * 1/R²

g_p = G * M * 1/R * 1/R

g_p = (v_esc)² * 1/2 * 1/R

g_p = (v_esc)² ÷ (2 * R)



The equations will the be:


v_esc = √(2 * G * M ÷ R)

g_p = (v_esc)² ÷ (2 * R)


Set the stack up as:

Y: M (mass, kg)

X: R (radius, m)


The results are shown in the stack:

Y: g_p (surface gravity, m/s²)

X: v_esc (escape velocity, m/s)


Algorithm (done with an HP 11C):

ENTER

ENTER

R↑

2

×

6.6743e-11 (Keys: 6 . 6 7 4 3 EEX 1 1 CHS)

×

R↑

÷

ENTER

√ (view escape velocity)

R↓

x<>y

÷

2

÷ (view surface gravity)

R↑ (set surface gravity in the Y stack, escape velocity in the X stack)



Example:


Estimate the surface gravity constant and escape velocity of Venus.


Venus

Mass ≈ 4.8675 * 10^24 kg

Radius ≈ 6.0518 * 10^6 m


Surface gravity ≈ 8.8704 m/s

Escape velocity ≈ 10361.6414 m/s



Determining a Planet's Radius and Escape Velocity


Problem: Given Earth's surface gravity is defined as 9.80665 m/s and mass of 5.972168 * 10^24. Estimate the radius and escape velocity.


Here we are given g_p and M, and we are tasked with finding R and v_esc.


Start by solving for R:


g_p = G * M ÷ R²


Multiply by R² and divide by g_p. Keep this in mind.


R² = G * M ÷ g_p


Take the square root and solve for the radius.


R = √(G * M ÷ g_p)


Note that:


R² = G * M ÷ g_p

g_p * R² = G * M

2 * g_p * R² = 2 * G * M

2 * g_p * R = 2 * G * M ÷ R


This makes for an easy substitution for v_esc.


v_esc = √(2 * G * M ÷ R) = √(2 * g_p * R)


The equations used are:


R = √(G * M ÷ g_p)

v_esc = √(2 * g_p * R)


The algorithm uses one memory register, I just picked R0 (done with an HP 11C):

STO 0

÷

6.6743e-11 (Keys: 6 . 6 7 4 3 EEX 1 1 CHS)

×

√ (view R)

ENTER

RCL 0

×

2

×

√ (view v_esc)



Set the stack up as:

Y: M (mass, kg)

X: g_p (surface gravity, m/s²)


The results are shown in the stack:

Y: R (radius, m)

X: v_esc (escape velocity, m/s)


Results:


Inputs:

Mass of Earth ≈ 5.972168 * 10^24 kg (enter as the y stack)

Surface Gravity = 9.80665 m/s² (enter as a x stack, and yes, surface gravity of Earth is defined to be exactly 9.80665 m/s²)


Outputs:

Y: Radius of Earth ≈ 6375416.060 m

X: Escape Velocity ≈ 11182.2604 m/s



Sources


The NIST Reference on Constants, Units, and Uncertainty. "Newtonian constant of gravitation" Fundamental Physical Constants. Last updated May 9, 2024. https://physics.nist.gov/cgi-bin/cuu/Value?bg Retrieved September 4, 2025.


Research & Education Association. The Essentials of Astronomy Piscataway, New Jersey. 2004. ISBN 0-87891-965-1



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.


Trigonometry Reduction Formula and Solving Simple Arcsine and Arccosine Equations

Trigonometry Reduction Formula and Solving Simple Arcsine and Arccosine Equations Some Background and Periodic Reduction Formulas ...