Program for ... HELP!!!
Jeff Epler
jepler at unpythonic.net
Wed Sep 4 19:57:47 CEST 2002
kyro,
One method is to perform LU decomposition of the matrix, then take
det(U) which is simply the product of the elements on the diagonals.
(det(A) = det(L)det(U) since A=LU, but det(L)=1 and U is triangular).
You can find a description of LU decomposition in any decent numerical
analysis text, or online. You could also try the search term "gaussian
elimination".
LU decomposition is probably expressible most clearly as iteration, not
recursion. There is a method whose name escapes me which involves
taking the sum of factors like
(-1)^(j+k) * A_jk * det(A with the row and column passing through jk removed)
which is naturally recursive, but this is not a "good" algorithm: it'll
take much longer than the O(n^3) operations of LU decomposition.
I don't know if there are better methods for finding determinants,
the LU method is the only one explored at length in the text I have on
hand.
If you're having trouble representing matricies in Python, well, that's
another matter. As another poster suggested, you should probably get
the "Numeric" package.
Jeff
More information about the Python-list
mailing list