Lab 4: Projections, Span, and Linear Independence

due for completion at 11:59PM Ann Arbor Time on Monday, May 18th, 2026

Each lab worksheet will contain several activities, some of which will involve writing code and others that will involve writing math on paper. To receive credit for a lab, you must complete as many of the activities as you can in 2 hours and submit a PDF of your work to Gradescope. We will provide specific instructions on how to submit programming activities (e.g. submitting the notebook or including a screenshot of some output).

Feel free to work with others in the course, but you must submit individually.


Activities


Recap: Projections, Span, and Linear Independence

  • (Chapter 3.4) The orthogonal projection of the vector \(\vec u\) onto the vector \(\vec v\) is given by
$$ \vec p = \frac{\vec u \cdot \vec v}{\vec v \cdot \vec v} \vec v $$

Above, the scalar \(k^* = \frac{\vec u \cdot \vec v}{\vec v \cdot \vec v}\) was chosen to minimize \(\lVert \vec u - k \vec v \rVert^2\).

  • The vector \(\vec p\) is called the orthogonal projection because the resulting error vector,
$$ \vec e = \vec u - \vec p = \vec u - k^* \vec v $$

is orthogonal to \(\vec v\).

$$ \vec e \cdot \vec v = 0 $$
  • (4.1) The span of a set of vectors is the set of all possible linear combinations of the vectors in the set.
$$ \text{span}(\{\vec v_1, \vec v_2, \ldots, \vec v_d\}) = \{a_1 \vec v_1 + a_2 \vec v_2 + \cdots + a_d \vec v_d \mid a_1, a_2, \ldots, a_d \in \mathbb{R}\} $$
  • The span of one vector in \(\mathbb{R}^n\) is a line through the origin.

  • The span of two non-parallel vectors in \(\mathbb{R}^n\) is a plane through the origin; this plane is called a 2-dimensional subspace of \(\mathbb{R}^n\).

  • In general, the span of \(d\) vectors in \(\mathbb{R}^n\) is a subspace of \(\mathbb{R}^n\) of dimension \(0\) to \(d\), depending on the vectors and their relationships.

  • Think of a \(d\)-dimensional subspace of \(\mathbb{R}^n\) as a “slice” of \(\mathbb{R}^n\) that goes through the origin, in which you can move in \(d\) directions.


Activity 1: Presidential Speeches and Cosine Similarity

Complete the tasks in the lab04.ipynb notebook.

There are two ways to access the supplemental Jupyter Notebook:

  • Option 1 (preferred): Set up a Jupyter Notebook environment locally, use git to clone our course repository, and open labs/lab04/lab04.ipynb. For instructions on how to do this, see the Environment Setup page of the course website.

  • Option 2: Click here to open lab04.ipynb on DataHub. Before doing so, read the instructions on the Environment Setup page on how to use the DataHub.

Once you’re done, include a screenshot of your completed Activity 1 implementation in your PDF submission of Lab 4 to Gradescope, making sure to include proof that the (local) autograder passed. Instructions on how to do this are in the lab notebook.


Activity 2: Orthogonal Projections

Let \(\vec c = \begin{bmatrix} 1 \\ 2 \\ -4 \\ 0 \end{bmatrix}\) and \(\vec d = \begin{bmatrix} 3 \\ 2 \\ 0 \\ -1 \end{bmatrix}\). Note that \(\lVert \vec c \rVert^2 = 21, \lVert \vec d \rVert^2 = 14\), and \(\vec c \cdot \vec d = 7\).

a)

Find the orthogonal projection of \(\vec c\) onto \(\vec d\). Call this vector \(\vec q\).

Solution
$$ \begin{align*} \vec q &= \left(\frac{\vec c \cdot \vec d}{\vec d \cdot \vec d}\right)\vec d \\\\ &= \frac{1 \cdot 3 + 2 \cdot 2 + (-4) \cdot 0 + 0 \cdot (-1)}{3^2 + 2^2 + 0^2 + (-1)^2} \vec d \\\\ &= \frac{3+4}{9+4+1} \vec{d} \\\\ &= \frac{7}{14} \vec{d} \\\\ &= \frac{1}{2} \vec{d} \\\\ &= \begin{bmatrix} 1.5 \\\\ 1 \\\\ 0 \\\\ -0.5 \end{bmatrix} \end{align*} $$
b)

