Assume $A$ and $B$ are $n \times n$ matrices and $x$ is $n \times 1$.
If $B=f(x)$ then how should I calculate the following gradient?
$$\nabla_x \mbox{tr} (AB)$$
Or, maybe $\nabla_{x_i} \mbox{tr} (AB)$?
Assume $A$ and $B$ are $n \times n$ matrices and $x$ is $n \times 1$.
If $B=f(x)$ then how should I calculate the following gradient?
$$\nabla_x \mbox{tr} (AB)$$
Or, maybe $\nabla_{x_i} \mbox{tr} (AB)$?
Copyright © 2021 JogjaFile Inc.
Let $a={\rm vec}(A^T)$ and $b={\rm vec}(B)$, then your scalar function can be written as $$s = {\rm tr}(AB) = a^Tb$$ and the differential as $$ds = a^T\,db = a^T\,\Big(\frac{\partial b}{\partial x^T}\,dx\Big)$$ and the gradient $$\frac{\partial s}{\partial x^T} = a^T\,\frac{\partial b}{\partial x^T}$$