The Matrix Cookbook says that:

$\frac{\partial}{\partial\mathbf{X}} Tr\{\mathbf{A}\mathbf{X}\mathbf{B}\} = \mathbf{A^T}\mathbf{B^T}$

I can't seem to get this. I know that:

$\frac{\partial}{\partial\mathbf{X}} Tr\{F(\mathbf{X})\} = f(\mathbf{A}\mathbf{X}\mathbf{B})^T$

Where $f$ is the scalar derivative of $F$.

So when I apply the rule: $\partial \mathbf{XY} = \partial \mathbf{X} \mathbf{Y} + \mathbf{X} \partial \mathbf{Y}$

I do:

Let: $\mathbf{C} = \mathbf{X}\mathbf{B}$

Then: $\mathbf{A}\mathbf{X}\mathbf{B} = \mathbf{A}\mathbf{C}$.

$\frac{\partial}{\partial\mathbf{X}} \mathbf{A}\mathbf{C} = \frac{\partial}{\partial\mathbf{X}} \mathbf{A} \mathbf{XB} + \mathbf{A} \frac{\partial}{\partial\mathbf{X}}\mathbf{X}\mathbf{B} = \mathbf{AB}$

But then:

$(\mathbf{AB})^{T} = \mathbf{B^TA^T} \neq \mathbf{A^{T}B^{T}}$

Am I confusing the notion of scalar derivative and matrix derivative? How can I verify the Cookbook's claim?

  • 1
    $\begingroup$ As a means of checking your answer, note that $$ Tr(AXB) = Tr(BAX) $$ $\endgroup$ – Omnomnomnom Mar 3 '17 at 23:19

The matrix inner product (denoted by a colon) is equivalent to the trace $$A^T:B = {\rm tr}(AB)$$

Therefore $$\eqalign{ f &= {\rm tr}(AXB) \cr &= {\rm tr}(BAX) \cr &= (BA)^T:X \cr &= A^TB^T:X \cr \cr df &= A^TB^T:dX \cr \cr \frac{\partial f}{\partial X} &= A^TB^T \cr }$$


I assume the domain is the space of $n\times n$-matrices $M(n,n)$. The function $f(X)=Tr(AXB)$ is a linear function $M(n,n)\rightarrow R$ since $f(X+Y)=Tr(A(X+Y)B)=Tr(AXB)+Tr(AYB)$. It is thus equal to its differential. To compute its matrix in the basis $e_{ij}$ where $e_{ij}$ is the matrix which has $1$ at the $(i,j)$-place ($i$ is the line and $j$ the column) and all other coefficients are zero.

$Tr(Ae_{ij}B)=Tr(ABe_{ij})$. The unique non zero coefficient on the diagonal of $ABe_{ij}$ is the $(j,j)$ coefficient which is the coefficient $(j,i)$ of $AB$ which is $\sum_ka_{jk}b_{ki}$ and this is the coefficient $(i,j)$ of $(AB)^T=B^TA^T$.


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.