Matrix derivative w.r.t time $\frac{d}{dt}\|A-X(t)\|^2=2\operatorname{tr}\big((X-A)\dot{X}\big)$

87 Views Asked by At

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

  1. $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)$$

2

There are 2 best solutions below

5
On BEST ANSWER

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!

Note: As elucidated in the comment by @mattos, the result can be obtained using inner product notatation. We could have begun by writing $||A-X(t)||^2=\langle A-X(t),A-X(t)\rangle$. Upon differentiating, we obtain $$\frac{d}{dt}||A-X(t)||^2=\langle X(t)-A,X'(t)\rangle +\langle X'(t),X(t)-A\rangle=2\text{tr}\left(A-X(t),X'(t)\right)$$as expected!

1
On

For a moment, consider the case where $X,\dot{X},A\in{\mathbb R}^{m\times n}$

Then your assumed answer cannot possibly be correct since the product $$(X-A)\dot{X}$$ has incompatible dimensions.

Several posters have suggested working with the inner product (which I'll denote by a colon).
If you follow that suggestion you obtain $$\eqalign{ f &= (X-A):(X-A) \cr\cr df &= 2(X-A):dX \cr &= 2(X-A):\dot{X} dt \cr\cr \frac{df}{dt} &= 2(X-A):\dot{X} \cr &= 2\operatorname{tr}\big((X-A)^T\dot{X}\big) \cr\cr }$$ This result is correct for the rectangular $(m\times n)$ case and also when $(m=n)$.

If you're sure that your assumed answer is correct, then perhaps you forgot to mention that $X$ is symmetric?