Let's consider a point $x \in \mathbb{R}^n$ and a hypercube $H_n = \{y \in \mathbb{R}^n: a_i \le y_i \le b_i \}$, where $a_i < b_i, i = 1, 2, \ldots, n$ are fixed, real numbers.
I would like to find a way to project $x$ on $H_n$. How can it be done and why that way is correct? How can I check whether a projection truly is a projection?
By projection I mean "to the nearest point".
You can define the point $y$ inside the hypercube that is closest to a given point $x$ like this:
$y_i=\begin{cases}x_i<a_i:&a_i\\a_i≤x_i≤b_i:&x_i\\x_i>b_i:&b_i\end{cases}$