Distance between line and plane in $\mathbb{R}^4$ If I know coordinates of a line, for example $(a,b,c,d)$ and $(e,f,g,h)$ and coordinates of a plane $(a_{1},b_{2},c_{2},d_{2}),(e_{2},f_{2},g_{2},h_{2}),(i,j,k,l)$, How can I find the shortest distance between line and plane in euclidean space $\mathbb{R}^4$? Any hints?
 A: The distance between the two sets (line and plane) is obtained as the minimal distance between any pair of points of the sets. So when you have a line, say $a + \lambda b$, and a plane, say $c + \mu d + \tau e$, you have an extremal problem 
$$d = \min_{\lambda, r, s} \| (a + \lambda b) - (c + \mu d + \tau e) \|.$$
Note that this can be a little bit simplified because it suffices to consider $d^2$. If you expand the term, you get a distance function
$$d^2 = d^2 (\lambda, \tau, \mu),$$ 
from which you can take all three partial derivatives to zero:
$$\nabla d^2 \stackrel{!}{=} 0.$$
In general, this will lead you to a linear equation system, which you can solve vor $(\lambda, \tau, \mu)$. If it has an unique solution, plug that into $d$ to get your distance. If it has infinitely many solutions, then your line and plane are parallel with multiple minimal solutions.
A: Any point on the plane equals
$$
a\textbf{u} + b\textbf{v} + \textbf{w}
$$
for a value for $a$ and $b$, where $\textbf{u}$, $\textbf{v}$, and $\textbf{w}$ depend on the three coordinates of the plane. For example, you might define 
$$
\textbf{u}=\begin{bmatrix}a_1 -i\\ b_2-j \\ c_2-k \\ d_2-l \end{bmatrix}, 
\textbf{v}=\begin{bmatrix}e_e -i\\ f_2-j \\ g_2-k \\ h_2-l \end{bmatrix},
\textbf{w}=\begin{bmatrix}i \\ j \\k \\l \end{bmatrix}.
$$
Similarly, a point on the line equals
$$
c\textbf{x} + \textbf{y}
$$
with, for example,
$$
\textbf{x}=\begin{bmatrix}a-e \\ b-f \\ c-g \\ d-h \end{bmatrix},
\textbf{y}=\begin{bmatrix}e \\ f \\ g \\ h \end{bmatrix}.
$$
The distance between a point on the line and a point on the plane then equals:
$$
\| a\textbf{u} + b\textbf{v} + \textbf{w} - c\textbf{x} - \textbf{y} \|=
\| X \theta - \textbf{z}\|,
$$
with $X=\begin{bmatrix} \textbf{u} & \textbf{v} & -\textbf{x}\end{bmatrix}$, $\textbf{z}=\textbf{y}-\textbf{w}$, and $\theta=\begin{bmatrix}a & b & c\end{bmatrix}^T$.
Minimizing this gives:
$$
\hat{\theta} = \arg \min_\theta \| X \theta - \textbf{z}\| = (X^TX)^{-1}X^T \textbf{z}.
$$
Hence, the (minimal) distance between the line and the plane is:
$$
\| (X(X^TX)^{-1}X^T - I) \textbf{z} \|,
$$
where $I$ denotes the identity matrix.
Update: Note that in case the matrix $X^TX$ is singular, your line and plane are parallel. In that case, you can take any point on the line and find the minimal distance to the plane. Mathematically, the distance can be computed similarly as before, but now with $c=0$ (in that case, we just take the point $\textbf{y}$, which obviously lies on the line), resulting in 
$$
\| (\tilde{X}(\tilde{X}^T\tilde{X})^{-1}\tilde{X}^T - I) \textbf{z}\|,
$$
with $\tilde{X}=\begin{bmatrix} \textbf{u} & \textbf{v} \end{bmatrix}$.
