Matrix gradient of $\ln(\det(X))$ I'm looking at The Matrix Cookbook, and their formulae for the gradient of the $\ln (\det( X ) )$ function seem to be inconsistent. Specifically formula 141 says that the gradient is $$2X^{-1} + (X^{-1} \circ I)$$ with $\circ$ being the Hadamard product. Several other sources (including formula 47 in the same document) state that the gradient is simply $X^{-1}$. Why the difference?
 A: Let $M_n$ (resp $S_n$) be the set of real (resp real symmetric) matrices. Let $(E_{i,j})_{i,j}$ be the canonical basis of $M_n$.
Let $f:X\in M_n\cap GL_n\rightarrow \log(\det(X))$; its derivative is $Df_X:H\in M_n\rightarrow tr(X^{-1}H)$. 
Let $g:X\in S_n\cap GL_n\rightarrow \log(\det(X))$; its derivative is $Dg_X:K\in S_n\rightarrow tr(X^{-1}K)$. 
Note that $Dg_X$ is the restriction to $S_n$ of $DF_X$. Moreover one always has the approximation $\log(\det(X+H))\approx \log(\det(X))+tr(X^{-1}H)$ when we are in $M_n$ or in $S_n$.
Of course, it is too simple; one has to bother the students... Then one uses the gradient; moreover if the entries $[a_{i,j}]$ of the matrices $A$ are linked, then the variables are no longer the same. For example, for $S_n$, the variables are the $a_{i,i}$ and the  $(a_{i,j}),i< j$. Then $\dfrac{\partial{A}}{\partial{a_{i,i}}}=E_{i,i}$ ($a_{i,i}$ appears one time) and $\dfrac{\partial{A}}{\partial{a_{i,j}}}=E_{i,j}+E_{j,i}$ ($a_{i,j}$ appears two times). The formula valid for any $i\leq j$ being 
$(*)$ $\dfrac{\partial{A}}{\partial{a_{i,j}}}=E_{i,j}+E_{j,i}-E_{ij}^2$. 
I hope the author of this great formula $(*)$ has received a prize. Then just pick up the pieces to find your required formula; formula which is (incidentally) false because, according to $(*)$, it takes a minus signum.
