第 05 章
转置、排列与向量空间 R^n
转置翻转行列,排列矩阵重排行序,二者都满足「反序」规则;向量空间则要求对加法与数乘封闭,这个要求直接推出「必须包含零向量」。
Transposes, Permutations, and the Vector Space R^n
Transposes flip rows and columns, permutation matrices reorder rows, and both obey a reversal rule. A vector space is closed under addition and scalar multiplication — which forces it to contain the zero vector.
篇内目录
- Three topics
- Timeline
- Permutations and elimination with row exchanges
- Transposes
- Definition and example
- The transpose of a product reverses the order
- Symmetric matrices
- Vector spaces: operations first, sets second
- Two basic operations
- and
- Why zero must be included
- Counterexample: the first quadrant
- Subspaces
- All subspaces of
- All subspaces of
- Building a subspace from a matrix: the column space
- Higher dimensions
- Takeaways
- Check your understanding
- How it connects
本讲的三件事
- 排列矩阵:有行交换时的消元怎么写。
- 转置与对称矩阵:一个几乎免费就能造出对称矩阵的方法。
- 向量空间与子空间:从「一堆向量」升级到「一个空间」。
前两件是上一讲的收尾,第三件是整门课真正开始的地方。
时间轴
| 时间 | 内容 |
|---|---|
| 0:21 | 排列矩阵与带行交换的消元 |
| 2:06 | 交换行得到主元 |
| 3:44 | MATLAB 如何记录行交换 |
| 9:13 | 排列矩阵的逆 |
| 10:33 | 转置的例子 |
| 12:52 | 对称矩阵 |
| 15:44 | 总是对称 |
| 18:27 | 转置规则:顺序反转 |
| 21:17 | 向量加法与线性组合 |
| 26:54 | 中的向量 |
| 32:32 | 子空间的定义 |
| 36:03 | 的所有子空间 |
| 42:46 | 从矩阵造出列空间 |
| 44:58 | 列空间是平面 |
| 47:22 | 其他子空间 |
排列矩阵与带行交换的消元
消元时如果主元位置出现 ,就要交换行。排列矩阵 就是把单位矩阵的行重新排列得到的矩阵;单位矩阵本身也算一个排列(什么都不做)。
的排列矩阵一共有 个: 有 个, 有 个, 有 个。
它们构成一个群:
- 两个排列相乘,仍是排列;
- 每个排列都可逆;
- 逆就是转置:
验证的思路很直接:交换两行再做一次就还原,所以很多 是自己的逆;对更长的循环,转置恰好把「谁移到哪里」倒过来。
有行交换时,消元写作
先记录行的正确顺序, 与 的结构不变。
补充: 实际数值计算中,MATLAB 一类软件不只检查主元是否为零,还会检查它是否足够大。主元非常接近零会放大舍入误差,所以软件会做「部分主元法」:在每一列挑选绝对值最大的元素换到主元位置。代数上不必要,数值上必要。
转置
定义与例子
转置把行和列互换:
例如
是 , 是 。
乘积的转置也反序
和逆的规则一样,顺序要反过来。
对称矩阵
如果 ,就称 对称。对称矩阵关于主对角线镜像相等。
一个几乎免费得到对称矩阵的办法:对任意矩阵 ,乘积 一定对称。证明只有两行:
用上面的 计算:
第 项是 ,第 项是 ,相等不是巧合。
一句话总结: 对称性不是碰巧,而是「转置两次回到原矩阵」这条规则的必然结果。
向量空间:先看运算,再看集合
两种基本运算
线性代数只做两件事:
- 向量相加;
- 向量乘标量。
如果一组向量对这两种运算都封闭——加完、乘完仍然在这组里——并且满足通常的运算律,它就是一个向量空间。
与
是所有二元实向量组成的空间,几何上就是整个平面。 是三维空间。 是所有 个实分量向量组成的空间。
约定:本课程使用列向量。
为什么零向量必须在
考虑 中「去掉原点」的平面。它不是向量空间,因为:
- 取向量 ,乘以 ,结果 不在集合里;
- 取 与 ,相加也回到原点,同样不在集合里。
所以每个向量空间都必须包含零向量。这不是额外规定,而是「对数乘封闭」的直接推论。
反例:第一象限
只取坐标非负的向量,加法没问题: 仍在第一象限。但乘以 就跑到第三象限,封闭性被破坏。因此它不是向量空间。
子空间
子空间是包含在更大空间里、自身也满足向量空间规则的集合。
的全部子空间
只有三类:
- 整个 ;
- 过原点的直线;
- 只含零向量 。
不过原点的直线不是子空间:把线上一个向量乘以 ,就离开了这条线。
注意「 中过原点的直线」与 很像,但不相同:前者的向量有两个分量,后者只有一个。
的全部子空间
四类:
- 整个 ;
- 过原点的平面;
- 过原点的直线;
- 。
维度从 3 到 0,逐级下降。
从矩阵造出子空间:列空间
取矩阵
它的两列 、 都是 中的向量。
只把这两列放在一起,还不构成子空间——必须把它们的所有线性组合都加进来:
这个集合叫 的列空间,记作 。
几何上,两个不共线的向量张成一个过原点的平面。所以这个例子的列空间是 中的一个平面。
如果两列恰好共线,列空间就退化成一条直线。子空间的大小取决于列向量之间的独立性——这正是下一讲要量化的东西。
推广到高维
中取五个向量,它们的组合形成某个子空间。它不可能是 ——向量有十个分量——而是一个过原点的「五维平坦对象」(如果五个向量线性无关的话);如果它们共线,就只剩一条线。
课程在这里的提醒:你必须在 里真正「看见」两个向量张成一个平面,之后才能在 里相信同样的结论。
本讲结论
- 排列矩阵是重排了行的单位矩阵,共 个,满足 。
- 有行交换时消元写作 。
- ,顺序反过来。
- 永远对称;对称矩阵满足 。
- 向量空间对加法与数乘封闭,因此必含零向量。
- 子空间是更大空间内部、自身也是向量空间的集合。
- 的子空间只有:全空间、过原点直线、零空间。
- 矩阵的列空间由列的所有线性组合构成;它一定是子空间。
理解检验
1. 为什么排列矩阵的逆等于它的转置?用「交换两次还原」解释。
参考答案:排列矩阵做的动作是「把行按某个置换搬动一次」。逆矩阵要做的就是把这次搬动撤销,也就是按相反的置换搬回去。交换两行是最基本的情形:换一次再换一次就回到原样,所以单个交换矩阵满足 ,而它恰好对称(),于是 。一般的排列可以看成若干次交换的复合,转置把复合的顺序倒过来,正好完成撤销。形式化的验证是 : 的列是互相垂直的标准基向量, 的第 行与 的第 列点积,等于 当且仅当 。
2. 写出 对称的两行证明,并指出哪一步用了 。
参考答案:
第一步用了乘积转置的反序规则 ,其中 、;第二步用了「转置两次回到原矩阵」。于是 ,按定义这就是对称。以文中的 为例,, 与 都是 ,相等不是巧合。
3. 第一象限为什么不是 的子空间?给出一个具体的反例。
参考答案:子空间要对数乘封闭,第一象限做不到。取 ,它坐标非负,在第一象限;取标量 ,则
两个分量都变成负数,落在第三象限,已经离开了第一象限。所以第一象限只对加法(和非负数乘)封闭,对一般的数乘不封闭,不是子空间。顺带一提,它还不含零向量之外的很多「反向」向量,这也说明它不是向量空间。
4. 不过原点的直线为什么不是子空间?
参考答案:子空间必须包含零向量,而且要对数乘封闭。设直线 不过原点,取线上任一向量 ,则 。如果 是子空间,零向量就必须在 上,但 不过原点,矛盾。几何上,把线上一点沿该方向缩到 倍,就跳出了这条线。同理,两条平行但不过原点的直线相加也可能跑出集合外。
5. 对 ,解释为什么它的列空间是一个平面而不是整条 。
参考答案: 只有两列 与 ,它们不是彼此的倍数(对应分量之比 不相同),所以线性无关。两个无关向量在 中张成一个二维子空间,即过原点的平面。它不可能是整个 : 需要三个方向,而两列的所有线性组合 只有两个自由度,平面外的向量无论怎么组合都到不了。列空间的维数等于独立列的个数,这里是 2。
与前后课的关系
这一讲建立了「空间」的语言。下一讲用它重写 :有解当且仅当 落在列空间里;同时引入零空间,作为另一个由矩阵自然产生的子空间。
Three topics
- Permutation matrices: how to write elimination when rows must be exchanged.
- Transposes and symmetric matrices: an almost free way to build a symmetric matrix.
- Vector spaces and subspaces: from "a bunch of vectors" to "a space".
The first two finish the previous lecture. The third is where the course properly begins.
Timeline
| Time | Topic |
|---|---|
| 0:21 | Permutations and elimination with row exchanges |
| 2:06 | Exchanging rows to get a pivot |
| 3:44 | How MATLAB records row exchanges |
| 9:13 | The inverse of a permutation matrix |
| 10:33 | An example of a transpose |
| 12:52 | Symmetric matrices |
| 15:44 | is always symmetric |
| 18:27 | The transpose rule: reverse the order |
| 21:17 | Vectors, addition and linear combinations |
| 26:54 | Vectors in |
| 32:32 | The definition of a subspace |
| 36:03 | All subspaces of |
| 42:46 | The column space of a matrix |
| 44:58 | The column space as a plane |
| 47:22 | Other subspaces |
Permutations and elimination with row exchanges
If a zero appears in a pivot position, rows must be swapped. A permutation matrix is the identity with its rows rearranged; the identity itself counts as a permutation (the one that does nothing).
There are permutation matrices of size : six of size , twenty-four of size , one hundred twenty of size .
They form a group:
- the product of two permutations is a permutation;
- every permutation is invertible;
- the inverse is the transpose:
The intuition: swapping two rows twice restores the original, so many permutations are their own inverse; for longer cycles, transposing reverses "who moves where".
With row exchanges, elimination is written
records the correct row order, and and keep their structure.
Background: In actual numerical software, MATLAB does not merely test whether a pivot is zero; it tests whether it is large enough. A pivot very close to zero amplifies rounding error, so the software uses partial pivoting: it moves the largest-magnitude entry in the column into the pivot position. Algebra does not require this; numerical accuracy does.
Transposes
Definition and example
The transpose swaps rows and columns:
For example,
is ; is .
The transpose of a product reverses the order
The same reversal rule as for inverses.
Symmetric matrices
If , the matrix is symmetric: entries mirror across the main diagonal.
There is an almost free way to produce one: for any matrix , the product is always symmetric. The proof takes two lines:
With the above:
Entry is , and entry is . The equality is not a coincidence.
One-sentence summary: Symmetry is not luck; it is forced by the rule that transposing twice returns the original matrix.
Vector spaces: operations first, sets second
Two basic operations
Linear algebra does two things:
- add vectors;
- multiply vectors by scalars.
A collection of vectors is a vector space when it is closed under both operations — the results stay in the collection — and the usual algebraic laws hold.
and
is all pairs of real numbers; geometrically, the whole plane. is three-dimensional space. is all vectors with real components.
Convention: the course uses column vectors.
Why zero must be included
Take the plane with the origin removed. It is not a vector space:
- multiply by and the result is missing;
- add and and you return to the origin, which is also missing.
So every vector space contains the zero vector. This is not an extra axiom; it follows from closure under scalar multiplication.
Counterexample: the first quadrant
Take only vectors with nonnegative coordinates. Addition is fine: stays in the quadrant. But multiplying by lands in the third quadrant, so closure fails. It is not a vector space.
Subspaces
A subspace is a set inside a larger space that is itself a vector space under the same operations.
All subspaces of
Only three:
- all of ;
- a line through the origin;
- the zero vector alone, .
A line not through the origin is not a subspace: multiply one of its vectors by and you leave the line.
A line through the origin in looks like , but they are not the same: vectors in the line have two components, vectors in have one.
All subspaces of
Four:
- all of ;
- a plane through the origin;
- a line through the origin;
- .
Dimensions run from 3 down to 0.
Building a subspace from a matrix: the column space
Take
Its columns and live in .
Two columns by themselves are not a subspace. To get one, include all linear combinations:
This is the column space of , written .
Geometrically, two non-collinear vectors span a plane through the origin. So this column space is a plane inside .
If the two columns happened to be collinear, the column space would shrink to a line. How large the subspace is depends on independence among the columns — the quantity the next lecture makes precise.
Higher dimensions
Take five vectors in . Their combinations form some subspace. It cannot be — the vectors have ten components — but it is a five-dimensional flat object through the origin (if the five are independent); if they are all collinear, it is only a line.
The lecture's warning: you must genuinely see two vectors spanning a plane in before you can trust the same conclusion in .
Takeaways
- A permutation matrix is the identity with reordered rows; there are of them, and .
- With row exchanges, elimination is .
- : the order reverses.
- is always symmetric; a symmetric matrix satisfies .
- A vector space is closed under addition and scalar multiplication, hence contains zero.
- A subspace is a vector space sitting inside a larger one.
- The subspaces of are the whole space, lines through the origin, and .
- The column space consists of all linear combinations of the columns; it is always a subspace.
Check your understanding
1. Why is the inverse of a permutation matrix its transpose? Use "swap twice and you are back".
Reference answer: A permutation matrix rearranges rows once; its inverse must undo that rearrangement, i.e. permute back. Row swap is the basic case: swapping twice restores the original, so a single swap matrix satisfies , and it is symmetric (), hence . A general permutation is a composite of swaps, and transposing reverses the order of the composite, which is exactly what undoing requires. Formally : the columns of are mutually orthogonal standard basis vectors, so the dot product of row of with column of is only when .
2. Write the two-line proof that is symmetric and identify where is used.
Reference answer:
The first step is the reversed-order rule with and ; the second uses . Hence , which is symmetry by definition. For the in the lecture, , and entries and are both — not a coincidence.
3. Why is the first quadrant not a subspace of ? Give a concrete counterexample.
Reference answer: A subspace must be closed under scalar multiplication, and the first quadrant is not. Take , which lies in the quadrant, and :
both coordinates negative, in the third quadrant. The quadrant is closed under addition and nonnegative scaling only; a general scalar breaks closure, so it is not a subspace.
4. Why is a line not through the origin not a subspace?
Reference answer: A subspace must contain the zero vector. Take any on a line that misses the origin; then , so if were a subspace the origin would have to lie on it — contradiction. Geometrically, scaling a point on the line down to zero jumps off the line.
5. For , explain why its column space is a plane rather than all of .
Reference answer: has only two columns, and , and they are not multiples of each other (the ratios differ), so they are independent. Two independent vectors in span a two-dimensional subspace, a plane through the origin. It cannot be all of : reaching every point needs three directions, while has only two degrees of freedom, so vectors off the plane are unreachable.
How it connects
This lecture builds the language of spaces. The next one uses it to rewrite : a solution exists exactly when lies in the column space. It also introduces the nullspace, the other subspace a matrix naturally produces.