第 10 章

四个基本子空间

一个 m×n 矩阵自带四个子空间:列空间、零空间、行空间与左零空间;它们的基、维数与所在的 R^m / R^n 构成线性代数的主干。

The Four Fundamental Subspaces

Every m by n matrix carries four subspaces — column, null, row, and left null — and their bases and dimensions form the backbone of linear algebra.

首发于 2009.05.07中 / EN
系统课程linear-algebrafour-subspacesrankrow-space
语言
字号
目录
篇内目录

一个错误的修正,也是本讲的引子

上一讲结尾,Strang 想给 R3\mathbb{R}^3 换一组基,取了

v1=[112],v2=[225],v3=[338].\mathbf{v}_1=\begin{bmatrix}1\\1\\2\end{bmatrix},\quad \mathbf{v}_2=\begin{bmatrix}2\\2\\5\end{bmatrix},\quad \mathbf{v}_3=\begin{bmatrix}3\\3\\8\end{bmatrix}.

他以为第三个向量跳出了前两个张成的平面。课后一位学生指出:这组向量相关。

验证的方法不是硬解组合系数,而是看矩阵

A=[123123258].A=\begin{bmatrix}1&2&3\\1&2&3\\2&5&8\end{bmatrix}.

第一行和第二行完全相同,所以 AA 不可逆,列必然相关。直接算也确实如此:

v1−2v2+v3=0.\mathbf{v}_1-2\mathbf{v}_2+\mathbf{v}_3=\mathbf{0}.

这个修正引出本讲的核心:行之间的关系会决定列的独立性。要讲清这件事,需要把行也当成一个空间来看。

时间轴

时间内容
0:09开场:上一讲的四个子空间图
2:02一个学生的修正:列空间与行空间并不相同
3:45四个子空间各自的定义
5:26C(A)C(A) 与 N(A)N(A) 同处 RmR^m 还是 RnR^n
8:54零空间:Ax=0A\mathbf{x}=0 的全部解
10:38RnR^n 中的两个子空间
14:05列空间的一组基
17:27行化简后行空间不变
19:15零空间维数 n−rn-r
21:03ATA^{T} 的列空间就是行空间
28:02最简行阶梯形给出最干净的基
35:01最简形的主元列构成单位阵
36:51消元矩阵 EE 与左零空间
42:03不求转置也能得到行空间的基
43:43矩阵空间 MM 本身也是向量空间
45:26矩阵空间上的加法与数乘
48:57右端项与解的关系预告

四个子空间

图:四个基本子空间:维数、基与两组正交关系。

对 m×nm\times n 矩阵 AA:

子空间记号定义所在空间维数
列空间C(A)C(A)所有列的线性组合Rm\mathbb{R}^mrr
零空间N(A)N(A)所有满足 Ax=0A\mathbf{x}=\mathbf{0} 的 x\mathbf{x}Rn\mathbb{R}^nn−rn-r
行空间C(A⊤)C(A^\top)所有行的线性组合Rn\mathbb{R}^nrr
左零空间N(A⊤)N(A^\top)所有满足 A⊤y=0A^\top\mathbf{y}=\mathbf{0} 的 y\mathbf{y}Rm\mathbb{R}^mm−rm-r

行空间写成 C(A⊤)C(A^\top),只是把躺着的行向量转成列向量,方便沿用列空间的全部结论。左零空间的名字来自转置:

A⊤y=0⟺y⊤A=0.A^\top\mathbf{y}=\mathbf{0} \quad\Longleftrightarrow\quad \mathbf{y}^\top A=\mathbf{0}.

y⊤\mathbf{y}^\top 是一个行向量,从左边乘 AA,所以叫左零空间。

四个空间的位置关系

在 Rn\mathbb{R}^n 里放行空间与零空间,它们的维数相加为 nn;在 Rm\mathbb{R}^m 里放列空间与左零空间,维数相加为 mm。这两组空间分别把输入空间与输出空间「分干净」了——后面会看到,它们还是正交补。

四个基与四个维数

列空间:主元列

对 AA 消元,找出主元所在的列。取原矩阵 AA 的这些列,它们构成列空间的一组基,数量为 rr。

为什么必须是 AA 的列而不是行简化形 RR 的列?因为行变换保持行空间,却会改变列空间。RR 的列空间一般与 AA 的不同。

