第 07 章
解 Ax = 0:主元变量、自由变量与特殊解
消元把矩阵化为阶梯形;主元列的个数就是秩 r,剩下 n-r 个自由变量。给每个自由变量取 1、其余取 0,就得到零空间的一组特殊解。
Solving Ax = 0: Pivot Variables, Free Variables, and Special Solutions
Elimination produces echelon form; the number of pivot columns is the rank r, leaving n-r free variables. Set each free variable to 1 and the rest to 0 to get the special solutions spanning the nullspace.
篇内目录
- From definition to algorithm
- Timeline
- Example: a matrix
- Elimination
- Pivot columns and free columns
- Special solutions: give free variables 1 and 0
- First special solution:
- Second special solution:
- The whole nullspace
- Reducing to
- Reading the nullspace off
- A second example: the transpose
- Elimination
- Nullspace
- Reducing to
- A basic fact about rank
- Takeaways
- Check your understanding
- How it connects
从定义到算法
上一讲定义了零空间 ,但没有说怎么把它算出来。这一讲给出算法,核心是消元。
一个关键事实:消元不改变零空间。行交换、某行减去另一行的倍数,都是合法的方程变换,解集不变。但消元会改变列空间——这一点要记清楚。
时间轴
| 时间 | 内容 |
|---|---|
| 1:22 | 主元与秩 |
| 3:55 | 消元产生零行 |
| 4:59 | 主元列与自由列 |
| 6:12 | 阶梯形 |
| 6:48 | 秩 |
| 8:13 | 找主元与自由变量 |
| 9:22 | 给自由变量赋值 |
| 10:17 | 回代求主元变量 |
| 12:14 | 零空间是一条直线 |
| 15:10 | 特殊解 |
| 17:28 | 主元变量与自由变量的个数 |
| 19:25 | 最简行阶梯形 |
| 21:53 | 向上消元化为 |
| 29:54 | 零空间矩阵 |
| 33:08 | 第二个例子 |
| 37:06 | 主元列数等于秩 |
| 41:28 | 解中出现的单位矩阵 |
| 42:39 | 的来源 |
例子:一个 矩阵
先观察:
- 第二列是第一列的 倍,不独立;
- 第三行是第一行与第二行之和,行之间也不独立。
这些都应该由消元自动发现。
消元
第一步:用第一个主元 消去下方。
第二步:第二列的主元位置是 ,下面也是 ,这一列没有主元。不停下,直接看第三列。
第三列在第二行的值是 ,这就是第二个主元。用 消去下方:
得到阶梯形
一共只有 两个主元。这个数叫矩阵的秩:
第三行变成全零,说明原来的第三行是前两行的线性组合。
主元列与自由列
- 主元在第 1、3 列 → 是主元变量;
- 第 2、4 列没有主元 → 是自由变量。
自由变量的个数是
「自由」的意思是:可以任意赋值,剩下的主元变量由方程唯一确定。
一句话总结: 消元找到 个真正独立的方程;剩下 个方向可以自由选择,它们张成零空间。
特殊解:给自由变量取 1 和 0
第一个特殊解:
写回方程:
代入 :
第二式给出 ,所以 。
第一式给出 ,所以 。
它说的正是「第二列是第 1 列的 2 倍」:。
第二个特殊解:
第二式:,所以 。
第一式:,所以 。
验证它对应列的关系:
整个零空间
这是 中的一个二维子空间。两个特殊解就是它的一组基。
化简到最简行阶梯形
阶梯形 已经够用,但还可以继续化简,得到最简行阶梯形(reduced row echelon form, rref):
- 用向上消元把主元上方的元素也清零;
- 把每个主元除以自身,使主元变成 。
对本例:
- :第一行变成 ;
- :第二行变成 。
的结构非常规整:
- 主元行列交叉处是一个单位矩阵;
- 其余非零部分 位于自由列;
- 下方是零行。
从 直接读出零空间
把 按块写:
即
如果给自由变量取单位矩阵的值(第一个取 、其余取 ,然后轮换),就得到零空间矩阵
两列正是前面求出的 。所以「特殊解」不是技巧,而是把 搬到了主元变量的位置。
第二个例子:转置矩阵
取
这是 , 只有三个分量。
预期:前两列独立,第三列等于前两列之和,所以秩仍然是 ,自由变量 个。
消元
第一个主元 :
第二列的主元位置是 ,但下面有 ,于是交换第二、三行:
再用第二行消去第四行:。得到
主元列是 1、2,自由列是 3。
零空间
令 。第二式:
第一式:
这是一条直线。
化简到
用第一行减去第二行,再把第二行除以 :
零空间矩阵是
秩的一个基本事实
与 的秩相同。本例中原来 是 、秩 ; 是 、秩仍是 。
秩等于主元个数,也等于列空间中独立方向的个数。这个数会在下一讲与四个基本子空间一起被完整解释。
本讲结论
- 消元不改变零空间,但会改变列空间。
- 秩 = 主元个数 = 主元列数。
- 自由变量有 个;每个自由变量对应一个特殊解。
- 特殊解的做法:一个自由变量取 ,其余取 ,再回代求主元变量。
- 零空间是所有特殊解的线性组合,维数为 。
- 最简行阶梯形 ,零空间矩阵直接是 。
- 与 的秩相同。
理解检验
1. 对第一个例子,写出秩、主元列、自由列,并解释第三行为什么会变成零行。
参考答案:秩 。主元列是第 1、3 列,所以主元变量是 ;自由列是第 2、4 列,自由变量是 ,共 个。 第三行变成零行的原因是它本来就是前两行的组合:
即 。消元先做 ,再做 ,恰好把组合关系逐步减掉,最后整行归零。零行说明第三个方程没有提供新信息。
2. 用 的块结构推导零空间矩阵 。
参考答案:把 与 分块,方程 变成
自由变量可以任意取值,所以零空间由「自由变量决定主元变量」这一条规则完全描述。依次让 取单位矩阵的各列(第一个自由变量取 1、其余取 0,再轮换),对应的 的相应列,把两者叠起来就得到
它的每一列就是一个特殊解,列数 就是零空间的维数。本例中 ,所以 ,两列正是 。
3. 第二个例子中,为什么交换行之后秩仍然是 ?
参考答案:行交换只是改变方程的排列顺序,不改变方程组本身,等价于左乘一个可逆的排列矩阵,因此不会增加或减少主元的个数。交换前第二个主元位置是 、下方有非零的 ,交换后主元变成 ,继续消元把第四行也消成零,最终仍只有两个主元:
另外也可从行列两个角度看:这个矩阵来自 ,而 的秩是 ,转置不改变秩,所以 的秩也是 。
4. 如果 是 且秩为 ,零空间的维数是多少?
参考答案:(列数),(主元个数),自由变量个数为
所以零空间 是 中的四维子空间。直观上:7 个未知数里只有 3 个被独立方程约束住,剩下 4 个方向可以自由变动,每个方向对应一个特殊解。
5. 为什么「消元不改变零空间」但「消元改变列空间」?各举一个具体变化。
参考答案:零空间不变,因为每一种行操作(交换、某行减另一行的倍数、某行乘非零常数)都是可逆的方程变换:若 ,则操作后仍然成立;反过来,把操作倒回去也能从 恢复 。解集完全相同。 列空间会变,因为行操作是把行重新组合,列的摆法随之改变。本例中 的第一列是 ,它显然在 里;但 的所有列第三分量都是 ,所以 只含第三分量为 的向量,。可见 ,尽管两者的零空间相同。记法是:行操作保零空间、改列空间;列操作则相反。
与前后课的关系
这一讲给出了零空间的完整算法。下一讲处理 :先用消元判断是否有解,再写出「特解 + 零空间」的全部解,并引出四个基本子空间。
From definition to algorithm
The previous lecture defined the nullspace but did not compute it. This lecture supplies the algorithm, built on elimination.
One key fact: elimination does not change the nullspace. Swapping rows and subtracting a multiple of one row from another are legitimate equation operations, so the solution set is unchanged. Elimination does change the column space — a distinction worth keeping straight.
Timeline
| Time | Topic |
|---|---|
| 1:22 | Pivots and rank |
| 3:55 | Elimination produces a zero row |
| 4:59 | Pivot columns and free columns |
| 6:12 | Echelon form |
| 6:48 | The rank |
| 8:13 | Finding pivots and free variables |
| 9:22 | Setting a free variable to one |
| 10:17 | Back substitution |
| 12:14 | The null space is a line |
| 15:10 | Special solutions |
| 17:28 | Counting pivot and free variables |
| 19:25 | Reduced row echelon form |
| 21:53 | Eliminating upward to reach |
| 29:54 | The null space matrix |
| 33:08 | A second example |
| 37:06 | The number of pivot columns equals the rank |
| 41:28 | The identity block inside the solution |
| 42:39 | Where the minus comes from |
Example: a matrix
Two things are visible before any computation:
- column two is twice column one, so it is not independent;
- row three is the sum of rows one and two, so the rows are not independent either.
Elimination should discover both.
Elimination
Step one: use the first pivot to clear below it.
Step two: the pivot position in column two is , and so is everything below it. That column has no pivot. Do not stop; move to column three.
Column three has a in row two, which becomes the second pivot. Use :
The echelon form is
There are only two pivots. That count is the rank:
The zero row records that the original third row was a combination of the first two.
Pivot columns and free columns
- Pivots are in columns 1 and 3, so are pivot variables;
- Columns 2 and 4 have no pivot, so are free variables.
The number of free variables is
"Free" means they may be assigned arbitrarily; the equations then determine the pivot variables uniquely.
One-sentence summary: Elimination finds the r genuinely independent equations; the remaining n-r directions are free choices, and they span the nullspace.
Special solutions: give free variables 1 and 0
First special solution:
Write as equations:
Substitute :
The second equation gives , so .
The first gives , so .
It says exactly that column two is twice column one: .
Second special solution:
Second equation: , so .
First equation: , so .
Check the column relation:
The whole nullspace
This is a two-dimensional subspace of . The two special solutions form a basis.
Reducing to
The echelon form is enough, but it can be cleaned further into reduced row echelon form (rref):
- eliminate upward so entries above each pivot are zero;
- divide each pivot row by its pivot so every pivot is .
For this example:
- : row one becomes ;
- : row two becomes .
The structure is now transparent:
- the pivot rows and pivot columns contain an identity matrix;
- the remaining nonzero part sits in the free columns;
- zero rows lie below.
Reading the nullspace off
Write in blocks:
So
Give the free variables the columns of the identity (one gets , the rest , then rotate), and the result is the nullspace matrix
Its columns are exactly . The "special solutions" are not a trick; they are moved into the pivot-variable slots.
A second example: the transpose
Take
This is , so has three components.
Prediction: the first two columns are independent, the third is their sum, so the rank is still and there is free variable.
Elimination
First pivot :
The pivot position in column two is , but there is a below it, so swap rows two and three:
Eliminate row four with row two: . Thus
Pivot columns are 1 and 2; column 3 is free.
Nullspace
Set . The second equation gives
The first gives
This is a line.
Reducing to
Subtract row two from row one, then divide row two by :
The nullspace matrix is
A basic fact about rank
and have the same rank. The original is with rank ; is with rank .
Rank equals the number of pivots, and also the number of independent directions in the column space. The next lecture explains this fully alongside the four fundamental subspaces.
Takeaways
- Elimination preserves the nullspace but changes the column space.
- Rank = number of pivots = number of pivot columns.
- There are free variables, one special solution per free variable.
- To get a special solution, set one free variable to and the rest to , then back-substitute.
- The nullspace is all combinations of the special solutions, with dimension .
- In rref, , and the nullspace matrix is .
- and have the same rank.
Check your understanding
1. For the first example, state the rank, pivot columns, and free columns, and explain why row three became a zero row.
Reference answer: The rank is . The pivot columns are columns 1 and 3, so are pivot variables; columns 2 and 4 are free, so are free variables, of them. Row three became zero because it was already a combination of the first two rows:
i.e. . Elimination performs and then , peeling off exactly that combination until the row vanishes. A zero row means the third equation adds no new information.
2. Derive the nullspace matrix from the block structure of .
Reference answer: Write and . Then becomes
Free variables are arbitrary and determine the pivot variables. Taking to be the columns of the identity (first free variable 1 and the rest 0, then rotate) produces the columns stacked on :
Each column is one special solution, and there are of them, the dimension of the nullspace. Here , so , whose columns are exactly .
3. In the second example, why is the rank still after the row exchange?
Reference answer: A row exchange only reorders the equations; equivalently it left-multiplies by an invertible permutation matrix, so it neither creates nor destroys pivots. Before the swap the second pivot slot was zero with a nonzero below it; after the swap that is the pivot, and further elimination zeros row four. Two pivots remain:
Consistently, this matrix is of the earlier matrix, which had rank ; transposition preserves rank.
4. If is with rank , what is the dimension of its nullspace?
Reference answer: With columns and pivots, the number of free variables is
so is a four-dimensional subspace of . Intuitively, only three of the seven unknowns are pinned down by independent equations; four directions remain free, one special solution each.
5. Why does elimination preserve the nullspace but change the column space? Give a concrete change for each.
Reference answer: The nullspace is preserved because every row operation is invertible: if then the operated system still holds, and reversing the operation recovers from . The solution sets coincide. The column space changes because row operations recombine rows. In the example, the first column of is , which is in ; but every column of has zero third component, so contains only vectors with third component zero, and . Hence even though the nullspaces agree. The slogan: row operations preserve the nullspace and change the column space; column operations do the reverse.
How it connects
This lecture gives the complete algorithm for the nullspace. The next tackles : elimination first decides whether a solution exists, then "particular solution plus nullspace" describes all of them, leading into the four fundamental subspaces.