Let $H$ be a Hilbert space and $\{ e_i\}_{i\in \mathbb N}$ be an orthonormal system. Let $B = \{x \in \mathrm{span} \{ e_i\} : \Vert x \Vert \leq 1 \}$.
I was able to show that for any $y\in H$, there exists unique $z \in \overline{B}$ that minimizes $\Vert y-z \Vert$. For existence, we can give a Cauchy sequence $z_n$ whose norm converges to $\inf_{w \in B} \Vert w-y \Vert$; and take its limit as $z$. For uniqueness, if there are two distinct $z_1, z_2$ that minimizes the distance, we can take $z_3 = (z_1+z_2)/2$ to contradict the minimality.
Now what I am curious about is actual representation of $z$ (in terms of $e_i$'s), and whether $z \in B$. I think that $$z = \sum \langle y/\Vert y \Vert, e_i \rangle e_i$$ and $z \in B$. However, I cannot give a proof about it. (I figured out that $z \in B$ using Bessel's inequality, but no more.) Am I correct with the representation of $z$?
Thank you for any form of help, hint, or solution.
What you guessed is close, but not exactly what it should be. There are two problems with your guess. One is that when $y\in\overline B$, dividing by the norm worsens the distance because $z=y$ already works. And when $y$ is not in $\overline B$, what you are missing is that there might be a part of $y$ that is orthogonal to $\overline B$ and thus plays no role (this are the $\alpha_k$ below).
Because $\{e_i\}$ is an orthonormal basis for $\def\spann{\operatorname{span}}\overline\spann B$, any element $w\in\overline B$ can be written as $$w=\sum_j\beta_j\,e_j$$ with $\sum_j|\beta_j|^2\leq1$. If we complete $\{e_j\}$ to an orthonormal basis $\{e_j\}\cup\{f_k\}$ of $H$, we can write $$ y=\sum_k\alpha_k\,f_k+\sum_j\gamma_j\,e_j,\qquad\qquad\sum_k|\alpha_k|^2+\sum_j|\gamma_j|^2=\|y\|^2. $$ Then \begin{align} \|y-w\|^2&=\sum_k|\alpha_k|^2+\sum_j|\gamma_j-\beta_j|^2\\[0.2cm] &=\sum_k|\alpha_k|^2+\sum_j|\gamma_j|^2+\sum_j|\beta_j|^2-2\operatorname{Re}\beta_j\overline{\gamma_j}\\[0.2cm] &=\|y\|^2+\|w\|^2-2\operatorname{Re}\beta_j\overline{\gamma_j}\\[0.2cm] &\geq\|y\|^2+\|w\|^2-2\|w\|\,\Big(\sum_j|\gamma_j|^2\Big)^{1/2}. \end{align} If $\sum_j|\gamma_j|^2\leq1$, then $w=\sum_j\gamma_j\,e_j\in\overline B$ and $\|y-w\|^2=\sum_k|\alpha_k|^2$ is minimum. If instead $\sum_j|\gamma_j|^2>1$, we notice that the inequality we used is Cauchy-Schwarz, and equality in Cauchy-Schwarz happens with both vectors are multiples of each other. Hence the minimum happens when $$ w=\lambda\sum_j\gamma_j\,e_j. $$ for some $\lambda>0$. Hence we get $\beta_j=\lambda\gamma_j$ for all $j$, and this forces the condition $$ 1\geq\sum_j|\beta_j|^2=\lambda^2\,\sum_j|\gamma_j|^2. $$ That is, $$ \lambda\leq\frac1{\Big(\sum_j|\gamma_j|^2\Big)^{1/2}}<1. $$ The expression to be minimized is now $$ \|y-w\|^2=\sum_k|\alpha_k|^2+\sum_j|\gamma_j|^2\,(1-\lambda)^2, $$ which will be minimum when $1-\lambda$ is maximum. That is, the minimum is achieved when $$ \lambda=\frac1{\Big(\sum_j|\gamma_j|^2\Big)^{1/2}}. $$ In other words, $$ z=\frac1{\Big(\sum_j|\gamma_j|^2\Big)^{1/2}}\,\sum_j\gamma_j\,e_j $$
So, to summarize, if $\sum_j|\gamma_j|^2\leq1$, then the minimizer is $$z=\sum_j\gamma_j\,e_j.$$ And when $\sum_j|\gamma_j|^2>1$, the minimizer is $$ z=\frac1{\Big(\sum_j|\gamma_j|^2\Big)^{1/2}}\,\sum_j\gamma_j\,e_j $$