行空间:RR 的前 rr 行

行变换是行与行之间的线性组合,因此行空间不变。把 AA 化成行简化形 RR 后,RR 的非零行就是一组基。

更准确地说:RR 的前 rr 行(非零行)构成行空间的基,维数为 rr。这也顺带证明了行秩等于列秩:两者都等于主元个数。

零空间:特殊解

对每个自由变量,令它取 1、其余自由变量取 0,解出主元变量,得到一个特殊解。共有 n−rn-r 个,构成零空间的基。

左零空间:来自消元矩阵 EE

左零空间的基不那么直观。做法是高斯-若尔当消元的「增广」版本:

[A∣I] ⟶ [R∣E],[A \mid I]\ \longrightarrow\ [R \mid E],

其中 EE 记录了所有行变换,满足

EA=R.EA=R.

EE 是 m×mm\times m 的。它的最后 m−rm-r 行构成左零空间的一组基。

一个小例子

取

A=[123246].A=\begin{bmatrix}1&2&3\\2&4&6\end{bmatrix}.

第二行是第一行的两倍,秩 r=1r=1。消元:r2−2r1=0r_2-2r_1=0,对应的消元矩阵

E=[10−21].E=\begin{bmatrix}1&0\\-2&1\end{bmatrix}.

EE 的最后 m−r=1m-r=1 行是 (−2,1)(-2,1)。验证:

(−2,1)[123246]=(0,0,0).(-2,1)\begin{bmatrix}1&2&3\\2&4&6\end{bmatrix}=(0,0,0).

它确实是左零空间的一组基。直观含义是:第二行减去两倍第一行得到零行,这个系数组合就是左零空间里的向量。

维数为什么这样分配

四个维数满足两条加法关系:

dim⁡C(A)+dim⁡N(A)=r+(n−r)=n,\dim C(A)+\dim N(A)=r+(n-r)=n, dim⁡C(A⊤)+dim⁡N(A⊤)=r+(m−r)=m.\dim C(A^\top)+\dim N(A^\top)=r+(m-r)=m.

第一条对应「nn 个变量 = rr 个主元变量 + n−rn-r 个自由变量」;第二条把同样的逻辑用在 A⊤A^\top 上——A⊤A^\top 是 n×mn\times m,有 mm 列,所以主元与自由变量相加为 mm。

行秩等于列秩

这是本讲最重要的定理之一:

dim⁡C(A)=dim⁡C(A⊤)=r.\dim C(A)=\dim C(A^\top)=r.

它解释了开头的错误:矩阵有两行相同,行空间维数至多为 2,因此列空间维数也至多为 2,三个列向量必然相关。

矩阵本身也可以构成向量空间

最后几分钟把「向量」的概念再拓宽一次。所有 3×33\times3 矩阵构成一个向量空间 MM:矩阵可以相加、可以乘标量,零矩阵是零元素。注意这里不使用矩阵乘法——向量空间只要求加法与数乘。

于是可以讨论子空间:

子空间约束维数
全体 3×33\times3 矩阵 MM无9
对称矩阵 SSaij=ajia_{ij}=a_{ji}6
上三角矩阵 UUi>ji>j 时 aij=0a_{ij}=06
对角矩阵 D=S∩UD=S\cap U非对角元为 03

对角矩阵的基可以取三个「只有一个对角元为 1」的矩阵,因此维数为 3。

交与和

  • 交 S∩US\cap U:既对称又上三角,只能是对角矩阵,维数 3。
  • 并不是子空间(两条不同方向的直线并起来,连加法都不封闭)。
  • 和 S+US+U:任取一个对称矩阵加一个上三角矩阵,可以得到任意 3×33\times3 矩阵,因此 S+U=MS+U=M,维数 9。

维数满足

dim⁡S+dim⁡U=dim⁡(S∩U)+dim⁡(S+U),\dim S+\dim U=\dim(S\cap U)+\dim(S+U),

即 6+6=3+96+6=3+9。这不是巧合,而是子空间维数的普遍公式。

