Simple matrix derivative identity

928 Views Asked by At

Is the following correct, and is there some kind of similar identity when $x$ and $y$ are matrices?

For $A \in \mathbb{R}^{n \times n}$, $\nabla_A x^T A y = x y^T$.

And my proof:

$\frac{\partial}{\partial A_{i j}} x^T A y = \frac{\partial}{\partial A_{i j}} \sum_{k_1 = 1}^n \sum_{k_2 = 1}^n x_{k_1} A_{k_1 k_2} y_{k_2} = x_i y_j$.

The motivation is the following identity which is also similar but not directly applicable:

For $A \in \mathbb{R}^{m \times n}, B \in \mathbb{R}^{n \times n}, C \in \mathbb{R}^{m \times m}$, $\nabla_A \text{tr} A B A^T C = C A B + C^T A B^T$.

2

There are 2 best solutions below

0
On

By product rule you obtain the derivative (for any $H\in\mathbb R^{m\times n}$) \begin{align} D_A \operatorname{tr}(ABA^T C)[H] &= \operatorname{tr}(ABH^T C) + \operatorname{tr}(HBA^T C) \\ &= \operatorname{tr}(H^T CAB) + \operatorname{tr}(BA^T C H) \\ &= \operatorname{tr}(H^T CAB) + \operatorname{tr}(H C^T A B^T) \\ &= \operatorname{tr}(H^T (CAB + C^T A B^T)). \end{align} Thus, $\nabla_A \operatorname{tr}(ABA^T C) = CAB + C^T A B^T$.

0
On

Define $F(A)=x^TAy$. Observe that $F$ is linear with respect to $A$. Then $$ F'(A)H = x^T\ H \ y. $$ The gradient of $F$ with respect to the inner produce $\langle A, B\rangle = tr(A^TB)$ is has to satisfy $$ F'(A)H = \langle \nabla F(A),H\rangle. $$ Now $$ F'(A)H = x^TH y = \sum_{i,j=1}^n h_{ij} x_i y_j =tr(H \cdot (xy^T)^T ) $$ which shows the desired identity $\nabla F(A) = xy^T$.