Suppose $~W~$ is an $~n \times n~$ matrix and $~x$,$~y~$ are $~n \times 1~$ vectors. Then define function $~f~$ as following:

\begin{equation} f=\left\|W\left(x-y\right)\right\|^{2} \end{equation} The question is what are $\frac{\partial f}{\partial W}$ and $\frac{\partial f}{\partial x}$?

  • 1
    $\begingroup$ idk, you tell me man $\endgroup$ – Sandeep Silwal Aug 17 at 4:47

Use chain rule and verify the following facts:

For Euclidean vector norm $\| \cdot \| : \mathbb{R^{n}} \to \mathbb{R}$:

$$ \frac{d \| \cdot \|}{d \mathbf{x}} = \frac{\mathbf{x}}{\|x\|} ; $$

For $f:\mathbb{R}\to \mathbb{R}$, $f(t) := t^2$ the derivative is: $$ \frac{d f(t) }{dt} = \frac{d t^2 }{dt} = 2t; $$

For $g:\mathbb{R^n}\to \mathbb{R^n}$, $~g(\mathbf{x}) := \mathbf{W}\mathbf{x}$:

$$ \frac{d g(\mathbf{x}) }{d\mathbf{x}} = \frac{d \mathbf{W}\mathbf{x} }{d\mathbf{x}} = \mathbf{W}; $$

For $h:\mathbb{R^{n\times n}}\to \mathbb{R^n}$, $~h(\mathbf{W}) := \mathbf{W}\mathbf{x}$:

$$ \frac{d h(\mathbf{W}) }{d\mathbf{W}} = \frac{d \mathbf{W}\mathbf{x} }{d\mathbf{W}} = \mathbf{x}^\top. $$


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.