# Derivative of matrix products

Let $a\in\mathbb{R}^{1\times2}, X\in\mathbb{R}^{2n\times 2m}$, and $b\in\mathbb{R}^{2m}$. How can I calculate

$$\frac{\partial[(a\otimes I_n)Xb]}{\partial X}$$

where $\otimes$ denotes the Kronecker product?

You can apply the formula $\dfrac{\partial AXB}{\partial X} = B^T \otimes A$ for $A = a \otimes I_n$ and $B=b$. Then $$\dfrac{\partial[(a\otimes I_n)Xb]}{\partial X} = b^T \otimes (a\otimes I_n) \ .$$

• Thanks, but I don't think your formula is correct for general $A,B$, and $X$ matrices. Do you know any reference for that formula? – krms Mar 9 '17 at 14:27
• Yes, you can see at the book "Matrix Algebra: Theory, computations, and applications in statistics" of James E. Gentle. – mathJuan Mar 9 '17 at 15:30
• Thanks. I saw the reference. There is another formula which I beleive is correct but not consistent with this formula: $\frac{\partial a^{\rm T}Xb}{X}=ab^{\rm T}$, which is not equal to $b^{\rm T}\otimes a^{\rm T}$. I guess there is a mistake here because dimensions do not work. – krms Mar 10 '17 at 16:39

Let linear function $\mathrm f : \mathbb R^{m \times n} \to \mathbb R^p$ be defined by

$$\mathrm f (\mathrm X) := \mathrm A \mathrm X \mathrm b$$

Vectorizing, we obtain a $\mathbb R^{m n} \to \mathbb R^p$ linear function in $\mbox{vec} (\mathrm X)$

$$\mbox{vec} (\mathrm A \mathrm X \mathrm b) = \left( \color{blue}{\mathrm b^{\top} \otimes \mathrm A} \right) \mbox{vec} (\mathrm X)$$

where $\mathrm b^{\top} \otimes \mathrm A$ is the $p \times m n$ Jacobian matrix of the $\mathbb R^{m n} \to \mathbb R^p$ function.