本讲结论

  • 每个矩阵自带四个子空间,分别住在 Rm\mathbb{R}^m 与 Rn\mathbb{R}^n。
  • 四个基:AA 的主元列、RR 的前 rr 行、特殊解、EE 的最后 m−rm-r 行。
  • 四个维数:r, n−r, r, m−rr,\ n-r,\ r,\ m-r。
  • 行秩等于列秩,这是「行约束列」的定量版本。
  • 矩阵本身可以看作向量,从而拥有子空间、基与维数。

理解检验

1. 为什么列空间的基要取 AA 的主元列,而不能取 RR 的列?

参考答案:行变换保持行空间与零空间,却会改写列向量,因此 C(R)≠C(A)C(R)\ne C(A) 一般不成立。RR 的列已经被消元改过,用它们张成的是另一个空间。

AA 的主元列则同时无关且张成 C(A)C(A):行变换不改变列之间的线性关系,所以主元列在 RR 中对应的列无关,AA 的主元列也无关;又因为 RR 的每一列都是其主元列的组合,且组合系数在行变换前后不变,所以 AA 的每一列也是 AA 的主元列的同一组合。两组性质合起来,AA 的主元列构成 C(A)C(A) 的基,个数为 rr。

2. 消元矩阵 EE 的最后 m−rm-r 行为什么是左零空间的基?

参考答案:由 EA=REA=R 可知 RR 的第 ii 行等于 EE 的第 ii 行左乘 AA。矩阵 RR 只有前 rr 行非零,第 r+1r+1 到第 mm 行全为零行,所以对这些行有

EiA=0⟺A⊤Ei⊤=0,E_i A=\mathbf{0}\quad\Longleftrightarrow\quad A^\top E_i^\top=\mathbf{0},

即 EE 的最后 m−rm-r 行都属于左零空间 N(A⊤)N(A^\top)(写成行向量)。它们线性无关,因为 EE 可逆(它是若干初等矩阵的乘积,行列式非零)。而 dim⁡N(A⊤)=m−r\dim N(A^\top)=m-r,所以这 m−rm-r 个无关向量恰好构成一组基。

3. 一个 4×64\times6 矩阵秩为 2,四个子空间的维数各是多少?它们分别住在哪个 Rk\mathbb{R}^k?

参考答案:m=4, n=6, r=2m=4,\ n=6,\ r=2。

子空间维数所在空间
列空间 C(A)C(A)r=2r=2R4\mathbb{R}^4
零空间 N(A)N(A)n−r=4n-r=4R6\mathbb{R}^6
行空间 C(A⊤)C(A^\top)r=2r=2R6\mathbb{R}^6
左零空间 N(A⊤)N(A^\top)m−r=2m-r=2R4\mathbb{R}^4

校验:2+4=6=n2+4=6=n,2+2=4=m2+2=4=m。注意列空间与左零空间都在 R4\mathbb{R}^4 里,行空间与零空间都在 R6\mathbb{R}^6 里。

4. 对称矩阵空间与上三角矩阵空间的交、和分别是什么?维数是否满足加法公式?

参考答案:在 3×33\times3 矩阵空间中,设 SS 为对称矩阵、UU 为上三角矩阵。

  • 交 S∩US\cap U:既对称又上三角。上三角矩阵满足 i>ji>j 时 aij=0a_{ij}=0,对称性又要求 aji=aija_{ji}=a_{ij},于是所有非对角元都为 00,只剩对角矩阵,dim⁡(S∩U)=3\dim(S\cap U)=3。
  • 和 S+US+U:任取一个对称矩阵与一个上三角矩阵相加可以得到任意矩阵。一个构造是:对任意 MM,把 MM 的下三角部分(不含对角)单独拿出来,其转置是上三角的,两者相加恰好还原 MM 的对角及以下部分;剩余部分用上三角补上。所以 S+U=MS+U=M,dim⁡(S+U)=9\dim(S+U)=9。

代入公式

dim⁡S+dim⁡U=6+6=12=3+9=dim⁡(S∩U)+dim⁡(S+U),\dim S+\dim U=6+6=12=3+9=\dim(S\cap U)+\dim(S+U),

满足。

5. 如果一个矩阵有两行相同,你能立刻对它的秩说什么?

参考答案:两行相同意味着这两行线性相关,所以行空间维数至多为 m−1m-1,由行秩等于列秩,

