Sage has inbulit method to find sum and intersection of two subspaces. However, shall also see how these can be obtained manually.
First of all we define
\(W_1=L(S_1)\text{.}\)
This show that
\(W_1\) is a 3-dimensional subspace of
\(V\text{.}\)
Next, we define
\(W_2=L(S_2)\)
Here
\(W_2\) is a 4 dimensional subspace of
\(V\text{.}\)
Now we find
\(W_1\cap W_2\) using the Sage method
W1.intersection(W2)
.
Next we can find
\(W_1+W_2\) as follows.
From the above computations, it is clear that
\begin{equation*}
\dim(W_1+W_2)=\dim(W_1)+\dim(W_2)-\dim(W_1\cap W_2)\text{.}
\end{equation*}
In fact, this is true in general and we shall prove this later.
How to find \(W_1+W_2\) manually?
This can be obtained as
\(L(S_1\cup S_2)\text{.}\) Thus we can construct a matrix
\(M\) whose rows are
\(S_1\cup S_2\) and apply RREF. Let us see this.
Clearly the first 5 rows of RREF(M) is the basis matrix obtained for
\(W_1+W_2\text{.}\)
Finding
\(W_1\cap W_2\) manually.
Let
\(c_1,c_2, c_3\) be a basis of
\(W_1\) and
\(d_1,d_2, d_3,d_4\) be a basis of
\(W_2\) obtined above. If
\(v\in W_1\cap W_2\text{.}\) Then
\begin{equation*}
v=\alpha_1c_1+\alpha_2c_2+\alpha_3c_3=\beta_1d_1+\beta_2d_2+\beta_3d_3+\beta_4 d_4\text{.}
\end{equation*}
In particular,
\(\alpha_1c_1+\alpha_2c_2+\alpha_3c_3-\beta_1d_1-\beta_2d_2-\beta_3d_3-\beta_4 d_4=0\text{.}\)Β We can obtain
\(\alpha_i\)βs and
\(\beta_i\)βs by solving
\begin{equation*}
\begin{bmatrix} c_1 \amp c_2\amp c_3\amp d_1\amp d_2\amp d_3 \amp d_4\end{bmatrix}
\begin{pmatrix} \alpha_1 \\ \alpha_2\\ \alpha_3\\ \beta_1\\ \beta_2\\ \beta_3\\\beta_4\end{pmatrix}=0
\end{equation*}
Thus we can find the null space of
\(\begin{bmatrix} c_1 \amp c_2\amp c_3\amp d_1\amp d_2\amp d_3 \amp d_4\end{bmatrix}\) and find the vectors in the basis of
\(W_1\cap W_2\text{.}\) Let see how to do this in Sage.
Once we have the basis of
\(null(P)\text{,}\) we can obained the basis vector in
\(W_1\cap W_2\) as follows.
Clearly these are the basis vectors for
\(W_1\cap W_2\) obtained using the inbulit Sage method.