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!

  • $\begingroup$ Do you know the chain rule and product rule? $\endgroup$ – wj32 Jul 4 '13 at 22:34
  • $\begingroup$ Of course in the scalar case, but I still have a doubt: are these rules applicable without changes also in the matrix case? How about the order of derivation in the latter case? Thanks $\endgroup$ – Ludwig Jul 5 '13 at 6:23

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$$


Clearly the calculation is quasi-unfeasible. In particular, the answer of GMB is absolutely false (cf. my comment above). Who has given a good point to his answer ? Yet, one can give a compact answer if $X=A^{-1}$ because $D\log_I=id$.

Let $f(X)=tr(B\log(XA))$. Then $Df_{A^{-1}}:H\rightarrow tr(BHA)$. Thus $\nabla (f)_{A^{-1}}=(AB)^T$.

EDIT: Let $h(X)=tr(\log(I+X))$ where $\log$ denotes the principal logarithm and $||X||<1$. Then $h(X)=tr(\sum_{k=1}^{\infty}(-1)^{k+1}/k.X^k) =\sum_{k=1}^{\infty}(-1)^{k+1}/k.tr(X^k)$ and $Dh_X:H\rightarrow \sum_{k=1}^{\infty}(-1)^{k+1}/k.tr(kX^{k-1}H)$ (because $tr(UV)=tr(VU)$)$=tr(\sum_{k=1}^{\infty}(-1)^{k-1}X^{k-1}H)=tr((I+X)^{-1}H)$. In other words $\nabla(h)_X={(I+X)^{-1}}^T$. More generally, if $X$ has no eigenvalues in $\mathbb{R}^-$, then let $g(X)=tr(\log(X))$. One has $Dg_X:H\rightarrow tr(X^{-1}H)$ and $\nabla(g)_X={X^{-1}}^T$.

Here $f(X)=tr(B\log(XA))=tr(B\log(Y))$; then we must derive $u(Y)=tr(BY^k)$. Unfortunately $Du_Y:K\rightarrow tr(B(kY^{k-1})K)$ is false in general ; yet, it is true if, for instance, $BY=YB$. Finally, when $BXA=XAB$, $Df_X:H\rightarrow tr(B(XA)^{-1}HA)$ (because $K=HA$)$=tr((XA)^{-1}BHA)=tr(X^{-1}BH)$ and $\nabla(f)_X=(X^{-1}B)^T$ does not depend on $A$.


Here's an incomplete answer:

$\log A = - \sum_{i = 1}^{\infty} \, \frac{1}{i}(I - A)^i$


$d \log A = \sum_{i = 0}^{\infty} \, (I - A)^i \, dA$

If you know the chain and product rules, deriving over the $\log A$ term should be the only tricky part.

  • $\begingroup$ Thanks for your answer. However, I was looking for a closed-form expression (if there exists). $\endgroup$ – Ludwig Jul 5 '13 at 6:27
  • 2
    $\begingroup$ Hi Levdub,the notation $df$ is really catastrophic. Here $A$ and $dA$ do not commute. The derivative of the function $log$ (and of the function $exp$) is complicate. For instance, the derivative of $f(A)=-(I-A)^3$ is $Df_A:H\rightarrow H(I-A)^2+(I-A)H(I-A)+(I-A)^2H$. $\endgroup$ – loup blanc Sep 5 '13 at 12:47

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.