第 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.

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

本讲的三件事

  1. 排列矩阵:有行交换时的消元怎么写。
  2. 转置与对称矩阵:一个几乎免费就能造出对称矩阵的方法。
  3. 向量空间与子空间:从「一堆向量」升级到「一个空间」。

前两件是上一讲的收尾,第三件是整门课真正开始的地方。

时间轴

时间内容
0:21排列矩阵与带行交换的消元
2:06交换行得到主元
3:44MATLAB 如何记录行交换
9:13排列矩阵的逆
10:33转置的例子
12:52对称矩阵
15:44RTRR^TR 总是对称
18:27转置规则:顺序反转
21:17向量加法与线性组合
26:54R3R^3 中的向量
32:32子空间的定义
36:03R2R^2 的所有子空间
42:46从矩阵造出列空间
44:58列空间是平面
47:22其他子空间

排列矩阵与带行交换的消元

消元时如果主元位置出现 00,就要交换行。排列矩阵 PP 就是把单位矩阵的行重新排列得到的矩阵;单位矩阵本身也算一个排列(什么都不做)。

n×nn\times n 的排列矩阵一共有 n!n! 个:3×33\times3 有 66 个,4×44\times4 有 2424 个,5×55\times5 有 120120 个。

它们构成一个群:

  • 两个排列相乘,仍是排列;
  • 每个排列都可逆;
  • 逆就是转置:
PTP=I  ⟹  P−1=PT.P^T P=I \;\Longrightarrow\; P^{-1}=P^T.

验证的思路很直接:交换两行再做一次就还原,所以很多 PP 是自己的逆;对更长的循环,转置恰好把「谁移到哪里」倒过来。

有行交换时,消元写作

PA=LU.PA=LU.

PP 先记录行的正确顺序,LL 与 UU 的结构不变。

补充: 实际数值计算中,MATLAB 一类软件不只检查主元是否为零,还会检查它是否足够大。主元非常接近零会放大舍入误差,所以软件会做「部分主元法」:在每一列挑选绝对值最大的元素换到主元位置。代数上不必要,数值上必要。

转置

定义与例子

转置把行和列互换:

(AT)ij=Aji.(A^T)_{ij}=A_{ji}.

例如

R=[124331],RT=[132341].R=\begin{bmatrix}1&2&4\\3&3&1\end{bmatrix}, \qquad R^T=\begin{bmatrix}1&3\\2&3\\4&1\end{bmatrix}.

RR 是 2×32\times3,RTR^T 是 3×23\times2。

乘积的转置也反序

(AB)T=BTAT.(AB)^T=B^T A^T.

和逆的规则一样,顺序要反过来。

对称矩阵

如果 AT=AA^T=A,就称 AA 对称。对称矩阵关于主对角线镜像相等。

一个几乎免费得到对称矩阵的办法:对任意矩阵 RR,乘积 RTRR^T R 一定对称。证明只有两行:

(RTR)T=RT(RT)T=RTR.(R^T R)^T=R^T (R^T)^T=R^T R.

用上面的 RR 计算:

RTR=[132341][124331]=[1011711131171117].R^T R= \begin{bmatrix} 1&3\\2&3\\4&1 \end{bmatrix} \begin{bmatrix}1&2&4\\3&3&1\end{bmatrix} = \begin{bmatrix} 10&11&7\\ 11&13&11\\ 7&11&17 \end{bmatrix}.

第 (1,2)(1,2) 项是 1⋅2+3⋅3=111\cdot2+3\cdot3=11,第 (2,1)(2,1) 项是 2⋅1+3⋅3=112\cdot1+3\cdot3=11,相等不是巧合。

一句话总结: 对称性不是碰巧,而是「转置两次回到原矩阵」这条规则的必然结果。

向量空间:先看运算,再看集合

两种基本运算

线性代数只做两件事:

  1. 向量相加;
  2. 向量乘标量。

如果一组向量对这两种运算都封闭——加完、乘完仍然在这组里——并且满足通常的运算律,它就是一个向量空间。

