Find the angle between a vector and a linear subspace spanned by vectors

linear algebra

I need to find the angle between a vector:
$$(2,2,1,1)$$
and a linear subspace spanned by vectors:
$$(3,4,-4,-1)$$ and $$(0,1,-1,2)$$

I know how to find the angle between two vectors using scalar product. But not a linear subspace.

I tried this:

I found a basis of that linear subspace:
$$(3,4)$$
$$(0,1)$$

And then tried to find angle between vector x and any vector constructed with that basis, but it didn't work out

Its from task book, so i know the answer, its 60

Best Answer

Call the vectors that span your subspace $a$ and $b$. Call $X$ the matrix whose columns are those vectors.Then, the projection of the given vector $y=(2,2,1,1)$ onto the subspace is given by $$ w=X(X^TX)^{-1}X^Ty $$ Finally, just find the angle between $y$ and $w$ using the dot product.

Related Question