TITLE: Efficient Way to Evaluate the Proximal Operator of $ f \left( x \right) = {\left\| x \right\|}_{2} + {I}_{\geq 0} \left( x \right) $
QUESTION [5 upvotes]: Is there an efficient way to evaluate the proximal operator of the function $f:\mathbb R^n \to \mathbb R \cup \{ \infty \}$ defined by
\begin{equation}
f(x) = \| x \|_2 + I_{\geq 0}(x),
\end{equation}
where $I_{\geq 0}$ is the indicator function of the nonnegative orthant:
\begin{equation}
I_{\geq 0}(x) = \begin{cases} 0 & \quad \text{if } x \geq 0,\\
\infty & \quad \text{otherwise.}
\end{cases}
\end{equation}
(The inequality $x \geq 0$ is interpreted componentwise.)
In other words, given $\hat x \in \mathbb R^n$, is there an easy way to solve the optimization problem
\begin{align}
\text{minimize} & \quad \|x\|_2 + \frac{1}{2} \| x - \hat x \|_2^2 \\
\text{subject to} & \quad x \geq 0.
\end{align}
The variable in this optimization problem is $x \in \mathbb R^n$.
Ideally I'd like a closed-form solution to this optimization problem, or else a way to compute the solution extremely quickly (without having to rely on an iterative algorithm).
Thoughts: the term $\| x \|_2$ doesn't depend on the direction of $x$.  If not for the nonnegativity constraints on $x$, we would pick $x$ to point in the same direction as $\hat x$, which simplifies the optimization problem enough that we can now solve it easily.  Perhaps there's a similar way to think about the problem when we have nonnegativity constraints on $x$.

REPLY [2 votes]: I think there is a simple way to look at it without using duality.
Our goal is to find the minimizer for the problem
\begin{align}
\tag{$\spadesuit$} \text{minimize} & \quad \| x \|_2 + \frac{1}{2t} \| x - \hat x \|_2^2 \\
\text{subject to} & \quad x \geq 0.
\end{align}
First note that if $\hat x_i <  0$, then there is no benefit from
taking $x_i$ to be positive.  If $x_i$ were positive, then both terms in the objective could be reduced just by setting $x_i = 0$.
It remains to select values for the other components of $x$.
This is a smaller optimization problem, with one unknown for
each positive component of $\hat x$.  The negative components
of $\hat x$ are irrelevant to the solution of this reduced problem.
Thus, we would still arrive at the same final answer if the negative
components of $\hat x$ were set equal to $0$ at the very beginning.
In other words, problem ($\spadesuit$) is equivalent to the problem
\begin{align}
\text{minimize} & \quad \| x \|_2 + \frac{1}{2t} \| x - \max(\hat x ,0)\|_2^2 \\
\text{subject to} & \quad x \geq 0,
\end{align}
which in turn is equivalent to the problem
\begin{align} \text{minimize} & \quad \| x \|_2 + \frac{1}{2t} \| x - \max(\hat x ,0)\|_2^2 
\end{align}
(because there would be no benefit from taking any component of $x$ to be negative).
This shows that $\text{prox}_{tf}(\hat x) = \text{prox}_{t \| \cdot \|_2}(\max(\hat x, 0))$.