# How to find a basis for the intersection of two vector spaces in $\mathbb{R}^n$?

What is the general way of finding the basis for intersection of two vector spaces in $\mathbb{R}^n$?

Suppose I’m given the bases of two vector spaces U and W:
$$\mathrm{Base}(U)= \left\{ \left(1,1,0,-1\right), \left(0,1,3,1\right) \right\}$$
$$\mathrm{Base}(W) =\left\{ \left(0,-1,-2,1\right), \left(1,2,2,-2\right) \right\}$$

I already calculated $U+W$, and the dimension is $3$ meaning the dimension of $U \cap W$ is $1$.

The answer is supposedly obvious, one vector is the basis of $U \cap W$ but how do I calculate it?

Assume $\textbf{v} \in U \cap W$. Then $\textbf{v} = a(1,1,0,-1)+b(0,1,3,1)$ and $\textbf{v} = x(0,-1,-2,1)+y(1,2,2,-2)$.
Since $\textbf{v}-\textbf{v}=0$, then $a(1,1,0,-1)+b(0,1,3,1)-x(0,-1,-2,1)-y(1,2,2,-2)=0$. If we solve for $a, b, x$ and $y$, we obtain the solution as $x=1$, $y=1$, $a=1$, $b=0$.
so $\textbf{v}=(1,1,0,-1)$
You can validate the result by simply adding $(0,-1,-2,1)$ and $(1,2,2,-2)$