第 30 章
线性变换与它的矩阵:先有变换,后有坐标
线性变换是无坐标的映射,保持加法与数乘;选定输入基与输出基后,变换才写成矩阵,矩阵的第 j 列就是 T(v_j) 在输出基下的坐标。
Linear Transformations and Their Matrices: Transformation First, Coordinates Second
A linear transformation is a coordinate-free map preserving addition and scaling; once input and output bases are chosen it becomes a matrix, whose j-th column is the coordinate vector of T(v_j).
篇内目录
- Reversing the usual order
- Timeline
- What makes a transformation linear
- An immediate consequence
- Four examples, two of them not linear
- Projection
- Rotation
- Translation
- Length
- The linear transformations matrices produce
- Knowing a basis is enough
- Coordinates come from a basis
- The rule for constructing the matrix
- Why the j-th column is exactly that
- Example one: the same projection, two bases
- In the eigenvector basis
- In the standard basis
- Example two: differentiation is linear
- Matrix operations as transformation operations
- Common mistakes
- Takeaways
- Check your understanding
- How this connects to the course
把顺序倒过来
很多线性代数课从线性变换开始,先讲映射,再引入矩阵。Strang 在这门课的最后才回头讲它,是因为此时已经积累了足够多的工具:基、坐标、零空间、特征值,都可以用来理解同一个对象。
核心观点是:
线性变换是本质,矩阵是它在某组基下的坐标表示。
矩阵不是凭空出现的数字表。它依赖基的选择;换一组基,同一个变换会写成另一个矩阵。
时间轴
| 时间 | 内容 |
|---|---|
| 0:07 | 线性变换:把注意力放到整个空间上 |
| 1:39 | 例一:投影到一条直线 |
| 5:37 | 例二:平移,它不是线性变换 |
| 7:53 | 零向量必须被映到零 |
| 10:35 | 例三:旋转 |
| 13:38 | 例四:由矩阵给出的变换 |
| 15:04 | 矩阵如何作用于平面上的所有向量 |
| 20:30 | 每个线性变换都对应一个矩阵 |
| 23:58 | 输入基的选择决定矩阵 |
| 26:21 | 坐标来自基 |
| 30:09 | 一般的 维到 维变换 |
| 32:37 | 投影例子:换一组基使矩阵变简单 |
| 36:58 | 特征向量基使矩阵成为对角阵 |
| 38:49 | 45 度投影及其矩阵 |
| 46:04 | 求导作为线性变换 |
| 48:10 | 求导在多项式基下的矩阵 |
什么是线性变换
一个映射 把输入空间的向量送到输出空间。它是线性的,当且仅当保持向量运算:
两条可以合并成一条:
也就是说,线性组合先变换还是先组合,结果相同。
一个立刻可用的推论
证明:取 ,,则 ,所以 ,即 。
这条推论是判断「不线性」的最快工具:只要原点被移动,映射一定不是线性的。
四个例子,两个不是
投影
把平面上每个向量投影到一条过原点的直线上。若 伸长两倍,投影也伸长两倍;若 变成 ,投影也变成相反方向。所以投影是线性的。
整个描述不需要坐标,也不需要矩阵。
旋转
把平面绕原点旋转 。旋转保持加法与数乘,因此是线性的。
如果输入是一个房子的轮廓,输出就是旋转后的房子。线性变换可以一次作用在整片区域上:只要知道边界点去哪里,就知道整个图形去哪里。
平移
把每个向量 变成 ,其中 是固定向量。这看起来很自然,但它不是线性的:
更直接地,。原点被移动了。
这也是为什么仿射变换(线性变换加平移)需要额外的一维坐标才能写成矩阵。
取长度
把向量送到它的长度 。它满足 ,也满足 ,但
负数的数乘被破坏了,所以不是线性的。
矩阵给出的线性变换
对任意矩阵 ,映射
都是线性的,因为矩阵乘法满足分配律与数乘结合律:
反过来,在有限维空间中,每个线性变换都来自某个矩阵——前提是选定了基。
矩阵的尺寸由输入输出空间的维数决定:从 到 的变换,对应一个 矩阵。
知道基上的像,就知道整个变换
这是本讲最重要的结构事实。
设 是输入空间的一组基。任意输入都可以唯一写成
由线性性,
所以,只要知道 在基向量上的取值,就能算出它在任何向量上的取值。
反过来说,未知的也只有这些取值: 个基向量各有 个输出坐标,共 个数,正好是一个 矩阵。
坐标来自基
在标准基下,向量 的三个分量就是坐标——因为默认基是 。
但基可以换。取任意一组基 ,向量 的坐标是唯一一组系数 ,使得
换基就换坐标。同一个向量,在不同基下的坐标不同;同一个变换,在不同基下的矩阵也不同。
构造矩阵的规则
设:
- 输入空间 的基为 ;
- 输出空间 的基为 。
矩阵 的第 列这样得到:
- 对第 个输入基向量作用 ,得到 ;
- 把 写成输出基的线性组合:
- 系数 就是 的第 列。
这样构造出的矩阵满足:输入坐标左乘 ,得到输出坐标。
为什么第 j 列是这样
取输入坐标为 (第 个位置为 ),它对应的输入向量正是 。用 乘这个坐标向量,得到的就是 的第 列。而第 列按定义是 的输出坐标。两边一致。
对每个基向量都成立,由线性性,对所有向量都成立。
例一:投影,两种基
把平面投影到 直线上。
用特征向量基
取
输入基与输出基都取这一组。
- ,因为沿直线的向量投影后不变;
- ,因为垂直分量被投影抹掉。
于是
矩阵为
这是对角矩阵,对角元正是特征值 与 。特征向量基是「好基」:它让变换写成最简单的形式。
用标准基
取 ,,输入输出都用标准基。
投影到 直线的投影矩阵是
检查:
两个标准基向量都落到同一条直线上,正是投影。
同一个变换,在特征向量基下是 ,在标准基下是 。矩阵不同,变换相同。
例二:求导也是线性变换
取输入空间为次数不超过 的多项式:
基为 。输出空间取次数不超过 的多项式,基为 。
求导:
按构造规则:
- ,输出坐标 ;
- ,输出坐标 ;
- ,输出坐标 。
所以矩阵是
验证:
这正是导数的坐标。
补充:求导之所以能如此高效,正是因为它线性。知道少数几个基本函数的导数,就能通过线性组合得到所有组合的导数。这也是微分法则背后的结构原因。
矩阵运算的变换解释
一旦把矩阵理解为变换的坐标表示,矩阵运算就有了自然含义:
- 矩阵乘法对应变换的复合:先做 ,再做 ,矩阵是 ;
- 逆矩阵对应逆变换: 把输出送回输入;
- 相似 对应换基:同一个变换在新基下的矩阵。
矩阵乘法「行乘列」的规则不是约定,而是为了保证复合变换的坐标计算正确。
常见误区
- 把平移当成线性变换。它移动了原点,违反 。
- 以为矩阵唯一确定变换。矩阵依赖基;换基后同一个变换对应不同矩阵。
- 只给输入基,不给输出基。构造矩阵需要两组基,输出基决定列坐标如何读出。
- 混淆向量与坐标。向量是几何对象,坐标是它在某组基下的系数。
本讲结论
- 线性变换保持加法与数乘,等价于保持一切线性组合。
- 线性变换必然把零送到零;平移与取长度都不是线性的。
- 知道变换在一组基上的像,就确定了整个变换。
- 选定输入基与输出基后,矩阵的第 列是 在输出基下的坐标。
- 好基(特征向量基)让矩阵变成对角;标准基让计算方便,但矩阵通常不简单。
- 矩阵乘法、逆、相似,分别对应复合、逆变换、换基。
理解检验
1. 用定义证明 ,并说明为什么平移不满足它。
参考答案:取数乘公理 ,令 、 任意,得 。另一种写法是 ,两边减去 也得 。平移 把零向量送到 ;只要 ,就有 ,违反这条必要条件,所以平移不是线性变换。这也是仿射变换需要额外一维坐标才能写成矩阵的原因。
2. 为什么「取长度」在 时成立,在 时不成立?
参考答案: 满足 。当 时 ,所以 成立。当 时 ,得 ,而 ;两者只在 时相等,一般情况下不等。破坏的正是「负数数乘」这一条:线性变换必须区分方向,而长度丢掉了符号。同时它也违反 。
3. 已知 在一组基上的像,为什么就能确定 在所有向量上的值?
参考答案:设 是输入空间的一组基,任一 都能唯一写成 。由线性性(把有限和的每一项拆开、系数提出),
右边的系数 由 的坐标给出, 已知,所以 被完全确定。这也解释了为什么一个 变换只需要 个数——每个基向量给出 个输出坐标。
4. 对 投影,特征向量基与标准基给出的矩阵分别是什么?它们为什么相似?
参考答案:在特征向量基 、 下,、,矩阵是 。在标准基下,投影矩阵是
两者相似,因为它们是同一个变换在不同基下的矩阵,换基公式为 ,其中 是以特征向量为列的基变换矩阵。相似不变量(迹 、行列式 、特征值 和 )在两边一致。
5. 求导矩阵 的零空间是什么?它在原函数空间中对应什么?
参考答案:求 :
所以 、, 自由。零空间是 ,维数 ,等于 。在多项式空间中, 对应常数多项式 ,其导数为零。所以零空间正是所有常函数组成的子空间——这与微积分里「导数为零当且仅当函数为常数」完全一致。
与前后课程的关系
上一讲的 SVD 通过选择两组正交基把任意矩阵对角化。这一讲回到更根本的层次:变换先于矩阵,矩阵依赖基。接下来的课程会在此基础上讨论基变换、图像压缩,以及整个课程的总结。
Reversing the usual order
Many linear algebra courses start with transformations and only then introduce matrices. Strang saves this topic for late in the course, when enough machinery exists — bases, coordinates, null spaces, eigenvalues — to understand the same object from several sides.
The central claim:
A linear transformation is the object; a matrix is its coordinate representation in a chosen basis.
A matrix is not a table of numbers that appears from nowhere. It depends on the bases. Change the bases and the same transformation is written as a different matrix.
Timeline
| Time | Topic |
|---|---|
| 0:07 | Linear transformations: looking at the whole space |
| 1:39 | Example one: projection onto a line |
| 5:37 | Example two: translation, which is not linear |
| 7:53 | The zero vector must map to zero |
| 10:35 | Example three: rotation |
| 13:38 | Example four: a transformation given by a matrix |
| 15:04 | How a matrix acts on every vector |
| 20:30 | Every linear transformation comes from a matrix |
| 23:58 | The input basis determines the matrix |
| 26:21 | Coordinates come from a basis |
| 30:09 | The general map from to |
| 32:37 | A basis that simplifies the projection matrix |
| 36:58 | An eigenvector basis makes the matrix diagonal |
| 38:49 | Projection onto the 45 degree line |
| 46:04 | Differentiation as a linear transformation |
| 48:10 | The matrix of differentiation in a polynomial basis |
What makes a transformation linear
A map sends vectors from an input space to an output space. It is linear exactly when it preserves the two vector operations:
The two combine into one statement:
In words: transforming a linear combination gives the same result as combining the transformed pieces.
An immediate consequence
Proof: take and . Then , so , hence .
This is the fastest test for non-linearity: if the origin moves, the map cannot be linear.
Four examples, two of them not linear
Projection
Project every vector in the plane onto a line through the origin. Doubling doubles its projection; replacing by reverses the projection. So projection is linear.
The description needs no coordinates and no matrix.
Rotation
Rotate the plane by about the origin. Rotation preserves addition and scaling, so it is linear.
If the input is the outline of a house, the output is the rotated house. A linear transformation acts on a whole region at once: once the boundary points are known to move, the entire figure moves.
Translation
Send every to for a fixed . Natural as it looks, it is not linear:
More directly, : the origin moved.
This is why an affine map (a linear map plus a translation) needs one extra coordinate before it can be written as a matrix.
Length
Send a vector to its length . It satisfies and , but
Scaling by a negative number fails, so it is not linear.
The linear transformations matrices produce
For any matrix , the map
is linear, because matrix multiplication distributes over addition and commutes with scaling:
Conversely, in finite dimensions, every linear transformation comes from some matrix — once bases are chosen.
The shape of the matrix is fixed by the dimensions: a map from to corresponds to a matrix.
Knowing a basis is enough
This is the key structural fact of the lecture.
Let be a basis of the input space. Every input has a unique expansion
By linearity,
So knowing what does to the basis vectors determines what it does to every vector.
Conversely, those values are all that must be specified: basis vectors, each with output coordinates, give numbers — exactly an matrix.
Coordinates come from a basis
In the standard basis, the entries of are its coordinates, because the basis is implicit.
But any basis will do. For a basis , the coordinates of are the unique coefficients with
Change the basis and the coordinates change. The same vector has different coordinates; the same transformation has different matrices.
The rule for constructing the matrix
Let:
- the input space have basis ;
- the output space have basis .
The -th column of is obtained as follows:
- Apply to the -th input basis vector, producing .
- Expand it in the output basis:
- The coefficients form the -th column.
The resulting matrix satisfies: input coordinates multiplied by give output coordinates.
Why the j-th column is exactly that
Take the input coordinate vector with a one in position . The corresponding input vector is . Multiplying by returns the -th column. By construction, that column is the output coordinate vector of . The two agree.
It holds for every basis vector, and by linearity it holds for every vector.
Example one: the same projection, two bases
Project the plane onto the line.
In the eigenvector basis
Take
Use this basis for both input and output.
- , since a vector along the line is unchanged;
- , since the perpendicular component is annihilated.
So
and the matrix is
Diagonal, with the eigenvalues and on the diagonal. The eigenvector basis is the good basis: it writes the transformation in its simplest form.
In the standard basis
Take and for both input and output.
The projection matrix onto the line through is
Check:
Both standard basis vectors land on the line, as projection requires.
One transformation, two matrices: in the eigenvector basis, in the standard basis. The matrix changes; the transformation does not.
Example two: differentiation is linear
Let the input space be polynomials of degree at most two,
with basis . Let the output space be polynomials of degree at most one, with basis .
Differentiation gives
Following the rule:
- , with output coordinates ;
- , with output coordinates ;
- , with output coordinates .
So the matrix is
Check:
exactly the coordinates of the derivative.
Background: differentiation is efficient precisely because it is linear. Knowing the derivatives of a few basic functions lets you differentiate every linear combination. That is the structural reason the differentiation rules work.
Matrix operations as transformation operations
Once matrices are understood as coordinate representations, the operations acquire natural meanings:
- Matrix multiplication is composition: apply , then , and the matrix is .
- The inverse matrix is the inverse transformation: it sends outputs back to inputs.
- Similarity is a change of basis: the same transformation in a new basis.
The row-by-column rule for matrix multiplication is not an arbitrary convention. It is forced by the requirement that composition of transformations compose correctly in coordinates.
Common mistakes
- Treating a translation as linear. It moves the origin, violating .
- Believing the matrix is unique. A matrix depends on the basis; one transformation has many matrices.
- Specifying only the input basis. Constructing the matrix needs both bases; the output basis determines how columns are read off.
- Confusing a vector with its coordinates. A vector is a geometric object; coordinates are its coefficients in a chosen basis.
Takeaways
- A linear transformation preserves addition and scaling, hence all linear combinations.
- Linearity forces ; translation and length are not linear.
- Knowing the image of a basis determines the whole transformation.
- With input and output bases chosen, column of the matrix is the coordinate vector of .
- A good basis (the eigenvectors) diagonalizes the matrix; the standard basis is convenient but usually not simple.
- Matrix multiplication, inversion, and similarity correspond to composition, inverse maps, and change of basis.
Check your understanding
1. Prove from the definition, and explain why translation fails it.
Reference answer: Apply the scaling axiom with and any : . Equivalently, , and subtracting from both sides gives . Translation sends the zero vector to ; whenever we get , violating this necessary condition, so translation is not linear. This is exactly why affine maps need an extra coordinate to be written as matrices.
2. Why does "take the length" satisfy the rule for but fail for ?
Reference answer: gives . For we have , so holds. For we get , whereas ; these agree only when . The failure is precisely the negative-scaling case: a linear map must track direction, while length forgets the sign. It also violates .
3. Why does knowing the images of a basis determine on every vector?
Reference answer: Let be a basis, so every has a unique expansion . By linearity (splitting a finite sum and pulling out scalars),
The coefficients come from the coordinates of and the are known, so is completely determined. This also explains why an transformation needs only numbers — each basis vector contributes output coordinates.
4. For the projection, what matrices arise in the eigenvector basis and in the standard basis, and why are they similar?
Reference answer: In the eigenvector basis , we have and , so the matrix is . In the standard basis the projection matrix is
They are similar because they are matrices of the same transformation in different bases, related by with the change-of-basis matrix. The similarity invariants agree: trace , determinant , eigenvalues and .
5. What is the null space of the derivative matrix , and what does it correspond to among polynomials?
Reference answer: Solve :
so , , and is free. The null space is of dimension . In polynomial space corresponds to the constant polynomial , whose derivative vanishes. The null space is therefore exactly the subspace of constant functions, matching the calculus fact that a function has zero derivative precisely when it is constant.
How this connects to the course
The previous lecture used SVD to diagonalize any matrix by choosing two orthonormal bases. This one returns to the more basic layer: transformations come before matrices, and matrices depend on bases. The remaining lectures build on this to discuss change of basis, image compression, and the course's overall synthesis.