Are the following matrix derivations correct? What are the involed rules?

39 Views Asked by At

Are the following two derivations correct?

$$ \nabla_{\mathbf{w}}\mathbf{w}^T\mathbf{w} = 2 \mathbf{w} $$

$$ \nabla_{\mathbf{w}} ||\mathbf{y}-\mathbf{X}\mathbf{w}||_2^2 = 2\mathbf{X}^T(\mathbf{y}-\mathbf{X}\mathbf{w}) $$

(I assume that $\mathbf{y}$ and $\mathbf{X}$ are not functions of $\mathbf{w}$)

What are the rules involed to solve these problems?

1

There are 1 best solutions below

0
On BEST ANSWER

Let $$M=Xw-y$$Then use the Frobenius Inner Product to write the function and its differential $$\eqalign{ f &= M:M \cr df &= 2\,M:dM \cr &= 2\,M:X\,dw \cr &= 2\,X^TM:dw \cr }$$ Since $df=\big(\frac{\partial f}{\partial w}:dw\big),\,$ the gradient must be $$\eqalign{ \frac{\partial f}{\partial w} &= 2\,X^TM \cr &= 2\,X^T(Xw-y) \cr\cr }$$ Frobenius products can be rearranged in a variety of ways $$\eqalign{ A:BC &= AC^T:B \cr &= B^TA:C \cr &= A^T:(BC)^T \cr &= BC:A \cr &= {\rm tr}(A^TBC) \cr }$$ all of which can proved directly, or by using the trace-equivalence and the cyclic property of the trace.