Recommended resources
The freely available resources this lesson will direct you to.
Hello! Welcome back to our journey into the mathematical foundations of AI.
In our last lesson, we introduced two fundamental concepts: the span of a set of vectors, which describes all the points they can "reach," and linear independence, which tells us if a set of vectors is efficient and free of redundancy.
Today, we will synthesize these two powerful ideas. This lesson focuses on the learning outcome: to define and construct a basis for a vector space and determine its dimension. We will define what constitutes a "perfect" set of vectors for describing a space and then use this to formally define and measure the "size" of that space. This concept is the bedrock of countless topics in machine learning, from dimensionality reduction to the very structure of neural network layers.
1. The Definition of a Basis
In the previous lesson, we saw that a set of vectors could be too small to span a space, or it could be too large and contain redundant, linearly dependent vectors. A basis is a set that is "just right."
Formally, a set of vectors is a basis for a vector space if it satisfies two conditions:
- The set is linearly independent.
- The set spans the vector space (i.e., ).
A basis is a maximally efficient description of a vector space. It contains the minimum number of vectors required to span the space, and every vector in that set is essential.
To begin, let's watch Professor Gilbert Strang formally introduce this crucial definition and provide some initial examples.
9. Independence, Basis, and Dimension
In this segment from his MIT lecture, Professor Strang combines the concepts of independence and span to define a basis. He provides clear examples in R³ to illustrate what qualifies as a basis and what does not.
Watch the segment from 21:47 to 34:14. Pay close attention to the two properties that define a basis and the examples given, including the standard basis and another, non-standard basis for R³.
To complement the video, the following text provides the same formal definitions along with further examples, including bases for spaces of matrices and polynomials.
This text from a linear algebra course provides a rigorous, written definition of a basis and its properties. It also introduces a key proposition: a set is a basis if and only if every vector in the space can be written as a unique linear combination of the basis vectors.
Read Section 1.5.1, 'Definition and Basic Properties of Bases'. Focus on the definition, the examples and non-examples, and the 'Proposition (Characterization of Bases)'. This proposition about unique representation is a cornerstone of why bases are so useful.
The concept of unique representation is powerful. It means that once you have chosen a basis for a vector space, you have established a coordinate system. Any vector in the space can be uniquely identified by its coordinates with respect to that basis.

2. Dimension: A Unique Size for Every Space
As Professor Strang mentioned, a vector space can have infinitely many different bases. But do all these bases have something in common? The answer is a profound yes, and it leads to one of the most important concepts in all of linear algebra.
Theorem: Any two bases of a finite-dimensional vector space have the same number of elements.
This theorem is so fundamental that it requires a formal proof. The proof relies on a "replacement" argument and is a fantastic exercise in rigorous logical thinking.
Proof: Any subspace basis has same number of elements | Linear Algebra | Khan Academy
This Khan Academy video provides a complete, step-by-step proof of the theorem that all bases for a vector space must have the same size. It uses a proof by contradiction, which is a common and powerful technique in mathematics.
Watch the entire video. The argument proceeds as follows: Assume for contradiction that you have a basis A with 'n' vectors and a spanning set B with 'm' vectors, where m < n. Show that you can replace one vector in B with a vector from A, and the resulting set still spans the space. Repeat this process 'm' times, until you have replaced all vectors in B with 'm' vectors from A. This new set, a subset of A, must also span the space. This leads to a contradiction, because it implies the full basis A (with 'n' vectors) must be linearly dependent, which is impossible. Follow this logical chain carefully; it is the formal justification for the concept of dimension.
Since every basis for a vector space has the same number of vectors, this number is an intrinsic, fundamental property of the space itself. We give it a special name: dimension.
Definition: The dimension of a finite-dimensional vector space , denoted , is the number of vectors in any basis for .
Let's hear Professor Strang summarize this idea.
9. Independence, Basis, and Dimension
This short clip concisely defines the dimension of a space as the number of vectors in any basis, solidifying the idea we just proved.
Watch from 34:14 to 37:21.
For example:
- The dimension of is , because the standard basis has vectors.
- The dimension of a plane through the origin in is 2.
- The dimension of a line through the origin in is 1.
- The dimension of the trivial vector space is 0, as its basis is the empty set.

3. Constructing a Basis
Now that we understand what a basis is and what its size (the dimension) means, how do we find one in practice? Given your background in building data pipelines, you'll appreciate that there are systematic algorithms for this.
The two main strategies are to "build up" an independent set or "reduce" a spanning set. A highly effective computational method for this involves row reduction, which connects back to concepts like rank and null space.
Let's watch a practical example of finding bases for the fundamental subspaces of a matrix.
9. Independence, Basis, and Dimension
Professor Strang now applies these concepts to find bases for the column space and null space of a matrix. This demonstrates a concrete algorithm and reinforces the connection between rank, nullity, and dimension.
Watch from 37:34 to 49:59. Note the following key procedures: Basis for the Column Space: The pivot columns of the original matrix form a basis for its column space. The dimension of the column space is the rank of the matrix, r. Basis for the Null Space: The 'special solutions' to Ax=0, which are found by setting each free variable to 1 in turn, form a basis for the null space. The dimension of the null space is the number of free variables, n - r.
This video establishes two crucial facts:
The sum of these dimensions is , the total number of columns, which is the famous Rank-Nullity Theorem.
For a detailed breakdown of the algorithms, please read the following text.
This resource formalizes the algorithms for finding bases of the row space, column space, and nullspace of a matrix using row reduction. It provides clear, step-by-step procedures that are directly applicable to computational problems.
Read Section 1.5.4, 'Finding Bases for Rn, Row Spaces, Column Spaces, and Nullspaces'. Pay close attention to the 'Theorem (Bases for Row and Column Spaces)' and the worked example that follows. This will solidify the computational procedure in your mind.
Test your understanding!
Let .
- Find a basis for the column space of , . What is its dimension?
- Find a basis for the null space of , . What is its dimension?
Hint: First, find the reduced row echelon form (RREF) of A.
Show answer
First, we row-reduce :
The RREF of is .
1. Basis for the Column Space
The pivot columns in the RREF are columns 1 and 2. Therefore, a basis for the column space of is formed by columns 1 and 2 of the original matrix .
A basis for is .
The dimension of the column space is the number of vectors in the basis, which is 2. So, .
2. Basis for the Null Space
From the RREF, we can write the system as:
The variables and are free. We can write the general solution as:
The two vectors in this linear combination form a basis for the null space.
A basis for is .
The dimension of the null space is the number of free variables, which is 2. So, .
Note that , which equals the number of columns of , as expected from the Rank-Nullity Theorem.
Conclusion
Today, we've taken a significant step in our journey, moving from collections of vectors to a deep understanding of the structure of the spaces they inhabit.
Here are the key takeaways from this lesson:
- A basis is a set of vectors that is both linearly independent and spans the vector space. It is an efficient, non-redundant "skeleton" for the entire space.
- A key theorem states that while a space can have many bases, they all have the same number of vectors.
- This unique number is called the dimension of the space, a fundamental measure of its size and complexity.
- We can construct a basis for key subspaces (like the column space and null space) of a matrix by using row reduction to identify pivot columns and free variables.
In the next lesson, we will shift our focus to matrix operations, including addition, multiplication, and transposition. With your newfound understanding of bases and dimension, you'll be equipped to see these operations not just as arithmetic rules, but as powerful tools that transform vector spaces.