The Museum of HP Calculators

HP Articles Forum

A Third Order Linear Equation Solver for the HP-35S

Posted by Palmer O. Hanson, Jr. on 20 May 2008, 11:24 p.m.

Program Description

This program is similar to my "A Label Saving Simultaneous Equation Solution for the 33s" (Article No. 599) but with modifications for use with the HP-35S. It will solve with real or complex coefficients. I wanted to use the same definition of the linear system and input routine as in the "Solution of Simultaneous Equations" program in pages 15-12 through 15-20 of the hp 33s user's guide. I couldn't because the indirect addressing registers (I and J) for the HP 35S are in the middle of the alphabetic data registers (a bad feature of the 35S to my way of thinking). Thus, the linear system is defined as

Ax + Dy + Gz = K

Bx + Ey + Hz = L

Cx + Fy + Iz = M

Where the definition of the matrix is the same but the definition of the vector uses data registers K through M rather than J through L as in the hp 33s manual..

The solution is obtained using Cramer's rule. The determinant subroutine is a copy of the subroutine on pages 15-16 and 15-17 of the hp 33s user's guide. The subroutine call is made using direct addressing to avoid using additional labels. The input data is restored at the completion of the solution. If the determinant is zero the calculator will stop with the message DIVIDE BY 0 in the display.

User Instructions

1. Press XEQ A ENTER to start the program.

2. The display will stop with a prompt for the coefficient to be entered. Press R/S to accept the displayed data or enter a new coefficient and press R/S. For complex coefficients use the Re i Im format.

3. The display will stop with a prompt for the next coefficient to be entered. Note that the entry is column by column not row by row.

4. Continue to enter the remaining coefficients in response to the prompts.

5. When you press R/S after entering the M value of the vector the program will proceed with the solution. If the determinant of the input matrix is zero program execution will stop with the message DIVIDE BY 0 in the display.

6. If the determinant of the input matrix is not zero the program willl stop with value of X in the display. Press R/S to see the value of Y. Press R/S again to see the value of Z.

7. Press R/S to return to the start of the input routine.and see the first element of the input matrix.

8. The solution values can be recalled for further use from data registers X, Y and Z. The determinant can be recalled for further use from data register W.

Program Listing

```A001   LBL A
A002   -1.1
A003   STO J
A004   INPUT (J)
A005   1.1
A006   STO- J
A007   -14.3
A008   RCL J
A009   x ne y?          x is not equal to y
A010   GTO A004
A011   XEQ A070
A012   STO W
A013   1/x
A014   RCL K
A015   x<> A
A016   STO K
A017   RCL L
A018   x<> B
A019   STO L
A020   RCL M
A021   x<> C
A022   STO M
A023   XEQ A070
A024   STO X
A025   RCL K
A026   x<> A
A027   x<> D
A028   STO K
A029   RCL L
A030   x<> B
A031   x<> E
A032   STO L
A033   RCL M
A034   x<> C
A035   x<> F
A036   STO M
A037   XEQ A070
A038   STO Y
A039   RCL K
A040   x<> D
A041   x<> G
A042   STO K
A043   RCL L
A044   x<> E
A045   x<> H
A046   STO L
A047   RCL M
A048   x<> F
A049   x<> I
A050   STO M
A051   XEQ A070
A052   STO Z
A053   RCL K
A054   x<> G
A055   STO K
A056   RCL L
A057   x<> H
A058   STO L
A059   RCL M
A060   x<> I
A061   STO M
A062   RCL W
A063   STO/ X
A064   STO/ Y
A065   STO/ Z
A066   VIEW X
A067   VIEW Y
A068   VIEW Z
A069   GTO A001
A070   RCL A
A071   RCLx E
A072   RCLx I
A073   RCL D
A074   RCLx H
A075   RCLx C
A076   +
A077   RCL G
A078   RCLx F
A079   RCLx B
A080   +
A081   RCL G
A082   RCLx E
A083   RCLx C
A084   -
A085   RCL A
A086   RCLx F
A087   RCLx H
A088   -
A089   RCL D
A090   RCLx B
A091   RCLx I
A092   -
A093   RTN
```
Length = 291; Check Sum = 2C23

Test problem:

The first number in each coefficient is the real part. The second number in each part is the imaginary part..

```    +1,+3     -1,+2     +4, 0          +10,-8
-3,-2     -5,+1     +1,+1          +10,-4
+2, 0      0,+3     -3,+4          +25,+12
```
The determinant of the matrix which can be read from W is +155,-66 .

The solution vector is

```     +3,+1
-2,-2
+1,-4
```