# How to differentiate trace of a quadratic function?

Some basic question about matrix calculus. Let $X$, $A$, $B$ be real matrices. Let $\operatorname{Tr}$ denote trace. Is $$\frac{d }{dX} \operatorname{Tr}(X^T A XB)$$ equal $(A+ A^T)XB$?

If not, How to compute it?

-
What exactly do you mean? Are you looking for the differenial $d_{X_0}\phi$ of the map $\phi:M_n(\mathbb R)\rightarrow \mathbb R,~X\mapsto \mathrm{Tr}(X^tAXB)$ at some point (i.e. matrix) $X_0$? If so, the answer will be a linear map from the matrices to the real numbers, not a matrix. You should proceed by steps. What is the differential of the matrix product inside the trace? What is the differential of the trace function? Then combine the two using the chain rule. – Olivier Bégassat Jul 7 '12 at 2:26
$\frac{d}{dX}$ is not notation that would universally make sense to mathematicians when $X$ is a matrix. That notation is only universally understood when $X$ takes numerical values. One reason for this is that $dX$ conceptually needs to be something "very small" that you could divide by; you cannot divide by matrices. – alex.jordan Jul 7 '12 at 7:21
I would disagree. The notation is fairly standard. – copper.hat Jul 7 '12 at 7:33

The derivative of $F:X\mapsto X^T A X B =: F(X)$ is $$D_V F (X) = V^TAXB+ X^TAVB$$ while the derivative of $Y\mapsto Tr(Y)$ is simply
$$D_V Tr(X)= Tr (V)$$ Hence the derivative of your function is $$D_V (Tr\circ F)(X) =DTr(F(X))D_VF(X) = Tr(V^TAXB+ X^TAVB)$$
Using the various trace identities, you could also write $\mathbb{tr}(V^TAXB+ X^TAVB) = \mathbb{tr}((AXB+A^T X B^T)^T V)$, which shows that the 'gradient' is $AXB+A^T X B^T$. – copper.hat Jul 7 '12 at 7:53