All formulas

Linear algebra

Log-determinant of a positive definite matrix

linalg.log-determinantAlso called log determinant, logdet, log det, slogdet

ln⁡det⁡A=2∑i=1dln⁡Lii\ln\det A = 2\sum_{i=1}^{d} \ln L_{ii}

whereL=the Cholesky factor, A=LL⊤L = \text{the Cholesky factor, } A = LL^\top

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

AA

symmetric positive definite matrix

A ∈ ℝd×d, symmetric positive definite

dd

matrix size

Size, at least 1

ln⁡det⁡A\ln\det A

Result: the log-determinant

scalar

Worked examples

Each result is solved exactly and confirmed by two independent computations.

  1. Given

    A=[[2,0],[0,3]]A = \left[\left[2, 0\right], \left[0, 3\right]\right]

    Result

    ln⁡det⁡A=log⁡(6)\displaystyle \ln\det A = \log{\left(6 \right)}

    ≈ 1.79175946923

  2. Given

    A=[[2,1],[1,2]]A = \left[\left[2, 1\right], \left[1, 2\right]\right]

    Result

    ln⁡det⁡A=log⁡(3)\displaystyle \ln\det A = \log{\left(3 \right)}

    ≈ 1.09861228867

  3. Given

    A=[[4]]A = \left[\left[4\right]\right]

    Result

    ln⁡det⁡A=log⁡(4)\displaystyle \ln\det A = \log{\left(4 \right)}

    ≈ 1.38629436112

  4. Given

    A=[[2,1,0],[1,2,1],[0,1,2]]A = \left[\left[2, 1, 0\right], \left[1, 2, 1\right], \left[0, 1, 2\right]\right]

    Result

    ln⁡det⁡A=log⁡(4)\displaystyle \ln\det A = \log{\left(4 \right)}

    ≈ 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.