# Why is $\frac{\partial \operatorname{Tr}(\mathbf X^n)}{\partial \mathbf X}=n\left(\mathbf X^{n-1}\right)^T ?$

Why is $$\frac{\partial \operatorname{Tr}(\mathbf X^n)}{\partial \mathbf X}=n\left(\mathbf X^{n-1}\right)^T ?$$ and why is $$\frac{\partial (\ln[\det(\mathbf X)])}{\partial \mathbf X}=\mathbf X^{-T} ?$$

I have found lots of website and information about them, matrix cook book for example, but they just tell me the result, not the proof. Does anyone know how to prove them?

• The first formula comes from computing $tr[(X + \delta X)^n]$ and isolating the first-order term $tr(nX^{n-1} \delta X)$. The second can be computed element wise using standard formula for the determinant, and observing that when you rearrange into a matrix you get $adj(A) / |A|$ where $adj$ denotes the adjugate matrix. – guy Oct 11 '18 at 13:37
• Note that the formula for the derivative of the determinant is known as Jacobi's formula. Hence, using the chain rule, $$\frac{\partial \ln\det X}{\partial X} = \frac{\partial \ln\det X}{\partial \det X}\frac{\partial \det X}{\partial X} = \frac{1}{\det X}( \det X)\, X^{-\top}$$ – Harry49 Oct 11 '18 at 16:48
• @guy do you know how to prove it? – shineele Oct 12 '18 at 0:20
• @shineele I explained how to prove both claims. If that isn’t enough for you to fill in the details then sorry, but I don’t have the desire to write up a proof with all the details you apparently need. It may be helpful for you to look up how matrix differentials can be used to compute matrix derivatives. – guy Oct 12 '18 at 3:24

For any matrix, the trace is just the sum of the eigenvalues, and the determinant is their product, so $${ \exp\big({\rm tr}(X)\big) = \exp\Big(\sum_k\lambda_k\Big) = \prod_k\Big(\exp(\lambda_k)\Big) = \det\big(\exp(X)\big) }$$ If the determinant is not zero, take the logarithm of both sides $$\log(\det(\exp(X))) = {\rm tr}(X)$$ Assume that a matrix $$Y$$ exists such that $$X=\log(Y) \implies Y=\exp(X)$$
Then \eqalign{ \log(\det(Y)) &= {\rm tr}(\log(Y)) \cr d\log(\det(Y)) &= d{\,\rm tr}(\log(Y)) = {\rm tr}(Y^{-1}\,dY) \cr \frac{\partial\log\det Y}{\partial Y} &= Y^{-T} \cr }
• Why will $tr(Y^{-1})=Y^{-T}$? – shineele Oct 12 '18 at 0:40