Fix a few vectors and let their weights run over all numbers. The set of points you can reach is their span. See why one vector spans a line, why two usually span a plane, what happens in three dimensions, and when adding a vector adds nothing at all.
Define the span of a set of vectors as the set of all their linear combinations.
Describe the span of one vector, and of two vectors in the plane, and say when two vectors fail to span the plane.
Describe the possible spans in three dimensions: a point, a line, a plane, or all of space.
Test whether a given vector lies in a span by solving for the weights entry by entry.
Explain why adding a vector that is already in a span leaves the span unchanged.
In review. The maths and code on this page are checked by automated tests on every change, but an independent reader has not signed it off yet. Spot a mistake or a confusing step? Tell us.
The question
A linear model with two features makes its predictions by combining two columns of numbers. With three houses, each column has three entries, and so does the list of prices you want to match. Can the two weights always be tuned to hit all three prices exactly? The answer depends on a set: everything that the two columns can reach.
From the last lesson
1. What is a linear combination of \(\vect{u}\) and \(\vect{v}\)?
Show answer
A vector of the form \({a\,\vect{u}} + {b\,\vect{v}}\), where the numbers \(a\) and \(b\) are called the weights: scale each vector, then add.
2. Which number must not be zero for the formula to give the weights?
Show answer
\(D = u_1 v_2 - u_2 v_1\). When \(D \neq 0\), every target has exactly one pair of weights.
Intuition
In the last lesson the weights were fixed and the answer was one point. Now fix the vectors and let the weights run over every real number. Each choice of weights gives a point. Collect all of those points into one set. That set is the span of the vectors: everything you can reach by scaling them and adding.
M02.2.2-F1
The span of one vector is a line through the origin. Add a second vector that points off that line and the span becomes the whole plane: the point \((2, 1)\), out of reach on the left, is \({1\,\vect{u}} + {1\,\vect{v}}\) on the right.
The running pair is the same as before, \(\vect{u} = (1, -1)\) and \(\vect{v} = (1, 2)\).
Build it up
Step 1. One vector spans a line. The combinations of a single vector \(\vect{u}\) are its multiples \({c\,\vect{u}}\). As \(c\) runs over all numbers the tip traces a straight line. The line passes through the origin, because \(c = 0\) is allowed, and it runs both ways, because \(c\) may be negative. One exception: if \(\vect{u}\) is the zero vector, every multiple is zero and the span is just the origin.
Step 2. A second vector off the line sweeps the plane. Take \({a\,\vect{u}} + {b\,\vect{v}}\) and hold \(b\) still. As \(a\) varies, the points form a copy of the line of \(\vect{u}\), moved over by \({b\,\vect{v}}\). Now change \(b\): the copy slides along \(\vect{v}\). If \(\vect{v}\) points off the line, the sliding copies sweep across the whole plane.
M02.2.2-F2
Each value of \(b\) gives a copy of the line of \(\vect{u}\), moved by \({b\,\vect{v}}\). Left: when \(\vect{v}\) points off the line, the copies sweep the plane. Right: when \(\vect{v}\) lies on the line, every copy is the line itself.
Step 3. A second vector on the line adds nothing. Suppose \(\vect{v}\) is a multiple of \(\vect{u}\), say \(\vect{v} = {k\,\vect{u}}\). Then
which is still a multiple of \(\vect{u}\). Sliding the line along itself goes nowhere. Two vectors, but still only a line.
Step 4. The same story in space. In three dimensions one vector still spans a line. Two vectors that do not share a line span a flat sheet through the origin: a plane sitting inside space. For \(\vect{u} = (1, 0, 1)\) and \(\vect{v} = (0, 1, 1)\),
so the sheet is exactly the set of points whose third entry is the sum of the first two.
M02.2.2-F3
Left: two vectors in space span a sheet through the origin, and a third vector that lies in the sheet adds nothing. Right: a third vector that points off the sheet slides it through space, and the copies fill everything.
The vector \(\vect{w} = (0, 0, 1)\) is off the sheet, since \(0 + 0 \neq 1\). With it, \({a\,\vect{u}} + {b\,\vect{v}} + {c\,\vect{w}} = (a,\; b,\; a + b + c)\), and any target \((t_1, t_2, t_3)\) is reached by \(a = t_1\), \(b = t_2\) and \(c = t_3 - t_1 - t_2\). The three vectors span all of space.
Step 5. Each new vector either adds a direction or adds nothing. A new vector that is already in the span changes nothing. A new vector outside the span makes the span larger: here a line became a plane, and a sheet became all of space.
The formal statement
NoteDefinition: span
The span of the vectors \(\vect{v}_1, \dots, \vect{v}_k\) in \(\R^n\) is the set of all their linear combinations:
The vectors span a set \(V\) if their span is all of \(V\).
Three facts follow from the definition. Each is used again later in this module.
Fact 1: every span contains the origin. Choose every weight to be zero: \({0\,\vect{v}_1} + \cdots + {0\,\vect{v}_k} = \vect{0}\). So a line or a plane that misses the origin is never a span.
Fact 2: a span is closed. Adding two vectors of the span, or scaling one, never leaves it. Take \(\vect{x} = a_1\vect{v}_1 + \cdots + a_k\vect{v}_k\) and \(\vect{y} = b_1\vect{v}_1 + \cdots + b_k\vect{v}_k\), and any number \(c\). Collecting the terms of each \(\vect{v}_i\),
Both are again combinations of \(\vect{v}_1, \dots, \vect{v}_k\). A set with this property is called a subspace, a word that module M02.7 uses heavily.
Fact 3: when adding a vector adds nothing. Write \(S\) for \(\operatorname{span}\{\vect{v}_1, \dots, \vect{v}_k\}\). For any vector \(\vect{w}\),
\[
\begin{gathered}
\operatorname{span}\{\vect{v}_1, \dots, \vect{v}_k, \vect{w}\} = S \\
\text{exactly when}\quad \vect{w} \in S .
\end{gathered}
\]
Why. The larger set of vectors always spans at least as much, since \(\vect{w}\) can be given the weight zero. Suppose first that \(\vect{w}\) is in the smaller span, say \(\vect{w} = d_1\vect{v}_1 + \cdots + d_k\vect{v}_k\). Then any combination that uses \(\vect{w}\) can be rewritten without it:
So the two spans are equal. In the other direction, suppose the spans are equal. The vector \(\vect{w} = {0\,\vect{v}_1} + \cdots + {0\,\vect{v}_k} + {1\,\vect{w}}\) is in the larger span, so it is in the smaller one too.
Two vectors in the plane. Let \(D = u_1 v_2 - u_2 v_1\), the number from the last lesson.
If \(D \neq 0\), every target has weights (lesson M02.2.1), so the span is the whole plane.
If \(D = 0\), the span is a line through the origin, or only the origin.
Why the second case. If \(\vect{u} = \vect{0}\), the span is the set of multiples of \(\vect{v}\) alone. Otherwise one entry of \(\vect{u}\) is not zero. Say \(u_1 \neq 0\) and put \(k = v_1 / u_1\), so that \(v_1 = k u_1\). Then \(D = 0\) reads \(u_1 v_2 = u_2 v_1\), and dividing by \(u_1\) gives
\[
v_2 = \frac{u_2 v_1}{u_1} = k\,u_2 .
\]
Both entries agree, so \(\vect{v} = {k\,\vect{u}}\). (If instead \(u_1 = 0\), then \(u_2 \neq 0\); put \(k = v_2 / u_2\), and \(D = 0\) reads \(0 = u_2 v_1\), so \(v_1 = 0 = k u_1\) and again \(\vect{v} = {k\,\vect{u}}\).) By Step 3 every combination is then a multiple of \(\vect{u}\), and the span is the line of \(\vect{u}\).
The converse is one line: if \(\vect{v} = {k\,\vect{u}}\) then \(D = u_1 (k u_2) - u_2 (k u_1) = 0\), and the same happens if \(\vect{u}\) is a multiple of \(\vect{v}\).
So two vectors span the plane exactly when \(D \neq 0\), which is exactly when neither is a multiple of the other.
Go deeper: why a line can never be the whole plane
The picture makes this obvious, but it can also be proved. Let the line be all multiples of a vector \(\vect{d} = (d_1, d_2) \neq \vect{0}\). We show that the point \((-d_2, d_1)\) is not on it.
Suppose it were: \((-d_2, d_1) = {c\,(d_1, d_2)}\) for some number \(c\). Then \(-d_2 = {c\,d_1}\) and \(d_1 = {c\,d_2}\). Put the first into the second:
Since \(1 + c^2\) is at least 1, this forces \(d_1 = 0\), and then \(d_2 = -{c\,d_1} = 0\) as well. That contradicts \(\vect{d} \neq \vect{0}\). So the point \((-d_2, d_1)\) is off the line, and the line is not the whole plane.
Worked example
Let \(\vect{u} = (1, 0, 1)\) and \(\vect{v} = (0, 1, 1)\). Are \(\vect{p} = (1, 2, 3)\) and \(\vect{q} = (1, 2, 2)\) in their span?
M02.2.2-F4
A vector is in the span exactly when weights exist. The first two entries fix the weights, and the third entry tests them. \(\vect{p}\) passes and \(\vect{q}\) fails: it hangs one unit below the sheet.
Every combination has the form \({a\,\vect{u}} + {b\,\vect{v}} = (a, b, a + b)\). Match it to \(\vect{p} = (1, 2, 3)\) one entry at a time.
First entry: \(a = 1\).
Second entry: \(b = 2\).
Third entry: \(a + b\) must equal 3, and \(1 + 2 = 3\). It does.
All three equations hold, so \(\vect{p} = {1\,\vect{u}} + {2\,\vect{v}}\) is in the span.
Now \(\vect{q} = (1, 2, 2)\). The first two entries force the same weights, \(a = 1\) and \(b = 2\). The third entry would then have to be \(1 + 2 = 3\), but it is 2. Three equations, two unknowns, and no solution: \(\vect{q}\) is not in the span.
By Fact 3, adding \(\vect{p}\) to the set changes nothing: \(\vect{u}, \vect{v}, \vect{p}\) still span only the sheet. Adding \(\vect{q}\) does change it. Exercise 3 shows that \(\vect{u}, \vect{v}, \vect{q}\) span all of space.
Back to the houses. The feature columns are \(\vect{s} = (50, 80, 120)\) and \(\vect{r} = (1, 2, 4)\). The prices \((170, 280, 440)\) are in their span, with weights 3 and 20 (lesson M02.2.1). Change the last price to 450 and test again. The first two entries give \(50a + b = 170\) and \(80a + 2b = 280\). From the first, \(b = 170 - 50a\). Put it into the second: \(80a + 340 - 100a = 280\), so \(a = 3\) and \(b = 20\). The third entry is then \({120 \cdot 3} + {4 \cdot 20} = 440\), not 450. The prices \((170, 280, 450)\) are not in the span, and no choice of weights fits all three houses exactly.
This is the normal situation in machine learning. Two columns in \(\R^3\) span only a sheet, and real targets almost never lie exactly on it. Fitting a model means finding the point of the span that is closest to the target, an idea that starts in lesson M02.3.4.
Code
From scratch, for two vectors of any length: solve for the weights using the first two entries (the formula of lesson M02.2.1), then test every entry.
def in_span(u, v, t, tol=1e-9):"""Is t a combination of u and v? Returns (answer, weights found from entries 0 and 1).""" D = u[0] * v[1] - u[1] * v[0]if D ==0:raiseValueError("entries 0 and 1 do not fix the weights: use another pair of entries") a = (t[0] * v[1] - t[1] * v[0]) / D b = (u[0] * t[1] - u[1] * t[0]) / D fits =all(abs(a * u[k] + b * v[k] - t[k]) < tol for k inrange(len(t)))return fits, (a, b)u, v = (1, 0, 1), (0, 1, 1)print("p = (1, 2, 3):", in_span(u, v, (1, 2, 3)))print("q = (1, 2, 2):", in_span(u, v, (1, 2, 2)))size, bedrooms = (50, 80, 120), (1, 2, 4)print("prices (170, 280, 440):", in_span(size, bedrooms, (170, 280, 440)))print("prices (170, 280, 450):", in_span(size, bedrooms, (170, 280, 450)))
With NumPy, np.linalg.lstsq finds the weights whose combination comes closest to the target. If the closest point is the target itself, the target is in the span.
import numpy as npdef closest_in_span(vectors, t):"""The weights that bring the combination nearest to t, and the point they reach.""" columns = np.column_stack(vectors) target = np.asarray(t, dtype=float) weights = np.linalg.lstsq(columns, target, rcond=None)[0]return weights, columns @ weightsfor t in [(1, 2, 3), (1, 2, 2)]: weights, reached = closest_in_span([u, v], t)print(t, "weights", weights.round(3), "reached", reached.round(3), "in span:", np.allclose(reached, t))weights, reached = closest_in_span([size, bedrooms], (170, 280, 450))print("houses: weights", weights.round(2), "predictions", reached.round(1))
For \(\vect{q}\) the nearest point of the sheet is \((0.667, 1.667, 2.333)\), not \(\vect{q}\) itself. For the houses the best weights miss every price a little. That small miss, made as small as possible, is what “fitting a linear model” means.
Explore
M02.2-X1
Span explorer
Drag the tips of \(\vect{u}\) and \(\vect{v}\), or use their sliders. The shaded region is their span. Move the two weight sliders to walk the combination around, and drag the target \(\vect{t}\) to ask whether it can be reached.
Things to try:
Press Parallel. The shading collapses to a line. Move the weights: the combination cannot leave the line, and the read-out says the target is out of reach.
Press Module’s pair, then Jump to the target. The weights become 3 and 2, the answer to the worked example of lesson M02.2.1.
Press Nearly parallel and read the weights needed for the target. They are large and of opposite sign. Lesson M02.2.3 returns to this.
Make \(\vect{v}\) the zero vector. What is the span now?
Pitfalls
M02.2.2-F5
Wrong beside right. The span is not the patch between the arrows. Weights may be negative or large, so the span of this pair is the whole plane.
“The span is the region between the two arrows.”
That region uses only weights between 0 and 1. The definition allows every real weight. Negative weights reach behind the arrows, and large weights reach far beyond their tips. The point \((-2, -1)\) is \({-1\,\vect{u}} - {1\,\vect{v}}\).
“More vectors always means a bigger span.”
Only a vector outside the current span enlarges it (Fact 3). In a dataset, a feature column that is a combination of other columns, such as a price in pounds beside the same price in pence, adds nothing to what a linear model can predict.
“Any line or plane is the span of something.”
Every span contains the origin (Fact 1). The line of points \((x,\, x + 1)\) misses the origin, so it is not a span. It is a span that has been shifted, which is what the bias term of a model does.
“Two vectors span a plane, and three vectors span space.”
Only usually. Two vectors on one line span just that line. Three vectors in one sheet, such as \(\vect{u}\), \(\vect{v}\) and \(\vect{u} + \vect{v}\), span just that sheet. Counting vectors is not enough. The next lesson says what must be checked.
Check yourself
Recall
1. What is the span of a set of vectors?
Show answer
The set of all their linear combinations: everything you can reach by scaling them and adding.
2. What is the span of one non-zero vector?
Show answer
The line through the origin along that vector: all of its multiples.
3. When do two vectors in the plane fail to span the plane?
Show answer
When one is a multiple of the other, so that both lie on one line through the origin. In coordinates, when \(D = u_1 v_2 - u_2 v_1 = 0\).
4. For \(\vect{u} = (1, 0, 1)\) and \(\vect{v} = (0, 1, 1)\), what rule do the points of the span obey?
Show answer
Every combination is \((a, b, a + b)\), so the third entry is the sum of the first two.
5. When does adding a vector \(\vect{w}\) to a set leave its span unchanged?
Show answer
Exactly when \(\vect{w}\) is already in the span of the set.
Exercises
1.★ Describe the span of each set in words: (a) \(\{(2, 1)\}\) (b) \(\{(2, 1), (4, 2)\}\) (c) \(\{(2, 1), (1, 3)\}\) (d) \(\{(0, 0)\}\).
Show solution
(a) The line through the origin and the point \((2, 1)\).
(b) The same line, because \((4, 2) = {2\,(2, 1)}\) adds nothing. Check: \(D = {2 \cdot 2} - {1 \cdot 4} = 0\).
(c) The whole plane, because \(D = {2 \cdot 3} - {1 \cdot 1} = 5 \neq 0\).
(d) Only the origin: every multiple of the zero vector is the zero vector.
2.★★ Let \(\vect{u} = (1, 0, 1)\) and \(\vect{v} = (0, 1, 1)\). Is \((3, 1, 4)\) in their span? Is \((2, -1, 2)\)?
Show solution
Every combination is \((a, b, a + b)\).
For \((3, 1, 4)\): \(a = 3\), \(b = 1\), and the third entry must be \(3 + 1 = 4\). It is. So \((3, 1, 4) = {3\,\vect{u}} + {1\,\vect{v}}\) is in the span.
For \((2, -1, 2)\): \(a = 2\), \(b = -1\), and the third entry must be \(2 - 1 = 1\). It is 2. So \((2, -1, 2)\) is not in the span.
3.★★★ Show that \(\vect{u} = (1, 0, 1)\), \(\vect{v} = (0, 1, 1)\) and \(\vect{q} = (1, 2, 2)\) span all of \(\R^3\), by finding weights that reach an arbitrary target \((t_1, t_2, t_3)\).
Show solution
We need
\[
\begin{aligned}
&a\,\vect{u} + b\,\vect{v} + c\,\vect{q} \\
&\;= (a + c,\; b + 2c,\; a + b + 2c) \\
&\;= (t_1, t_2, t_3).
\end{aligned}
\]
The first entry gives \(a = t_1 - c\) and the second gives \(b = t_2 - 2c\). Put both into the third:
Weights exist for every target, so the span is all of \(\R^3\). For instance the target \((0, 0, 1)\) needs \(c = -1\), \(a = 1\), \(b = 2\): indeed \((1, 0, 1) + {2\,(0, 1, 1)} - (1, 2, 2) = (0, 0, 1)\).
Summary card
The span is everything the weights can reach.
M02.2.2-F1
One vector: a line. Two: usually a plane.
Span.\(\operatorname{span}\{\vect{v}_1, \dots, \vect{v}_k\}\) is the set of all \(c_1\vect{v}_1 + \cdots + c_k\vect{v}_k\).
Always through the origin, and closed under adding and scaling.
Two vectors in the plane span it exactly when \(D = u_1 v_2 - u_2 v_1 \neq 0\).
Adding \(\vect{w}\) changes nothing exactly when \(\vect{w}\) is already in the span.
Membership test.\(\vect{t}\) is in the span exactly when the equations for the weights have a solution.
Sources and next steps
Sources. Each was opened and checked against this lesson on 12 November 2026.
Sheldon Axler, Linear Algebra Done Right, 4th edition (open access). Section 2A, definition 2.4 (span, as the set of all linear combinations), result 2.6 (the span is the smallest subspace containing the vectors) and the second half of the linear dependence lemma 2.19 (removing a vector that lies in the span of the ones before it does not change the span).
Grant Sanderson, Linear combinations, span, and basis vectors, 3Blue1Brown, Linear Algebra, chapter 2. The span of most pairs of vectors in the plane is the whole plane, and a line when they line up; in space two vectors span a flat sheet through the origin, and a third vector on that sheet does not change the span.
Dan Margalit and Joseph Rabinoff, Interactive Linear Algebra, Section 2.2, Vector Equations and Spans. A vector is in the span exactly when the vector equation has a solution; two collinear vectors span a line and three coplanar vectors span a plane.
Marc Deisenroth, Aldo Faisal and Cheng Soon Ong, Mathematics for Machine Learning (free PDF). Section 2.6.1, definition 2.13 (generating set and span).
NumPy reference, numpy.linalg.lstsq: it returns the least-squares solution, the x that makes the length of b - a @ x as small as possible. Those are the weights whose combination is nearest the target.
Next.M02.2.3 Linear independence gives a name to the situation where a vector adds nothing, and a test for it.