How do I solve the following for x?
$$ 0 = x-b+\lambda\frac{x}{|x|} $$
I'm trying to minimize $$f(x) = \frac{1}{2}(x-b)^2 + \lambda|x|$$ I took the derivative and now I'm trying to set it to $0$ and solve. It's a pen-and-paper question so I can't turn it into a quadratic program and feed it into a solver. I think the solution is something like $x = b \pm \lambda$ but I can't quite get there.
Use definition $$|x| =\begin{cases}x ,\ \ \ \text{if}\ \ x \geq 0 \\ -x ,\text{if}\ \ \ x < 0\end{cases}$$
Then you'll have $$\frac{x}{|x|} =\begin{cases}1 ,\ \ \ \text{if}\ \ x >0 \\ -1 ,\text{if}\ \ \ x < 0\end{cases} $$