Analytical Solution to a simple l1 norm problem Can we solve this simple optimization problem analytically?
$ \min_{w}\dfrac{1}{2}\left(w-c\right)^{2}+\lambda\left|w\right| $
where c is a scalar and w is the scalar optimization variable.

Set $f(w)=\frac{1}{2}(w-c)^2+\lambda |w|$, equal to $\frac{1}{2}(w-c)^2\pm\lambda w$.  We find $f'(w)=w-c\pm \lambda$.  Setting this to zero gives $c\pm \lambda$ as the only critical values of $f$.  As $w$ gets large, $f(w)$ grows without bound, so the minimum is going to be at one of the two critical values.  At those values, we have $f(c+\lambda)=\frac{\lambda^2}{2}+\lambda|c+\lambda|$, and $f(c-\lambda)=\frac{\lambda^2}{2}+\lambda|c-\lambda|$.  Which one is minimal depends on whether $c,\lambda$ are the same sign or different signs.
Also need to compare with $f(0)=\frac{c^2}{2}$, $f$ is nondifferentiable there.
