Linear algebra
Log-determinant of a positive definite matrix
linalg.log-determinantAlso called log determinant, logdet, log det, slogdet
where
Natural log of the determinant of a symmetric positive definite matrix, computed from its Cholesky factor so it stays finite where the determinant itself overflows or underflows.
Notation
symmetric positive definite matrix
A ∈ ℝd×d, symmetric positive definite
matrix size
Size, at least 1
Result: the log-determinant
scalar
Worked examples
Each result is solved exactly and confirmed by two independent computations.
Given
Result
≈ 1.79175946923
Given
Result
≈ 1.09861228867
Given
Result
≈ 1.38629436112
Given
Result
≈ 1.38629436112
Common mistakes
Sums ln Lii without the factor 2
The log-determinant of the Cholesky factor is half that of A.
Fix: Multiply the sum of ln Lii by 2.
Sums the logs of A's diagonal
The diagonal of A gives the determinant only when A is diagonal; it ignores the off-diagonal entries.
Fix: Take the diagonal of the Cholesky factor, not of A.
Sources
Golub and Van Loan 2013
Golub, Gene H.; Van Loan, Charles F. Matrix Computations. 4th ed. Johns Hopkins University Press, 2013.
Horn and Johnson 2013
Horn, Roger A.; Johnson, Charles R. Matrix Analysis. 2nd ed. Cambridge University Press, 2013.