Determinant of matrix and log in matlab

245 Views Asked by At

The determinant of a triangular matrix is equal to the product of its diagonal entries. Use this fact to develop a routine for computing the determinant of an arbitrary nn matrix $A$ by using its $LU$ factorization. You may use a library routine for Gaussian elimination with partial pivoting to obtain the $LU$ factorization, or you may design your own routine. How can you determine the proper sign for the determinant? To avoid risk of overflow or underflow, you may wish to consider computing the logarithm of the determinant instead of the actual value of the determinant.

I'm not sure what I'm suppose to do here. I use matlab and do [L,U] = lu(A) to the get the $LU$ product, but how does the log come into play?

1

There are 1 best solutions below

2
On

We have $A = LU$, and $$ \det(A) = \det(L)\det(U) $$ So it suffices to find the determinant of the (triangular!) matrices $L$ and $U$. Assuming that you've decided on the sign of the determinant, the idea with the logs is to note that $$ \log|\det(L)| = \log(|L_{11}L_{22} \cdots L_{nn}|) = \log|L_{11}| + \log|L_{22}| + \cdots + \log |L_{nn}| $$ A similar idea applies to $\det(U)$.