Find the error vector, \(\vec r = \vec c - \vec q\). Which vector is \(\vec r\) orthogonal to, \(\vec c\) or \(\vec d\)? Draw a rough picture of the relationship between \(\vec c\), \(\vec d\), \(\vec q\), and \(\vec r\).

Solution

First, let’s find \(\vec{r}\).

$$ \begin{align*} \vec{r} &= \vec{c} - \vec{q} \\\\ &= \begin{bmatrix} 1 \\\\ 2 \\\\ -4 \\\\ 0 \end{bmatrix} - \begin{bmatrix} 1.5 \\\\ 1 \\\\ 0 \\\\ -0.5 \end{bmatrix} \\\\ &=\begin{bmatrix} -0.5 \\\\ 1 \\\\ -4 \\\\ 0.5 \end{bmatrix} \end{align*} $$

\(\vec{r}\) is orthogonal to \(\vec{d}\), not \(\vec{c}\), as confirmed by the dot products. The key idea we introduced in Chapter 3.4 is that the error vector is orthogonal to the vector we projected onto. Here, \(\vec r\) is the error vector and \(\vec d\) is the vector we projected onto.

$$ \begin{align*} \vec{r} \cdot \vec{c} &= (-0.5) \cdot 1 + 1 \cdot 2 + (-4) \cdot (-4) + 0.5 \cdot 0 \\\\ &= -0.5 + 2 + 16 \\\\ &= 17.5 \\\\ \\\\ \vec{r} \cdot \vec{d} &= (-0.5) \cdot 3 + 1 \cdot 2 + (-4) \cdot 0 + 0.5 \cdot (-1) \\\\ &= -1.5 + 2-0.5 \\\\ &=0 \end{align*} $$

Activity 3: Orthogonal Decomposition

a)

Let \(\vec{v}_1 = \begin{bmatrix} -1 \\ 2 \\ 2 \end{bmatrix}\) \(\vec{v}_2 = \begin{bmatrix} 2 \\ 2 \\ -1 \end{bmatrix}\) and \(\vec{v}_3 = \begin{bmatrix} 2 \\ -1 \\ 2 \end{bmatrix}\). Write \(\vec{u} = \begin{bmatrix} 1 \\ 1 \\ 1 \end{bmatrix}\) as a linear combination of \(\vec{v}_1\), \(\vec{v}_2\), and \(\vec{v}_3\), and verify that your answer is correct. Note that \(\vec v_1\), \(\vec v_2\), and \(\vec v_3\) are pairwise orthogonal.

Solution

We are given

$$ \vec v_1=\begin{bmatrix}-1\\\\2\\\\2\end{bmatrix}\quad \vec v_2=\begin{bmatrix}2\\\\2\\\\-1\end{bmatrix}\quad \vec v_3=\begin{bmatrix}2\\\\-1\\\\2\end{bmatrix}\quad \vec u=\begin{bmatrix}1\\\\1\\\\1\end{bmatrix} $$

We’re looking for scalars \(a,b,c\) such that \(\vec u=a\vec v_1+b\vec v_2+c\vec v_3\).

Solution 1: Solving a system of equations

$$ a\!\begin{bmatrix}-1\\\\2\\\\2\end{bmatrix} +b\!\begin{bmatrix}2\\\\2\\\\-1\end{bmatrix} +c\!\begin{bmatrix}2\\\\-1\\\\2\end{bmatrix} =\begin{bmatrix}1\\\\1\\\\1\end{bmatrix} $$

Is equivalent to the system of equations:

$$ \begin{align} -a+2b+2c=1 \\\\ 2a+2b-c=1 \\\\ 2a-b+2c=1 \end{align} $$

Using elimination:

$$ \begin{align*} \text{(Eq.\,2)}-\text{(Eq.\,3)}&:\quad (2a-2a)+(2b-(-b))+(-c-2c)=0 \\\\[-2pt] &\qquad\Rightarrow\quad 3b-3c=0 \quad\Rightarrow\quad b=c \\\\[6pt] \text{(Eq.\,2)}-\text{(Eq.\,1)}&:\quad (2a-(-a))+(2b-2b)+(-c-2c)=0 \\\\[-2pt] &\qquad\Rightarrow\quad 3a-3c=0 \quad\Rightarrow\quad a=c \end{align*} $$

This tells us that \(a = b = c\). Plugging this back into Eq. 2 gives us:

