Re: Complex Matrix Determinant on the 15C Message #4 Posted by Karl Schneider on 23 May 2010, 5:47 p.m., in response to message #3 by Andrew H.
Andrew --
This enticed me to investigate in more detail a few things I've wondered about.
As I had suspected, if a complex-valued matrix is singular (determinant of 0 + i0), the HP-15C will also compute a value of virtually zero for the real-valued transformation matrix ('Py,x' followed by MATRIX 2). As an example, for the following singular matrix
[ 1+i3 2+i4 ]
[ 2+i6 4+i8 ]
the HP-15C calculates -2.053600001E-18 as the determinant (more about this later), while the HP-42S computes exactly 0 + i0.
Thus, if you are simply wondering if a complex-valued matrix is invertible, the HP-15C can tell you that.
For the nonsingular matrix
[ 1+i5 2+i4 ]
[ 2+i6 4+i8 ]
the HP-42S calculates -16 + i8 (exactly) as the determinant, while the HP-15C calculates 319.9999999 as the determinant of the transformation matrix. Note that 320 is the squared magnitude of the complex-valued determinant. I doubt that this is coincidental.
It seems that the HP-15C can give you the magnitude of a complex-valued determinant. I'm open to suggestions how that piece of information, along with the computed inverse matrix, could be employed using linear algebra to obtain the actual determinant.
Now, why does the HP-15C seem unable to compute exact integer values for the determinants of integer-valued matrices?
ANSWER: The HP-15C does not calculate determinants directly. Instead, it first computes a 'unitized' LU decomposition of the matrix that can be stored in the same space. The determinant of that is simply the product of the main-diagonal elements of the U matrix (those of the L matrix are all unity), with a sign change for an odd number of necessary row transpositions.
The LU decomposition is part of the process for matrix inversion (allows in-place inversion), and speeds up solution of linear equations.
So, why is LU decomposition performed unnecessarily for determinants, when direct computation is faster and more accurate? Couldn't LU be computed when inversion or linear solutions are subsequently requested?
ANSWER: This was probably a consequence of limited ROM space for the functionality to be implemented. Additional machine code -- similar to what I devised above, but more extensive -- would have been needed for direct computation of determinants. Instead, the existing LU-decomposition code was utilized. Having LU already computed also provides a 'head start' on subsequent inversion or linear-solution calculations.
However, the unintuitive LU decomposition as part of the HP-15C's determinant calculation is indeed a potential "gotcha" to the user. The user may be chagrined to see his calculation of a determinant -- merely a scalar-valued output -- overwrite a needed matrix with an LU matrix. Or, if insufficient free memory exists to store the LU decomposition to the RESULT matrix, the operation will fail with a cryptic message "Error 10". No additional space is needed if the identifier of the RESULT matrix is designated as that of the original matrix, which can be approximately recovered by twice inverting the LU matrix.
-- KS
Edited: 28 May 2010, 1:49 a.m. after one or more responses were posted
|