Wednesday, June 7, 2017

HP 20S and HP 21S: 2 x 2 Matrices Inverse and Square

HP 20S and HP 21S:  2 x 2 Matrices Inverse and Square

Let M be the 2 x 2 matrix:

M = [ [ R1,  R2 ] [ R3, R4 ] ]

Store values in R1, R2, R3, and R4 before executing the program.

HP 20S and HP 21S:  Inverse of a Matrix

Output:  Determinant of M in R0.  If the determinant is 0, then the program terminates, since the matrix is determined to be singular (and have normal inverse).  Output:

M^-1:  [ [ R5, R6 ], [ R7, R8 ] ] where
R5 = R4/det(M)
R6 = -R2/det(M)
R7 = -R3/det(M)
R8 = R4/det(M)

The keystrokes for the HP 20S and HP 21S are the same.

 STEP CODE KEY 01 61, 41, A LBL A 02 22, 1 RCL 1 03 55 * 04 22, 4 RCL 4 05 65 - 06 22, 2 RCL 2 07 55 * 08 22, 3 RCL 3 09 74 = 10 21, 0 STO 0 11 26 R/S 12 61, 43 X=0? 13 61, 26 RTN 14 22, 4 RCL 4 15 41, 1 XEQ 1 16 21, 5 STO 5 17 26 R/S 18 22, 2 RCL 2 19 41, 1 XEQ 1 20 32 +/- 21 21, 6 STO 6 22 26 R/S 23 22, 3 RCL 3 24 41, 1 XEQ 1 25 32 +/- 26 21, 7 STO 7 27 26 R/S 28 22, 1 RCL 1 29 41, 1 XEQ 1 30 21, 8 STO 8 31 61, 26 RTN 32 61, 41, 1 LBL 1 33 45 ÷ 34 22, 0 RCL 0 35 74 = 36 61, 26 RTN

Example 1:
[ [1.9, -7], [-3.5, 4.2] ]^-1 = [ [ -0.2542, -0.4237], [ -0.2119, -0.1150 ]]
Determinant:  -16.52

Example 2:
[ [-2, 8],[5, 6] ]^-1 = [ [-0.1154, 0.1538], [ 0.0962, 0.0385] ]
Determinant:  -52

HP 20S and HP 21S:  Square of a Matrix

Output:  [ [ M5, M6 ] [ M7, M8 ] ]
M5 = R1^2 + R2 * R3
M6 = R2 * (R1 + R4)
M7 = R3 * (R1 + R4)
M8 = R2 * R3 + R4

 STEP CODE KEY 01 61, 41, A LBL A 02 22, 1 RCL 1 03 51, 11 x^2 04 75 + 05 22, 2 RCL 2 06 55 * 07 22, 3 RCL 3 08 74 = 09 21, 5 STO 5 10 26 R/S 11 22, 2 RCL 2 12 55 * 13 33 ( 14 22, 1 RCL 1 15 75 + 16 22, 4 RCL 4 17 34 ) 18 74 = 19 21, 6 STO 6 20 26 R/S 21 22, 3 RCL 3 22 55 * 23 33 ( 24 22, 1 RCL 1 25 75 + 26 22, 4 RCL 4 27 34 ) 28 74 = 29 21, 7 STO 7 30 26 R/S 31 22, 2 RCL 2 32 55 * 33 22, 3 RCL 3 34 75 + 35 22 ,4 RCL 4 36 51, 11 x^2 37 74 = 38 21, 8 STO 8 39 61, 26 RTN

Example 1:
[ [1.9, -7], [-3.5, 4.2] ]^2 = [ [ 28.11, -42.7], [ -21.35, 42,14 ]]

Example 2:
[ [-2, 8],[5, 6] ]^2 = [ [ 44, 32 ], [ 20, 76 ] ]

Eddie

This blog is property of Edward Shore, 2017