rank⁡(A)=dim⁡C(A⊤)≤m−1<m.\operatorname{rank}(A)=\dim C(A^\top)\le m-1<m .

也就是说矩阵不是满行秩,A⊤A^\top 必有非零零空间(左零空间维数至少为 11);若 AA 是方阵,则 AA 不可逆。对列的影响是:当 n≥mn\ge m 时列数不少于秩的上界,列必然相关——这正是本讲开头 3×33\times3 例子中「第一行与第二行相同 ⇒\Rightarrow 三列相关」的道理。

与前后课程的关系

上一讲定义了无关、基与维数;这一讲把它们一次性用在矩阵的四个子空间上。下一讲继续拓宽「向量空间」的边界:矩阵空间、函数空间,以及秩一矩阵作为所有矩阵的积木。

An error corrected, and the lecture it opens

At the end of the previous lecture Strang tried to replace the standard basis of R3\mathbb{R}^3 with

v1=[112],v2=[225],v3=[338],\mathbf{v}_1=\begin{bmatrix}1\\1\\2\end{bmatrix},\quad \mathbf{v}_2=\begin{bmatrix}2\\2\\5\end{bmatrix},\quad \mathbf{v}_3=\begin{bmatrix}3\\3\\8\end{bmatrix},

assuming the third vector stepped out of the plane spanned by the first two. A student pointed out that the three are dependent.

The check does not require solving for coefficients. Form the matrix

A=[123123258].A=\begin{bmatrix}1&2&3\\1&2&3\\2&5&8\end{bmatrix}.

Rows one and two are identical, so AA is singular and its columns must be dependent. Direct calculation confirms

v1−2v2+v3=0.\mathbf{v}_1-2\mathbf{v}_2+\mathbf{v}_3=\mathbf{0}.

The lesson opens the lecture: relations among rows constrain the columns. To say that precisely, rows have to be treated as a space of their own.

Timeline

TimeTopic
0:09Opening: the four-subspace picture
2:02A student's correction: column space is not row space
3:45Definitions of the four subspaces
5:26Which ambient space each subspace lives in
8:54The null space as all solutions of Ax=0A\mathbf{x}=0
10:38The two subspaces of RnR^n
14:05A basis for the column space
17:27Row reduction preserves the row space
19:15Null space dimension n−rn-r
21:03The column space of ATA^{T} is the row space
28:02Reduced row echelon form gives the cleanest basis
35:01Pivot columns of the reduced form form an identity block
36:51The elimination matrix EE and the left null space
42:03Row space bases without transposing
43:43The matrix space MM is a vector space
45:26Addition and scalar multiplication on matrix spaces
48:57Looking ahead to the right-hand side

The four subspaces

Figure:The four subspaces: dimensions, bases and orthogonality。

For an m×nm\times n matrix AA:

SubspaceNotationDefinitionLives inDimension
Column spaceC(A)C(A)All combinations of the columnsRm\mathbb{R}^mrr
Null spaceN(A)N(A)All x\mathbf{x} with Ax=0A\mathbf{x}=\mathbf{0}Rn\mathbb{R}^nn−rn-r
Row spaceC(A⊤)C(A^\top)All combinations of the rowsRn\mathbb{R}^nrr
Left null spaceN(A⊤)N(A^\top)All y\mathbf{y} with A⊤y=0A^\top\mathbf{y}=\mathbf{0}Rm\mathbb{R}^mm−rm-r

Writing the row space as C(A⊤)C(A^\top) just stands the rows up so that every fact proved for column spaces applies. The left null space earns its name by transposing:

A⊤y=0⟺y⊤A=0.A^\top\mathbf{y}=\mathbf{0} \quad\Longleftrightarrow\quad \mathbf{y}^\top A=\mathbf{0}.

Now y⊤\mathbf{y}^\top is a row vector multiplying AA from the left.

Where the spaces sit

In Rn\mathbb{R}^n, the row space and null space have dimensions adding to nn. In Rm\mathbb{R}^m, the column space and left null space have dimensions adding to mm. Each pair splits one ambient space completely — and, as later lectures show, each pair is an orthogonal complement.

Four bases, four dimensions

Column space: the pivot columns

Run elimination on AA and identify the pivot columns. Take those columns from the original AA; they form a basis, and there are rr of them.

