[Math] Derivative of matrix involving trace and log

calculusderivativesmatricesmatrix-calculus

I'm stuck on this problem.
Let $X\in\mathbb{R}^{n\times n}$, compute the following matrix derivatives
$$\frac{\partial}{\partial X}\mathrm{tr}(\log(XA)\log(XA)^\top),$$
$$\frac{\partial}{\partial X}\mathrm{tr}(B\log(XA)), $$
where $\log(\cdot)$ is the matrix logarithm (not element-wise) and $A,B\in\mathbb{R}^{n\times n}$ are constant matrices.

Thanks in advance for your suggestions!

Best Answer

I assume you are able to compute the derivative without trace. And the rest part, actually, is not hard. Try to compute it componentwisely, then $$\begin{align} \frac{\partial}{\partial X^i_j}\text{tr}f(X)=& \frac{\partial}{\partial X^i_j}f^k_l(X)\delta^l_k\\ =&\frac d{dx}f^k_m(x)|_{x=X}\frac{\partial}{\partial X^i_j}X^m_l\delta^l_k\\ =&\frac d{dx}f^k_m(x)|_{x=X}\delta^m_i\delta^j_l\delta^l_k\\ =&\frac d{dx}f^j_i(x)|_{x=X} \end{align}$$ The conclusion is

$$\frac{\partial}{\partial X}\text{tr}f(X)=\left(\frac d{dx}f(x)|_{x=X}\right)^T$$

Related Question