Given $X=(4,8,4,-8)\in R^4$ and $S = span\{(1,2,1,0),(-1,1,-1,1), (1,0,1,2)\}$ is a subspace,
Find the orthogonal projections of $X$ onto both $S$ and $S^\perp$.
-------------

Now, I've already found $S^\perp = span\{(-6,-3,4,1)\}$ so I can decompose X into $Y\in S$ and $Z\in S^\perp$ s.t.
X = Y + Z.

Let Z = a(-6,-3,4,1), a in R.

So, $(4,8,4,-8)=Y+a(-6,-3,4,1)$

(I chose to use Z instead of Y since dim(Z)=1, but dim(Y)=3, so fewer inner-products.)

Dotting both sides with (-6,-3,4,1), we get:

$(4,8,4,-8)\cdot(-6,-3,4,1)=a\|(-6,-3,4,1)\|^2$ since $Y\cdot(-6,-3,4,1) = 0$.

So $a = \frac{-24}{31}$ and $Z = \frac{-24}{31}(-6,-3,4,1)$.

Y = X - Z so
$Y = (-14,-1,16,-5)$

Hope that's right!