Why not the pivot columns of the reduced form RR? Because row operations preserve the row space but change the column space. The columns of RR generally span a different space.

Row space: the first rr rows of RR

Row operations combine rows with rows, so the row space is unchanged. Once AA is reduced to RR, the nonzero rows of RR form a basis.

More precisely, the first rr (nonzero) rows of RR form a basis of the row space. This also proves row rank equals column rank: both count pivots.

Null space: the special solutions

For each free variable, set it to 1 and the other free variables to 0, then solve for the pivot variables. The n−rn-r resulting vectors form a basis of the null space.

Left null space: via the elimination matrix EE

This basis is less immediate. Use the augmented Gauss-Jordan form:

[A∣I] ⟶ [R∣E],[A \mid I]\ \longrightarrow\ [R \mid E],

where EE records every row operation and satisfies

EA=R.EA=R.

EE is m×mm\times m. Its last m−rm-r rows form a basis of the left null space.

A small example

Take

A=[123246].A=\begin{bmatrix}1&2&3\\2&4&6\end{bmatrix}.

The second row is twice the first, so r=1r=1. Elimination does r2−2r1=0r_2-2r_1=0, and the elimination matrix is

E=[10−21].E=\begin{bmatrix}1&0\\-2&1\end{bmatrix}.

Its last m−r=1m-r=1 row is (−2,1)(-2,1). Check:

(−2,1)[123246]=(0,0,0).(-2,1)\begin{bmatrix}1&2&3\\2&4&6\end{bmatrix}=(0,0,0).

So (−2,1)(-2,1) is a basis of the left null space. The meaning is concrete: row two minus twice row one gives the zero row, and those coefficients are the vector.

Why the dimensions split this way

The four dimensions satisfy two additive relations:

dim⁡C(A)+dim⁡N(A)=r+(n−r)=n,\dim C(A)+\dim N(A)=r+(n-r)=n, dim⁡C(A⊤)+dim⁡N(A⊤)=r+(m−r)=m.\dim C(A^\top)+\dim N(A^\top)=r+(m-r)=m.

The first mirrors "nn variables = rr pivot variables + n−rn-r free variables". The second applies the same logic to A⊤A^\top, which is n×mn\times m and therefore has mm columns.

Row rank equals column rank

This is the central theorem of the lecture:

dim⁡C(A)=dim⁡C(A⊤)=r.\dim C(A)=\dim C(A^\top)=r.

It resolves the opening error: two identical rows mean the row space has dimension at most 2, so the column space does too, and three columns must be dependent.

Matrices are themselves vectors

The last minutes widen the definition once more. All 3×33\times3 matrices form a vector space MM: they can be added and scaled, and the zero matrix is the zero element. Note that matrix multiplication is not used — a vector space only needs addition and scalar multiplication.

Subspaces follow:

SubspaceConstraintDimension
All 3×33\times3 matrices, MMnone9
Symmetric matrices, SSaij=ajia_{ij}=a_{ji}6
Upper triangular matrices, UUaij=0a_{ij}=0 for i>ji>j6
Diagonal matrices, D=S∩UD=S\cap Uall off-diagonal entries zero3

A basis of DD is the three matrices with a single 1 on one diagonal position, so the dimension is 3.

Intersection and sum

  • Intersection S∩US\cap U: symmetric and upper triangular forces diagonal, dimension 3.
  • Union is not a subspace: two differently directed lines fail closure under addition.
  • Sum S+US+U: any symmetric plus any upper triangular can produce an arbitrary 3×33\times3 matrix, so S+U=MS+U=M, dimension 9.

Dimensions obey

dim⁡S+dim⁡U=dim⁡(S∩U)+dim⁡(S+U),\dim S+\dim U=\dim(S\cap U)+\dim(S+U),

that is, 6+6=3+96+6=3+9. This is not a coincidence but a general formula for subspaces.

Takeaways

  • Every matrix carries four subspaces, living in Rm\mathbb{R}^m and Rn\mathbb{R}^n.
  • Bases: pivot columns of AA, first rr rows of RR, special solutions, last m−rm-r rows of EE.
  • Dimensions: rr, n−rn-r, rr, m−rm-r.
  • Row rank equals column rank — the quantitative form of "rows constrain columns".
  • Matrices can be treated as vectors, with their own subspaces, bases, and dimensions.

