I'm trying to find a vector in $\mathbb{R}^4$ that is both orthogonal to the space $W$ spanned by $\{(1,2,0,1), (0,1,1,1)\}$ and happens to be "closest" to the vector $(3,3,3,3)$.
From reading Friedberg Insel and Spence and drawing out a diagram, I know that my vector should be $v=(3,3,3,3) - P_{W}v$, where $P_{W}v$ is the orthogonal projection of $(3,3,3,3)$ onto $W$.
How can I compute $P_{W}v$? Should I try to find a projection matrix of coefficients and apply it to $(3,3,3,3)$, or is there a more geometric way of computing the vector?
Thanks
Edit: so I was able to answer this question - at least my answer matches that of another student's. But I was wondering: the vector that I computed, which is orthogonal to the space W, why do vector addition laws work in 4-dimensions and higher, even though we can't visualize this? Should I just accept this as fact? The vector I wanted - and found - was $(3,3,3,3) - P_w(3,3,3,3)$.
Define $A =\left[ \begin{matrix}1 & 0 \\ 2 & 1\\ 0 & 1 \\ 1 & 1 \end{matrix}\right], x = \left[\begin{matrix}3\\3\\3\\3\\\end{matrix}\right]$.
Then $W = range(A)$. The projection of $x$ onto the range of $A$ is $P_R(A) = A(A^TA)^{\dagger}A x$. where $(A^TA)^\dagger$ is the pseudoinverse of $A^TA$ (but luckily in your case $A^TA$ is nonsingular so it's just the inverse.)
What you want is the projection onto $W^\perp$, which, as you pointed out, is
$P_{R^\perp}(A)x = (I-P_R(A))x = (I-A(A^TA)^{-1}A )x$.