Post Reply 
HP-41 RPN program solution sought - test problem
10-27-2021, 08:03 PM
Post: #1
HP-41 RPN program solution sought - test problem
What's the best (shortest meant here) way you can devise to program a solution to this problem in HP-41 RPN?


Enter an angle in degrees mode and press A to return the answer.

So start with LBL A and evaluate:

Equation T = ...

What can you come up with ?

Gene
Find all posts by this user
Quote this message in a reply
10-27-2021, 09:05 PM
Post: #2
RE: HP-41 RPN program solution sought - test problem
I hope this is not completely stupid, but I'll try (without testing):

lbl A
xeq deg
sto 01
sqrt
1
+
sto 02
sin
2,5
*
sto 03
pi
/
rcl 02
cos
rcl 01
sin
/
+
rcl 03
/

My calculators - former: CBM PR100, HP41CV, HP11C, HP28S - current: HP48G(+), HP35S, Prime, DM41X, DM42
Find all posts by this user
Quote this message in a reply
10-27-2021, 09:19 PM (This post was last modified: 10-27-2021 09:20 PM by Gerson W. Barbosa.)
Post: #3
RE: HP-41 RPN program solution sought - test problem
Assuming angle mode is DEG:

Code:

 01 LBL A
 02 SIN
 03 LASTX
 04 SQRT
 05 1
 06 +
 07 TAN
 08 *
 09 5
 10 *
 11 1/X
 12 ST+ X
 13 PI
 14 1/X
 15 +
 16 END
Find all posts by this user
Quote this message in a reply
10-28-2021, 06:33 AM
Post: #4
RE: HP-41 RPN program solution sought - test problem
I can shave off one byte:

Code:
 01 LBL A
 02 SIN
 03 LASTX
 04 SQRT
 05 1
 06 +
 07 TAN
 08 *
 09 .4
 10 X<>Y
 11 /
 12 PI
 13 1/X
 14 +
 15 END

Cheers, Werner
Find all posts by this user
Quote this message in a reply
10-28-2021, 08:39 AM
Post: #5
RE: HP-41 RPN program solution sought - test problem
(10-27-2021 08:03 PM)Gene Wrote:  What's the best (shortest meant here) way you can devise to program a solution to this problem in HP-41 RPN?


Enter an angle in degrees mode and press A to return the answer.

So start with LBL A and evaluate:

Equation T = ...

What can you come up with ?

Gene
First I draw it in my preferred graphical calculator https://www.desmos.com/calculator/pop31xijnj?lang=de
And in the time I was drawing (took 5min), smarter ones has give to you some solutions.
I was not quick enough ;-)


Attached File(s) Thumbnail(s)
   

HP71 & Multimod, HP41CV/CX & Nov64d, PILBOX, HP-IL-PRINTER 82162A, RS232 HP-IL interface, Debian11 64bits-PC w/ pyILPER, V41R9F & EMU71
Find all posts by this user
Quote this message in a reply
10-29-2021, 05:27 PM
Post: #6
RE: HP-41 RPN program solution sought - test problem
Great job Werner!

I was curious and comparing it to an algebraic (AOS) version. That was 39 steps/bytes.
Find all posts by this user
Quote this message in a reply
10-31-2021, 12:58 PM (This post was last modified: 10-31-2021 01:04 PM by C.Ret.)
Post: #7
RE: HP-41 RPN program solution sought - test problem
(10-28-2021 08:39 AM)floppy Wrote:  First I draw it in my preferred graphical calculator https://www.desmos.com/calculator/pop31xijnj?lang=de

Nice plotter, except that it is missing the important fact that x have to be in degrees (not radians nor Bogenmaßen).

(10-29-2021 05:27 PM)Gene Wrote:  I was curious and comparing it to an algebraic (AOS) version. That was 39 steps/bytes.

Let's have a try.

Assuming that the complicated function can be simplify as W.Barbosa and Werner have done:

\( f(x)=\frac{\frac{2.5\times sin(\sqrt{x}+1)}{\pi}+\frac{cos(\sqrt{x}+1)}{sin(x)}}{2.5\times sin(\sqrt{x}+1)}=\frac{1}{\pi}+\frac{.4}{sin(x)\times tan(\sqrt{x}+1)} \)

And using a blue TI-57 LCD using certified AOS technology:

STO0 .4 ÷ ( RCL0 sin × ( 1 + RCL0 √x ) tan ) + ∏ 1/x = R/S RST

The last too steps are optional but useful in program; so this function can be recorded using 22 steps (or bytes) in LRN mode.
Find all posts by this user
Quote this message in a reply
10-31-2021, 05:43 PM
Post: #8
RE: HP-41 RPN program solution sought - test problem
(10-31-2021 12:58 PM)C.Ret Wrote:  And using a blue TI-57 LCD using certified AOS technology:

STO0 .4 ÷ ( RCL0 sin × ( 1 + RCL0 √x ) tan ) + ∏ 1/x = R/S RST

The last too steps are optional but useful in program; so this function can be recorded using 22 steps (or bytes) in LRN mode.


Perhaps you can save one byte by eliminating the parentheses:

STO0 √x + 1 = tan × RCL0 sin × 2.5 = 1/x + ∏ 1/x = R/S RST
Find all posts by this user
Quote this message in a reply
10-31-2021, 08:54 PM (This post was last modified: 10-31-2021 09:08 PM by C.Ret.)
Post: #9
RE: HP-41 RPN program solution sought - test problem
(10-31-2021 05:43 PM)Gerson W. Barbosa Wrote:  Perhaps you can save one byte by eliminating the parentheses:

Good suggestion :
STO0 √x + 1 = tan × RCL0 sin ÷ .4 = 1/x + ∏ 1/x = R/S RST (one Werner's step spare here)

STO0 √x + 1 = tan 1/x EXC0 sin STO÷0 .4 STO×0 ∏ 1/x STO+0 RCL0 R/S RST (two more steps spare , but, is this still AOS logic ?)
Find all posts by this user
Quote this message in a reply
10-31-2021, 09:17 PM
Post: #10
RE: HP-41 RPN program solution sought - test problem
If it can be keyed on a TI-57 or TI-58C, then we will call it AOS. :-)

Gene
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 1 Guest(s)