$$ -a + 2a + 2a = 1 \rightarrow 3a = 1 \rightarrow a = \frac{1}{3} $$

So, \(a = b = c = \frac{1}{3}\), and:

$$ \vec u=\tfrac13\,\vec v_1+\tfrac13\,\vec v_2+\tfrac13\,\vec v_3 $$

We can verify that we did this correctly by computing the right-hand side above:

$$ \frac{1}{3}\vec v_1+\frac{1}{3}\vec v_2+\frac{1}{3}\vec v_3 =\frac{1}{3}\begin{bmatrix}-1\\\\2\\\\2\end{bmatrix}+\frac{1}{3}\begin{bmatrix}2\\\\2\\\\-1\end{bmatrix}+\frac{1}{3}\begin{bmatrix}2\\\\-1\\\\2\end{bmatrix} =\begin{bmatrix}-1/3+2/3+2/3\\\\2/3+2/3-1/3\\\\2/3-1/3+2/3\end{bmatrix} =\begin{bmatrix}1\\\\1\\\\1\end{bmatrix} =\vec u $$

Solution 2: Using the fact that \(\vec v_1, \vec v_2, \vec v_3\) are orthogonal

As is alluded to in part b), we can use the fact that \(\vec v_1, \vec v_2, \vec v_3\) are orthogonal to find coefficients \(a\), \(b\), and \(c\) by projecting \(\vec u\) onto each of the \(\vec v_i\)s. This is similar to what was done in the Orthogonal Decomposition section of Chapter 3.4.

Let \(\vec p_i\) be the projection of \(\vec u\) onto \(\vec v_i\), for \(i = 1, 2, 3\). Then, we have:

$$ \vec p_1 = \frac{\vec u \cdot \vec v_1}{\vec v_1 \cdot \vec v_1} \vec v_1 = \frac{1 \cdot (-1) + 1 \cdot 2 + 1 \cdot 2}{(-1)^2 + 2^2 + 2^2} \vec v_1 = \frac{3}{9} \vec v_1 = \frac{1}{3} \vec v_1 $$
$$ \vec p_2 = \frac{\vec u \cdot \vec v_2}{\vec v_2 \cdot \vec v_2} \vec v_2 = \frac{1 \cdot 2 + 1 \cdot 2 + 1 \cdot (-1)}{2^2 + 2^2 + (-1)^2} \vec v_2 = \frac{3}{9} \vec v_2 = \frac{1}{3} \vec v_2 $$
$$ \vec p_3 = \frac{\vec u \cdot \vec v_3}{\vec v_3 \cdot \vec v_3} \vec v_3 = \frac{1 \cdot 2 + 1 \cdot (-1) + 1 \cdot 2}{2^2 + (-1)^2 + 2^2} \vec v_3 = \frac{3}{9} \vec v_3 = \frac{1}{3} \vec v_3 $$

Adding \(\vec p_1, \vec p_2, \vec p_3\) gives us:

$$ \vec p_1 + \vec p_2 + \vec p_3 = \frac{1}{3} \vec v_1 + \frac{1}{3} \vec v_2 + \frac{1}{3} \vec v_3 = \vec u $$
b)

In general, suppose that \(\vec v_1, \vec v_2, \ldots, \vec v_d\) are orthogonal vectors in \(\mathbb{R}^n\), meaning that \(\vec v_i \cdot \vec v_j = 0\) for all \(i \neq j\). Given that it is possible to write \(\vec u\) as a linear combination of \(\vec v_1, \vec v_2, \ldots, \vec v_d\),

show that the coefficients of the linear combination

$$ \vec u = a_1 \vec v_1 + a_2 \vec v_2 + \cdots + a_d \vec v_d $$

are given by

$$ a_i = \frac{\vec u \cdot \vec v_i}{\vec v_i \cdot \vec v_i} $$

Hint: Start by taking the dot product of both sides of the linear combination equation with \(\vec v_1\). What do you notice?

Solution

We’re told to assume that any pair of vectors among \(\vec v_1, \vec v_2, \ldots, \vec v_d\) are orthogonal, and that \(\vec u\) can be written as a linear combination of \(\vec v_1, \vec v_2, \ldots, \vec v_d\).

$$ \vec u = a_1 \vec v_1 + a_2 \vec v_2 + \cdots + a_d \vec v_d $$

As the hint suggests, let’s take the dot product of both sides with \(\vec v_i\), where \(i\) is some value in \(\lbrace1, 2, \ldots, d\rbrace\).