Check your understanding

1. Why must a column-space basis use the pivot columns of AA rather than the columns of RR?

Reference answer: Row operations preserve the row space and the null space but rewrite the columns, so generally C(R)≠C(A)C(R)\ne C(A). The columns of RR have been altered by elimination and span a different space.

The pivot columns of AA are both independent and spanning for C(A)C(A): row operations do not change linear relations among columns, so the pivot columns of AA are independent because their counterparts in RR are; and every column of RR is a combination of its pivot columns with coefficients unchanged by the row operations, so every column of AA is the same combination of the pivot columns of AA. Hence the pivot columns of AA form a basis of C(A)C(A), and there are rr of them.

2. Why do the last m−rm-r rows of the elimination matrix EE form a basis of the left null space?

Reference answer: From EA=REA=R, the ii-th row of RR equals the ii-th row of EE times AA. Since RR has only rr nonzero rows, rows r+1,…,mr+1,\dots,m are zero, so for each of them

EiA=0⟺A⊤Ei⊤=0,E_i A=\mathbf{0}\quad\Longleftrightarrow\quad A^\top E_i^\top=\mathbf{0},

meaning the last m−rm-r rows of EE (read as row vectors) lie in N(A⊤)N(A^\top). They are linearly independent because EE is invertible, being a product of elementary matrices with nonzero determinant. Since dim⁡N(A⊤)=m−r\dim N(A^\top)=m-r, these m−rm-r independent vectors form a basis.

3. For a 4×64\times6 matrix of rank 2, give the four dimensions and the ambient space of each.

Reference answer: m=4m=4, n=6n=6, r=2r=2.

SubspaceDimensionAmbient space
Column space C(A)C(A)r=2r=2R4\mathbb{R}^4
Null space N(A)N(A)n−r=4n-r=4R6\mathbb{R}^6
Row space C(A⊤)C(A^\top)r=2r=2R6\mathbb{R}^6
Left null space N(A⊤)N(A^\top)m−r=2m-r=2R4\mathbb{R}^4

Check: 2+4=6=n2+4=6=n and 2+2=4=m2+2=4=m. The column and left null spaces live in R4\mathbb{R}^4; the row and null spaces live in R6\mathbb{R}^6.

4. What are the intersection and sum of the symmetric and upper triangular matrix spaces? Do the dimensions satisfy the formula?

Reference answer: In the space of 3×33\times3 matrices, let SS be symmetric and UU upper triangular.

  • Intersection S∩US\cap U: a matrix that is both. Upper triangular means aij=0a_{ij}=0 for i>ji>j; symmetry forces aji=aija_{ji}=a_{ij}, so all off-diagonal entries vanish. The intersection is the diagonal matrices, of dimension 33.
  • Sum S+US+U: every matrix is a sum of a symmetric and an upper triangular matrix. One construction: for an arbitrary MM, take the strictly lower triangular part separately; its transpose is upper triangular, and adding the two recovers the diagonal-and-below part of MM; the rest is upper triangular. Hence S+U=MS+U=M and dim⁡(S+U)=9\dim(S+U)=9.

Substituting,

dim⁡S+dim⁡U=6+6=12=3+9=dim⁡(S∩U)+dim⁡(S+U),\dim S+\dim U=6+6=12=3+9=\dim(S\cap U)+\dim(S+U),

so the formula holds.

5. If a matrix has two identical rows, what can you say immediately about its rank?

Reference answer: Two identical rows are linearly dependent, so the row space has dimension at most m−1m-1; since row rank equals column rank,

rank⁡(A)=dim⁡C(A⊤)≤m−1<m.\operatorname{rank}(A)=\dim C(A^\top)\le m-1<m .

So the matrix is not of full row rank, A⊤A^\top has a nontrivial null space (left null space of dimension at least 11), and if AA is square it is singular. On the column side: when n≥mn\ge m, the columns are necessarily dependent — exactly the lesson of the opening 3×33\times3 example, where identical first and second rows forced the three columns to be dependent.

How this connects to the course

The previous lecture defined independence, basis, and dimension. This one applies them to a matrix's four subspaces. The next lecture widens "vector space" again: matrix spaces, function spaces, and rank-one matrices as the building blocks of all matrices.

来源