Search code examples
matlabsimulationscaleprecisiondeterminants

Determinants of huge matrices in MATLAB


from a simulation problem, I want to calculate complex square matrices on the order of 1000x1000 in MATLAB. Since the values refer to those of Bessel functions, the matrices are not at all sparse.

Since I am interested in the change of the determinant with respect to some parameter (the energy of a searched eigenfunction in my case), I overcome the problem at the moment by first searching a rescaling factor for the studied range and then calculate the determinants,

result(k) = det(pre_factor*Matrix{k});

Now this is a very awkward solution and only works for matrix dimensions of, say, maximum 500x500.

Does anybody know a nice solution to the problem? Interfacing to Mathematica might work in principle but I have my doubts concerning feasibility. Thank you in advance

Robert

Edit: I did not find a convient solution to the calculation problem since this would require changing to a higher precision. Instead, I used that

ln det M = trace ln M

which is, when I derive it with respect to k

A = trace(inv(M(k))*dM/dk)

So I at least had the change of the logarithm of the determinant with respect to k. From the physical background of the problem I could derive constraints on A which in the end gave me a workaround valid for my problem. Unfortunately I do not know if such a workaround could be generalized.


Solution

  • If speed is not a concern, you may want to use det(e^A) = e^(tr A) and take as A some scaling constant times your matrix (so that A - I has spectral radius less than one).

    EDIT: In MatLab, the log of a matrix (logm) is calculated via trigonalization. So it is better for you to compute the eigenvalues of your matrix and multiply them (or better, add their logarithm). You did not specify whether your matrix was symmetric or not: if it is, finding eigenvalues are easier than if it is not.