第 33 章
左逆、右逆与伪逆:按秩分类的四种「求逆」
逆是否存在取决于 m、n、r 的关系:满秩方阵有双侧逆,满列秩有左逆,满行秩有右逆,一般情形只能用 SVD 构造伪逆,它在行空间与列空间之间是真正的逆。
Left, Right, and Pseudoinverses: Four Cases by Rank
Whether an inverse exists depends on m, n, and r: full-rank square gives a two-sided inverse, full column rank a left inverse, full row rank a right inverse, and the general case a pseudoinverse built from SVD.
篇内目录
- Classifying inverses with the four subspaces
- Timeline
- Four cases
- Case one: full-rank square
- Case two: full column rank, left inverse
- Case three: full row rank, right inverse
- The other product is a projection
- The general case: the pseudoinverse
- Why it is a bijection
- Constructing it from SVD
- Both products are projections
- Why this is the best inverse
- Why statistics needs it
- Common mistakes
- Takeaways
- Check your understanding
- How this connects to the course
用四个子空间给「求逆」分类
设 是 矩阵,秩为 。整个讨论围绕那张熟悉的图:
- 行空间 ,维数 ;
- 零空间 ,维数 ;
- 列空间 ,维数 ;
- 左零空间( 的零空间),维数 。
逆之所以有时不存在,是因为零空间里的向量被 送到零,没有任何映射能把它们「复活」。所以能否求逆,取决于零空间有多大。
时间轴
| 时间 | 内容 |
|---|---|
| 0:03 | 用四个子空间给「求逆」分类 |
| 2:26 | 可逆方阵:双侧逆存在 |
| 5:59 | 列独立时的左逆 |
| 8:55 | 满列秩时 可逆 |
| 11:42 | 长方矩阵不可能有双侧逆 |
| 12:34 | 满行秩时的右逆 |
| 14:38 | 的解的个数 |
| 16:13 | 右逆与投影的关系 |
| 18:56 | 是投影矩阵 |
| 23:03 | 伪逆:从行空间到列空间 |
| 24:42 | 行空间与列空间维数相同 |
| 26:21 | 伪逆的定义与几何图像 |
| 28:10 | 在行空间上 是一一对应的 |
| 31:11 | 伪逆与最小二乘 |
| 32:53 | 由 SVD 构造伪逆 |
| 35:48 | 的例外:零奇异值 |
| 36:40 | 与 都是投影 |
| 39:59 | 伪逆能做什么、不能做什么 |
四种情形
| 情形 | 秩 | 零空间 | 解的情况 | 逆的类型 |
|---|---|---|---|---|
| 满秩方阵 | 双侧都只有零 | 唯一解 | 双侧逆 | |
| 满列秩 | 的零空间为零 | 或 个解 | 左逆 | |
| 满行秩 | 的零空间为零 | 总有解,无穷多 | 右逆 | |
| 一般情形 | 两侧都有零空间 | —— | 伪逆 |
情形一:满秩方阵
, 可逆,左右两侧都得到单位矩阵:
情形二:满列秩,左逆
列线性无关,, 的零空间只有零向量。此时 是 对称矩阵,并且可逆。
定义
它是 矩阵,并且
这就是最小二乘里反复出现的组合。列无关时,正规方程的系数矩阵可逆,最小二乘有唯一解。
注意维度: 是 单位阵;但反过来的 是 ,不可能是单位阵(因为 )。
情形三:满行秩,右逆
行线性无关,, 的零空间只有零向量。此时 可逆。
定义
它是 矩阵,并且
因为 ,零空间维数为 ,所以只要 有解,就有无穷多个解。
另一侧的乘积是投影
左逆放在右边,得不到单位阵,但得到的是一个熟悉的矩阵:
这是到列空间的投影矩阵。它尽量充当单位阵:在列空间上等于恒等,在左零空间上等于零。
同理,
这是到行空间的投影矩阵。
这解释了一个常见疑问:为什么左逆只能「左乘」才得到单位阵?因为另一侧的空间维度不够,投影是能做到的最好结果。
一般情形:伪逆
当 时,两侧都有零空间,真正的逆不存在。但 在行空间与列空间之间是一个完美的双射。
为什么是双射
设 都在行空间,且 。则
所以 在零空间中。可是 又是两个行空间向量的差,仍在行空间中。零空间与行空间正交,交集只有零向量,因此
这就证明了:行空间中的不同向量,被 送到列空间中的不同向量。
同时,行空间与列空间维数都是 ,所以这是一个可逆映射。它的逆就是伪逆 。
用 SVD 构造
设
是 对角矩阵,前 个对角元 ,其余为零。
把 的每个非零对角元取倒数,并转置成 :
则
两个乘积都是投影
是 ,前 个对角元为 ,其余为 ; 是 ,结构相同。它们分别把向量投影到列空间与行空间。
为什么这是「最好的逆」
伪逆在所有可能的选择中最小:零空间方向上没有信息,任何取值都无法被检验,取零是最自然的。多填任何数都不会改变 与 的结果,只会让伪逆变大。
补充:伪逆满足四个 Penrose 条件:、、、。前两条说明它在可行范围内尽量充当逆,后两条说明两个乘积都是正交投影。
统计学为什么需要伪逆
最小二乘的核心是解正规方程
只要 满列秩, 可逆,一切顺利。但现实中经常出现重复测量或线性相关的特征,此时 奇异,正规方程有无穷多解。
伪逆给出的
是其中范数最小的解。这正是统计软件在共线性情形下采用的默认处理方式。
常见误区
- 以为长方矩阵也有双侧逆。维度不匹配, 是 ,不可能等于 。
- 把左逆与右逆的公式记反。左逆用 ,右逆用 。
- 以为伪逆等于「先转置再求逆」。只有当 的奇异值全为 时才碰巧如此。
- 忽略零空间自由度。伪逆在零空间方向上不做任何「恢复」,这是信息论上无法做到的。
本讲结论
- 四种情形由 的关系决定。
- 满列秩:左逆 ,另一侧乘积是列空间投影。
- 满行秩:右逆 ,另一侧乘积是行空间投影。
- 一般情形:,在行空间与列空间之间是真正的逆。
- 与 分别是到列空间、行空间的正交投影。
- 伪逆给出的最小二乘解是范数最小的解,适用于 奇异的情形。
理解检验
1. 为什么长方矩阵不可能有双侧逆?
参考答案:设 是 。若存在左逆 ()使 ,则 ,结合 得 。若同时存在右逆 使 ,则 ,得 。两者同时成立只能有 。更直接的代数证明是:由 、,
于是 ,同一矩阵既是左逆又是右逆, 为方阵且可逆。所以当 时,最多只有单侧逆。
2. 左逆与右逆的公式中,为什么一个用 ,另一个用 ?
参考答案:左逆要在左边得到 ,需要 的可逆矩阵,而 正是 ;它在列无关()时可逆,因为 。于是 左乘 得 。右逆要在右边得到 ,需要 矩阵, 正是 ,在行无关()时可逆,同理 右乘 得 。维度决定了各自该用哪个乘积。
3. 证明 在行空间上是单射,并指出证明中用到了哪两个子空间的性质。
参考答案:设 都在行空间,且 。则 ,所以 。另一方面,行空间对减法封闭, 仍在行空间中,即 。用到的第一个性质是零空间与行空间正交(),第二个是行空间是子空间(对线性组合封闭)。正交子空间的交集只有零向量,所以 ,即 。行空间与列空间维数同为 ,单射加上维数相等就得到双射,其逆正是伪逆。
4. 为什么 是投影而不是单位阵?它的零空间是什么?
参考答案:,其中 是 对角阵,前 个对角元为 、其余 个为 。它在列空间(由 张成)上是恒等映射,在左零空间(由 张成)上是零映射。只有当 时它才等于单位阵;一般情形 ,左零空间方向被抹掉,所以只能是投影。它的零空间正是左零空间 ,维数 。
5. 当 奇异时,最小二乘为什么需要伪逆?伪逆选出的解有什么特殊性?
参考答案: 奇异意味着 的列相关(),正规方程 有无穷多个解——它们相差零空间中的任意向量,而最小二乘只约束「残差最小」,无法区分这些解。伪逆给出
它把 在左零空间上的分量投影掉,再把列空间分量按 映回行空间,因此在零空间方向上取零。于是 是所有最小二乘解中范数最小的那一个(最小范数最小二乘解),这也是统计软件在共线性下采用的默认解。
与前后课程的关系
前几讲分别处理了特征值、正定、相似与 SVD;这一讲把 SVD 用于非方阵求逆,把四个子空间、秩与最小二乘串成一个完整分类。下一讲是全课程总结,用旧考题回顾这些主线。
Classifying inverses with the four subspaces
Let be of rank . Everything turns on the familiar picture:
- row space , dimension ;
- null space , dimension ;
- column space , dimension ;
- left null space (null space of ) , dimension .
Inverses fail exactly because vectors in the null space are sent to zero, and no map can bring them back. How much can be inverted depends on how large the null spaces are.
Timeline
| Time | Topic |
|---|---|
| 0:03 | Classifying inverses by the four subspaces |
| 2:26 | Invertible square matrices have two-sided inverses |
| 5:59 | The left inverse when columns are independent |
| 8:55 | is invertible in the full column rank case |
| 11:42 | A rectangular matrix has no two-sided inverse |
| 12:34 | The right inverse in the full row rank case |
| 14:38 | The number of solutions of |
| 16:13 | Right inverses and projection |
| 18:56 | The matrix is a projection |
| 23:03 | The pseudoinverse: row space to column space |
| 24:42 | Row and column spaces share a dimension |
| 26:21 | Definition and picture of the pseudoinverse |
| 28:10 | is one-to-one on the row space |
| 31:11 | The pseudoinverse and least squares |
| 32:53 | Constructing the pseudoinverse from the SVD |
| 35:48 | Where fails: zero singular values |
| 36:40 | Both and are projections |
| 39:59 | What the pseudoinverse can and cannot do |
Four cases
| Case | Rank | Null spaces | Solutions | Kind of inverse |
|---|---|---|---|---|
| Full-rank square | trivial on both sides | unique | two-sided | |
| Full column rank | null space of trivial | zero or one | left inverse | |
| Full row rank | null space of trivial | always, infinitely many | right inverse | |
| General | both nontrivial | — | pseudoinverse |
Case one: full-rank square
, so is invertible and both sides give the identity:
Case two: full column rank, left inverse
The columns are independent, , and the null space of is trivial. Then is , symmetric, and invertible.
Define
It is , and
This is the combination that appears throughout least squares. With independent columns, the normal equations have an invertible coefficient matrix and a unique least-squares solution.
Watch the dimensions: is . The other order, , is and cannot be the identity because .
Case three: full row rank, right inverse
The rows are independent, , and the null space of is trivial. Then is invertible.
Define
It is , and
Since , the null space has dimension , so whenever is solvable it has infinitely many solutions.
The other product is a projection
Put the left inverse on the right and you do not get the identity, but something familiar:
the projection onto the column space. It does the best a matrix can do: identity on the column space, zero on the left null space.
Similarly,
the projection onto the row space.
This explains why a left inverse only works from the left: the other side does not have the right dimension, and a projection is the best available result.
The general case: the pseudoinverse
When , both null spaces are nonzero and no true inverse exists. But is a perfect bijection between the row space and the column space.
Why it is a bijection
Let lie in the row space and suppose . Then
so lies in the null space. But is also a difference of two row-space vectors, hence lies in the row space. The null space and the row space are orthogonal complements, so their intersection is only the zero vector. Therefore
So distinct row-space vectors map to distinct column-space vectors. Both spaces have dimension , so the map is invertible. Its inverse is the pseudoinverse .
Constructing it from SVD
Let
is with on the diagonal and zeros elsewhere.
Reciprocate each nonzero diagonal entry and transpose to shape :
Then
Both products are projections
is with ones and zeros; is with the same structure. They project onto the column and row spaces respectively.
Why this is the best inverse
The pseudoinverse is the smallest possible choice. Along the null spaces there is no information, so no value can be tested; setting it to zero is natural. Adding anything there would not change or , only make the pseudoinverse larger.
Background: the pseudoinverse satisfies the four Penrose conditions: , , , and . The first two make it an inverse where possible; the last two say both products are orthogonal projections.
Why statistics needs it
Least squares centers on the normal equations
When has full column rank, is invertible and everything is fine. But repeated measurements or linearly dependent features make singular, and the normal equations have infinitely many solutions.
The pseudoinverse gives
the solution of smallest norm. That is exactly what statistical software does by default under collinearity.
Common mistakes
- Expecting a rectangular matrix to have a two-sided inverse. The dimensions forbid it: is , not .
- Swapping the left and right inverse formulas. Left uses ; right uses .
- Thinking the pseudoinverse is just "transpose then invert". That happens only when all singular values equal one.
- Ignoring null-space freedom. The pseudoinverse cannot recover anything along the null space; no inverse could.
Takeaways
- The four cases are determined by the relation among , , and .
- Full column rank: left inverse ; the other product is the column-space projection.
- Full row rank: right inverse ; the other product is the row-space projection.
- General case: is a genuine inverse between row and column spaces.
- and are orthogonal projections onto the column and row spaces.
- The pseudoinverse gives the minimum-norm least-squares solution when is singular.
Check your understanding
1. Why can a rectangular matrix never have a two-sided inverse?
Reference answer: Let be . If a left inverse () satisfies , then , and since we get . If at the same time a right inverse satisfies , then , so . Both can hold only if . A direct algebraic proof: from and ,
so is simultaneously a left and a right inverse, making square and invertible. Hence for at most one side can exist.
2. Why does the left inverse use while the right inverse uses ?
Reference answer: A left inverse must produce on the left, which requires an invertible matrix — and is exactly . It is invertible when the columns are independent (), because . Hence times on the left gives . A right inverse must produce , requiring an matrix; is exactly that and is invertible when the rows are independent (), so gives on the right. The dimensions dictate which product to use.
3. Prove that is injective on the row space, and identify which two subspace facts the proof uses.
Reference answer: Take in the row space with . Then , so . On the other hand the row space is closed under subtraction, so . The first fact used is : the null space is orthogonal to the row space. The second is that the row space is a subspace, hence closed under linear combinations. Two orthogonal subspaces meet only at zero, so , i.e. . Since the row and column spaces both have dimension , injectivity plus equal dimensions gives a bijection, and its inverse is the pseudoinverse.
4. Why is a projection rather than the identity? What is its null space?
Reference answer: , where is the diagonal matrix with the first diagonal entries and the remaining entries . It acts as the identity on the column space (spanned by ) and as zero on the left null space (spanned by ). It equals the identity only when ; in general and the left-null-space directions are killed, so it can only be a projection. Its null space is precisely the left null space , of dimension .
5. When is singular, why does least squares need the pseudoinverse, and what is special about the solution it selects?
Reference answer: singular means the columns of are dependent (), so the normal equations have infinitely many solutions — they differ by arbitrary null-space vectors, and "least residual" alone cannot distinguish them. The pseudoinverse gives
which projects away the component of in the left null space and maps the column-space component back through ; it assigns zero on the null space. Among all least-squares solutions, is therefore the one of minimum norm (the minimum-norm least-squares solution), which is the default that statistical software uses under collinearity.
How this connects to the course
The preceding lectures covered eigenvalues, positive definiteness, similarity, and SVD. This one applies SVD to inverting non-square matrices and ties the four subspaces, rank, and least squares into one classification. The next lecture is the final review, revisiting these threads through old exam problems.