Derivative of a trace with relation to a vector inside a kronecker product I'm trying to obtain the derivative wrt $\beta$ in
$\textrm{Tr}(A(I_n \otimes \beta)B(I_n \otimes \beta))$.
I've tried to follow the same procedure as this question Derivative of a trace with second order Kronecker product
but I'm confused. I've tried to make
$X^\top A^\top : BX$
by taking $X = (I_n \otimes \beta)$ but I couldn't go further than this.
Any thoughts?
 A: Though not the most elegant solution, here is one that gives the derivative with respect to the vectorized version of beta using the standard text book result $${\rm Tr}\{A X B X^{\rm T} C^{\rm T}\} = {\rm vec}\{X\}^{\rm T} \cdot \left(B^{\rm T} \otimes (C^{\rm T} A) \right) \cdot {\rm vec}\{X\}.$$ Applied to your problem, this gives $${\rm Tr}\{A (I_n \otimes \beta) B (I_n \otimes \beta) \} = {\rm vec}\{I_n \otimes \beta\}^{\rm T} \cdot \left(B^{\rm T} \otimes  A \right) \cdot {\rm vec}\{(I_n \otimes \beta)^{\rm T}\}.$$ Next, use the fact that ${\rm vec}\{X^{\rm T}\} = K_{m,n}^{\rm T} \cdot {\rm vec}\{X\}$, for any $X$ of size $m \times n$ where $K_{m,n}$ is the commutation matrix so that we have $${\rm Tr}\{A (I_n \otimes \beta) B (I_n \otimes \beta) \} = {\rm vec}\{I_n \otimes \beta\}^{\rm T} \cdot \left(B^{\rm T} \otimes  A \right) \cdot K_{n,n}^{\rm T} \cdot {\rm vec}\{I_n \otimes \beta\}.$$ Then, use the fact that we can write ${\rm vec}\{I_n \otimes X\} = (P\otimes I_n) \cdot {\rm vec}\{X\}$, where $P = [(I_n \otimes e_{n,1})^{\rm T}, \ldots, (I_n \otimes e_{n,n})^{\rm T}]^{\rm T}$. This gives $${\rm Tr}\{A (I_n \otimes \beta) B (I_n \otimes \beta) \} = {\rm vec}\{\beta\}^{\rm T}\cdot (P^{\rm T} \otimes I_n) \cdot \left(B^{\rm T} \otimes  A \right) \cdot K_{n,n}^{\rm T} \cdot (P \otimes I_n) \cdot {\rm vec}\{ \beta\}.$$ Finally, we have $\frac{\partial}{\partial q} q^T X^{\rm T} q = (X + X^{\rm T}) q$, wich gives something like $$\frac{\partial}{\partial {\rm vec}\{\beta\}} {\rm Tr}\{A (I_n \otimes \beta) B (I_n \otimes \beta) \} = (P^{\rm T} \otimes I_n) \cdot [\left(B^{\rm T} \otimes  A \right) \cdot K_{n,n}^{\rm T}+K_{n,n} \left(B \otimes  A^{\rm T} \right) ] \cdot (P \otimes I_n) \cdot {\rm vec}\{ \beta\}.$$
Yeah. Not the most elegant solution, as I said.
A: Let's follow through on your idea and take
$$X = I\otimes\beta$$
then you can write the cost function in two equivalent ways
$${\cal J} = X^TA^T:BX = X^TB^T:AX$$
Both are needed to calculate the differential of the function.
$$\eqalign{
d{\cal J}
 &= X^TA^T:B\,dX + X^TB^T:A\,dX \\
 &= (B^TX^TA^T + A^TX^TB^T):dX \\
 &= G:dX \\
 &= G:(I\otimes d\beta) \\
}$$
Now use the same procedure as in the linked question.
$$\eqalign{
G &= \sum_{k=1}^{r} \sigma_k u_k v_k^T,\qquad r={\rm rank}(G) \\
}$$
$$\eqalign{
d{\cal J} &= \sum_{k=1}^{r} \sigma_k u_k v_k^T:(I\otimes d\beta) \\
 &= \sum_{k=1}^{r} \sigma_k u_k:(I\otimes d\beta)\,v_k \\
 &= \sum_{k=1}^{r} \sigma_k u_k:{\rm vec}(d\beta\,v_k^T) \\
 &= \sum_{k=1}^{r} \sigma_k U_k:d\beta\,v_k^T \\
 &= \sum_{k=1}^{r} \sigma_k U_kv_k:d\beta \\
\frac{\partial{\cal J}}{\partial\beta}
 &= \sum_{k=1}^r \sigma_k U_k v_k^T
}$$
where
$$\eqalign{
U_k = {\rm Mat}(u_k) \quad\iff\quad u_k = {\rm vec}(U_k)
}$$
Or you could also skip the SVD and use the component form
of the gradient described in the lower half of the linked question.
Which is
$\big($assuming $\;\beta\in{\mathbb R}^{m\times 1}\big)$
given by
$$\eqalign{
\frac{\partial{\cal J}}{\partial\beta_k} &= \sum_{j=1}^n G_{(jm-m+k)\,(j)}
}$$
