**HP Articles Forum**

[Return to the Index ]

[ Previous | Next ]

**Sixth Order Linear Equation Solver for the hp 33s**

*Posted by Palmer O. Hanson, Jr. on 16 Sept 2006, 10:37 p.m.*

This program is a translation for the hp 33s of a translation for the Durabrand 828 of a TI-59 program by Henrik Ohlsson which appeared in the 81-2 issue of the Swedish newsletter Programbiten. Henrik's program expanded the linear equation solution capability of the TI-59 from order 8 to order 16. The translations were essentially brute force command by command from AOS to EOS to hp 33s language. The resulting hp 33s program isn't pretty but it is functional. Henrik's program was written for fast mode on the TI-59 which meant that subroutines were not allowed. I modified Henrik's program to run in normal mode and perform the data entry routine as a subroutine in order to save enough space to fit the program in the 828. Because only register arithmetic was used in the hp 33s version (no use of the stack in RPN and no use of parentheses or equal signs in ALG) the hp 33s program will run as written in either RPN or ALG mode.

Program Listing:

N0001 LBL N

N0002 CLVARS

N0003 INPUT N

N0004 STO A

N0005 STO G

N0006 1

N0007 STO+ G

N0008 0

N0009 STO N

N0010 9

N0011 STO C

O0001 LBL O

O0002 0

O0003 STO H

O0004 RCL G

O0005 STO B

O0006 9

O0007 STO F

O0008 RCL D

O0009 IP

O0010 STO E

O0011 STO D

O0012 1

O0013 STO+ D

O0014 RCL E

O0015 x=0?

O0016 GTO C

A0001 LBL A

A0002 XEQ S

A0003 RCL Z

A0004 +/-

A0005 STO Z

B0001 LBL B

B0002 RCL F

B0003 STO i

B0004 RCL (i)

B0005 STO Y

B0006 RCL Z

B0007 STOx Y

B0008 RCL C

B0009 STO i

B0010 RCL Y

B0011 STO+ (i)

B0012 1

B0013 STO+ C

B0014 STO+ F

B0015 DSE B

B0016 GTO B

B0017 RCL G

B0018 STO B

B0019 STO- C

B0020 DSE E

B0021 GTO A

C0001 LBL C

C0002 XEQ S

C0003 RCL Z

C0004 STO E

C0005 RCL C

C0006 STO i

C0007 RCL (i)

C0008 STO+ E

C0009 1

C0010 STO- B

D0001 LBL D

D0002 XEQ S

D0003 1

D0004 STO+ C

D0005 RCL C

D0006 STO i

D0007 RCL (i)

D0008 STO+ Z

D0009 0

D0010 STO (i)

D0011 1

D0012 STO- C

D0013 RCL C

D0014 STO i

D0015 RCL Z

D0016 STO (i)

D0017 RCL E

D0018 STO/ (i)

D0019 1

D0020 STO+ C

D0021 DSE B

D0022 GTO D

D0023 RCL D

D0024 IP

D0025 STO E

D0026 DSE E

D0027 GTO I

D0028 GTO H

I0001 LBL I

I0002 8

I0003 STO C

I0004 RCL A

I0005 STO B

E0001 LBL E

E0002 1

E0003 STO+ C

E0004 STO+ H

E0005 RCL C

E0006 STO i

E0007 RCL (i)

E0008 STO Z

E0009 0

E0010 STO (i)

F0001 LBL F

F0002 1

F0003 STO+ C

F0004 RCL F

F0005 STO i

F0006 RCL (i)

F0007 STO Y

F0008 RCL Z

F0009 +/-

F0010 STOx Y

F0011 RCL C

F0012 STO i

F0013 RCL (i)

F0014 STO+ Y

F0015 0

F0016 STO (i)

F0017 RCL H

F0018 STO- C

F0019 RCL C

F0020 STO i

F0021 RCL Y

F0022 STO (i)

F0023 RCL H

F0024 STO+ C

F0025 1

F0026 STO+ F

F0027 DSE B

F0028 GTO F

F0029 RCL A

F0030 STO- F

F0031 STO B

F0032 DSE E

F0033 GTO E

F0034 RCL H

F0035 STO- C

F0036 1

F0037 STO+ C

G0001 LBL G

G0002 RCL F

G0003 STO i

G0004 RCL (i)

G0005 STO Y

G0006 RCL C

G0007 STO i

G0008 RCL Y

G0009 STO (i)

G0010 RCL F

G0011 STO i

G0012 0

G0013 STO (i)

G0014 1

G0015 STO+ C

G0016 STO+ F

G0017 DSE B

G0018 GTO G

H0001 LBL H

H0002 1

H0003 STO- G

H0004 DSE A

H0005 GTO O

H0006 9

H0007 STO i

H0008 RCL H

H0009 STO+ i

H0010 1000

H0011 STO/ i

H0012 9

H0013 STO+ i

J0001 LBL J

J0002 RCL (i)

J0003 STOP

J0004 ISG i

J0005 GTO J

J0006 GTO K

J0007 STOP

S0001 LBL S

S0002 0.01

S0003 STO+ D

S0004 RCL D

S0005 FIX 2

S0006 STOP

S0007 FIX 9

S0008 STO Z

S0009 RTN