R2R^2 与 RnR^n

R2R^2 是所有二元实向量组成的空间,几何上就是整个平面。R3R^3 是三维空间。RnR^n 是所有 nn 个实分量向量组成的空间。

约定:本课程使用列向量。

为什么零向量必须在

考虑 R2R^2 中「去掉原点」的平面。它不是向量空间,因为:

  • 取向量 [3,2]T[3,2]^T,乘以 00,结果 [0,0]T[0,0]^T 不在集合里;
  • 取 [3,2]T[3,2]^T 与 [−3,−2]T[-3,-2]^T,相加也回到原点,同样不在集合里。

所以每个向量空间都必须包含零向量。这不是额外规定,而是「对数乘封闭」的直接推论。

反例:第一象限

只取坐标非负的向量,加法没问题:[3,2]+[5,6]=[8,8][3,2]+[5,6]=[8,8] 仍在第一象限。但乘以 −5-5 就跑到第三象限,封闭性被破坏。因此它不是向量空间。

子空间

子空间是包含在更大空间里、自身也满足向量空间规则的集合。

R2R^2 的全部子空间

只有三类:

  1. 整个 R2R^2;
  2. 过原点的直线;
  3. 只含零向量 {0}\{\mathbf{0}\}。

不过原点的直线不是子空间:把线上一个向量乘以 00,就离开了这条线。

注意「R2R^2 中过原点的直线」与 R1R^1 很像,但不相同:前者的向量有两个分量,后者只有一个。

R3R^3 的全部子空间

四类:

  1. 整个 R3R^3;
  2. 过原点的平面;
  3. 过原点的直线;
  4. {0}\{\mathbf{0}\}。

维度从 3 到 0,逐级下降。

从矩阵造出子空间:列空间

取矩阵

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

它的两列 c1=[1,2,4]T\mathbf{c}_1=[1,2,4]^T、c2=[3,3,1]T\mathbf{c}_2=[3,3,1]^T 都是 R3R^3 中的向量。

只把这两列放在一起,还不构成子空间——必须把它们的所有线性组合都加进来:

{x1c1+x2c2∣x1,x2∈R}.\{x_1\mathbf{c}_1+x_2\mathbf{c}_2\mid x_1,x_2\in R\}.

这个集合叫 AA 的列空间,记作 C(A)C(A)。

几何上,两个不共线的向量张成一个过原点的平面。所以这个例子的列空间是 R3R^3 中的一个平面。

如果两列恰好共线,列空间就退化成一条直线。子空间的大小取决于列向量之间的独立性——这正是下一讲要量化的东西。

推广到高维

R10R^{10} 中取五个向量,它们的组合形成某个子空间。它不可能是 R5R^5——向量有十个分量——而是一个过原点的「五维平坦对象」(如果五个向量线性无关的话);如果它们共线,就只剩一条线。

课程在这里的提醒:你必须在 R3R^3 里真正「看见」两个向量张成一个平面,之后才能在 R10R^{10} 里相信同样的结论。

本讲结论

  • 排列矩阵是重排了行的单位矩阵,共 n!n! 个,满足 P−1=PTP^{-1}=P^T。
  • 有行交换时消元写作 PA=LUPA=LU。
  • (AB)T=BTAT(AB)^T=B^T A^T,顺序反过来。
  • RTRR^T R 永远对称;对称矩阵满足 AT=AA^T=A。
  • 向量空间对加法与数乘封闭,因此必含零向量。
  • 子空间是更大空间内部、自身也是向量空间的集合。
  • R2R^2 的子空间只有:全空间、过原点直线、零空间。
  • 矩阵的列空间由列的所有线性组合构成;它一定是子空间。

理解检验

1. 为什么排列矩阵的逆等于它的转置?用「交换两次还原」解释。

