How do I write it as a sum of a vector and other vector in the orthogonal complement of span? Let
$$U = \left\{ \begin{bmatrix} 3\\ 4\\ 5\end{bmatrix},\begin{bmatrix} 2\\ 1\\ -2\end{bmatrix}\right\},\qquad v =\begin{bmatrix} 1\\ 2\\ 3\end{bmatrix}.$$
Write $v$ as a sum of a vector in $W = \operatorname{span}(U)$ and the other vector in the orthogonal complement of $\operatorname{span}(U)$.
I am really lost in class. I don't even know where to start. Please show steps and answers for the exercise problem so that I can learn. Thank you
 A: *

*What you want to achieve is to write $v=a+b$ where $a$ and $b$ are orthogonal (i.e. $a\cdot b=0$) and $a\in W$. This can be achieved by writing $a=\operatorname{proj}_U(v)$ and then $b=v-a$.

*We can also write
$$a=\operatorname{proj}_U(v)=\operatorname{arg min}\limits_x \left\|Ax-v\right\|^2,$$
where $A$ has as its columns the basis vectors for $W$. i.e.
$$A=\begin{bmatrix}3&2\\4&1\\5&-2\end{bmatrix}.$$
However, note that the basis vectors for $W$ are orthogonal, making $W$ an orthogonal set. Define $w_1=[3,4,5]^T$ and $w_2=[2,1,-2]^T$. It is easy to show that $w_1\cdot w_2=0$ to verify this claim. This significantly simplifies the calculation of $a$ to be $a=c_1w_1+c_2w_2$, where
$$c_1=\frac{v\cdot w_1}{\|w_1\|^2}\text{ and }c_2=\frac{v\cdot w_2}{\|w_2\|^2}.$$

*With these calculations, we obtain $c_1=\frac{26}{50}$, $c_2=\frac{-2}{9}$, which gives
$$
a=\left[\frac{251}{225},\frac{418}{225},\frac{137}{45}\right]^T\text{ and }b=\left[\frac{-26}{225},\frac{32}{225},\frac{-2}{45}\right]^T.
$$
It is now simple to verify that $v=a+b$, $a\cdot b=0$ and $a\in W$, which were the desired conclusions.

