How to compute the distance of an affine space from the origin I have an affine space in $V_6(\mathbb{R})$: $\{Y=(2,-2,0,1,-1,0)+a(1,-1,0,0,0,0)+b(1,0,0,1,-3,1)+c(1,-4,0,2,1,0)$ with $a,b,c \in \mathbb{R}\}$.
A generic vector of $Y$ is something like this :$P+rA+sB+tC=  \left( \begin{array}{c}
2+r+s+t \\
-2-r-4t \\
0 \\
1+s+2t \\
-1-3s+t \\
0+s \end{array} \right)$
The orthogonal complement $Y'= 0 + \{ (1,-1,0,0,0,0),(1,0,0,1,-3,1),(1,-4,0,2,1,0) \}^\perp $ passes through the origin and intersects $Y$ in one point. That is the point of the intersection between the affine space and its perpendicular line through the origin, so it is supposed to be the point of $Y$ at a minimum distance from the origin. The idea is to compute this vector's length and say 'That is the distance from O'.
The carthesian equations representation of the orthogonal complement is  $\begin{equation}
   \begin{cases}
   x_1-x_2=0\\x_1+x_4-3x_5+x_6=0\\x_1-4x_2+2x_4+x_5=0
   \end{cases}
\end{equation}$
(from this representation I can check again that $0 \in Y'$).
Now, if I substitute $x_1, x_2$ ... with the coordinates of the generic vector of $Y$ I should get the intersection between $Y$ and the orthogonal complement passing through the origin and this point should be good to compute the distance. The problem is: the solution of the system is 
r = -132/103,   s = -81/206,   t = -43/206 [See Wolfram]. 
This solution is corresponding to the vector $(12/103, 12/103, 0, 39/206, -3/103, -81/206)$ whose length is $3 \sqrt{5/206}$. 
User A.P. used instead another formula in the Update of this answer:
$$
\vec{x}_\perp = \vec{x} - (\vec{x} \cdot \vec{v}_1) \, \frac{\vec{v}_1}{\|\vec{v_1}\|^2} - \dotsb - (\vec{x} \cdot \vec{v}_d) \, \frac{\vec{v}_d}{\|\vec{v_d}\|^2}.
$$ and got $\sqrt{11/2}$.  Where's the problem? Thanks for the help!
 A: The discrepancy is due to an oversight by A.P. He’s subtracting the orthogonal projection $\pi_V\vec x$ from $\vec x$ to get the orthogonal rejection $\vec x_\perp$, but the formula he uses for the projection requires an orthogonal basis $\{\vec v_i\}$ of $V$. It looks like he used the given generators of $V$ in the formula without checking that they were orthogonal first. If you compute $\pi_V\vec x$ some other way, then the answer does agree with the one you got by solving the system of linear equations.  
One way to compute this projection is to take $\pi_v=U(U^TU)^{-1}U^T$, where $U$ has any basis of $V$ as its columns. Taking $\vec x=(2,-2,0,1,-1,0)^T$ as before, we end up with $(I-\pi_V)\vec x=\frac1{206}(24,24,0,39,-6,-81)^T$, which has the norm $\sqrt{45/206}$.  
Another approach is to find an orthogonal basis for $V$. Applying the Gram-Schmidt process without normalizing yields the basis $\vec v_1=(1,-1,0,0,0,0)^T$, $\vec v_2=(1/2,1/2,0,1,-3,1)^T$ and $\vec v_3=(-32/23,-32/23,0,51/23,8/23,5/23)^T$. Using these vectors in the formula given by A.P. produces the same vector as above.
