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

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)$


The comment of Annan with slight correction is one possibility of finding basis for the intersection space $ U \cap W $, the steps are as follow:

1) Construct the matrix $ A=\begin{pmatrix}\mathrm{Base}(U) & | & -\mathrm{Base}(W)\end{pmatrix} $ and find the basis vectors $ \textbf{s}_i=\begin{pmatrix}\textbf{u}_i \\ \textbf{v}_i\end{pmatrix} $ of its nullspace.

2) For each basis vector $ \textbf{s}_i $ construct the vector $ \textbf{w}_i=\mathrm{Base}(U)\textbf{u}_i=\mathrm{Base}(W)\textbf{v}_i $.

3) The set $ \{ \textbf{w}_1,\ \textbf{w}_2,...,\ \textbf{w}_r \} $ constitute the basis for the intersection space $ span(\textbf{w}_1,\ \textbf{w}_2,...,\ \textbf{w}_r) $.


I will use the same ideas as this other answer, but will add some more detail on some of the steps.

Let $\mathcal U$ and $\mathcal V$ be two finite-dimensional vector spaces. I want to find a basis for the intersection $\mathcal U\cap\mathcal V$.

Let $U$ and $V$ be matrices whose columns are the basis vectors of $\mathcal U$ and $\mathcal V$, respectively. The problem is then equivalent to that of characterising $\operatorname{Range}(U)\cap \operatorname{Range}(V)$. In other words, the problem is that of finding the non-zero solutions for $x,y$ to the matrix equation $$Ux=Vy.\tag A$$ Indeed, $z\in\operatorname{Range}(U)\cap \operatorname{Range}(V)$ iff there are $x,y$ such that $z=Ux=Vy$.

Now, to solve (A) we can define $A\equiv(U|-V)$ (this is the matrix with columns the full set of the vectors in both the bases of $\mathcal U$ and $\mathcal V$), and find its nullspace. Indeed, $AX=0$ where $X\equiv\begin{pmatrix}x\\y\end{pmatrix}$ implies $Ux=Vy$.

Once we have a full basis set for the nullspace of $A$, in the form of an orthonormal set of vectors $\{X_i\}$ (with each $X_i$ corresponding to a pair $x_i,y_i$), we can compute the corresponding set of vectors in the intersection that we are looking for, by simply computing $w_i\equiv Ux_i=Vy_i$ for each $i$.

Now to prove that $\{w_i\}_i$ is linearly independent. Suppose $\sum_i c_i w_i=0$. Then $U(\sum_i c_i x_i)=0$ and $V(\sum_i c_i y_i)=0$. But because $\operatorname{Ker}(U)=\operatorname{Ker}(V)=\{0\}$, this means that $\sum_i c_i x_i=\sum_i c_i y_i=0$. But this is, in turn, equivalent to $\sum_i c_i X_i=0$, and because $\{X_i\}$ is a linearly independent set, this implies $c_i=0$.

We conclude that $\{w_i\}$, where $w_i\equiv U x_i=V y_i$ and $\{(x_i, y_i)\}_i$ is a basis for $\operatorname{Ker}[(U|-V)]$, is a basis for $\mathcal U \cap\mathcal V$.