Calculate the distance of the point $(1,1,1,1)$ from the subspace $W$. This is a duplicate question.

Let $W$=span$\left(\frac{1}{\sqrt{2}}(0,0,1,1),\frac{1}{\sqrt{2}}(1,-1,0,0)\right)$ be a subspace of the Euclidean space $\mathbb{R^4}$. Then the square of the distance from the point $(1,1,1,1)$ to the subspace $W$ is equal to_____?

So this question is already been asked and has an accepted answer here.
But I didn't understand the answer fully. To be honest, I didn't get the idea at all. The answer is talking about some distance $r_{AA_w}$ I don't know nothing how to get that.
So by this question, I want to know about the concept behind the distance of a point to a subspace. How to calculate this distance and what is the idea behind this? If someone can explain this to me then it would be really helpful. Thanks.
 A: Start with simple cases: What’s the distance from a point to a line? How about to a plane? After a bit of experimentation, you might hit upon the idea that it’s the minimum distance between that fixed external point and any point on the line/plane. Simple geometric considerations show that this minimum distance is obtained when we measure it in a direction perpendicular to the line/plane, and so the nearest point to the fixed external point is the latter’s orthogonal projection onto the line/plane (labeled $\pi A$ in the diagram).  

If we subtract this projection from the original point, we get a vector that’s orthogonal to the line/plane (called the orthogonal rejection from the line/plane), so the distance we’re looking for is equal to the length of this difference vector.  
One can prove in various ways that this holds in general, namely, that the minimum distance from a point to an $m$-dimensional subspace lies along a direction that’s perpendicular to it. We’ll just take that as given. So, to compute this distance, you project the point onto the subspace and find the length of the difference between that projection and the original point.  
There are many ways to construct this projection, depending on what you’re starting with. For this problem, you’ve got an orthonormal basis for $W$ (verify that for yourself), so you can use what you might recognize as a step in the Gram-Schmidt process, which computes successive orthogonal rejections from ever-growing subspaces. So, letting $\mathbf w_1$ and $\mathbf w_2$ be the two basis vectors of $W$, and $\mathbf v=(1,1,1,1)^T$, you would compute $\mathbf v-(\mathbf v\cdot \mathbf w_1)\mathbf w_1-(\mathbf v\cdot \mathbf w_2)\mathbf w_2$ and then compute the norm of this vector.
A: You can write any vector in $W$ in the generic form $(a,-a,b,b)$ for $a,b\in \mathbb{R}.$ The distance squared from $(1,1,1,1)$ to an arbtrary vector $(a,-a,b,b)\in W$ is $$d^2 = (a-1)^2 +(a+1)^2 + 2(b-1)^2.$$ 
The distance from $(1,1,1,1)$ to $W$ is the minimum distance to any point in $W$. So we can minimize this by taking the derivative of $d^2$ with respect to $a$ and $b$ and setting equal to zero. So we get $$0 = 2(a-1) + 2(a+1)\\0 = 4(b-1) $$ which can be solved to give $a=0$ and $b=1.$ Plugging this back in, we get a squared distance of $d^2 = 2$ for the answer.
A: Here is the general idea behind this problem ...
Instead of working in $\mathbb{R^4}$, consider a more general euclidean vector space $E$ (that is a real vector space, equipped with an inner product (aka dot product)).
Let us denote by $\left<a\mid b\right>$ the scalar product of $a$ by $b$.
The norm of a vector is defined by $\Vert x\Vert=\sqrt{\left< x\mid x\right>}$.
The distance between two vectors $x$ and $y$ is $\Vert x-y\Vert$.
Consider a finite dimensional subspace $W$ of $E$ and $x\in E$.
The question is to minimize the distance from $x$ to the vectors of $W$.
It can be proved that :

there exist a unique $p\in W$ such that :
$$\Vert x-p\Vert=\inf\{\Vert x-w\Vert;\;w\in F\}$$

and that $p$ is obtained as the orthogonal projection of $x$ on $F$, that is :

$$p=\sum_{k=1}^n\left<x\mid e_k\right>\,e_k$$

where $(e_1,\cdots,e_n)$ denotes any orthonormal basis of $W$.
As an example, you could calculate the square of the distance of the map $x\mapsto x^2$ to $W=\mathrm{span}\left(x\mapsto 1,\,x\mapsto x\right)$. Here $E$ is the space of all continuous functions from $[0,1]$ to $\mathbb{R}$ and the inner product is defined by :
$$\forall (u,v)\in E^2,\left<u\mid v\right>=\int_0^1u(t)v(t)\,dt$$
The correct answer is $\frac{1}{180}$
