I am currently studying linear algebra and am getting very confused on orthogonality and projections. I am reviewing questions to better understand it but can not get a certain one. Here is the question: $$ \vec{b} = \begin{bmatrix} 1 \\ 2 \\ 2\end{bmatrix} \quad\text{and}\quad\vec{a} = \begin{bmatrix}1 \\ 1 \\ 1\end{bmatrix}. $$ First thing I need to do is Project b onto the line through a. But how would I check that $\vec e = \vec b - \vec p$ is orthogonal to a? I am unclear on what that exactly means.
The questions asks me to find the projection matrix $P = \frac{\vec a\vec a^T}{\vec a^T\vec a}$ onto the line through $\vec a.$ I also need to verify $P^2 = P.$ Lastly, I need to multiply $P\vec b$ to compute the projection $\vec p.$
The definition of projection is
$$pr_\vec{a}(\vec{b}) = \frac{(\vec{a},\vec{b})}{(\vec{a},\vec{a})}\vec{a}$$
where $(\vec{a},\vec{b})$ is an inner product between $\vec{a}$ and $\vec{b}$. (In this case, we have the dot product).
You can conclude with a geometric intuitive argument that $\vec{b}-pr_\vec{a}(\vec{b})$ is orthogonal to $\vec{a}$. Just draw a right triangle with $\vec{b}$ as it's hypotenuse and cathetus $pr_\vec{a}(\vec{b})$ (on the line through $\vec{a}$). $\vec{b}-pr_\vec{a}(\vec{b})$ will be the other cathetus, hence orthogonal to $\vec{a}$.
To prove orthogonality, just show that $(\vec{b}-pr_\vec{a}(\vec{b}),\vec{a})=0$.
EDIT:
To find the transformation matrix, just compute the transformation of the canonical basis and put these vectors as columns on $P$, and you can prove why it works really easy. For exaple, if you apply the transformation $P$ on the vectors $e_1=(1,0,0)$,$e_2=(0,1,0)$ and $e_3=(0,0,1)$ you can obtain, say, $Pe_1=v_1,Pe_2=v_2,Pe_3=v_3$. All you have to do is build the matrix: $$P = \begin{bmatrix}v_1 v_2 v_3 \end{bmatrix} $$ that is, $v_1$ is the first column, $v_2$ is the second column and $v_3$ the third column.
Well, obviously you can't use the matrix $P$ to compute $Pe_1$ and so on. These transformations you must compute by hand, using the projection and orthogonality concepts introduced before.