Post Reply 
(42S) Short Quadratic Solver
05-27-2014, 05:30 PM (This post was last modified: 05-28-2014 10:21 PM by Jeff_Kearns.)
Post: #4
RE: Short Quadratic Solver (HP-42S) --- and 32Sii??
(05-25-2014 09:55 PM)Gerson W. Barbosa Wrote:  Thank you for your interest!

Gerson,

I am interested! The following routine for the HP-32sii and HP-33s (slightly modified from Eddie Shore's original to display the roots as x + iy) is the one I use but it is 39 steps long!

Q0001 LBL Q ' Set label Q
Q0002 INPUT A
Q0003 INPUT B
Q0004 INPUT C
Q0005 SQ(B)-4xAxC ' Equation (enter by RS [right shift] EQN)
Q0006 STO D
Q0007 RCL D ' Is the discriminant negative?
Q0008 x<0?
Q0009 SF 1 ' Flag 1 - indicate that the roots are complex
Q0010 RCL D
Q0011 FS? 1
Q0012 +/- ' The HP 33 cannot take square roots of x<0
Q0013 square root
Q0014 STO E ' E = abs(sqrt(D))
Q0015 -B/(2xA) ' enter this as an equation
Q0016 STO F
Q0017 E/(2xA) ' enter this an an equation
Q0018 STO G
Q0019 RCL G
Q0020 0
Q0021 FS? 1
Q0022 x<>y
Q0023 RCL F
Q0024 0
Q0025 CMPLX+
Q0026 x<>y
Q0027 STOP ' press the R/S key: display first root
Q0028 RCL G
Q0029 +/-
Q0030 0
Q0031 FS? 1
Q0032 x<>y
Q0033 RCL F
Q0034 0
Q0035 CMPLX+
Q0036 x<>y
Q0037 STOP
Q0038 CF 1 ' clean up command
Q0039 RTN


Can you think of a way of dramatically shortening it, in line with your 15-liner for the HP-42s, so that it still gives real and complex roots? The memory in the HP-32Sii is so limited and shortening this program might allow me to squeeze one more program in there...

Thanks,

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


Messages In This Thread
RE: Short Quadratic Solver (HP-42S) --- and 32Sii?? - Jeff_Kearns - 05-27-2014 05:30 PM



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