Saturday, November 9, 2019

HP 35S: Determinant and Cramers Rule - 3 x 3 Matrices

HP 35S: Determinant and Cramers Rule - 3 x 3 Matrices

Determinant of a 3 x 3 Matrix

The following program calculates a determinant of a matrix:

[ [ K, N, Q ]
[ L, O, R ]
[ M, P, S ] ]

The determinant is  K*O*S + N*R*M + Q*L*P - M*O*Q - P*R*K - S*L*N.

Enter the elements in columns. 

Program HP 35S:  Determinant

D001 LBL D
D002 SF 10
D003 "DET 3x3"
D004 CF 10
D005 INPUT K
D006 INPUT L
D007 INPUT M
D008 INPUT N
D009 INPUT O
D010 INPUT P
D011 INPUT Q
D012 INPUT R
D013 INPUT S
D014 RCL K
D015 RCL* O
D016 RCL* S
D017 RCL N
D018 RCL* R
D019 RCL* M
D020 +
D021 RCL Q
D022 RCL* L
D023 RCL* P
D024 +
D025 RCL M
D026 RCL* O
D027 RCL* Q
D028 -
D029 RCL P
D030 RCL* R
D031 RCL* K
D032 -
D033 RCL S
D034 RCL* L
D035 RCL* N
D036 -
D037 RTN

Examples:

[ [ -3, 3, 2 ]
[ 5, 4, -1 ]
[ 2, 1, 4 ] ]
Determinant:  -123

[ [ 5, 0, 7 ]
[ -2, 4, -1 ]
[ -3, 11, 6 ] ]
Determinant:  105

Cramer's Rule

Cramer's Rule solves the linear system:

[[ A, D, G ]   [[ x ]  = [[ X ]
[ B, E, H ]     [ y ]  = [ Y ]
[ C, F, I ]]      [ z ]] = [ Z ]]

x = U, y = V, z = W,  T = determinant of the coefficients

Program HP 35S: Cramer's Rule

C001 LBL C
C002 GTO C027
C003 RCL K     // determinant calculation
C004 RCL* O
C005 RCL* S
C006 RCL N
C007 RCL* R
C008 RCL* M
C009 +
C010 RCL Q
C011 RCL* L
C012 RCL* P
C013 +
C014 RCL M
C015 RCL* O
C016 RCL* Q
C017 -
C018 RCL P
C019 RCL* R
C020 RCL* K
C021 - 
C022 RCL S
C023 RCL* L
C024 RCL* N
C025 - 
C026 RTN
C027 SF10  // input numbers into the system
C028 "COL 1"
C029 INPUT A
C030 STO K
C031 INPUT B
C032 STO L
C033 INPUT C
C034 STO M
C035 "COL 2"
C036 INPUT D
C037 STO N
C038 INPUT E
C039 STO O
C040 INPUT F
C041 STO P
C042 "COL 3"
C043 INPUT G
C044 STO Q
C045 INPUT H
C046 STO R
C047 INPUT I
C048 STO S
C049 "VECTOR" 
C050 INPUT X
C051 INPUT Y
C052 INPUT Z
C053 XEQ C003
C054 STO T
C055 "DET="
C056 VIEW T
C057 RCL X
C058 STO K
C059 RCL Y
C060 STO L
C061 RCL Z
C062 STO M
C063 XEQ C003
C064 RCL÷ T
C065 STO U
C066 "X="
C067 STOP
C068 RCL A
C069 STO K
C070 RCL B
C071 STO L
C072 RCL C
C073 STO M
C074 RCL X
C075 STO N
C076 RCL Y
C077 STO O
C078 RCL Z
C079 STO P
C080 XEQ C003
C081 RCL÷ T
C082 STO V
C083 "Y="
C084 STOP
C085 RCL D
C086 STO N
C087 RCL E
C088 STO O
C089 RCL F
C090 STO P
C091 RCL X
C092 STO Q
C093 RCL Y
C094 STO R
C095 RCL Z
C096 STO S
C097 XEQ C003
C098 RCL÷ T
C099 STO W
C100 "Z="
C101 CF 10
C102 TOP
C103 RTN

Examples:

[[ -3, 2, -4 ]   [[ x ]  = [[ 0 ]
[ 6, 1, 2 ]       [ y ]  = [ 2 ]
[ 3, 3, 7 ]]      [ z ]] = [ 6 ]]
T:  -135
x ≈ 0.0296
y ≈ 0.9333
z ≈ 0.4444

[[ 0, 10, 6 ]  [[ x ] = [[ 3 ]
[ 5, 3, 8 ]     [ y ]  = [ 6.5 ]
[ -5, 8, 2 ]]    [ z ]] = [ 7 ]]
T:  -830
x ≈ -0.0843
y ≈ 0.6687
z ≈ 0.6145

Source:

Pike, Scott.  "Using Cramer's Rule to Solve Three Equations with Three Unknowns"  Mesa Community College.  http://www.mesacc.edu/~scotz47781/mat150/notes/cramers_rule/Cramers_Rule_3_by_3_Notes.pdf  Retrieved September 24, 2019

Eddie

All original content copyright, © 2011-2019.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.