Derivative of the inverse of a symmetric matrix I am quite a beginner in linear algebra and matrix calculus. I was wondering what is the derivative of the matrix inverse when the matrix is symmetric. More precisely, I'm looking for $\frac{\partial}{\partial \mathbf{X}} \mathbf{X}^{-1}$ when $\mathbf{X}$ is a symmetric matrix.
I am asking this because I have a function $f: \mathbb{R}^{n\times n} \to \mathbb{R}$ in the form of 
\begin{equation*}
f(\mathbf{X}) = \mathrm{trace}(\mathbf{A}  \mathbf{X}^{-1}) - \log |\mathbf{X}|
\end{equation*}
and I want to find its extremums using derivatives. I also know if $\mathbf{X}$ is symmetric, then
\begin{align*}
\frac{\partial \mathrm{trace} (\mathbf{A} \mathbf{X})}{\partial \mathbf{X}} & = \mathbf{A} + \mathbf{A}^T - (\mathbf{A} \circ \mathbf{I}) \\
\frac{\partial \log |\mathbf{X}|}{\partial \mathbf{X}} & = 2 \mathbf{X}^{-1} - (\mathbf{X}^{-1} \circ \mathbf{I})
\end{align*}
(from http://www.mit.edu/~wingated/stuff_i_use/matrix_cookbook.pdf Section 2.5).
I somehow want to use the above with the chain rule to write
\begin{equation*}
\frac{\partial f}{\partial \mathbf{X}} = \frac{\partial f}{\partial \mathbf{X}^{-1}} \frac{\partial \mathbf{X}^{-1}}{\partial \mathbf{X}}
\end{equation*}
and compute the derivative of $f$ with respect to $\mathbf{X}$ (since I can easily write $\log |\mathbf{X}| = - \log |\mathbf{X}^{-1}|$).

Ignoring for the moment the symmetry constraint. First rewrite the function as
$$\eqalign{
 f &= A^T:X^{-1} - {\rm tr}({\rm log}(X)) \cr
}$$
Then take the differential 
$$\eqalign{
 df &= A^T:(-X^{-1}\,dX\,X^{-1}) - X^{-T}:dX \cr
    &= -X^{-T}A^TX^{-T}:dX - X^{-T}:dX \cr
    &= -(X^{-T}A^TX^{-T}+X^{-T}):dX \cr
}$$
Since $df = \frac{\partial f}{\partial X}:dX$, the unconstrained derivative is 
$$\eqalign{
 \frac{\partial f}{\partial X} &= -X^{-T}A^TX^{-T}-X^{-T} \cr
}$$
The symmetry of $X$ constrains the actual gradient to
$$\eqalign{
  g &= \Big(\frac{\partial f}{\partial X}\Big) + \Big(\frac{\partial f}{\partial X}\Big)^T - \Big(\frac{\partial f}{\partial X}\Big)\circ I \cr
  &= I\circ\Big(X^{-1}AX^{-1}+X^{-1}\Big)-X^{-1}(A+A^T)X^{-1}-2X^{-1} \cr
}$$
Update
Taking things a bit further, let $S=\frac{1}{2}(A+A^T)$.
Then 
$$\eqalign{
 g 
&= I\circ\Big(X^{-1}SX^{-1}+X^{-1}\Big)-2X^{-1}SX^{-1}-2X^{-1} \cr
&= I\circ B-2B \cr
}$$
Setting the gradient to zero leaves us with $I\circ B=2B$, which can only be true if $B=0$. So now we solve
$$\eqalign{
  X^{-1}SX^{-1}+X^{-1} &= 0 \cr
  X &= -S = -\frac{1}{2}(A+A^T) \cr
}$$
Compare this to the solution of the unconstrained problem, which is 
$$\eqalign{
  X^{-1}AX^{-1}+X^{-1} &= 0 \cr
  X &= -A \cr
}$$
