Dear Matrix Calculus Experts,
What is the derivative of $\mbox{tr}\left\{ X^T A X^{-1} B\right\}$ with respect to matrix $X$ for a given $A$ and $B$ matrices?
I came across http://www.matrixcalculus.org/, which can compute it for me (not sure either whether it is correct), i.e., \begin{align} \nabla_{X} \ \mbox{tr}\left\{ X^T A X^{-1} B\right\} = AX^{-1}B - X^{-T}A^TXB^TX^{-T}. \end{align}
However, I would be happy to know the derivation steps. Could you experts please help me how to derive this?
Thank you so much in advance,
If we denote the trace/Frobenius product with a colon, i.e. $$A:B = {\rm tr}(A^TB)$$ then the function can be written as $$\phi = X:AX^{-1}B$$ The differential of the matrix inverse can be calculated from first principles $$\eqalign{ I &= X^{-1}X \cr 0 &= dX^{-1}\,X+X^{-1}\,dX \cr dX^{-1} &= -X^{-1}\,dX\,X^{-1} \cr }$$ and this can be used to find the differential and gradient of the function $$\eqalign{ d\phi &= dX:AX^{-1}B + X:A\,dX^{-1}B \cr &= AX^{-1}B:dX - A^TXB^T:X^{-1}\,dX\,X^{-1} \cr &= \Big(AX^{-1}B - X^{-T}A^TXB^TX^{-T}\Big):dX \cr \frac{\partial\phi}{\partial X} &= AX^{-1}B - X^{-T}A^TXB^TX^{-T} \cr }$$ This differs from the result you quoted in the sign of the second term.