Re: Programming Challenge Message #2 Posted by Vieira, Luiz C. (Brazil) on 8 Nov 2001, 12:09 a.m., in response to message #1 by Luca de Alfaro
Hello;
I wrote this based in an example given at the HP42S Programming Examples and Technics (p.75), which is based in the original for the HP41, published in one HP Key Notes V6 N2, p. 14. The small routine was created by Paul Baker (Stillwaker, Oklahoma) and I include it's original in here, too. This program changed my way of searching for a solution. Both roots are found AND complex solution was available (flag 0 set). This is the original listing:
LBL SOL
X<> Z
ST/ Z
/
-2
/
ENTER^
ENTER^
X^2
R^
CF 00
X>Y?
SF 00
-
ABS
SQRT
ST- Z
X<>Y
FC? 00
+
.END.
Just enter a, b and c and run it. If flag 0 is set, complex results.
This is my (morphed) listing for the HP11C. Enter a, b and c and run it.
ENTER
R^
÷
R^
LASTx
÷
2
CHS
÷
ENTER
ENTER
x^2
R^
-
SF 0
X<0
CF 0
ABS
sqrt
ENTER
R^
x<>y
-
LASTx
R^
F? 0
+
If there is nothing wrong, it should work, even for complex results (real in X, imaginary in Y. Or the opposite...). In this program, flag 0 is clear for complex results. It is 27 steps long (29 if LBL and RTN or R/S are added), but I believe wizards in here will make it look too long...
My R$0.25
|