1

In this answer Derivation of soft thresholding operator how can I derive that $\nabla(||x-b||_2^2)=b-x$?

volperossa
  • 239
  • 1
  • 3
  • 9

2 Answers2

2

$\nabla(||x-b||_2^2)=b-x$

Proof:
$\nabla(||x-b||_2^2) = \nabla(||b-x||_2^2) = \nabla[(x-b)^T(x-b)] = \nabla[(x^T-b^T)(x-b)] = \nabla[x^Tx-x^Tb-b^Tx-b^Tb] = 2x-b-b=2(x-b)$

  1. I think there should be $2$ there.
  2. I think $x$ should be positive since whatever you expand it, $x^x$ must be positive.

You can see the following vedio: (a similar derivation)

https://www.youtube.com/watch?v=jbdyR7ESOh4&list=PL7y-1rk2cCsDOv91McLOnV4kExFfTB7dU&index=6

(roughly around 40:00)

sleeve chen
  • 8,576
2

The following fact will be helpful in your problem.

$$\frac{\partial}{\partial {\bf x}}||{\bf x}||_2^2 = \frac{\partial}{\partial {\bf x}}||{\bf x}^T{\bf x}||_2 = 2{\bf x}$$

To obtain the above result (namely the last equality), write the definition of the $2$-norm of ${\bf x}^T{\bf x}$ and differentiate wrt to each $x_i$. Now, just replace ${\bf x}$ with ${\bf x}-{\bf a}$ and carefully step through the process again to obtain $\frac{\partial}{\partial {\bf x}}||{\bf x}-{\bf a}||_2^2$.

Erik M
  • 2,441