参考答案:排列矩阵做的动作是「把行按某个置换搬动一次」。逆矩阵要做的就是把这次搬动撤销,也就是按相反的置换搬回去。交换两行是最基本的情形:换一次再换一次就回到原样,所以单个交换矩阵满足 P2=IP^2=I,而它恰好对称(PT=PP^T=P),于是 P−1=P=PTP^{-1}=P=P^T。一般的排列可以看成若干次交换的复合,转置把复合的顺序倒过来,正好完成撤销。形式化的验证是 PTP=IP^TP=I:PP 的列是互相垂直的标准基向量,PTP^T 的第 ii 行与 PP 的第 jj 列点积,等于 11 当且仅当 i=ji=j。

2. 写出 RTRR^T R 对称的两行证明,并指出哪一步用了 (AB)T=BTAT(AB)^T=B^TA^T。

参考答案:

(RTR)T=RT(RT)T=RTR.(R^T R)^T=R^T(R^T)^T=R^T R .

第一步用了乘积转置的反序规则 (AB)T=BTAT(AB)^T=B^TA^T,其中 A=RTA=R^T、B=RB=R;第二步用了「转置两次回到原矩阵」(RT)T=R(R^T)^T=R。于是 (RTR)T=RTR(R^TR)^T=R^TR,按定义这就是对称。以文中的 RR 为例,RTR=[1011711131171117]R^TR=\begin{bmatrix}10&11&7\\11&13&11\\7&11&17\end{bmatrix},(1,2)(1,2) 与 (2,1)(2,1) 都是 1⋅2+3⋅3=111\cdot2+3\cdot3=11,相等不是巧合。

3. 第一象限为什么不是 R2R^2 的子空间?给出一个具体的反例。

参考答案:子空间要对数乘封闭,第一象限做不到。取 v=[3,2]T\mathbf{v}=[3,2]^T,它坐标非负,在第一象限;取标量 c=−5c=-5,则

cv=[−15−10],c\mathbf{v}=\begin{bmatrix}-15\\-10\end{bmatrix},

两个分量都变成负数,落在第三象限,已经离开了第一象限。所以第一象限只对加法(和非负数乘)封闭,对一般的数乘不封闭,不是子空间。顺带一提,它还不含零向量之外的很多「反向」向量,这也说明它不是向量空间。

4. 不过原点的直线为什么不是子空间?

参考答案:子空间必须包含零向量,而且要对数乘封闭。设直线 LL 不过原点,取线上任一向量 v≠0\mathbf{v}\ne\mathbf{0},则 0⋅v=00\cdot\mathbf{v}=\mathbf{0}。如果 LL 是子空间,零向量就必须在 LL 上,但 LL 不过原点,矛盾。几何上,把线上一点沿该方向缩到 00 倍,就跳出了这条线。同理,两条平行但不过原点的直线相加也可能跑出集合外。

5. 对 A=[132341]A=\begin{bmatrix}1&3\\2&3\\4&1\end{bmatrix},解释为什么它的列空间是一个平面而不是整条 R3R^3。

参考答案:AA 只有两列 c1=[1,2,4]T\mathbf{c}_1=[1,2,4]^T 与 c2=[3,3,1]T\mathbf{c}_2=[3,3,1]^T,它们不是彼此的倍数(对应分量之比 3, 3/2, 1/43,\ 3/2,\ 1/4 不相同),所以线性无关。两个无关向量在 R3R^3 中张成一个二维子空间,即过原点的平面。它不可能是整个 R3R^3:R3R^3 需要三个方向,而两列的所有线性组合 x1c1+x2c2x_1\mathbf{c}_1+x_2\mathbf{c}_2 只有两个自由度,平面外的向量无论怎么组合都到不了。列空间的维数等于独立列的个数,这里是 2。

与前后课的关系

这一讲建立了「空间」的语言。下一讲用它重写 Ax=bA\mathbf{x}=\mathbf{b}:有解当且仅当 b\mathbf{b} 落在列空间里;同时引入零空间,作为另一个由矩阵自然产生的子空间。

Three topics

  1. Permutation matrices: how to write elimination when rows must be exchanged.
  2. Transposes and symmetric matrices: an almost free way to build a symmetric matrix.
  3. 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

