# Scalar derivative of ${\rm tr}~[A(x)\log A(x)]$ where $A(x)$ is a square matrix

How do i proceed to calculate

$$\frac{d}{dx}{\rm tr}\left[{A(x) \log A(x)}\right]$$

where $A(x) \in \mathbb{M}(n)$ and $x \in \mathbb{R}$?

The $\log$ function is the one defined by the exponential map for matrices in the following sense: If $A=e^B$ then $B=\log A$, where $e ^X \equiv \sum_{k=0}^\infty X^k / k!$. The multiplication between $A$ and $\log A$ is matrix multiplication.

Further assume that $A(x)$ are diagonalizable and nonsingular.

This problem arises in a statistical physics model where $A(x)$ is a density matrix depending on a scalar quantity and the trace expression is the (von Neumann) entropy. I tried to find it on the net but no luck and i got confused with the literature on matrix derivatives that are usually for derivation with respect to another matrix or with respect to a vector. Thanks anyone!

• What is the log of a rectangular matrix? Is it the entrywise log? – Rahul Jun 21 '15 at 15:26
• Same for multiplication $A(x)\log A(x)$, is it entrywise ? I suspect so since you say matrices are rectangular. Anyway, this just sums up to a standard derivative after the trace. – Bertrand R Jun 21 '15 at 15:33
• No, the log here is the one defined by the exponential map in this sense: If $A=e^B$ then $B=\log A$, where $e ^X \equiv \sum_{k=0}^\infty X^k / k!$. The multiplication between $A$ and $\log A$ is matrix multiplication. I edited the question to make it clear. Thanks for the replies! – planckstars Jun 21 '15 at 15:33
• Your log is not well defined then – Bertrand R Jun 21 '15 at 15:34
• why do you say that? – planckstars Jun 21 '15 at 15:40

You just carry out the chain rule as you would normally. $$\frac{d}{dx}{\rm tr}\left[{A(x) \log A(x)}\right] = {\rm tr} [A'(x)\log A(x) + A(x)A^{-1}(x)A'(x)]$$ See here.

• Well this i like a lot since it is simple! So, i can just move the differential operation inside the trace then, $d(trX)=tr(dX)$? How about Bertrand R's previous comment/objection? – planckstars Jun 21 '15 at 16:21
• I don't understand why Bertrand R is getting all caught up in the technical details. Any diagonalizable square nonsingular matrix has a well defined principal log. – Victor Liu Jun 21 '15 at 16:23
• ok well thanks a lot to everyone; for the moment i am voting this up and unless it turns out not to be correct i am very happy with it! – planckstars Jun 21 '15 at 16:28
• Hmm, deriving the trace is indeed quite simple but I don't think deriving the log is that easy. My first guess would be that $\frac{d \;}{dx} \log A(x)=A(x)^{-1}A'(x)$ only if $A(x)$ and $A'(x)$ commute and in general it's not the case. So I don't think that works here. – Sylvain L. Jun 21 '15 at 16:29
• Because of the trace it works. But in general it is wrong to write $\log(A(x))' = A'(x)\log A(x) + A'(x)$. Anyway, my point was precisely to find out that the matrix was something, in this case diagonalizable and nonsingular. And it's not a "technical detail" – Bertrand R Jun 21 '15 at 16:42

We assume that $A(x)$ has no eigenvalues in $(-\infty,0]$ and $\log$ denotes the principal logarithm. Since $g(A)=\log(A)$ is a matrix function, (E): $\log(A)$ is a polynomial in $A$. Let $P$ be a polynomial and $f:x\rightarrow tr(P(A)\log(A))$. According to (E), $f'(x)=tr(P'(A)\log(A)A')+tr(P(A)Dg_A(A'))$.

Now $Dg_A(A')=\int_0^1(t(A-I)+I)^{-1}A'(t(A-I)+I)^{-1}dt$; then $tr(P(A)Dg_A(A'))=\int_0^{1}tr(P(A)(t(A-I)+I)^{-1}A'(t(A-I)+I)^{-1})dt=\int_0^{1}tr(P(A)(t(A-I)+I)^{-2}A')dt=tr(P(A)A'\int_0^1(t(A-I)+I)^{-2}dt)=tr(P(A)A'A^{-1})$.

Finally $f'(x)=tr((P'(A)\log(A)+P(A)A^{-1})A')$.