TITLE: Proximal Mapping of Least Squares with $ {L}_{1} $ and $ {L}_{2} $ Norm Terms Regularization (Similar to Elastic Net)
QUESTION [6 upvotes]: I was trying to solve 
$$\min_x \frac{1}{2} \|x - b\|^2_2 + \lambda_1\|x\|_1 + \lambda_2\|x\|_2,$$ 
where $ b \in \mathbb{R}^n$ is a fixed vector, and $\lambda_1,\lambda_2$ are fixed scalars. Let $f = \lambda_1\|x\|_1 + \lambda_2\|x\|_2$, that is to say my question is how to find out the proximal mapping of $f$.  It formulates as
$$\begin{equation}
prox_f(b)=arg\min_x\{ \frac{1}{2}\|x - b\|_2 + \lambda_1\| x \|_1 + \lambda_2\| x \|_2 \}.
\label{eq1}
\end{equation}$$
There are two ways to get proximal mapping of $l_2$-norm and $l_1$-norm respectively.
For $l_1$-norm, soft threshold operator was given in
Derivation of soft threshold operator.
For $l_2$-norm, block soft threshold was given in 
deriving block soft threshold from l2 norm.
EDIT: I got stuck to find the subgradient of the object function. I followed above-mention methods to solve my problem. The subgradient of original target shows as,
$$\begin{equation}
0 \in x - b + \lambda_1 \partial \|x\|_2 + \lambda_2 \partial \|x\|_1.
\label{eq2}
\end{equation}$$
I guess that it should be discussed for different conditions:

If $x = 0$, then $\partial \|x\|_1 = \{g: g_i \in [-1,1]\}$ and $\partial \|x\|_2 = \{g: \|g\|_2 \leq 1\}$, where $g_i$ denotes $i$th element of $g$. Thus, I got 
$$
0\in \lambda_1 \{g: g_i \in [-1,1]\} + \lambda_2 \{g:\|g\|_2 \leq 1 \} - b
\\ \Leftrightarrow b \in \lambda_1 \{g: g_i \in [-1,1]\} + \lambda_2 \{g:\|g\|_2 \leq 1 \}.
$$
It implies that for $\|b\|_2 < \lambda_2$ or for all $|b_i|_1 < \lambda_1$, the optimal condition is $x = 0$.
If $x \neq 0$, then $\partial \|x\|_2 = x/\|x\|_2$, and the optimal is 
$$
b \in \lambda_1 \partial \|x\|_1 + \lambda_2 \frac {x}{\|x\|_2} + x.
$$
If $x_i = 0$, then $\partial |x_i|= sgn(x_i)$, where $sgn(x_i)$ takes the sign of $x_i$. I guess that it also should be discussed the conditions that whether or not $x_i = 0$ by each component. But the question is that I don't know how to discuss. The reason is that $x_i$ is restricted by $\|x\|_2$, and each dimension cannot be separated. 

I would really appreciate help on solving my problem. Thanks very much.

REPLY [6 votes]: Edit: Closed-form solution for prox of L1 + L2 norm
By first-order optimality conditions,
$$
\begin{split}
p = \operatorname{prox}_{\lambda_1\|.\|_1 + \lambda_2\|.\|_2}(a) &\iff a - p \in \partial (\lambda_1\|.\|_1 + \lambda_2\|.\|_2)(p)\\
 &\iff a - p = \lambda_1 u + \lambda_2 v,\;\text{for some }(u,v) \in \partial \|.\|_1(p) \times \partial \|.\|_2(p),
\end{split}
$$
Now, it's a classical computation that for any norm $\|.\|$, one has
$$\partial \|.\|(p) = \{z | \|z\|_* \le 1,\; p^Tz = \|p\|\},
$$
where $\|z\|_* := \max_{w, \|w\| \le 1} z^Tw$ defines the dual norm. In particular, one has
$$
\partial \|.\|_2(p) = \begin{cases}\{z | \|z\|_2 \le 1\},&\mbox{ if }p = 0,\\ p/\|p\|_2,&\mbox {else},
\end{cases}
$$
and by separability, $\partial \|.\|_1(p) = \times_{i=1}^n \partial |.|(p_i)$, with
$$
\partial |.|(p_i) = \begin{cases}[-1,1],&\mbox{ if }p_i = 0,\\ \operatorname{sign}(p_i),&\mbox {else}.
\end{cases}
$$
The rest of the computation is basic algebra and can be read-off page 6 of the paper - A Sparse Group Lasso:
$$
p = (1 - \lambda_2 / \|\operatorname{ST}_{\lambda_1}(a)\|_2)_+\operatorname{ST}_{\lambda_1}(a) = \operatorname{prox}_{\lambda_2 \|.\|_2}\left(\operatorname{prox}_{\lambda _1\|.\|_1}(a)\right),
$$
where ST is the element-wise soft-thresholding operator.
Bonus
OK, now if you've used to playing with proximal operators you should fall off your chair at this point! The prox of the sum of those two norms is just the composition of the respective proximal operators, in a percular order (the prox of the L2 norm is applied last). Behold, the following lemma gives a sufficient condition for such a phenomenon to occur.
Lemma [Theorem 1 of the paper On Decomposing the Proximal Map]. Let $f$ and $g$ be convex l.s.c functions on a Hilbert space $\mathcal H$. A sufficient condition for (A) $\operatorname{prox}_{f + g} = \operatorname{prox}_f \circ \operatorname{prox}_g$ is that (B) $\partial g(\operatorname{prox}_f(p)) \subseteq \partial g(p)\; \forall p \in \mathcal H$.
The OP's problem is then a special case with $f = \lambda_1 \|.\|_1$ and $g = \lambda_2\|.\|_2$.