Projection onto the second-order cone I'm having difficulties in proving that the projection of $$(s,y)\in R \times R^{n}$$ onto the second-order cone $$Q^{n+1} = \{(t,x) \in R \times R^n : \|x\|_2 \leq t \}$$ is $$ \frac{s+\|y\|_2}{2\|y\|_2} (\|y\|_2,y)$$ when $\|y\|_2 > s $ and $ \|y\|_2 > -s  $.
I tried to first show that to minimize the distance, $x$ must be parallel to $y$, then I construct $$\alpha (\|y\|_2 + \epsilon,y)$$ and minimize the distance over $\alpha$ and $\epsilon$.
I indeed come up with two quadratic functions individually attains its minimum when $$\epsilon = 0$$ and $$\alpha = \frac{s+\|y\|_2}{2\|y\|_2}$$ but  I still have $$-\frac{s^2(\|y\|_2+\epsilon)}{2\|y\|_2} - \frac{{\|y\|_2}^3}{2\|y\|_2 + \epsilon}$$ which attains its maximum when $$\epsilon = 0$$ As a result, I can't say the distance attains its minimum accordingly.
Is there any other method or elementary method to prove the optimal solution is $$ \frac{s+\|y\|_2}{2\|y\|_2} (\|y\|_2,y)$$ when $\|y\|_2 > s $ and $ \|y\|_2 > - s  $ ?
 A: In an elementary point of view, usually we use the method of Lagrangian function. The projection can be considered as a optimization problem:
$$\min_{(x,s)} \frac{1}{2}\|x-y\|_2^2+\frac{1}{2}(s-t)^2\quad s.t.\quad \|x\|_2^2\leq s.$$
The Lagrangian function of this problem is 
$$l(x,s,\lambda) = \frac{1}{2}\|x-y\|_2^2+\frac{1}{2}(s-t)^2-\lambda(\|x\|_2^2-s^2).$$
And then we consider its KKT system (Compute the gradient of $l$ with respect to $x$ and $s$, then let the gradients equal to zeros):
$$x-y-2\lambda x=0,\quad s-t+2\lambda s=0.$$
Which is 
$$x = \frac{y}{1-2\lambda},\quad s = \frac{t}{1+2\lambda}.$$
Now putting the above equations into the Lagrangian function $l(x,s,\lambda)$, and compute the gradient w.r.t. $\lambda$, letting it to be 0, then we get 
$$\frac{1}{1-2\lambda} = \frac{\|y\|_2+t}{2\|y\|_2},$$
which gives the results.
A: Let $(t^*,x^*)$ be the projection.
The optimality condition implies that for any $(t,x) \in Q^{n+1}$ we must have
$$\langle(t-t^*, x-x^*), (s-t^*, y-x^*)\rangle \le 0.$$
Applying this inequality to $(t,x)=(0,0)$ and $(t,x) = 2(t^*,x^*)$ shows that in particular we have
$$\langle(t^*, x^*), (s-t^*, y-x^*)\rangle = 0\tag{1}$$
and consequently, the first inequality can be rewritten as
$$\langle(t,x), (s - t^*, y - x^*)\rangle \le 0.\tag{2}$$
These last two lines actually characterize $(t^*,x^*)$. That is, $(t^*,x^*)$ is the unique element of $Q^{n+1}$ satisfying both (1) and (2).
Note that $(s-t^*, y -x^*) = \frac{\|y\|_2 - s}{2} (-1, y/\|y\|_2)$.
From here (1) is easily verified.
To verify $2$, note that the left-hand side is
$$\frac{\|y\|_2 - s}{2} (-t + x^\top y / \|y\|_2),$$
and the first term is positive by the assumption $\|y\|_2 > s$,
and the second term is nonpositive by Cauchy-Schwarz and the definition of $Q^{n+1}$.
