determinant of a very large matrix in MATLAB

1.9k Views Asked by At

I have a very large random matrix which its elements are either $0$ or $1$ randomly. The size of the matrix is $5000$, however when I want to calculate the determinant of the matrix, it is either $Inf$ or $-Inf$. Why it is the case (as I know thw determinant is a real number and for a finite size matrix with finite elements, it cannot be $Inf$) and how can I remedy any possible mistake?

2

There are 2 best solutions below

4
On BEST ANSWER

I did a search for "determinant of random matrix" and found this article:

https://people.math.osu.edu/nguyen.1261/cikk/loglaw.pdf

It shows that the log of the determinant of a n by n random matrix is usually about $n\log(n)/2 $.

Therefore, for large $n$, any computation of the determinant will almost certainly overflow.

0
On

If the determinant is needed, then a numerically reliable strategy is to compute the $QR$ decomposition of $A$ with column pivoting, i.e. $AP = QR$, where $P$ is a permutation matrix, $Q$ is an orthogonal matrix and $R$ is an upper triangular matrix. In MATLAB the relevant subroutine is 'qr'. Then the determinant of $A$ equals the product of the diagonal entries of $R$ (up to a sign change which is determined by the determinant of $P$). The question of computing the determinant then reduces to handling the product of $n$ terms. This product can easily overflow or underflow, but it is likely that you will be able to determine the logarithm of the absolute value of this product, using the relation $\log(ab) = \log(a) + \log(b)$.

There are exceptions, but normally the condition number of a matrix is more important than the determinant.