Post Reply 
(42S) Short Quadratic Solver
05-28-2014, 04:18 AM
Post: #6
RE: Short Quadratic Solver (HP-42S)
(05-27-2014 06:57 PM)Thomas Klemm Wrote:  
(05-27-2014 05:30 PM)Jeff_Kearns Wrote:  Can you think of a way of dramatically shortening it, (...) so that it still gives real and complex roots?

Copied most of it from here: Short quadratic solver (HP-15C)
Code:
Q01 LBL Q
Q02 ENTER
Q03 R^
Q04 /
Q05 R^
Q06 LASTx
Q07 /
Q08 2
Q09 +/-
Q10 /
Q11 ENTER
Q12 ENTER
Q13 x^2
Q14 R^
Q15 -
Q16 SQRT
Q17 ENTER
Q18 +/-
Q19 CMPLX-
Q20 RTN

Doesn't give you the complex solution but that should be easy to add. There are probably shorter solutions possible by using a register.

Cheers
Thomas

Nice use of CMPLX- for saving a step or two!

This might do while we don't think of something better:

Code:

Q01 LBL Q
Q02 CF 1
Q03 ENTER
Q04 R^
Q05 /
Q06 R^
Q07 LASTx
Q08 /
Q09 -2
Q10 /
Q11 ENTER
Q12 ENTER
Q13 x^2
Q14 R^
Q15 -
Q16 x<0?
Q17 SF 1
Q18 ABS
Q19 SQRT
Q20 FS? 1
Q21 RTN
Q22 ENTER
Q23 +/-
Q24 CMPLX-
Q25 RTN

If the roots are complex, the flag 1 announciator will be lit and the real and complex parts will be in registers Y and X, respectively.

Cheers,

Gerson[/code]
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: Short Quadratic Solver (HP-42S) - Gerson W. Barbosa - 05-28-2014 04:18 AM



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