The Museum of HP Calculators

HP Forum Archive 08

[ Return to Index | Top of Index ]

What is this HP-41 program doing?
Message #1 Posted by HrastProgrammer on 26 July 2002, 2:50 a.m.

LBL A RCL Z ST+ T * 4 * RCL Y CHS STO Z X^2 X<>Y - SQRT STO T X<>Y + LASTX R^ - RCL Z ST/ Z / END

Just a little exercise for the hot summer days ...

      
Re: What is this HP-41 program doing?
Message #2 Posted by Ex-PPC member on 26 July 2002, 4:12 a.m.,
in response to message #1 by HrastProgrammer

It is computing the real roots of a quadratic equation, where the coefficients have been entered into the X,Y,Z stack registers initially.

            
Re: What is this HP-41 program doing?
Message #3 Posted by HrastProgrammer on 26 July 2002, 6:33 a.m.,
in response to message #2 by Ex-PPC member

Bravo! I used it in the school, some 17 years ago. In fact, I have used the following program which can handle complex solutions as well:

LBL A CF 00 RCL Z ST+ T * 4 * RCL Y CHS STO Z X^2 X<>Y - X<0? SF 00 FS? 00 CHS SQRT FS? 00 GTO 01 STO T X<>Y + LASTX R^ - LBL 01 RCL Z ST/ Z / END

Real solutions: flag 0 cleared, X=x1, Y=x2 Complex solutions: flag 0 set, X=Im, Y=Re

The size of this program is 41 bytes (not counting LBL A and END). I am aware this is not optimal and would like to make a proposal: Who can write a shorter program? Only stack registers and flag 00 can be used. Alpha register and data registers cannot be used. Synthetic instructions are welcome but alpha register should not be disturbed.

                  
Re: What is this HP-41 program doing?
Message #4 Posted by HrastProgrammer on 26 July 2002, 6:48 a.m.,
in response to message #3 by HrastProgrammer

This is a slightly modified version:

LBL A CF 00 RCL Z ST+ T * 4 * RCL Y CHS STO Z X^2 X<>Y - X<0? SF 00 ABS SQRT FS? 00 GTO 01 STO T X<>Y + LASTX R^ - LBL 01 RCL Z ST/ Z / END

39 bytes.

                        
Re: What is this HP-41 program doing?
Message #5 Posted by Mike (Stgt) on 26 July 2002, 8:57 a.m.,
in response to message #4 by HrastProgrammer

Reminds me the integration with Simpson rule I've once done only on the stack. Was useful when you had a table of points with uniform steps in X.

Ciao.....Mike

                  
Re: What is this HP-41 program doing?
Message #6 Posted by Vieira, Luiz C. (Brazil) on 26 July 2002, 2:39 p.m.,
in response to message #3 by HrastProgrammer

Hi, HrastProgrammer;

Hey, have a look here. If you cannot open it, tell me and I'll send the text.

Cheers.

                        
Re: What is this HP-41 program doing?
Message #7 Posted by HrastProgrammer on 28 July 2002, 3:00 a.m.,
in response to message #6 by Vieira, Luiz C. (Brazil)

Thanks Luiz ...


[ Return to Index | Top of Index ]

Go back to the main exhibit hall