Moreau envelope of the Euclidean norm (source code)

= Moreau envelope of the Euclidean norm
{c}
{title2=$f_\tau(x)=\begin{cases}\|x\|_2^2/(2\tau),&\|x\|_2\leq\tau,\\\|x\|_2-\tau/2,&\|x\|_2>\tau.\end{cases}$}

For $r=\|x\|_2$, the <Moreau envelope> of the <Euclidean norm> is $r^2/(2\tau)$ when $r\leq\tau$ and $r-\tau/2$ otherwise. Its gradient is $x/\tau$ in the core and $x/r$ outside. The approximation error is between zero and $\tau/2$.