In linear algebra, understanding the span of a set of vectors is fundamental. The span tells us what vectors can be formed using linear combinations of that set.
In this guide, we'll use MATLAB to answer two critical questions:
- Does a set of vectors span an entire space?
- Does a specific vector lie in the span of that set?
What is Span?
The span of vectors v₁, v₂, ..., vₙ is the set of all possible linear combinations:
c₁v₁ + c₂v₂ + ... + cₙvₙwhere c₁, c₂, ..., cₙ are scalars.
If the span equals the entire space (like ℝ⁴), we say the vectors span that space.
Step 1: Enter the Vectors
We begin by entering our vectors as row vectors in MATLAB:
v1 = [1 0 1 1];
v2 = [2 -2 3 2];
v3 = [1 -1 1 0];
v4 = [0 -1 1 1];Step 2: Create the Matrix of Column Vectors
To test span, the vectors must be placed into the columns of a matrix. We use the transpose operator .':
A = [v1.' v2.' v3.' v4.'];This creates a 4×4 matrix where each column is one of our vectors.
Step 3: Check if the Vectors Span the Space
We compute the reduced row echelon form (RREF):
reducedA = rref(A)Interpreting the Result
Count the number of pivot columns (columns with leading 1s in the reduced matrix).
Rule: If the number of pivot columns equals the dimension of the space, the vectors span that space.
In our example:
- The reduced matrix has 3 pivot columns, not 4
- We're working in ℝ⁴ (4-dimensional space)
Conclusion: The vectors do not span ℝ⁴.
Step 4: Check if a Vector Is in the Span
To test whether a vector w lies in the span, we form an augmented matrix:
w = [2 1 1 1];
Aw = [A w.'];
reducedAw = rref(Aw)Interpreting the Result
Look at the last column of the reduced augmented matrix:
- If there's a pivot in the last column: The system is inconsistent → w is not in the span
- If there's no pivot in the last column: The system is consistent → w is in the span
In our example, there's no pivot in the last column.
Conclusion: The vector w is in the span of the given vectors.
Why This Works
The augmented matrix represents the system:
c₁v₁ + c₂v₂ + c₃v₃ + c₄v₄ = wIf MATLAB can find values for c₁, c₂, c₃, c₄ that satisfy this equation, then w is in the span.
Quick Reference
| Task | MATLAB Code | What to Check |
|---|---|---|
| Do vectors span ℝⁿ? | rref([v1.' v2.' ...]) | Pivot columns = n? |
| Is w in the span? | rref([A w.']) | No pivot in last column? |
Key Takeaways
- Span of a space → count pivot columns in
rref(A) - Vector in span → check consistency of augmented matrix
rrefmakes both checks fast and reliable
Master these techniques and you'll breeze through linear algebra computations!



