My question is just how to derive this equality?
$$\frac{d}{dt}\|A-X(t)\|^2=2\operatorname{tr}\big((X-A)\dot{X}\big)$$
where
- $A, X\in \mathbb{R}^{n\times n}$
In particular, how to obtain the matrices trace product term?
It seems there are three levels chain rule, one for square, one for norm and then $X(t)$
I just know the following: $$\nabla_x \|Ax-b\|^2=2A^T(Ax-b)$$
Let's use the $L^2$ norm as an example. Then, we have
$$\begin{align} ||A-X(t)||^2&=\sum_{i,j}|A_{ij}-X_{ij}(t)|^2\\\\ &=\sum_{i,j}(A^2_{ij}-2A_{ij}X_{ij}(t)+X^2_{ij}(t)) \end{align}$$
Differentiating $(1)$ we obtain
$$\begin{align} \frac{d}{dt}||A-X(t)||^2&=\sum_{i,j}(-2A_{ij}X'_{ij}(t)+2X_{ij}X_{ij}'(t))\\\\ &=2\sum_{ij}(X_{ij}(t)-A_{ij})X'_{ij}(t)\\\\ &=2\sum_{ij}(X_{ij}(t)-A_{ij})(X'_{ji})^T(t)\\\\ &=2\,\text{tr}\left((X(t)-A)X'(t)\right) \end{align}$$
as was to be shown!