HP15C program to compute 3x3 complex matrix determinant Message #1 Posted by Karl Schneider on 10 June 2010, 11:58 a.m.
Please refer to the following archived thread:
Complex Matrix Determinant on the 15C
The HP15C represents an m x n complexvalued matrix as an m x 2n realvalued matrix. The HP15C's builtin utility functions will transform an m x m complexvalued square matrix represented in this 'complex' format into an 2m x 2m realvalued square matrix. The determinant of such a matrix is the squared magnitude of the complexvalued determinant of the m x m original matrix.
This procedure can be employed to obtain the magnitude of the determinant of a complexvalued matrix dimensioned up to 4 x 4. However, no builtin capability is available to return the complexvalued determinant itself.
Here's my completed program to calculate the complexvalued determinant of a 3 x 3 complexvalued matrix on the HP15C. The matrix must be entered as a 3 x 6 realvalued matrix "A" in standard HP15C 'complex' format. The program was tested with the following matrix A on the HP15C, and verified using the builtin DET function on the HP42S:
A =
[ 1+i3 2i5 7+i1 ]
[ 4i2 6+i9 8+i4 ]
[3i7 3+i2 1+i6 ]
det A = 217 + i231, as computed exactly by this HP15C program and by the HP42S. The HP15C's native capabilities return 100,450.0000 as the squared magnitude of the determinant, whose calculation time is 15 seconds.
If A(1,3) is edited to 7i1, my HP15C program returns the exact determinant of 75 + i289, and the HP15C's native capabilities return 89,146.00002. (The HP42S computes a slightlyinexact 74.9999999999 + i289, suggesting that the HP42S does not calculate determinants directly.)
It may be that the exact answers produced by the HP42S for the original matrix are attributable to the squared magnitude of the determinant exceeding 10^{5}. If so, that was pure luck. My only criterion for populating A was that each component of each element be a singledigit integer, with a variety of signs.
This HP15C program consumes about 25 registers and takes 21 seconds to run. It utilizes indirect access of any matrix {AE} by storing the descriptor of the matrix into the indirect register I.
Procedure: Store 3 x 6 matrix in 'complex' form with identifier {AE}; RCL {AE}; GSB D.
 Check if dimension of matrix is 3 x 6
 (If not, display blinking descriptor and stop)
 Compute and store first complex subdeterminant
 Compute second subdeterminant
 Combine with first subdeterminant and store
 Compute third subdeterminant
 Combine with first two subdeterminants
 Display complex result
 NOTE: "(u)" denotes user mode, which is necessary for advancing the matrixelement index.
001 LBL D 056 MATRIX 1 102 MATRIX 1
002 STO I 057 2 103 2
003 RCL DIM I 058 STO 0 104 STO 0
004 f I 059 RCL(i) (u) 105 RCL(i) (u)
005 3 060 RCL(i) 106 RCL(i)
006 ENTER 061 f I 107 f I
007 6 062 3 108 3
008 f I 063 STO 0 109 STO 0
009  064 5 110 STO 1
010 x=0? 065 STO 1 111 R_down
011 GTO 8 066 R_down 112 RCL(i) (u)
012 CF 8 067 R_down 113 RCL(i)
013 RCL I 068 RCL(i) (u) 114 f I
014 SF 9 069 RCL(i) 115 *
015 RTN 070 f I 116 2
016 LBL 8 071 * 117 STO 0
017 2 072 2 118 3
018 STO 0 073 STO 0 119 STO 1
019 3 074 5 120 R_down
020 STO 1 075 STO 1 121 R_down
021 RCL(i) (u) 076 R_down 122 RCL(i) (u)
022 RCL(i) (u) 077 R_down 123 RCL(i)
023 f I 078 RCL(i) (u) 124 f I
024 3 079 RCL(i) (u) 125 MATRIX 1
025 STO 0 080 f I 126 3
026 R_down 081 RCL(i) (u) 127 STO 0
027 RCL(i) (u) 082 RCL(i) 128 R_down
028 RCL(i) 083 f I 129 RCL(i) (u)
029 f I 084 * 130 RCL(i)
030 * 085  131 f I
031 2 086 MATRIX 1 132 *
032 STO 0 087 3 133 
033 CLx 088 STO 1 134 MATRIX 1
034 5 089 R_down 135 5
035 STO 1 090 RCL(i) (u) 136 STO 1
036 R_down 091 RCL(i) 137 R_down
037 RCL(i) (u) 092 f I 138 RCL(i) (u)
038 RCL(i) (u) 093 * 139 RCL(i)
039 f I 094 RCL 2 140 f I
040 3 095 RCL 3 141 *
041 STO 1 096 f I 142 RCL 2
042 R_down 097 x<>y 143 RCL 3
043 RCL(i) (u) 098  144 f I
044 RCL(i) 099 STO 2 145 +
045 f I 100 Re<>Im 146 PSE
046 * 101 STO 3 147 Re<>Im
047  148 PSE
048 MATRIX 1 149 Re<>Im
049 RCL(i) (u) 150 RTN
050 RCL(i)
051 f I
052 *
053 STO 2
054 Re<>Im
055 STO 3
Edited: 19 June 2010, 2:52 p.m. after one or more responses were posted
