Post Reply 
(41C 32S): n = a^2 + b
07-18-2021, 06:17 AM (This post was last modified: 07-18-2021 06:52 AM by C.Ret.)
Post: #2
RE: (41C 32S): n = a^2 + b
Hello,

Interesting decomposition. I have not fully understand why this spare memory since, two registers may be more than one. Also, not clear why you are using the round function RND that need to chance display FIX format in the process.

Can we envisage using a simpler version based on INT and stack arithmetic operations ? Such as:

Code:
001 LBL "SQY2X
002   ENTER^  SQRT  INT  ST/Y  ST-Y  ST*Y  X<>Y
009 END

And for system like the HP-15C and classic that have no stack arithmetic facilities:
Code:
01 LBL A
02   ENTER  √x  INT  ÷  LASTX  -  LASTX  ×  LASTX  X<>Y
12 RTN

Having the decomposition results of n = a² + b in the inverse order in the final registers Y: b and X: a may spare the X<>Y instruction then.

EDIT:
In this sunny sunday mornig, I was posting this message when by rereading it, a shorter and simpliest version pop up in my awaking brain that use a MOD instruction :

Code:
01 LBL "SQYX2"
02 ENTER^  SQRT  INT  MOD  LSTX
06 END

Here the last X<>Y is missing so the final results are in the inverse stack order that was asked : Y: \( b\) X: \(a\) for the initial input \( n = a^2+b \).
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
(41C 32S): n = a^2 + b - Eddie W. Shore - 07-18-2021, 05:00 AM
RE: (41C 32S): n = a^2 + b - C.Ret - 07-18-2021 06:17 AM
RE: (41C 32S): n = a^2 + b - J-F Garnier - 07-18-2021, 09:19 AM



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