8. Span, linear independence
§16.0 introduced the linear combination; §17.0 showed that a set closed under linear combinations is exactly a subspace. This lesson names the subspace a given set of vectors generates (span), and asks the natural follow-up question — does every vector in that set genuinely contribute, or is one of them redundant (linear independence)?
Span
The span of vectors \vec v_1,\dots,\vec v_k\in V is the set of all their linear combinations:
\operatorname{span}\{\vec v_1,\dots,\vec v_k\}=\{c_1\vec v_1+\cdots+c_k\vec v_k:c_1,\dots,c_k\in\mathbb{R}\}
\operatorname{span}\{\vec v_1,\dots,\vec v_k\} is always a subspace — it trivially contains \vec0 (all c_i=0), and it's closed under addition and scaling because combining two linear combinations, or scaling one, is still a linear combination. This is the main source of subspaces in practice: rather than checking §17.0's three-part test by hand, exhibit the subspace as a span and the test is automatic.
Geometric pictures: \operatorname{span}\{\vec v\} for a single nonzero \vec v\in\mathbb{R}^3 is the line through the origin in \vec v's direction. \operatorname{span}\{\vec v_1,\vec v_2\} for two non-parallel vectors is the plane through the origin containing both. Add a third vector not in that plane, and the span becomes all of \mathbb{R}^3.
"Does span\{\vec v_1,\dots,\vec v_k\} contain \vec b?" is exactly §16.1's question "is A\vec x=\vec b consistent?" for A=[\vec v_1\ \cdots\ \vec v_k] (the \vec v_i as columns) — this is just restating §16.2's column-combination view of matrix-vector multiplication. A set spans \mathbb{R}^n (reaches every vector) exactly when the corresponding matrix has a pivot in every row after elimination.
Linear independence
\vec v_1,\dots,\vec v_k are linearly independent if the only linear combination equal to \vec0 is the trivial one:
c_1\vec v_1+\cdots+c_k\vec v_k=\vec0\ \Longrightarrow\ c_1=c_2=\cdots=c_k=0
If some other combination also gives \vec0, the set is linearly dependent. Equivalently — and this is the operationally useful version — a set is dependent exactly when some vector in it is a linear combination of the others (solve the dependence relation for any c_i\neq0 and divide through). Independence is the precise sense in which "no vector in the set is redundant": removing any vector from an independent set genuinely shrinks the span, while removing a dependent vector from a dependent set changes nothing.
Testing independence is again exactly a linear-system question: form A=[\vec v_1\ \cdots\ \vec v_k] and solve A\vec c=\vec0 (a homogeneous system, always consistent since \vec c=\vec0 always works — the only question is whether it's the only solution). By §16.1's RREF analysis:
\{\vec v_1,\dots,\vec v_k\}\text{ independent}\iff A\vec c=\vec0\text{ has only the trivial solution}\iff A\text{ has a pivot in every column}
A quick necessary condition: more than n vectors in \mathbb{R}^n are always dependent (a matrix with more columns than rows cannot have a pivot in every column — there aren't enough rows to hold them). This doesn't decide independence for k\le n vectors, but it rules it out immediately for k>n.
Doing it in Python
import sympy as sp
v1 = sp.Matrix([1, 2, 1])
v2 = sp.Matrix([2, 1, 0])
b = sp.Matrix([4, 5, 2])
A = sp.Matrix.hstack(v1, v2)
sol = sp.linsolve((A, b))
print("does span{v1,v2} contain b?", sol != sp.EmptySet)
print("coefficients:", list(sol)[0] if sol != sp.EmptySet else None)
does span{v1,v2} contain b? True
coefficients: (2, 1)
Testing independence directly:
import sympy as sp
def independent(vectors):
A = sp.Matrix.hstack(*vectors)
rref, pivots = A.rref()
return len(pivots) == A.cols
v1 = sp.Matrix([1, 0, 1])
v2 = sp.Matrix([0, 1, 1])
v3 = sp.Matrix([1, 1, 2]) # = v1 + v2
print("{v1, v2} independent:", independent([v1, v2]))
print("{v1, v2, v3} independent:", independent([v1, v2, v3]))
A = sp.Matrix.hstack(v1, v2, v3)
rref, pivots = A.rref()
print("pivot columns:", pivots, " (only", len(pivots), "of 3 columns are pivots)")
{v1, v2} independent: True
{v1, v2, v3} independent: False
pivot columns: (0, 1) (only 2 of 3 columns are pivots)
Worked example
Are \vec v_1=(1,2,3), \vec v_2=(0,1,4), \vec v_3=(2,1,-2) linearly independent?
Solve c_1\vec v_1+c_2\vec v_2+c_3\vec v_3=\vec0, i.e. row-reduce A=\begin{pmatrix}1&0&2\\2&1&1\\3&4&-2\end{pmatrix}.
R_2\leftarrow R_2-2R_1, R_3\leftarrow R_3-3R_1:
\begin{pmatrix}1&0&2\\0&1&-3\\0&4&-8\end{pmatrix}
R_3\leftarrow R_3-4R_2:
\begin{pmatrix}1&0&2\\0&1&-3\\0&0&4\end{pmatrix}
Three pivots (columns 1,2,3) — a pivot in every column.
\boxed{\text{Independent}}
Sanity check. Since there are 3 pivots for 3 vectors in \mathbb{R}^3, this set is also a basis for \mathbb{R}^3 (§17.2 makes precise why "independent set of the right size" earns that name) — and indeed \det A=1(1(-8)-(-3)(4))-0+2(2(4)-1(3))=1(4)+2(5)=14\neq0, confirming full rank independently via §16.4's determinant test, a completely different calculation arriving at the same conclusion.
Your turn
1. Does \operatorname{span}\{(1,0),(0,1)\} equal all of \mathbb{R}^2? Justify briefly.
2. Are \vec v_1=(1,-1,2) and \vec v_2=(-2,2,-4) linearly independent?
3. True or false: any set of vectors containing \vec0 is linearly dependent.
Solutions
1. Yes. Any (a,b)\in\mathbb{R}^2 equals a(1,0)+b(0,1) directly — every target vector is reachable, so the span is all of \mathbb{R}^2. (These are the standard basis vectors \vec e_1,\vec e_2 from §16.0.)
2. Dependent. \vec v_2=-2\vec v_1 — one vector is a scalar multiple of the other, i.e. 2\vec v_1+\vec v_2=\vec0 is a nontrivial combination (c_1=2,c_2=1, not both zero) equal to \vec0. (Any two parallel vectors are automatically dependent — geometrically, they span only a line, not a plane, even though there are two of them.)
3. True. If \vec0 is among the vectors, then 1\cdot\vec0+0\cdot(\text{everything else})=\vec0 is a nontrivial combination (the coefficient on \vec0 is 1\neq0) equal to \vec0 — so the set is dependent regardless of what the other vectors are.
Check yourself in code
Determine whether \vec v_1=(1,2,0), \vec v_2=(2,1,1), \vec v_3=(0,0,1) are linearly independent, and whether they span \mathbb{R}^3.
Print exactly this:
pivots: (0, 1, 2)
independent: True
spans R^3: True
import sympy as sp
v1 = sp.Matrix([1, 2, 0])
v2 = sp.Matrix([2, 1, 1])
v3 = sp.Matrix([0, 0, 1])
A = sp.Matrix.hstack(v1, v2, v3)
rref, pivots = A.rref()
print("pivots:", pivots)
# print "independent" (pivot in every column) and "spans R^3"
# (a pivot in every row, since A is 3x3, is the same condition here)
import sympy as sp
v1 = sp.Matrix([1, 2, 0])
v2 = sp.Matrix([2, 1, 1])
v3 = sp.Matrix([0, 0, 1])
A = sp.Matrix.hstack(v1, v2, v3)
rref, pivots = A.rref()
print("pivots:", pivots)
print("independent:", len(pivots) == A.cols)
print("spans R^3:", len(pivots) == A.rows)
Span collects every linear combination of a set of vectors into a subspace; linear independence asks whether that set has any redundancy, tested by whether A\vec c=\vec0 has only the trivial solution — equivalently, a pivot in every column. Both questions reduce to the same Gaussian-elimination machinery from Module 16, just aimed at \vec0 instead of a general \vec b.
Next: combining an independent spanning set into a single idea — a basis — and the number that turns out to be the same no matter which basis is chosen: dimension.