# Computing log-determinant?

Mathematica does-not have a function to compute the log-det of matrix? Naively computing Log[Det[M]] can be numerically unstable.

• If speed isn't an issue, you could just do a SingularValueDecomposition, take the log of the singular values and take the Total – Niki Estner Feb 13 '20 at 11:48
• Yes, speed (and memory) are an issue. Having to compute and store all the singular vectors is very wasteful. – becko Feb 13 '20 at 12:01
• SingularValueList is about 2-3 times faster, and I would like to know too if there are significantly better ways to compute the log-determinant. – aooiiii Feb 13 '20 at 12:08
• LUDecomposition is much faster, but potentially less stable. So, something like Total[Log[Abs[Diagonal[First[LUDecomposition[m]]]]]] should work (this removes the sign of the determinant, though) – Niki Estner Feb 13 '20 at 13:33
• For general $\mathbf M$, I don't expect that you can do better than $O(n^3)$ effort for $\log\det\mathbf M$, even if it's SPD. But if the matrix has some sort of exploitable structure, perhaps... – J. M.'s torpor May 24 '20 at 6:44