TimeTopic
0:21Permutations and elimination with row exchanges
2:06Exchanging rows to get a pivot
3:44How MATLAB records row exchanges
9:13The inverse of a permutation matrix
10:33An example of a transpose
12:52Symmetric matrices
15:44RTRR^TR is always symmetric
18:27The transpose rule: reverse the order
21:17Vectors, addition and linear combinations
26:54Vectors in R3R^3
32:32The definition of a subspace
36:03All subspaces of R2R^2
42:46The column space of a matrix
44:58The column space as a plane
47:22Other subspaces

Permutations and elimination with row exchanges

If a zero appears in a pivot position, rows must be swapped. A permutation matrix PP is the identity with its rows rearranged; the identity itself counts as a permutation (the one that does nothing).

There are n!n! permutation matrices of size nn: six of size 33, twenty-four of size 44, one hundred twenty of size 55.

They form a group:

  • the product of two permutations is a permutation;
  • every permutation is invertible;
  • the inverse is the transpose:
PTP=I  ⟹  P−1=PT.P^T P=I \;\Longrightarrow\; P^{-1}=P^T.

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

PA=LU.PA=LU.

PP records the correct row order, and LL and UU 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:

(AT)ij=Aji.(A^T)_{ij}=A_{ji}.

For example,

R=[124331],RT=[132341].R=\begin{bmatrix}1&2&4\\3&3&1\end{bmatrix}, \qquad R^T=\begin{bmatrix}1&3\\2&3\\4&1\end{bmatrix}.

RR is 2×32\times3; RTR^T is 3×23\times2.

The transpose of a product reverses the order

(AB)T=BTAT.(AB)^T=B^T A^T.

The same reversal rule as for inverses.

Symmetric matrices

If AT=AA^T=A, the matrix is symmetric: entries mirror across the main diagonal.

There is an almost free way to produce one: for any matrix RR, the product RTRR^T R is always symmetric. The proof takes two lines:

(RTR)T=RT(RT)T=RTR.(R^T R)^T=R^T (R^T)^T=R^T R.

With the RR above:

RTR=[132341][124331]=[1011711131171117].R^T R= \begin{bmatrix} 1&3\\2&3\\4&1 \end{bmatrix} \begin{bmatrix}1&2&4\\3&3&1\end{bmatrix} = \begin{bmatrix} 10&11&7\\ 11&13&11\\ 7&11&17 \end{bmatrix}.

Entry (1,2)(1,2) is 1⋅2+3⋅3=111\cdot2+3\cdot3=11, and entry (2,1)(2,1) is 2⋅1+3⋅3=112\cdot1+3\cdot3=11. 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:

  1. add vectors;
  2. 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.

R2R^2 and RnR^n

R2R^2 is all pairs of real numbers; geometrically, the whole plane. R3R^3 is three-dimensional space. RnR^n is all vectors with nn 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 [3,2]T[3,2]^T by 00 and the result [0,0]T[0,0]^T is missing;
  • add [3,2]T[3,2]^T and [−3,−2]T[-3,-2]^T 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: [3,2]+[5,6]=[8,8][3,2]+[5,6]=[8,8] stays in the quadrant. But multiplying by −5-5 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 R2R^2

Only three:

  1. all of R2R^2;
  2. a line through the origin;
  3. the zero vector alone, {0}\{\mathbf{0}\}.

A line not through the origin is not a subspace: multiply one of its vectors by 00 and you leave the line.

A line through the origin in R2R^2 looks like R1R^1, but they are not the same: vectors in the line have two components, vectors in R1R^1 have one.

All subspaces of R3R^3

Four:

  1. all of R3R^3;
  2. a plane through the origin;
  3. a line through the origin;
  4. {0}\{\mathbf{0}\}.

Dimensions run from 3 down to 0.

Building a subspace from a matrix: the column space

Take

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