$$ \vec u\cdot \vec v_i =\bigl(a_1\vec v_1+\cdots+a_d\vec v_d\bigr)\cdot \vec v_i $$

Since \(\vec v_i\cdot \vec v_j=0\) for \(i\neq j\), only the \(i=j\) term survives:

$$ \begin{align*} \vec u\cdot \vec v_i &= \bigl(a_1\vec v_1+\cdots+a_d\vec v_d\bigr)\cdot \vec v_i \\\\[6pt] &= a_1(\vec v_1\cdot \vec v_i)+\cdots+a_{i-1}(\vec v_{i-1}\cdot \vec v_i) +a_i(\vec v_i\cdot \vec v_i) +a_{i+1}(\vec v_{i+1}\cdot \vec v_i)+\cdots+a_d(\vec v_d\cdot \vec v_i) \\\\[6pt] &= a_1(0)+\cdots+a_{i-1}(0) +a_i(\vec v_i\cdot \vec v_i) +a_{i+1}(0)+\cdots+a_d(0) \\\\[6pt] &= a_i(\vec v_i\cdot \vec v_i) \\\\[6pt] \end{align*} $$

Solving for \(a_i\) above gives us

$$ \vec u \cdot \vec v_i = a_i(\vec v_i\cdot \vec v_i) \implies a_i = \frac{\vec u \cdot \vec v_i}{\vec v_i\cdot \vec v_i} $$

Since \(i\) was arbitrary, the same calculation holds for any value of \(i\) in \(\lbrace1, 2, \ldots, d\rbrace\).

What we proved here in part b) is that when writing a vector \(\vec u\) as a linear combination of orthogonal vectors, the coefficients of the linear combination can be found by projecting the vector \(\vec u\) onto each of the orthogonal vectors and adding the results, rather than solving a system of equations.


Activity 4: Planes and the Cross Product

An important idea from Chapter 4.1 is that two non-parallel vectors in \(\mathbb{R}^n\) (where \(n \geq 2\)) span a plane in \(n\)-dimensional space. Here, we’ll show you how to find the equation of such a plane, given two vectors in \(\mathbb{R}^3\). This is also touched on in Chapter 4.4.

a)

Given two vectors \(\vec a, \vec b \in \mathbb{R}^3\), show that the vector \(\vec q\) is orthogonal to both \(\vec a\) and \(\vec b\).

$$ \vec q = \begin{bmatrix} a_2 b_3 - a_3 b_2 \\\\ a_3 b_1 - a_1 b_3 \\\\ a_1 b_2 - a_2 b_1 \end{bmatrix} $$

The vector \(\vec q\) is called the cross product of \(\vec a\) and \(\vec b\). The cross product is only defined for two vectors in \(\mathbb{R}^3\) specifically, and the product is another vector in \(\mathbb{R}^3\). (This differentiates it from the dot product, which is defined for two vectors in any \(\mathbb{R}^n\), and whose output is a scalar.)

Solution
$$ \begin{align*} \vec{a} \cdot \vec{q} &= a_1(a_2 b_3 - a_3 b_2) + a_2(a_3 b_1 - a_1 b_3) + a_3(a_1 b_2 - a_2 b_1) \\\\ &={\color{blue}a_1a_2b_3} {\color{magenta}- a_1a_3b_2} {\color{orange}+a_2a_3b_1} { \color{blue}-a_1a_2b_3} {\color{magenta}+a_1a_3b_2} {\color{orange}-a_2a_3b_1} \\\\ &=0 \\\\ \\\\ \vec{b} \cdot \vec{q} &= b_1(a_2 b_3 - a_3 b_2) + b_2(a_3 b_1 - a_1 b_3) + b_3(a_1 b_2 - a_2 b_1) \\\\ &={\color{blue}a_2b_1b_3} {\color{magenta}- a_3b_1b_2} {\color{magenta}+ a_3b_1b_2} {\color{orange}- a_1b_2b_3} {\color{orange}+ a_1b_2b_3} {\color{blue}- a_2b_1b_3} \\\\ &=0 \end{align*} $$
b)

Find the cross product of \(\vec v_1 = \begin{bmatrix} 2 \\ -1 \\ 3 \end{bmatrix}\) and \(\vec v_2 = \begin{bmatrix} 1 \\ 2 \\ -1 \end{bmatrix}\).

Solution

Let’s call the cross product of \(\vec v_1\) and \(\vec v_2\) \(\vec q\).

$$ \begin{align*} \vec{q} &= \begin{bmatrix} (-1) \cdot (-1) - 3 \cdot 2 \\\\ 3 \cdot 1 - 2 \cdot (-1) \\\\ 2 \cdot 2 - (-1) \cdot 1 \end{bmatrix} \\\\ &= \begin{bmatrix} 1 - 6 \\\\ 3 + 2 \\\\ 4 + 1 \end{bmatrix} \\\\ &=\begin{bmatrix} -5 \\\\ 5 \\\\ 5 \end{bmatrix} \end{align*} $$
c)

Let \(\vec q = \begin{bmatrix} q_1 \\ q_2 \\ q_3 \end{bmatrix}\) be your answer to part b).

Verify that the points \((0, 0, 0)\), \((2, -1, 3)\) and \((1, 2, -1)\) satisfy the equation

$$ q_1 x + q_2 y + q_3 z = 0 $$

(Those points are the endpoints of the vectors \(\vec v_1\) and \(\vec v_2\), along with the origin.)

Solution

The equation of the plane in question is

$$ -5x + 5y + 5z = 0 $$

For \((0, 0, 0)\),

$$ -5(0) + 5(0) + 5(0) = 0 $$

For \((2, -1, 3)\),

$$ \begin{align*} &-5(2) + 5(-1) + 5(3) \\\\ &=-10 -5 + 15 \\\\ &=0 \\\\ \end{align*} $$

For \((1, 2, -1)\),

$$ \begin{align*} &-5(1)+5(2)+5(-1) \\\\ &=-5+10-5 \\\\ &=0 \end{align*} $$

Note that a simpler way of writing the equation of the plane is \(x - y - z = 0\), which comes from dividing both sides of the original equation by \(-5\). Another equivalent form is \(z = x - y\).

d)

Above, we wrote the equation of the plane spanned by \(\vec v_1\) and \(\vec v_2\) in the “standard form” for planes in \(\mathbb{R}^3\), \(ax + by + cz + d = 0\) (where \(d = 0\)). Now, write the equation of the plane spanned by \(\vec v_1\) and \(\vec v_2\) in parametric form. The parametric form of a plane is given by

$$ P = \vec p_0 + s \vec u + t \vec v, \quad s, t \in \mathbb{R} $$

This won’t require much work; it’s more that we want you to understand that there are two ways of expressing planes in \(\mathbb{R}^3\). In higher dimensions, all planes (also called 2-dimensional subspaces) must be expressed in parametric form. Read Chapter 4.4.

Solution

\(P=\begin{bmatrix} 0 \\ 0 \\ 0 \end{bmatrix} + s_1 \begin{bmatrix} 2 \\ -1 \\ 3 \end{bmatrix} + s_2 \begin{bmatrix} 1 \\ 2 \\ -1 \end{bmatrix}\), \(s_1, s_2 \in \mathbb{R}\)

The plane spanned by \(\vec{v_1}\) and \(\vec{v_2}\) is the set of all of their possible linear combinations, shown through the scalars \(s_1\) and \(s_2\). The \(\begin{bmatrix} 0 \\ 0 \\ 0 \end{bmatrix}\) at the start isn’t necessary to write, since if we set \(s_1 = s_2 = 0\) we get the point \((0, 0, 0)\) anyways, but it’s good to emphasize that the span of \(\vec{v_1}\) and \(\vec{v_2}\) includes the origin. The span of any collection of vectors always includes the origin.


Activity 5: Finding a Linearly Independent Subset

Recall from Chapter 4.2 that a set of vectors \(\vec v_1, \vec v_2, \ldots, \vec v_d\) is linearly independent if either of the following equivalent conditions hold:

  • None of the vectors can be written as a linear combination of the others.

  • The only way to create the zero vector as a linear combination of the vectors is if all the coefficients are zero. In other words, the only solution to

$$ a_1 \vec v_1 + a_2 \vec v_2 + \ldots + a_d \vec v_d = \vec 0 $$

is \(a_1 = a_2 = \ldots = a_d = 0\).

Chapter 4.2 introduces an algorithm for finding a linearly independent subset of a given set of vectors with the same span as the original set:

given v_1, v_2, ..., v_d
initialize linearly independent set S = {v_1}
for i = 2 to d:    if v_i is not a linear combination of S:
        add v_i to S

