The Museum of HP Calculators


Nth polynom --- real-root finder for HP32SII

This program is by Tizedes Csaba and is used here by permission.

This program is supplied without representation or warranty of any kind. Tizedes Csaba and The Museum of HP Calculators therefore assume no responsibility and shall have no liability, consequential or otherwise, of any kind arising from the use of this program material or any part thereof.

Overview

This program can solve polynom-equations ANY of order (limited by mem). It's not too long, only 92 byte ;). It work's fast with built-in solver, and use Horner-method:

Only one problem with it, it's solve JUST REAL ROOTS...

An example:

Solve this polynom with this program:

-2*x6 -6*x5 +82*x4 +174*x3 -800*x2 -888*x +1440 =0

A*X6 +B*X5 +C*X4 +D*X3 +E*X2 +F*X +G =0

In the program the coefficients are A, B, C, ... The limit of order N=12, because the 14th variable is N, and we use this variable for the order of solved polynom. If you replace it with Z, you can solve the 24th order of polynomials (if the memory is not full). And it's not a joke...

Now, start the program: [XEQ S] the calc prompting for order of polynom:

N? type 6 [R/S].

Then the program prompts for all of coefficients, type it in decrease order:

A? -2 [R/S] 
B? -6 [R/S] 
C? 82 [R/S] 
D? 174 [R/S] 
E? -800 [R/S] 
F? -888 [R/S] 
G? 1440 [R/S]

Then you will see the 'RUNNING/SOLVING' message, and the program stops with one of six roots: for example X=1. Press [R/S], and you'll see N=5 this mean, the polynom's got 5 root yet. Press [R/S] and repeat this method until all of roots founded.

When N=0 press [R/S], the 'flag1' anunciator set and program end. 'flag1' set mean, all of roots was real.

This polynom got 6 real roots: 1, -2, 3, -4, 5, -6, and the simplified form is: -2*(x-1)*(x+2)*(x-3)*(x+4)*(x-5)*(x+6)

If the program stops and 'flag0' is set, that means, the polynom got non real root(s). Number of it's are equal the last displayed N.

The Program:

E01 LBL E        #prepare of 'i'
    FIX 3
    RCL N
    1
    +
    1E3
    ÷
    1
    +
    RND
    STO i
    0
E13 RTN

P01 LBL P        #the 'dinamical polynom'
    XEQ E
H01 LBL H        #Horner's method
    RCL × X
    RCL + (i)
    ISG i
    GTO H
H06 RTN

X01 LBL X        #polynom solver
    SOLVE X
    GTO R        #if found root goto 'R'
    SF 0         #no real root, set flag 0
X05 RTN

D01 LBL D        #decrement polynom order,
    XEQ E
J01 LBL J        #use a little modified Horner method
    RCL × X
    RCL + (i)
    STO (i)      #overwrite coefficients 
    ISG i        #with decremented polyn.'s coefficients
    GTO J
J07 GTO X

S01 LBL S        #start-routine
    CF 0
    CF 1
    INPUT N
S05 XEQ E
I01 LBL I        #coefficient input-routine
    INPUT (i)
    ISG i
    GTO I
    FN= P
I06 GTO X

R01 LBL R        #we found a root
    VIEW X
    1
    STO − N
    VIEW N       #number of roots, what we dont found yet
    RCL N
    x≠0?         #more root?
    GTO D        #go decrement order, and solve again
    SF 1         #no more root, and all was REAL: set flag 1
R10 RTN


The checksums:

E:CK=0BE8 27.5 byte
P:CK=E452  3.0 byte
H:CK=3E78  9.0 byte
X:CK=3894  7.5 byte
D:CK=11DF  3.0 byte
J:CK=C765 10.5 byte
S:CK=BB8E  7.5 byte
I:CK=32B5  9.0 byte
R:CK=E775 15.0 byte

Go back to the software library
Go back to the main exhibit hall