To use the program press XEQ N and see the prompt N? in the display. Enter the order of the solution desired (n = 2 to 6) and press R/S. 1.01 will appear in the display indicating that the machine is ready to accept the A(1,1) element of the matrix Enter the A(1,1) element and press R/S. 1.02 will appear in the display indicating that the machine is ready to accept the A(1,2) element of the matrix. Proceed as before to enter the A(1,2) element and see the prompt for the A(1.3) element, and so on. When the column element of the prompt is n+1 enter the corresponding element of the vector B. When the last element of the vector has been entered the machine will stop with the first element of the solution, X(1), in the display. Press R/S to see X(2), and so on. When all of elements of the solution vector have been displayed the message NONEXISTENT will be displayed.. .

If you run the problem with the matrix as a 6x6 sub-Hilbert and the vector all ones you will get the following answer:

Exact hp 33s Relative Errorfor a mean relative error of 3.080E-07. Hendrik's program running on the TI-59 yields a mean relative error of 8.79E-06. The Durabrand translation yielded a mean relative error of 7.03E-06 .The ML-02 program running on the TI-59 yields a mean relative error of 2.90E-06. The matrix routine in the Math Pak of the HP-41 yields a mean relative error of 3.8E-04. The matrix solution in the HP-28 yield a mean relative error of 9.99 E-06. The simultaneous equation solver on the TI-85 yields a mean relative error of 3.012E-07..-42 -41.999994975 1.196E-07 840 839.999760819 2.847E-07 -5040 -5039.99824184 3.488E-07 12600 12599.9953562 3.686E-07 -13860 -13859.9948996 3.680E-07 5544 5543.99801446 3.581E-07

Historical notes: With Hendrik's program on the TI-59 the calculations after the entry of an element required a significant amount of time so that the user was always waiting on the machine. For example, in a fifth order solution when the third vector element is entered in response to the prompt 3.06 the TI-59 would run for nine seconds in fast mode or fifteen seconds in normal mode before the next prompt (4.01) appears. The much higher calculating speed of the hp 33s yields much shorter wait times.

You can see Henrik's program by going to Viktor Toth's site (www.rskey.org/), selecting the Texas Instruments part of the library, and going to page 16 of the V8N6 issue of TI PPC Notes. I did the translation for the Durabrand 828 when Richard Nelson and I were assessing the capabilities of that machine. The listing of the translation for the Durabrand 828 follows: Program 0 is the main program. Program 1 is the data entry subroutine. Since I don't know how to print the data entry triangle I have used the {} symbol in place of the data entry triangle in the listing.

Program 0 (388 steps)

Mcl : "N=" {} ? -> B : B + 1 -> H : 9 -> D :

Lbl 0 : 0 -> I : H -> C : 9 -> G : Int E -> F: F + 1 -> E : F = 0 => Goto 3 :

Lbl 1 : Prog 1 : - A -> A :

Lbl 2 : A x A[G] + A[D] -> A[D] ; D + 1 -> D : G + 1 -> G : Dsz C : Goto 2 :

H -> C : D - H -> D : Dsz F : Goto 1 :

Lbl 3 : Prog 1 : A + A[D] -> F : C - 1 -> C :

Lbl 4 : Prog 1 : D + 1 -> D : A + A[D] -> A : 0 -> A[D] : D - 1 -> D :A / F -> A[D] : D + 1 -> D : Dsz C : Goto 4 :

Int E -> F : Dsz F : Go to 9 :

Goto 8 :

Lbl 9 : 8 -> D : B -> C :

Lbl 5 : D + 1 -> D : I + 1 -> I : A[D ] -> A : 0 -> A[D] :

Lbl 6 : D + 1 -> D: A[D] - A x A[G] -> Z : 0 -> A[D] : D - I -> D :Z -> A[D] : D + I -> D : G + 1 -> G : Dsz C : Goto 6 :

G - B -> G : B -> C : Dsz F : Goto 5 :

D - I + 1 -> D :

Lbl 7 : A[G] -> A[D] : 0 -> A[G] : D + 1 -> D : G + 1 -> G : Dsz C : Goto 7 :

Lbl 8 : H - 1 -> H : Dsz B : Goto 0 :

J{}

Program 1 (10 step subroutine)

E + .01 -> E {} ? -> A

The Durabrand 828 does NOT provide alphanumeric prompting as described in paragraph 4.9 (page 47) of the manual. For example the manual indicates that if the user enters the command "N="?->A then the machine will display N=? and wait for an input. The fx-7000G does that. The Durabrand does not. To see the prompt with the Durabrand one has to insert the "Display Results" triangle between the = and the ? . The calculator will then stop with X= in the display. The user will have to press EXE to see the question mark and press EXE again after the input value has been entered.

To use the program select Program 0, press EXE and see the prompt N= in the display. Press EXE a second time and see a question mark in the display. Enter the order of the solution desired (n = 2 to 6) and press EXE. 1.01 will appear in the display indicating that the machine is ready to accept the A(1,1) element of the matrix Press EXE and see a question mark in the display. Enter the A(1,1) element and press EXE. 1.02 will appear in the display indicating that the machine is ready to accept the A(1,2) element of the matrix. Proceed as before to enter the A(1,2) element and see the prompt for the A(1.3) element, and so on. When the column element of the prompt is n+1 enter the corresponding element of the vector. When the last elementof the vector has been entered the machine will stop with the first element of the solution, X(1), in the display. Press AC, press Alpha J and press EXE to see the same value for X(1). Then press Alpha K followed by EXE to see X(2), Alpha L followed by EXE to see X(3) and so on as needed up to Alpha O to see the rest of the solution. .