What is this HP-41 program doing?



#2

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 ...


#3

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


#4

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.


#5

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.


#6

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

#7

Hi, HrastProgrammer;

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

Cheers.


#8

Thanks Luiz ...


Possibly Related Threads...
Thread Author Replies Views Last Post
  HP-41(CL): The easiest way to transfer FOCAL programs from a Linux PC to the HP-41 Geir Isene 13 2,469 12-05-2013, 02:40 AM
Last Post: Hans Brueggemann
  HP Prime: run a program in another program Davi Ribeiro de Oliveira 6 1,107 11-11-2013, 08:28 PM
Last Post: Davi Ribeiro de Oliveira
  Updated PPC DVD Version 2.10: HP-41 Searchable Program Files and Scannable Barcode Jake Schwartz 3 828 09-27-2013, 09:51 PM
Last Post: Olivier (Wa)
  Looking for PLTMX80 program for HP- 41 Ángel Martin 1 415 10-19-2012, 05:21 AM
Last Post: Ángel Martin
  New 41 model to use rom of "big" program Olivier De Smet 4 759 10-03-2012, 07:35 PM
Last Post: Brian Walsh
  Editable PDF Docs for HP-41 Program Documentation? Namir 8 1,119 03-08-2012, 11:13 PM
Last Post: John Robinson
  HP-41 Ohms Law Program Jeff Davis 45 4,403 12-28-2010, 09:23 PM
Last Post: Ren
  HP-41: Sail boat parameter program Geir Isene 0 341 11-24-2010, 01:37 PM
Last Post: Geir Isene
  HP-41 Program conversion to Text files Jeff Davis 9 1,163 01-28-2008, 02:54 AM
Last Post: Christoph Klug
  HP-41 MCODE: Making an MCODE program call another MCODE program Geir Isene 10 1,354 01-13-2008, 05:58 AM
Last Post: Raymond Del Tondo

Forum Jump: