At the end of Chapter 2.3, we considered the problem of approximating u=⎣⎡136⎦⎤ using a linear combination of v1=⎣⎡101⎦⎤ and v2=⎣⎡221⎦⎤.
from utils import plot_vectors
import numpy as np
import plotly.graph_objects as go
# Define the vectors
u = (1, 3, 6)
v1 = (1, 0, 1)
v2 = (2, 2, 1)
# Plot the vectors using plot_vectors function
vectors = [
(u, "orange", r"u"),
(v1, "#3d81f6", r"v₁"),
(v2, "#3d81f6", r"v₂"),
]
fig = plot_vectors(vectors, show_axis_labels=True, vdeltay=1)
# Make the plane look more rectangular by using a smaller, symmetric range for s and t
plane_extent = 20 # controls the "size" of the rectangle
num_points = 3 # fewer points for a cleaner rectangle
s_range = np.linspace(-plane_extent, plane_extent, num_points)
t_range = np.linspace(-plane_extent, plane_extent, num_points)
s_grid, t_grid = np.meshgrid(s_range, t_range)
plane_x = s_grid * v1[0] + t_grid * v2[0]
plane_y = s_grid * v1[1] + t_grid * v2[1]
plane_z = s_grid * v1[2] + t_grid * v2[2]
fig.add_trace(go.Surface(
x=plane_x,
y=plane_y,
z=plane_z,
opacity=0.8,
colorscale=[[0, 'rgba(61,129,246,0.3)'], [1, 'rgba(61,129,246,0.3)']],
showscale=False,
))
fig.update_layout(
scene_camera=dict(
eye=dict(x=0.8, y=2, z=1.2)
),
scene=dict(
zaxis=dict(range=[-3, 4]) # ensure z-axis hits -3
),
)
fig.show()
Loading...
v1 and v2 define a plane in R3. But not all pairs of vectors in R3 define a plane – for example, the vectors ⎣⎡100⎦⎤ and ⎣⎡200⎦⎤ define a line. How do we know if a set of vectors define a plane, line, or something else?
To motivate our discussion, let me recap “The Three Questions” involving linear combinations from Chapter 2.1.
So far, we’ve informally answered these questions in the context of various examples and problems. Here, I want to introduce a unifying framework for addressing these questions.
Above, I’ve used set builder notation to describe the span of a set of vectors. You’ll notice that I refer to v1,v2,…,vd as a set of vectors, but you’ll notice that I don’t always write them inside {set brackets}; this is just to save space. But when referring to a span, I’ll always write the spanning set inside {set brackets}.
Let’s look at several examples of spans, introducing important geometrical objects and ideas as we go. Chapter 2.5 will (eventually) cover how to describe lines, planes, and hyperplanes in Rn, and is designed to complement this section.
span({v}) is the set of all linear combinations of just v. Since there is only vector in the spanning set, there aren’t any other vectors to add to v, so the span is just the set of all scalar multiples of v.
span({v})={av∣a∈R}
The span of a single vector is always a line that passes through the origin and the vector’s coordinates. Another way of saying this is that a single vector spans a line. In Chapter 2.3, we learned how to project one vector onto the span of another vector.
For example, if we consider v=[12] in R2, the span is the line through the origin and (1,2), which you might also recognize as the line y=2x.
from utils import plot_vectors
import numpy as np
import plotly.graph_objects as go
v = (1, 2)
# Create the line spanned by v (all scalar multiples)
t = np.linspace(-2, 2, 100)
line_x = t * v[0]
line_y = t * v[1]
fig = plot_vectors([(v, "#3d81f6", r"v")], show_axis_labels=True, vdeltax=0.1)
# Add the line spanned by v
fig.add_trace(
go.Scatter(
x=line_x,
y=line_y,
mode="lines",
line=dict(color="rgba(0,77,64,0.6)", width=3, dash="dash"),
showlegend=False,
hoverinfo="skip",
zorder=0
),
)
# This annotation indicates the line represents all possible linear combinations of v alone
fig.add_annotation(
x=1.5 * v[0] - 0.1,
y=1.5 * v[1] - 0.6,
text=r"$\text{This line represents all possible} \\\ \text{linear combinations of } \vec v$",
showarrow=True,
arrowhead=2,
ax=40,
ay=40,
font=dict(size=12),
bgcolor="rgba(255,255,255,0.8)"
)
fig.update_yaxes(
scaleanchor="x",
scaleratio=1
)
fig.update_xaxes(
tickvals=np.arange(-1.5, 3, 0.5)
)
fig.show(renderer='png', scale=3)
There are infinitely many vectors in span({[12]}), including [24] and [−1−2], and the line shown above contains all of them. Notationally, we could say
As another example, consider v=⎣⎡2−13⎦⎤ in R3. The span of v is the line through the origin and (2,−1,3).
from utils import plot_vectors
import numpy as np
import plotly.graph_objects as go
v = (2, -1, 3)
# Create the line spanned by v (all scalar multiples)
t = np.linspace(-2, 2, 100)
line_x = t * v[0]
line_y = t * v[1]
line_z = t * v[2]
fig = plot_vectors([(v, "#3d81f6", r"v")], show_axis_labels=True, vdeltax=0.1)
# Add the line spanned by v to the 3D plot
fig.add_trace(
go.Scatter3d(
x=line_x,
y=line_y,
z=line_z,
mode="lines",
line=dict(color="rgba(0,77,64,0.6)", width=5, dash="dash"),
showlegend=False,
hoverinfo="skip"
)
)
# Draw small points at (0, 0, 0) and the tip of v
fig.add_trace(
go.Scatter3d(
x=[0, v[0]],
y=[0, v[1]],
z=[0, v[2]],
mode="markers",
marker=dict(size=4, color=["#222", "#222"]),
showlegend=False,
hoverinfo="skip"
)
)
fig.update_layout(
scene_camera=dict(
eye=dict(x=-1.2, y=2, z=1.2)
),
)
fig.show()
Loading...
The two marked points above are at the origin and (2,−1,3); I’ve marked them to emphasize that span({⎣⎡2−13⎦⎤}) is the unique line that passes through both (2,−1,3) and the origin. There are infinitely many lines that pass through (2,−1,3), but only one of those also passes through the origin.
Note that lines are 1-dimensional objects, regardless of the dimension of the space they live in. The line shown above is 1-dimensional in the sense that any point on the line can be described using a single variable. That variable is a from the definition of the span:
span({⎣⎡2−13⎦⎤})=⎩⎨⎧a⎣⎡2−13⎦⎤∣a∈R⎭⎬⎫
Give me an a, and I’ll give you a point on the line.
The fact that a single vector spans a line is true, regardless of the dimension of the vectors themselves. The span of the vector ⎣⎡12⋮100⎦⎤∈R100 is the line through the origin and (1,2,…,100) in R100. We can’t visualize what a line in 100-dimensional space looks like, but we know that it exists in this abstract sense.
Finally, I’ll say that in the edge case where v=⎣⎡00⋮0⎦⎤=0, span({0})={0} is just the single point corresponding to the origin, not a line.
To read more about how to describe lines in Rn – especially those that aren’t forced to pass through the origin, see Chapter 2.5.
v1 and v2 are scalar multiples of each other – i.e. they are collinear – so they only span a line, despite there being two vectors. They span the same line that either one of them spans individually, which is the line through the origin, (1,1), and (2,2).
If we start with just v1, the vector v2 doesn’t “unlock” or “contribute” any new vectors to the span, since v2 is just a scalar multiple of v1. As we will soon see, this means that the vectors v1 and v2 are linearly dependent.
If we didn’t immediately recognize that v2 is just a scalar multiple of v1 and tried to write b=[811] as a linear combination of v1 and v2, we might think it’s possible, since we’re working with a system of two equations and two unknowns.
a1[11]+a2[22]=[811]
But, when you go to solve, you’ll find
a1+2a2=8
a1+2a2=11
which is a contradiction, since 8=11.
And, for the vectors b that are in span({v1,v2}), there are infinitely many ways to write them as linear combinations of v1 and v2. For example,
1[11]+3[22]=[77]
7[11]+0[22]=[77]
−35[11]+21[22]=[77]
When solving for a1 and a2, I like to avoid situations where there are infinitely many solutions, since I’d like to make sure that if we all solve the same problem, we’ll all get the same answer. Remember that all of this connects back to linear regression and machine learning; the analog of a1 and a2 are the parameters of a linear model, and we’d like to have interpretable parameter values so that we can see how the inputs of a model relate to the outputs.
Back to the main idea. In R2, the span of two vectors is a line if the vectors are collinear, and the entire xy-plane otherwise.
As was the case in R2, since v1 and v2 aren’t collinear, they span a plane. In R2, there was only one possible plane that two vectors could span, because all of R2 itself is a plane, but in R3 there are infinitely many planes.
A plane is a flat surface that extends infinitely in all directions, with the property that if you connect any two points on the plane, the line connecting them lies entirely on the plane.
I hope to have convinced you earlier that lines are 1-dimensional objects, since you only need a single “variable” to describe any point on a given line.
Similarly, planes are 2-dimensional objects, since you need two “variables” to describe any point on a given plane. In the standard xy-plane, all you need to describe a point is an x coordinate and a y coordinate. Effectively, every vector in R2 can be written as a linear combination of the “default” (formally basis) vectors [10] and [01].
any point in R2=x[10]+y[01]
The plane shown above is also 2-dimensional, despite living in R3, since all I need are two variables to describe any point on it. The variables I need are a1 and a2, which are the multipliers on v1 and v2, respectively.
any point in span({v1,v2})=a1⎣⎡521⎦⎤+a2⎣⎡−230⎦⎤
Think of v1 and v2 as defining a new coordinate system for the plane that they span, where the coordinates themselves are the scalars a1 and a2. a1 and a2 can be arbitrarily large or small, which is what allows the plane to extend infinitely.
The picture above makes clear that there are many vectors in span({v1,v2}), but also many vectors in R3 that are not in the span. a1v1+a2v2=b has a solution for a1 and a2 if and only if b lies in the plane above.
In Chapter 2.5, I’ll say more about how to find the equation of a plane in the form ax+by+cz+d=0, but that’s not particularly important to us right now.
What if we’re dealing with two vectors in some arbitrary Rn? Consider
v1=⎣⎡5132−8⎦⎤,v2=⎣⎡01401⎦⎤
These vectors live in R5, but what they span is a “plane” in R5. The more typical way of phrasing this is that these vectors span a 2-dimensional subspace of R5.
We will formally define vector spaces and subspaces in a later chapter, but for now, think of a subspace as a flat object that passes through the origin and contains all linear combinations of some set of vectors.
A line through the origin is a 1-dimensional subspace.
A plane through the origin is a 2-dimensional subspace.
In higher dimensions, we’ll have 3-dimensional subspaces, 4-dimensional subspaces, and so on.
(A line that doesn’t pass through the origin is still a line, but isn’t a subspace, since subspaces must pass through the origin.)
The dimension of a subspace is the number of coordinates you need to describe any point in the subspace.
So although v1=⎣⎡5132−8⎦⎤ and v2=⎣⎡01401⎦⎤ sit inside R5, what they span is not all of R5, but rather a 2-dimensional “slice” of it, consisting of all linear combinations of v1 and v2. Any point in that subspace can be described using two coordinates, like a1 and a2 in
any point in span({v1,v2})=a1⎣⎡5132−8⎦⎤+a2⎣⎡01401⎦⎤
So far, as special cases, we’ve considered the span of one vector and the span of two vectors. The case of three vectors is the last special case I’ll cover, and then we’ll generalize to any number of vectors in any Rn.
Suppose we have three vectors in R2. What are their possible arrangements?
All three are the zero vector, 0.
All three are collinear, meaning they lie on the same line.
Two are collinear, and the third points in a different direction.
All three point in different directions.
In all of these cases, the “largest” their span can be is all of R2. Case 3 and Case 4 are shown below, on the left and right, respectively.
from utils import plot_vectors
import plotly.graph_objects as go
from plotly.subplots import make_subplots
import numpy as np
# Vectors
v1 = (1, 1)
v2_a = (2, 2)
v2_b = (-1, 2)
v3 = (-3, 0)
# Common style for axes/layout
common_axis = dict(
gridcolor="#f0f0f0",
griddash="solid",
showgrid=True,
zeroline=True,
zerolinecolor="#f0f0f0",
zerolinewidth=1,
constrain="domain",
showticklabels=False,
title_text=None,
)
common_layout = dict(
xaxis_range=[-3, 4],
yaxis_range=[-3, 4],
plot_bgcolor="white",
paper_bgcolor="white",
font_family="Palatino",
font_size=18,
)
# Helper to generate a figure for a given v2
def make_vector_fig(v2, label):
fig = plot_vectors(
[(v2, "#3d81f6", r"v₂"), (v1, "orange", r"v₁"), (v3, "#d81b60", r"v₃")],
show_axis_labels=False,
vdeltax=0.1,
)
fig.update_xaxes(scaleanchor="y", scaleratio=1, **common_axis)
fig.update_yaxes(scaleanchor="x", scaleratio=1, **common_axis)
fig.update_layout(**common_layout)
return fig
# Two separate figs
fig1 = make_vector_fig(v2_a, "v₂ = (2, 2)")
fig2 = make_vector_fig(v2_b, "v₂ = (-1, 2)")
# Combine in subplots
subplot_fig = make_subplots(
rows=1, cols=2, horizontal_spacing=0.01
)
for trace in fig1.data:
subplot_fig.add_trace(trace, row=1, col=1)
for trace in fig2.data:
subplot_fig.add_trace(trace, row=1, col=2)
subplot_fig.update_xaxes(**common_axis, range=[-3, 4], row=1, col=1)
subplot_fig.update_yaxes(**common_axis, range=[-3, 4], row=1, col=1,
scaleanchor="x", scaleratio=1)
subplot_fig.update_xaxes(**common_axis, range=[-3, 4], row=1, col=2)
subplot_fig.update_yaxes(**common_axis, range=[-3, 4], row=1, col=2,
scaleanchor="x", scaleratio=1)
# Annotate the left graph (col 1) to indicate we only need one of the blue or orange vectors
subplot_fig.add_annotation(
text=r"The <span style='color: #3d81f6'>blue</span> and <span style='color: orange'>orange</span> vectors are redundant.<br>Remove either one of them,<br>and the remaining 2 vectors<br>will still span all of R².",
x=0.5, y=4,
xref="x1", yref="y1",
showarrow=False,
font=dict(size=18, color="black"),
bgcolor="rgba(255,255,255,0.8)",
# bordercolor="black",
borderwidth=1,
)
# Annotate the right graph (col 2) to indicate any 2 of the 3 vectors will span the same plane
subplot_fig.add_annotation(
text=r"Any 2 of these 3 vectors<br>span all of R².<br>One is redundant.",
x=0.5, y=3.85,
xref="x2", yref="y2",
showarrow=False,
font=dict(size=18, color="black"),
bgcolor="rgba(255,255,255,0.8)",
borderwidth=1,
)
subplot_fig.update_layout(width=800, height=500, showlegend=False, **common_layout)
subplot_fig.show(renderer="png", scale=3)
In the left example, v3=[−30] travels in a direction that v1=[11] and v2=[22] don’t, so removing v3 would impact the span (it would drop from R2 to a line). But, we don’t need both v1 and v2 to span R2, since v1 already travels in the direction of v2.
In the right example, where
v1=[11],v2=[−12],v3=[−30]
Any two of these vectors will span the entirety of R2, meaning that if you pick any two of them, you can recreate the third one. These three vectors are linearly dependent.
Notice that all three vectors lie on the same plane. But, as we saw earlier, you only need two vectors to span a plane. If you remove any one of the three vectors, the remaining two will still span the exact same plane.
This is a consequence of the fact that you can write v3 as a linear combination of v1 and v2.
v1=⎣⎡111⎦⎤,v2=⎣⎡1−2−3⎦⎤,v3=⎣⎡−301⎦⎤
v3=−2v1−v2
Starting from v1 and v2 alone, adding v3 doesn’t unlock any new directions, since it’s already a linear combination of v1 and v2.
There is nothing “especially wrong” about v3. We can rearrange the above to get v2=−2v1−v3 and v1=−21v2−21v3, too.
As we saw earlier in the case of two collinear vectors in R2, having a vector that can be written as a linear combination of the other vectors in the set means that when we go to write other vectors as linear combinations of the vectors in the set, if it’s possible, there are infinitely many solutions.
If we let b=⎣⎡b1b2b3⎦⎤ be any arbitrary vector in R3, then the system
a1v1+a2v2+a3v3=b
either has no solutions, if b is not on the plane defined by span({v1,v2,v3}), or it has infinitely many.
Let’s now consider Case 4, from the 4 cases above.
All three are the zero vector, 0. (Annoying edge case, but I’m including it for completeness.)
All three are collinear, meaning they span a line.
All three are on the same plane, meaning they span that same plane.
Drag the plot around to see the space from different angles. If we look at any pair of these vectors, we see they span a plane. But, since neither is a linear combination of the other two, all three of them bring something new to the span; none are redundant.
So, the span of these three vectors is all of R3! You can think of these three vectors as defining a new coordinate system for R3.
The default coordinate system in R3 uses three numbers to describe any point in R3. Those three numbers are used to take a linear combination of the default basis vectors,
any point in R3=x⎣⎡100⎦⎤+y⎣⎡010⎦⎤+z⎣⎡001⎦⎤
The coordinate system defined by v1, v2, and v3 also uses three numbers to describe any point in R3, it’s just that the coordinates used multiply vectors other than the default ones.
any point in R3=a1⎣⎡111⎦⎤+a2⎣⎡14−3⎦⎤+a3⎣⎡−301⎦⎤
So, any vector b∈R3 can be written as a linear combination of v1, v2, and v3.
Let’s generalize what we’ve discussed so far. What I’m about to say is abstract, but try and keep track of how it relates to the examples we’ve seen so far. If ever in doubt, plug in numbers for d and n to help make sense of it.
Remember that I’ve told you to think of a subspace as a flat object that passes through the origin and contains all linear combinations of some set of vectors. The dimension of a subspace is the number of coordinates you need to describe any point in the subspace; for instance, a line through the origin is a 1-dimensional subspace, and a plane through the origin is a 2-dimensional subspace.
Suppose we have d vectors, all in Rn, labeled v1, v2, ..., vd. Then,
If we have fewer than n vectors, i.e. d<n, then the vectors span a 1, or 2, or 3, ..., or d-dimensional subspace of Rn.
If we have at least n vectors, i.e. d≥n, then the vectors span a 1, or 2, or 3, ..., or n-dimensional subspace of Rn. (An n-dimensional subspace of Rn is all of Rn.)
Put this succinctly, the dimension of the subspace spanned by the vectors is between 1 and min(d,n).
In general, given a set of d vectors in Rn, actually finding the dimension of the subspace they span involves solving a system of n equations and d unknowns. Later in this section, when we discuss how to find linear independent subsets, we’ll see how to do this by hand. But, know that numpy can help us.
For example, suppose we have d=5 vectors in R7, given by
Intuitively, if a set of vectors is linearly dependent, then one of the vectors is a linear combination of the others. Equivalently, if a set of vectors is linearly dependent, there’s a non-trivial linear combination of the vectors that equals the zero vector (by non-trivial, I mean that at least one of the coefficients is non-zero).
Why are these two conditions equivalent? Here’s one way to see it. Suppose v1=αv2+βv3, meaning that v1 can be written as a linear combination of v2 and v3. Rearranging the equation above gives us
v1−αv2−βv3=0
which shows us a non-trivial linear combination of v1,v2,v3 that gives 0. The converse (reverse direction) is true too: if you start with a non-trivial linear combination of v1,v2,…,vd that gives 0, then you can rearrange it to get v1=some linear combination of v2,…,vd.
Let’s look at several sets of vectors and comment on their linear independence (or lack thereof).
Vectors
Linearly...
Why?
⎣⎡103⎦⎤,⎣⎡215⎦⎤
Independent
Neither is a multiple of the other.
⎣⎡103⎦⎤,⎣⎡215⎦⎤,⎣⎡5210⎦⎤,⎣⎡111⎦⎤
Dependent
These vectors live in R3, which is a universe that only has 3 independent directions, so you only need 3 vectors to span it. Give 4 vectors, we can write at least one of them as a linear combination of the others.
⎣⎡103⎦⎤,⎣⎡215⎦⎤,⎣⎡5213⎦⎤
Dependent
first vector+2(second vector)=third vector
⎣⎡103⎦⎤,⎣⎡215⎦⎤,⎣⎡5210⎦⎤
Independent
The first two were already linearly independent from the first example, and we can’t write the third as a linear combination of the first two.
Note that if a set of vectors is linearly dependent, it doesn’t mean that every vector in the set can be written as a linear combination of the others. It just means that there’s at least one vector that can be written as a linear combination of the others. A good go-to example for this is the one below – v1 and v2 are scalar multiples of each other, making the entire set of three vectors linearly dependent, but but v3 is not a linear combination of v1 and v2.
Fact: If a set of vectors v1,v2,…,vd is linearly independent, then any vector b in the span of the vectors can be written as a unique linear combination of the vectors.
We’ve built intuition for this above, but let’s give a formal proof.
Let’s imagine an alternate universe where b∈span({v1,v2,…,vd}) can be written as two different linear combinations of the vectors. (We’re doing a proof by contradiction, if you’re familiar with the idea.) In other words, suppose
a1v1+a2v2+…+advd=b
and
c1v1+c2v2+…+cdvd=b
and not all of the ai and ci are equal, meaning there’s at least one i such that ai=ci.
What happens if we subtract the two equations?
(a1−c1)v1+(a2−c2)v2+…+(ad−cd)vd=0
Since v1,v2,…,vd are linearly independent, the only way this equation can hold is if all of the coefficients on the vi are zero. In other words, we’d need
a1−c1=0a2−c2=0…ad−cd=0
But if that’s the case, then ai=ci for all i, which contradicts our assumption that not all of the ai and ci are equal.
So, this means that it can’t be the case that b can be written as two different linear combinations of the vectors. In other words, b can be written as a unique linear combination of the vectors, when the vectors v1,v2,…,vd are linearly independent.
Finding Linearly Independent Subsets with the Same Span¶
Given a set of vectors v1,v2,…,vd∈Rn, we’d like to find a subset of the vectors that is linearly independent and has the same span as the original set of vectors. In other words, we’d like to “drop” the vectors that are linearly dependent on the others. For example, if we have 3 vectors in R3 and they span a plane, we can drop one of them and still span the same plane (not just any plane).
In the example below, we can remove any one of the three vectors, and the span of the remaining two is still the same plane.
Dropping any “unnecessary” vectors will give us the desirable property that any vector in the span of the original set of vectors can be written as a unique linear combination of the vectors in the subset. (Remember that this has a connection to finding optimal model parameters in linear regression --- this is not just an arbitrary exercise in theory.)
One way to produce a linear independent subset is to execute the following algorithm:
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
The vectors we’re left with form a basis for the span of the original set of vectors. The number of vectors we’re left with is the dimension of the span of the original set of vectors.
Let’s evaluate this algorithm on the following set of vectors:
Iteration 1 (i=2): Is v2 a linear combination of the vectors in S? No, since v2 is not a multiple of v1. The first components (3 in v1, 0 in v2) imply that if v2 were a multiple of v1 it’d need to be 0v1, but the other components of v2 are non-zero.
Outcome: Add v2 to S. Now, S={v1,v2}.
Iteration 2 (i=3): Is v3 a linear combination of the vectors in S? To determine the answer, we need to try and find scalars a1 and a2 such that a1v1+a2v2=v3.
The first equation implies a1=−1 and the third equation implies a2=2. Plugging both into the second equation gives 4(−1)+1(2)=−2, which is consistent. This means that v3=−v1+2v2, so v3 is a linear combination of v1 and v2, and we should not add it to S.
Outcome: Leave S unchanged. Now, S={v1,v2}.
Iteration 4 (i=4): Is v4 a linear combination of the vectors in S? To determine the answer, we need to try and find scalars a1 and a2 such that a1v1+a2v2=v4.
Similarly, we see that a1=2 (from the first equation) and a2=−3 (from the third equation) are consistent with the second equation. This means that v4=2v1−3v2, so v4 is a linear combination of v1 and v2, and we should not add it to S.
Outcome: Leave S unchanged. Now, S={v1,v2}.
Iteration 5 (i=5): Is v5 a linear combination of the vectors in S? To determine the answer, we need to try and find scalars a1 and a2 such that a1v1+a2v2=v5.
The first equation implies a1=32 and the third equation implies a2=1. Plugging both into the second equation gives 4(32)+1(1)=311=5, which means the system is inconsistent. So, v5 is not a linear combination of v1 and v2, and we should add it to S.
Outcome: Add v5 to S. Now, S={v1,v2,v5}.
v1,v2,v5 are linearly independent vectors that have the same span as the original set of vectors. And since these are 3 linearly independent vetors in R3, their span is all of R3, since R3 is 3-dimensional and only has 3 independent directions to begin with!
Note that the subset that this algorithm produces is not unique, meaning that there exist other subsets of 3 of {v1,v2,v3,v4,v5} that are also linearly independent and have the same span as all of {v1,v2,v3,v4,v5} do (which is also the span of {v1,v2,v5}) If you started with v5, then considered v4, then considered v3, and so on, you’d end up with a subset that includes v4, for instance.
What is fixed, though, is how many linearly independent vectors you need to span the entire subspace that these five vectors span, and the answer to that is 3.
Homework 4 will have you practice this algorithm several times, though – as mentioned above – we’ll use the power of Python to handle some of this for us, soon.
Here’s one final abstract activity to think about. Answers aren’t provided since there’s a very similar question on Homework 4. But come ask us questions about it in office hours!