19
$\begingroup$

How to calculate the gradient with respect to $X$ of: $$ \log \mathrm{det}\, X^{-1} $$ here $X$ is a positive definite matrix, and det is the determinant of a matrix.

How to calculate this? Or what's the result? Thanks!

  • 2
    Note that $\log\det\mathbf X^{-1}=\log\frac1{\det\mathbf X}=-\log\det\mathbf X$...2011-05-12
  • 4
    And note that $\log \det X =\text{tr} \log X$...2011-05-12
  • 0
    Somehow I wonder if what you actually need is the Gâteaux or the Fréchet derivative... where did you encounter this, and what are you *actually* doing?2011-05-12
  • 0
    I encounter this when deriving a lower bound of D-optimal experimental design using dual theory (an exercise of _Convex Optimization_). I want to find the optimal of a function which involves $\log\mathrm{det}\,(X^{-1})$.2011-05-12
  • 0
    A closely related question and answer, worth a cross-reference: [How to calculate the derivative of log det matrix?](https://math.stackexchange.com/questions/1151569/how-to-calculate-the-derivative-of-log-det-matrix/1151578) but the question is framed in the context of Matrix Calculus2017-10-30
  • 0
    @Fabian why $\log \det X=tr \log X$? $\log \det X=\log \lambda_1+\cdots+\log \lambda_n$, while $tr \log X=\log X_{11}+\cdots+\log X_{nn}$, where $\lambda$ is an eigenvalue of $X$.2018-12-18

3 Answers 3

30

I assume that you are asking for the derivative with respect to the elements of the matrix. In this cases first notice that

$$\log \det X^{-1} = \log (\det X)^{-1} = -\log \det X$$

and thus

$$\frac{\partial}{\partial X_{ij}} \log \det X^{-1} = -\frac{\partial}{\partial X_{ij}} \log \det X = - \frac{1}{\det X} \frac{\partial \det X}{\partial X_{ij}} = - \frac{1}{\det X} \mathrm{adj}(X)_{ji} = - (X^{-1})_{ji}$$

since $\mathrm{adj}(X) = \det(X) X^{-1}$ for invertible matrices (where $\mathrm{adj}(X)$ is the adjugate of $X$, see http://en.wikipedia.org/wiki/Adjugate).

  • 0
    Thank you very much! This solved my problem!2011-05-12
  • 0
    The $\frac{\partial \det X}{\partial X_{ij}} = \mathrm{adj}(X)_{ji}$ was very non-obvious to me, but can be worked out using the [Jacobi formula](https://en.wikipedia.org/wiki/Jacobi's_formula).2017-01-05
7

Or you can check section A.4.1 of the book Stephen Boyd, Lieven Vandenberghe, Convex Optimization for an alternative solution, where they compute the gradient without using the adjugate.

4

The simplest is probably to observe that $$-\log\det (X+tH) = -\log\det X -\log\det(I+tX^{-1}H) \\= -\log\det X - t \textrm{Tr}(X^{-1}H) + o(t),$$

where is used the "obvious" fact that $\det(I+A) = 1+\textrm{Tr}(A)+o(|A|)$ (all the other terms are quadratic expressions of the coefficients of $A$).

Notice that $\textrm{Tr}(X^{-1}H)=(X^{-T},H)$ in the Frobenius scalar product, hence $\nabla [-\log\det(X)] = -X^{-T}$ in this scalar product. (This gives another proof that $\nabla\det (X) = cof(X)$.)

Of course if $X$ is symmetric positive definite then $-X^{-1}$ is also a valid expression. Moreover, one has in this case, for $X,Y$ positive definite, $(-X^{-1}+Y^{-1},X-Y)\ge 0$.