Hello! Welcome to our fourth lesson on Singular Value Decomposition.
In our previous lessons, we built a strong foundation for SVD. We learned how to construct the decomposition and, crucially, developed a geometric intuition for it: any matrix transformation is just a sequence of a rotation (), a scaling (), and a final rotation ().
Today, we will connect this geometric picture to the fundamental algebraic structure of a matrix. Our goal is to use the SVD to determine the rank, kernel (null space), and image (column space) of a matrix. You'll see that once you have the SVD of a matrix, these essential properties can be identified almost by simple inspection. This turns SVD into a powerful analytical tool, revealing the core structure of any linear transformation.
1. The Four Fundamental Subspaces
Before we dive into the SVD's role, let's briefly revisit the four fundamental subspaces associated with any matrix . You've encountered some of these concepts before, like span and solution sets, but let's organize them.
- Column Space (or Image), : The set of all possible output vectors. It's the span of the columns of . A vector is in the column space if the equation has a solution. It is a subspace of .
- Null Space (or Kernel), : The set of all input vectors that are mapped to the zero vector. It's the set of all solutions to the equation . It is a subspace of .
- Row Space, : The span of the rows of . It is a subspace of .
- Left Null Space, : The null space of the transpose of . It is a subspace of .
These four spaces are not independent; they are linked by deep and elegant relationships. The following diagram, famously drawn by Gilbert Strang, provides a powerful mental map of how they relate.

The dimension of both the column space and the row space is the rank of the matrix, denoted by . The diagram also shows the dimensions of the null spaces, which are given by what we'll later know as the Rank-Nullity Theorem.
The amazing thing about SVD is that it gives us an orthonormal basis for all four of these subspaces.
2. Reading the Subspaces from SVD
Let's see how the SVD factorization cleanly separates these subspaces.
The most direct and perhaps most important property that SVD reveals is the rank of the matrix.
The rank of a matrix is equal to the number of its non-zero singular values.
This is because the singular values represent the "stretching" factors of the transformation. If a singular value is zero, it means the transformation collapses that dimension entirely. The number of dimensions that survive the transformation is the rank.
To understand how SVD reveals the bases for the subspaces, it's helpful to expand the SVD equation. Let's assume is an matrix of rank . This means there are non-zero singular values. We can write the equation as . Let's look at what this means for each column vector of :
By looking at this column by column, we get two distinct cases:
- For :
- For : (since the corresponding singular values are zero)
These two simple equations are incredibly powerful. They tell us exactly where SVD places the basis vectors for the fundamental subspaces.
The following reading explains this derivation clearly and summarizes the results.
Singular Value Decomposition (SVD)
This article from the Quantecon project provides a concise and clear explanation of how the matrices U and V from the SVD provide orthonormal bases for the four fundamental subspaces.
Please read the section '4.4. Four Fundamental Subspaces'. Focus on the partitioned matrix equation (4.2) and the resulting systems of equations (4.3 and 4.5). The final summary in table (4.7) is the main takeaway, which you should understand thoroughly.
Summary of SVD and the Four Subspaces
Let's consolidate the key findings from the reading. For an matrix of rank , with SVD :
- Column Space : The first columns of , , form an orthonormal basis for the column space.
- Intuition: The equation shows that the outputs of the transformation are spanned by these vectors.
- Null Space : The last columns of , , form an orthonormal basis for the null space.
- Intuition: The equation for these vectors is the very definition of the null space.
- Row Space : The first columns of , , form an orthonormal basis for the row space.
- Left Null Space : The last columns of , , form an orthonormal basis for the left null space.
This is a remarkable result. The SVD calculation, which we perform for geometric reasons, simultaneously gives us a complete, orthonormal description of the matrix's fundamental structure.
3. A Concrete Example
Let's solidify this with a practical example. As a computer science student, you'll appreciate that libraries like NumPy can compute the SVD in a single line of code, after which we can just "read off" the subspaces.
Consider the following Python code, which analyzes a 5x5 matrix A.
import numpy as np
np.set_printoptions(precision=2, suppress=True)
# Define a 5x5 matrix of rank 2
A = np.array([[1, 2, 3, 4, 5],
[2, 4, 6, 8, 10],
[3, 5, 8, 11, 14],
[4, 7, 11, 15, 19],
[5, 9, 14, 19, 24]])
# Compute the SVD
U, S, Vt = np.linalg.svd(A)
# Compute the rank
rank = np.linalg.matrix_rank(A)
print("Rank of matrix A:", rank)
print("\nSingular values (S):", S)
# Identify the basis vectors
# Note: In Python, we use slicing. V is already transposed in the output, so we take rows.
basis_col_space = U[:, :rank]
basis_left_null_space = U[:, rank:]
basis_row_space = Vt[:rank, :].T # Transpose to get column vectors
basis_null_space = Vt[rank:, :].T # Transpose to get column vectors
print("\nShape of basis for Column Space:", basis_col_space.shape)
print("Shape of basis for Null Space:", basis_null_space.shape)
Running this code would produce output like this:
Rank of matrix A: 2
Singular values (S): [50.84 2.39 0. 0. 0. ]
Shape of basis for Column Space: (5, 2)
Shape of basis for Null Space: (5, 3)
Let's interpret this result:
- The rank is 2, which matches the number of non-zero singular values (50.84 and 2.39).
- The column space is a 2-dimensional subspace of . An orthonormal basis for it is given by the first 2 columns of the
Umatrix. - The null space is a 3-dimensional subspace of (since and , the dimension is ). An orthonormal basis is given by the last 3 columns of the
Vmatrix (or last 3 rows ofVt).
Test your understanding!
You are given the SVD for a 4x3 matrix . The matrix of singular values is:
The columns of are and the columns of are .
- What is the rank of ?
- Provide an orthonormal basis for the column space (image) of .
- Provide an orthonormal basis for the null space (kernel) of .
Show answer
-
Rank: The rank is the number of non-zero singular values. Here, the non-zero singular values are 12 and 3. So, the rank of is 2.
-
Column Space Basis: The column space is spanned by the first columns of . An orthonormal basis is .
-
Null Space Basis: The null space is spanned by the last columns of . Here, and , so we need the last column of . An orthonormal basis is .
Conclusion
In this lesson, we transitioned from the geometric view of SVD to its structural interpretation. You now have a powerful and practical method to dissect any matrix and understand its fundamental properties.
Key Takeaways:
- The SVD, , provides orthonormal bases for the four fundamental subspaces of .
- The rank of is simply the number of non-zero singular values.
- The first columns of form an orthonormal basis for the column space (image).
- The last columns of form an orthonormal basis for the null space (kernel).
- Similarly, the first columns of form a basis for the row space, and the last columns of form a basis for the left null space.
Preview of the Next Lesson:
What happens when a matrix is not invertible? This occurs when its null space is non-trivial (i.e., it has at least one zero singular value), making it impossible to uniquely reverse the transformation. However, for many practical problems in machine learning, like finding the best fit line in linear regression, we still need a way to "solve" systems involving such matrices.
In our next lesson, we will learn how to use the SVD to compute the pseudoinverse of a matrix. This is a generalization of the inverse that provides the best possible solution even for non-invertible or non-square matrices.