<s>[INST] Distance from a set to a point There is this exercise I cannot understand well. It asks me for the distance between this set in $\mathbb{R}^3$ 
$$U = \{(x, y, z)\ |\ ax + y - 2z = 0, z = 0 \}$$
and the point $(0, b, 1)$. 
Also it tells me to say "what is that".
Any hint or help? 
 [/INST] This is a least-squares problem. Note that $U$ contains the origin and is parametrized by
$$\left\{ \gamma \begin{bmatrix} 1\\ -a\\ 0\end{bmatrix} : \gamma \in \mathbb R \right\}$$
The projection matrix that projects onto $U$ is
$$P := \begin{bmatrix} 1\\ -a\\ 0\end{bmatrix} \left(\begin{bmatrix} 1\\ -a\\ 0\end{bmatrix}^T \begin{bmatrix} 1\\ -a\\ 0\end{bmatrix}\right)^{-1} \begin{bmatrix} 1\\ -a\\ 0\end{bmatrix}^T = \frac{1}{1+a^2} \begin{bmatrix} 1 & -a & 0\\ -a & a^2 & 0\\ 0 & 0 & 0\end{bmatrix}$$
and the projection matrix that projects onto the orthogonal complement of $U$ is
$$I_3 - P = \frac{1}{1+a^2} \begin{bmatrix} a^2 & a & 0\\ a & 1 & 0\\ 0 & 0 & 1+a^2\end{bmatrix}$$
The Euclidean distance between $U$ and $y := \begin{bmatrix} 0\\ b\\ 1\end{bmatrix}$ is given by
$$\| (I_3 - P) y \|_2 = \left\|\frac{1}{1+a^2} \begin{bmatrix} a^2 & a & 0\\ a & 1 & 0\\ 0 & 0 & 1+a^2\end{bmatrix} \begin{bmatrix} 0\\ b\\ 1\end{bmatrix}\right\|_2 = \frac{1}{1+a^2} \left\| \begin{bmatrix} ab\\ b\\ 1+a^2\end{bmatrix} \right\|_2$$
</s>