In each of the parts below, find a linearly independent set of vectors that spans the same span as the given set of vectors. There are multiple possible answers for each part, but all of them have the same number of vectors.

a)
$$ \vec v_1 = \begin{bmatrix} 1 \\\\ 0 \\\\ 0 \end{bmatrix}, \quad \vec v_2 = \begin{bmatrix} 1 \\\\ 1 \\\\ 0 \end{bmatrix}, \quad \vec v_3 = \begin{bmatrix} 1 \\\\ 1 \\\\ 1 \end{bmatrix}, \quad \vec v_4 = \begin{bmatrix} 2 \\\\ 3 \\\\ 4 \end{bmatrix} $$
Solution

\(i=2,S=\lbrace\vec{v_1}\rbrace: \vec{v_2} \notin \text{span}(S)\). There’s no way to make \(\vec{v_2}\) as a linear combination of \(v_1\), because \(\vec{v_1}\) has a 0 in the second component, while \(\vec{v_2}\) has a 1. So, we add \(\vec{v_2}\) to the set.

\(i=3,S=\lbrace\vec{v_1}, \vec{v_2}\rbrace: \vec{v_3} \notin \text{span}(S)\). Similar idea here, but with the third component instead of the second. Add \(\vec{v_3}\) to the set.

\(i=4,S=\lbrace\vec{v_1}, \vec{v_2}, \vec{v_3}\rbrace: \vec{v_4} \in \text{span}(S)\). We can make \(\vec{v_4}\) using \(-{v_1}+-{v_2}+4\vec{v_3}\).

Therefore, \(\boxed{S=\lbrace\vec{v_1}, \vec{v_2}, \vec{v_3}\rbrace}\). This is a set of 3 vectors. There are other possible answers too, like \(S=\lbrace\vec{v_1}, \vec{v_2}, \vec{v_4}\rbrace\); all possible answers have 3 vectors. In fact, since \(\text{span}(\lbrace\vec{v_1}, \vec{v_2}, \vec{v_3}\rbrace) = \mathbb{R}^3\), any three vectors in \(\mathbb{R}^3\) that don’t all lie on the same plane will form a linearly independent set with the same span as \(\vec v_1, \vec v_2, \vec v_3, \vec v_4\).

b)
$$ \vec v_1 = \begin{bmatrix} 1 \\\\ -1 \\\\ 0 \\\\ 0 \end{bmatrix}, \quad \vec v_2 = \begin{bmatrix} 1 \\\\ 0 \\\\ -1 \\\\ 0 \end{bmatrix}, \quad \vec v_3 = \begin{bmatrix} 1 \\\\ 0 \\\\ 0 \\\\ -1 \end{bmatrix}, \quad \vec v_4 = \begin{bmatrix} 0 \\\\ 1 \\\\ -1 \\\\ 0 \end{bmatrix}, \quad \vec v_5 = \begin{bmatrix} 0 \\\\ 1 \\\\ 0 \\\\ -1 \end{bmatrix}, \quad \vec v_6 = \begin{bmatrix} 0 \\\\ 0 \\\\ 1 \\\\ -1 \end{bmatrix} $$

Hint: Use the 0’s in the vectors strategically, plus use the fact that you can’t have more than 4 linearly independent vectors in \(\mathbb{R}^4\).

Solution
$$ \begin{align*} \text{Start with } S=\{\vec{v_1}\}& \\\\ i=2&: \vec{v_2} \notin \text{span}(S), \:\: S=\{\vec{v_1}, \vec{v_2}\}\\\\ i=3&: \vec{v_3} \notin \text{span}(S), \:\: S=\{\vec{v_1}, \vec{v_2}, \vec{v_3}\} \\\\ i=4&: \vec{v_4} \in \text{span}(S), \:\: -\vec{v_1}+\vec{v_2}=\vec{v_4}\\\\ i=5&: \vec{v_5} \in \text{span}(S), \:\: -\vec{v_1}+\vec{v_3}=\vec{v_5}\\\\ i=6&: \vec{v_6} \in \text{span}(S), \:\: -\vec{v_2}+\vec{v_3}=\vec{v_6 }\\\\ \text{Therefore: } \boxed{S=\{\vec{v_1}, \vec{v_2}, \vec{v_3}\}}. \end{align*} $$

This is a set of 3 vectors.