I want to calculate the distance of the vector $x=(1,1,1,1)$ to the subspace $\{(1,0,2,0) , (0,1,0,2)\}$
I have solved this in 2 ways that I know of but the thing is, the results are different.
For instance when I use $||x-Pr(x)||$ I get $\sqrt{2}$, but when I calculate it using the gram determinant (more info here: Distance between a point and a m-dimensional space in n-dimensional space ($m<n$) ) I get $\sqrt{\frac{10}{25}}$ which is weird because both ways should be equivalent.
So my question is, what am I missing here? Which one of these result was the correct one?
Thank you.
Edit: Solution using $||x-Pr(x)||$ :
Let $v_1$ be $(1,0,2,0)$ and $v_2$ be $(0,1,0,2)$
Both vectors $v_1$ and $v_2$ are orthogonal meaning the inner product of them is $0$. Now we need to make them orthonormal. After doing so we get $e_1=v_1/\sqrt{3}$ and $e_2=v_2/\sqrt{3}$
Now we calculate $\Pr(x)$.
$$\Pr(x)= (x,e_1)e_1+(x,e_2)e_2 =\ldots= (1,1,2,2)$$
Therefore the distance is $d(x,U)= ||x-\Pr(x)||=||(1,1,1,1)-(1,1,2,2)||= ||(0,0,-1,-1)||= \sqrt{2}$
Best Answer
I'll offer the third method:
Let the point in that subspace be given by $x (0,1,0,2)+y(1,0,2,0)$. Then the square of the distance to the point $(1, 1, 1, 1)$ can be written as,
$$(1-y)^2+(1-x)^2+(1-2y)^2+(1-2x)^2$$ We need to minimize the above expression with respect to $x$ and $y$. Due to symetry, it's sufficient to consider only the minimization $$\min_x ( (1-x)^2 +(1-2x)^2) =\min_x( 5x^2-6x+2).$$ The minimum is attained at $x=\frac 35$ and the minimal value is $\frac 15$. Therefore, the square of the minimum distance is $\frac 25$ (i.e. the same as you obtained via Gram's determinant).
It seems that you made some mistakes while calculating $\|x-\mathrm{Pr}\, x\|$.