Suppose $S = \{x \in \mathbb{R}^n : \Vert x \Vert \leq 1\}$. Find the projection of a point to $S$, so find the shortest distance subject to the unit disk. That is we need to solve the following problem
min $\frac{1}{2} \Vert x - x_0 \Vert^2$
s.t $\Vert x \Vert^2 - 1 = 0$
So doing the work I got
$\nabla \frac{1}{2} \Vert x - x_0 \Vert^2 = \lambda\nabla (\Vert x \Vert^2 - 1) \implies x - x_0=\lambda (2x)$. And I need to solve
$\left\{\begin{matrix} x - x_0=\lambda (2x) \\ \Vert x \Vert^2 - 1 = 0 \end{matrix}\right.$
Now apparently the answer is
$P_s(x_0)= \left\{\begin{matrix} \frac{x_0}{\Vert x_0 \Vert} & \Vert x_0\Vert > 1\\ x_0 & \Vert x_0 \Vert \leq 1 \end{matrix}\right.$
I am having problems solving the set of equations (I honestly lost track of which is the variable and parameter)