Its columns c1=[1,2,4]T\mathbf{c}_1=[1,2,4]^T and c2=[3,3,1]T\mathbf{c}_2=[3,3,1]^T live in R3R^3.

Two columns by themselves are not a subspace. To get one, include all linear combinations:

{x1c1+x2c2∣x1,x2∈R}.\{x_1\mathbf{c}_1+x_2\mathbf{c}_2\mid x_1,x_2\in R\}.

This is the column space of AA, written C(A)C(A).

Geometrically, two non-collinear vectors span a plane through the origin. So this column space is a plane inside R3R^3.

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 R10R^{10}. Their combinations form some subspace. It cannot be R5R^5 — 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 R3R^3 before you can trust the same conclusion in R10R^{10}.

Takeaways

  • A permutation matrix is the identity with reordered rows; there are n!n! of them, and P−1=PTP^{-1}=P^T.
  • With row exchanges, elimination is PA=LUPA=LU.
  • (AB)T=BTAT(AB)^T=B^T A^T: the order reverses.
  • RTRR^T R is always symmetric; a symmetric matrix satisfies AT=AA^T=A.
  • 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 R2R^2 are the whole space, lines through the origin, and {0}\{\mathbf{0}\}.
  • 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 P2=IP^2=I, and it is symmetric (PT=PP^T=P), hence P−1=P=PTP^{-1}=P=P^T. A general permutation is a composite of swaps, and transposing reverses the order of the composite, which is exactly what undoing requires. Formally PTP=IP^TP=I: the columns of PP are mutually orthogonal standard basis vectors, so the dot product of row ii of PTP^T with column jj of PP is 11 only when i=ji=j.

2. Write the two-line proof that RTRR^T R is symmetric and identify where (AB)T=BTAT(AB)^T=B^T A^T is used.

Reference answer:

(RTR)T=RT(RT)T=RTR.(R^T R)^T=R^T(R^T)^T=R^T R .

The first step is the reversed-order rule (AB)T=BTAT(AB)^T=B^TA^T with A=RTA=R^T and B=RB=R; the second uses (RT)T=R(R^T)^T=R. Hence (RTR)T=RTR(R^TR)^T=R^TR, which is symmetry by definition. For the RR in the lecture, RTR=[1011711131171117]R^TR=\begin{bmatrix}10&11&7\\11&13&11\\7&11&17\end{bmatrix}, and entries (1,2)(1,2) and (2,1)(2,1) are both 1⋅2+3⋅3=111\cdot2+3\cdot3=11 — not a coincidence.

3. Why is the first quadrant not a subspace of R2R^2? Give a concrete counterexample.

Reference answer: A subspace must be closed under scalar multiplication, and the first quadrant is not. Take v=[3,2]T\mathbf{v}=[3,2]^T, which lies in the quadrant, and c=−5c=-5:

cv=[−15−10],c\mathbf{v}=\begin{bmatrix}-15\\-10\end{bmatrix},

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 v≠0\mathbf{v}\ne\mathbf{0} on a line LL that misses the origin; then 0⋅v=00\cdot\mathbf{v}=\mathbf{0}, so if LL 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 A=[132341]A=\begin{bmatrix}1&3\\2&3\\4&1\end{bmatrix}, explain why its column space is a plane rather than all of R3R^3.

Reference answer: AA has only two columns, c1=[1,2,4]T\mathbf{c}_1=[1,2,4]^T and c2=[3,3,1]T\mathbf{c}_2=[3,3,1]^T, and they are not multiples of each other (the ratios 3, 3/2, 1/43,\ 3/2,\ 1/4 differ), so they are independent. Two independent vectors in R3R^3 span a two-dimensional subspace, a plane through the origin. It cannot be all of R3R^3: reaching every point needs three directions, while x1c1+x2c2x_1\mathbf{c}_1+x_2\mathbf{c}_2 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 Ax=bA\mathbf{x}=\mathbf{b}: a solution exists exactly when b\mathbf{b} lies in the column space. It also introduces the nullspace, the other subspace a matrix naturally produces.

来源