What is this HP-41 program doing? - Printable Version +- HP Forums (https://archived.hpcalc.org/museumforum) +-- Forum: HP Museum Forums (https://archived.hpcalc.org/museumforum/forum-1.html) +--- Forum: Old HP Forum Archives (https://archived.hpcalc.org/museumforum/forum-2.html) +--- Thread: What is this HP-41 program doing? (/thread-20274.html) What is this HP-41 program doing? - HrastProgrammer - 07-26-2002 ``` 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? - Ex-PPC member - 07-26-2002 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? - HrastProgrammer - 07-26-2002 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? - HrastProgrammer - 07-26-2002 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? - Mike (Stgt) - 07-26-2002 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? - Vieira, Luiz C. (Brazil) - 07-26-2002 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? - HrastProgrammer - 07-28-2002 Thanks Luiz ...