Given vectors are $v_1 = (1,-2,1,3) $ , $v_2=(0,3,1,-1) $ and $v_3=(1,1,-1,-1) $ in $ R^4$ with the standard inner product. The question is how to find the orthogonal projection of $v_3$ on the subspace spanned by $v1$ and $v2$. So I approached this question as first I project $v_3$ on $v_1$, then $v_2$. Like:
$v_{31} = \frac{(v_3|v_1)}{(v_1|v_1)}*v_1$
I get = $\frac{-5}{15}*(1,-2,1,3)$
$v_{32} = \frac{(v_3|v_2)}{(v_2|v_2)}*v_2$
$\frac{3}{11}*(0,3,1,-1)$
and Projection should be the sum of $\frac{-5}{15}*v_1$ + $\frac{3}{11}*v_2$.
But suggested answer claims:
let projection $P = x_1*v_1 + x_2*v_2$ where:
$(v_1|v_1)*x_1 + (v_2|v_1)*x_2 = (v_3|v_1)$
$(v_1|v_2)*x_1 + (v_2|v_2)*x_2 = (v_3|v_2)$
Then solving this equastions yields $P=\frac{-31}{101}*v_1 + \frac{5}{101}*v_2$
So is my assumption wrong ( if it is where did I make a mistake) or the suggested answer(also what do these equations mean) thanks in advance...
In the first way, you first need to form an orthonormal basis out of $\;v_1,\,v_2\;$ , and not normalize these two vectors separatedly. Thus, we begin with Gram-Schmidt
$$\color{red}{u_1}=\frac{v_1}{||v_1||}=\color{red}{\frac1{\sqrt{15}}(1,-2,1,3)}, \;w_2:=v_2-(v_2|u_1)u_1=(0,3,1,-1)-\frac1{15}(-8)(1,-2,-1,3)=$$
$$=(0,3,1,-1)+\left(\frac8{15},\,-\frac{16}{15}\,,\,-\frac8{15}\,,\,\frac85\right)=\frac1{15}(8,\,29,\,7,\,16)\implies$$
$$\color{red}{u_2}=\frac{w_2}{||w_2||}=\sqrt\frac3{242}\frac1{15}(8,29,7,16)=\color{red}{\frac1{5\sqrt{726}}(8,29,7,16)}=$$
and etc. (you fill up here what is lacking).
But there is a nice matrix thingy way: form the matrix $\;A\;$ with $\;v_1,v_2\;$ as columns:
$$A=\begin{pmatrix}\;\;1&\;\;0\\-2&\;\;3\\\;\;1&\;\;1\\\;\;3&-1\end{pmatrix}\implies A^t=\begin{pmatrix}1&-2&1&\;3\\ 0&3&\;1&-1\end{pmatrix}\implies$$
$$ A^tA=\begin{pmatrix}1&-2&1&\;3\\ 0&3&\;1&-1\end{pmatrix}\begin{pmatrix}\;\;1&\;\;0\\-2&\;\;3\\\;\;1&\;\;1\\\;\;3&-1\end{pmatrix}=\begin{pmatrix}\;15&-8\\ -8&11\end{pmatrix}\implies(A^tA)^{-1}=\frac1{101}\begin{pmatrix}\;\;11&8\\ 8&15\end{pmatrix}$$
so finally:
$$P:=A(A^tA)^{-1}A^t=\begin{pmatrix}\;\;1&\;\;0\\-2&\;\;3\\\;\;1&\;\;1\\\;\;3&-1\end{pmatrix}\frac1{101}\begin{pmatrix}11&8\\ 8&15\end{pmatrix}\begin{pmatrix}1&-2&1&\;3\\ 0&3&\;1&-1\end{pmatrix}=$$
$$=\frac1{101}\begin{pmatrix}\;\;1&\;\;0\\-2&\;\;3\\\;\;1&\;\;1\\\;\;3&-1\end{pmatrix}\begin{pmatrix}11&2&19&25\\ 8&29&23&9\end{pmatrix}=\frac1{101}\begin{pmatrix} 11&2&19&25\\ 2&83&31&-23\\ 19&31&42&34\\ 25&-23&34&66\end{pmatrix}$$
and thus the orthogonal projection wanted is
$$Pv_1=\frac1{101}\begin{pmatrix} 11&2&19&25\\ 2&83&31&-23\\ 19&31&42&34\\ 25&-23&34&66\end{pmatrix}\begin{pmatrix}1\\1\\-1\\-1\end{pmatrix}=\frac1{101}\begin{pmatrix}-31\\77\\-26\\-98\end{pmatrix}$$
You can check the above is exactly the same as in the suggested answer...