How do we get from one fromula to another? My question is about the projection. The projection onto a hyperplane defined by $$H:=\{x\in \mathbb{R}^n:\langle a,x\rangle=b\}$$ is defined by $$P_{H}(x)=x-\frac{\langle a,x\rangle-b}{||a||^2}a\dots\dots(1).$$Also when this hyperplane passes through the origin then we will have a subspace$$S:=\{x\in\mathbb{R}^n:\langle a,x\rangle=0\}$$and the projection can be defined by $$P_{S}(x)=x-\frac{\langle a,x\rangle}{||a||^2}a\dots\dots(2).$$Now for any subspace $V$ (not necessary to be a hyperplane) if we construct a matrix $A$ whose columns consists of linearly independents spanning set for $V$ then the projection can be defined by $$P_V(x)=A(A^TA)^{-1}A^T(x)\dots\dots(3).$$My question is how do we get from $(3) $ to $(2)$? Can anyone show that to me? I know that the hyperplane $H$ and the subspace $S$ are of dimension $n-1$and I can understand how do we get $(1)$ and $(2)$ but not able to make an argument about how do we get$(1)$ from $(3)$.I will be great full for any explanation or proof. 
 A: Let me rephrase your question a little bit.
We are given a matrix $B \in \mathbb R^{n\times (n-1)}$ with $rank\ B = n-1.$ Then the columns of $B$ are linearly independent and form the basis of a linear hyperplane $S := B \mathbb R^{n-1} \subseteq \mathbb R^n.$ The orthogonal projection onto $S$ is described by $y = B(B^TB)^{-1}B^Tx$ for $x\in\mathbb R^n.$ For future reference, we put $$
P := B(B^TB)^{-1}B^T \in \mathbb R^{n\times n}.
$$
We also have the "dual" description of $S,$ namely there is a vector $a \in\mathbb R^n\setminus\{0\}$ such that $S = \{x \in \mathbb R^n|a^Tx = 0\}.$ With this data, the orthogonal projection onto $S$ is described by $y = x - \frac{a^Tx}{a^Ta}a.$ Note that $a^Tx \in \mathbb R,$ and thus $(a^Tx)a = a(a^Tx) = (aa^T)x.$ Here, note that $aa^T \in \mathbb R^{n\times n}.$ We can use this to rewrite
$$
\begin{align}
y & = x - \frac{a^Tx}{a^Ta}a \\
& = x - \frac{aa^T}{a^Ta}x \\
& = (I - \frac{aa^T}{a^Ta})x,
\end{align}
$$
where $I \in \mathbb R^{n\times n}$ denotes the identity matrix. Let's put
$$
Q := \left(I - \frac{aa^T}{a^Ta}\right) \in \mathbb R^{n\times n}.
$$
With all these preparations, we want to show $P = Q.$ This can be done as follows. Since the columns of $B$ are elements of $S,$ we have
$$
a^TB = 0.
$$
This implies that $a$ and the columns of $B$ are linearly independent. Thus, the matrix
$$
U := (a\ B) \subseteq \mathbb R^{n\times n}
$$
has rank $n$ and is invertible. Then, also its transpose
$$
U^T = {a^T\choose B^T}
$$
is invertible. With that, we have
$$
P = Q\qquad iff \qquad U^TP = U^TQ.
$$
Now we calculate (observing  that $a^TB = 0$ is equivalent to $B^Ta = 0$)
$$
\begin{align}
U^TP & = {a^T\choose B^T}B(B^TB)^{-1}B^T \\
& = {a^TB(B^TB)^{-1}B^T\choose B^TB(B^TB)^{-1}B^T} \\
& = {(a^TB)(B^TB)^{-1}B^T\choose (B^TB)(B^TB)^{-1}B^T} \\
& = {0\choose B^T}, \\
\end{align}
$$
since $a^TB = 0,$ and moreover
$$
\begin{align}
U^TQ & = {a^T\choose B^T}\left(I - \frac{aa^T}{a^Ta}\right) \\
& = {a^T\choose B^T} - {\frac{a^Taa^T}{a^Ta}\choose\frac{B^Taa^T}{a^Ta}} \\
& = {a^T\choose B^T} - {\frac{(a^Ta)a^T}{a^Ta}\choose\frac{(B^Ta)a^T}{a^Ta}} \\
& = {a^T\choose B^T} - {a^T\choose 0} \\
& = {0\choose B^T},
\end{align}
$$
since $B^Ta = 0.$
So we have indeed $P = Q,$ as desired.
