The following warnings occurred:
Warning [2] count(): Parameter must be an array or an object that implements Countable - Line: 795 - File: showthread.php PHP 7.4.33 (FreeBSD)
File Line Function
/showthread.php 795 errorHandler->error





Post Reply 
Need help debugging program on HP 35s
04-11-2015, 03:12 PM
Post: #1
Need help debugging program on HP 35s
I'm learning to program on the HP 35s; most of my experience programming an HP calculator is with the 41 series. I wrote a program to Solve Linear Systems. Its objective is to reduce the matrix on the upper right to a diagonal form with only ones in the diagonal. The determinant of this matrix is also computed and stored in named variable D.

Given a system of equations, for example:

2x + 3y + 5z + 4t = 39
-4x + 2y + z + 3t = 15
3x - y + 2z + 3t = 19
5x + 7y - 3z + 2t = 18

is re-written

39 = 2x + 3y + 5z + 4t
15 = -4x + 2y + z + 3t
19 = 3x - y + 2z + 3t
18 = 5x + 7y - 3z + 2t

storing these 20 numbers column-wise in R01 thru R20.

-If flag F00 is clear the pivots smaller than E-7 ( line 60 ) is regarded as zero
-If flag F00 is set, only zero is regarded as zero
-CF 01 = partial pivoting , SF 01 = no pivoting

There are 4 rows and 5 columns,

CF 00 CF 01
4 ENTER
5 XEQ "L" ENTER

Det A = 840 = Named Variable D

Registers R05 thru R16 now contain the unit matrix and registers R01 thru R04 contain the solution x = 1 , y = 2 , z = 3 , t = 4

When the program stops, D = det A.

Code:
L001 LBL "L"
L002 X<>Y
L003 .1
L004 %
L005 +
L006 STO N
L007 *
L008 LASTX
L009 FP
L010 -
L011 STO O
L012 1
L013 STO D       
L014 LASTX
L015 %
L016 REGZ
L017 IP
L018 +
L019 STO M
L020 FS? 1
L021 GTO L059
L022 IP
L023 RCL O
L024 FP
L025 +
L026 STO I
L027 0
L028 RCL(I)
L029 ABS 
L030 X<Y?
L031 GTO L036
L032 X<>Y
L033 CLX
L034 RCL I
L035 STO J
L036 RDN
L037 DSE I
L038 GTO L028
L039 RCL M
L040 STO I
L041 ENTER
L042 FP
L043 RCL J
L044 IP
L045 +
L046 STO J
L047 X=Y?
L048 GTO L059
L049 RCL(J)
L050 X<>(I)
L051 STO(J)
L052 DSE J
L053 RDN
L054 DSE I
L055 GTO L049
L056 RCL D
L057 +/-
L058 STO D
L059 CLX
L060 FS? 0
L061 GTO L063
L062 E-7
L063 RCL M
L064 STO I
L065 CLX
L066 RCL(I)
L067 STO* D
L068 ABS
L069 X<=Y?
L070 CLX
L071 X=0?
L072 STO D
L073 X=0?
L074 GTO L100
L075 LASTX
L076 ST/(I)
L077 DSE I
L078 GTO L076
L079 RCL O
L080 STO P
L081 RCL M
L082 STO I
L083 ENTER
L084 FP
L085 RCL P
L086 IP
L087 +
L088 X=Y?
L089 GTO L098
L090 STO J
L091 RCL(I)
L092 RCL*(J)
L093 STO-(J)
L094 DSE J
L095 RDN
L096 DSE I
L097 GTO L091
L098 DSE P
L099 GTO L081
L100 RCL N
L101 STO- O
L102 RCL O
L103 RCL M
L104 1
L105 -
L106 STO M
L107 X<=Y?
L108 CLX
L109 DSE M
L110 GTO L113
L111 RCL D
L112 RTN
L113 RCL M
L114 GTO L020

Program Notes:

Lines 28-38 Find the largest element of a column above the diagonal
Lines 49-55 Swap rows
Lines 59-78 Divides all the row by the pivot so this diagonal element becomes 1
Then this row is used to replace by 0 all the other elements of this column using linear combinations of rows.

Lines 81-89 Scans all the column to which belongs a given pivot ( = 1 now )
If the element of this column is the diagonal element ( line 88 X=Y? ) the process below is skipped ( GTO L098 ).

Lines 90-97 A linear combination of the rows is performed to replace the element of this column by 0.

The program isn't working quite right yet and I haven't been able to trace the error. Any help would be appreciated.
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
Need help debugging program on HP 35s - mbrethen - 04-11-2015 03:12 PM



User(s) browsing this thread: 4 Guest(s)