线性代数的本质 · 精研复习站

第 04 集:矩阵乘法与线性变换复合

Matrix multiplication as composition
一句话直觉:两个矩阵相乘,本质上就是把两个线性变换先后复合作用在空间上(从右向左依次执行),乘积的各列直接记录基向量的最终落点。

本讲将矩阵乘法从“行乘列”的机械计算口诀彻底解放,揭示其作为线性变换复合(Composition)的几何真谛。通过追踪 $\hat{\imath}$ 与 $\hat{\jmath}$ 连续经历两次变换后的最终坐标,不仅能零死记推出一般 $2\times 2$ 矩阵乘法公式,更能直观秒懂“为何矩阵乘法不满足交换律($AB \neq BA$)”以及“为何结合律 $(AB)C = A(BC)$ 天经地义”。

▶ YouTube 原片 📺 B站官方双语 P5 🎙 B站中文配音 P5

前置依赖

← 第 03 集 · 矩阵与线性变换:必须先理解矩阵的列代表基向量落点,以及矩阵向量乘法代表施加一次线性变换

后续延伸

→ 第 04·附注 集 · 三维空间的线性变换:将矩阵乘法与变换复合直觉直接推广至三维空间的 3×3 矩阵
→ 第 05 集 · 行列式:利用复合变换直觉立刻看穿乘法法则 $\det(AB)=\det(A)\det(B)$
→ 第 09 集 · 基变换:通过三矩阵乘积 $P^{-1}AP$ 描述“在别人的坐标系下做变换”
旋转后剪切的复合矩阵
$$\begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix} \begin{bmatrix} 0 & -1 \\ 1 & 0 \end{bmatrix} = \begin{bmatrix} 1 & -1 \\ 1 & 0 \end{bmatrix}$$
一般 2×2 矩阵乘法的列追踪推导
$$\begin{bmatrix} a & b \\ c & d \end{bmatrix} \begin{bmatrix} e & f \\ g & h \end{bmatrix} = \begin{bmatrix} ae+bg & af+bh \\ ce+dg & cf+dh \end{bmatrix}$$
非交换性对比(先剪切再旋转 vs 先旋转再剪切)
$$\begin{bmatrix} 0 & -1 \\ 1 & 0 \end{bmatrix} \begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix} = \begin{bmatrix} 0 & -1 \\ 1 & 1 \end{bmatrix} \neq \begin{bmatrix} 1 & -1 \\ 1 & 0 \end{bmatrix} = \begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix} \begin{bmatrix} 0 & -1 \\ 1 & 0 \end{bmatrix}$$
矩阵乘法结合律
$$(AB)C = A(BC)$$

快速回顾:矩阵即线性变换与列向量语言

⏱ 00:11 – 02:01

在进入矩阵相乘之前,先快速巩固上一讲的核心地基:线性变换在视觉上就是保持网格线平行且等距分布、并保持原点固定的空间变形。在二维空间里,任意向量 $\begin{bmatrix}x\\y\end{bmatrix} = x$$\hat{\imath}$ $+ y$$\hat{\jmath}$,变换后必然落在 $x(\text{新 }\hat{\imath}) + y(\text{新 }\hat{\jmath})$。

📐 矩阵向量乘法的几何含义回顾
$$\begin{bmatrix} a & b \\ c & d \end{bmatrix} \begin{bmatrix} x \\ y \end{bmatrix} = x \begin{bmatrix} a \\ c \end{bmatrix} + y \begin{bmatrix} b \\ d \end{bmatrix}$$
习惯上将变换后 $\hat{\imath},\,\hat{\jmath}$ 的坐标记为矩阵的两列,并将这种按 $(x, y)$ 缩放列向量再求和的运算定义为矩阵向量乘法
  • 一个矩阵对应一个特定的线性变换。
  • 矩阵左乘向量 $\vec{v}$,在计算上就等价于把该变换施加到 $\vec{v}$ 上。
核心前提回顾:线性变换保持网格线平行且等距分布、原点固定 00:38
核心前提回顾:线性变换保持网格线平行且等距分布、原点固定画面重点:Grid lines remain parallel and evenly spaced 画面回顾
矩阵作用于向量:取向量的坐标分别缩放矩阵的第一、二列并相加 01:55
矩阵作用于向量:取向量的坐标分别缩放矩阵的第一、二列并相加画面重点:矩阵列坐标与网格上变换后向量的对应关系
[00:11] ↗
嘿 大家好! 上期视频结束前 我展示了线性变换长什么样,以及如何用矩阵描述它们
Hey everyone, where we last left off, I showed what linear transformations look like and how to represent them using matrices.
[00:18] ↗
这值得我们快速回顾一下,因为它们实在是很重要 当然,如果你觉得不是“回顾”这么简单,那就再回去看看上期视频吧
This is worth a quick recap because it's just really important, but of course if this feels like more than just a recap, go back and watch the full video.
[00:26] ↗
严格意义上说,线性变换是将向量作为输入和输出的一类函数 但是上期视频中,我说过可以将线性变换看作对空间的挤压伸展 它保持网格线平行且等距分布,并且保持原点不变
Technically speaking, linear transformations are functions with vectors as inputs and vectors as outputs, but I showed last time how we can think about them visually as smooshing around space in such a way that grid lines stay parallel and evenly spaced, and so that the origin remains fixed.
[00:42] ↗
关键的一点在于,线性变换由它对空间的基向量的作用完全决定 在二维空间中,基向量就是i帽和j帽
The key takeaway was that a linear transformation is completely determined by where it takes the basis vectors of the space, which for two dimensions means i-hat and j-hat.
[00:51] ↗
这是因为其他任意向量都能表示为基向量的线性组合
This is because any other vector could be described as a linear combination of those basis vectors.
[00:58] ↗
坐标为(x, y)的向量就是x乘以i帽加上y乘以j帽
A vector with coordinates x, y is x times i-hat plus y times j-hat.
[01:03] ↗
在线性变换之后 网格线保持平行且等距分布这一性质有个绝妙的推论
After going through the transformation, this property that grid lines remain parallel and evenly spaced has a wonderful consequence.
[01:10] ↗
向量(x, y)变换之后的结果,将是x乘以变换后的i帽,加上y乘以变换后的j帽
The place where your vector lands will be x times the transformed version of i-hat plus y times the transformed version of j-hat.
[01:18] ↗
这意味着只要记录下i帽和j帽变换后的位置 你就能计算出一个坐标为(x, y)的向量变换后的坐标 就是x乘以变换后i帽的坐标,加上y乘以变换后j帽的坐标
This means if you keep a record of the coordinates where i-hat lands and the coordinates where j-hat lands, you can compute that a vector which starts at x, y must land on x times the new coordinates of i-hat plus y times the new coordinates of j-hat.
[01:34] ↗
习惯上,我们将变换后i帽和j帽的坐标作为一个矩阵的列 并且将两列分别与x和y相乘后加和的结果定义为矩阵向量乘积
The convention is to record the coordinates of where i-hat and j-hat land as the columns of a matrix, and to define this sum of the scaled versions of those columns by x and y to be matrix-vector multiplication.
[01:46] ↗
这样,矩阵代表一个特定的线性变换 而矩阵与向量相乘 就是将线性变换作用于那个向量
In this way, a matrix represents a specific linear transformation, and multiplying a matrix by a vector is what it means computationally to apply that transformation to that vector.
[01:59] ↗
回顾结束!开始新的内容
Alright, recap over, on to the new stuff.

连续作用两个变换:复合变换与“从右向左”阅读顺序

⏱ 02:02 – 04:29

现实中我们常需要连续施加多个变换:比如先把平面逆时针旋转 $90^\circ$,接着再施加一次水平剪切(Shear)。从起点到终点的总体效果,本身也是一个全新的线性变换(既不同于单独的旋转,也不同于单独的剪切),数学上称之为前两个变换的复合变换(Composition)。

既然复合变换也是线性变换,它就能仅靠追踪 $\hat{\imath}$ 与 $\hat{\jmath}$ 的最终落点用一个独立矩阵表示:经“先旋转 $90^\circ$、后剪切”两步后,$\hat{\imath}$ 先到 $(0,1)$ 再被剪切带到 $(1,1)$;$\hat{\jmath}$ 先到 $(-1,0)$ 再保持不动于 $(-1,0)$。因此复合矩阵为 $\begin{bmatrix}1&-1\\1&0\end{bmatrix}$。

📐 矩阵乘法的定义起源:两次左乘 $\equiv$ 复合矩阵一次作用
$$\underbrace{\begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix}}_{\text{Shear}} \left( \underbrace{\begin{bmatrix} 0 & -1 \\ 1 & 0 \end{bmatrix}}_{\text{Rotation}} \begin{bmatrix} x \\ y \end{bmatrix} \right) = \underbrace{\begin{bmatrix} 1 & -1 \\ 1 & 0 \end{bmatrix}}_{\text{Composition}} \begin{bmatrix} x \\ y \end{bmatrix} \implies \begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix} \begin{bmatrix} 0 & -1 \\ 1 & 0 \end{bmatrix} = \begin{bmatrix} 1 & -1 \\ 1 & 0 \end{bmatrix}$$
无论选取什么向量 $\begin{bmatrix}x\\y\end{bmatrix}$,先左乘旋转矩阵、再左乘剪切矩阵的结果,恒等于直接左乘复合矩阵,故理应把复合矩阵定义为两矩阵之积
💡 为什么矩阵乘法要“从右向左”读?
两个矩阵相乘时,先施加右边矩阵代表的变换,再施加左边矩阵代表的变换。这一反直觉的顺序源于标准函数记号:因为我们把函数写在自变量左侧,复合两个函数必然写成 $f(g(\vec{v}))$——靠近向量 $\vec{v}$ 的 $g$ 必须先作用,外层的 $f$ 后作用(笑称“对希伯来语读者是好消息,对习惯从左向右阅读的人则是坏消息”)。
⚠️ 易错提醒:切勿按英语习惯从左向右读顺序!
看到乘积 $M_2 M_1$ 时,千万不要以为先做 $M_2$ 再做 $M_1$;正相反,最靠右(离列向量 $\vec{v}$ 最近)的 $M_1$ 最先作用,$M_2$ 随后作用。
复合案例起点:先将平面逆时针旋转 $90^\circ$,再施加水平剪切变换 02:15
复合案例起点:先将平面逆时针旋转 $90^\circ$,再施加水平剪切变换画面重点:First rotation then shear 标题与初始网格
追踪两步后的基向量最终坐标:$\hat{\imath}$ 最终落在 $(1, 1)$,记为复合矩阵第一列 02:42
追踪两步后的基向量最终坐标:$\hat{\imath}$ 最终落在 $(1, 1)$,记为复合矩阵第一列画面重点:Record where i-hat and j-hat land 记录第一列 [1, 1]
单一步骤的复合矩阵:$\begin{bmatrix}1&-1\\1&0\end{bmatrix}$ 将连续两步动作压缩为一次独立变换 03:00
单一步骤的复合矩阵:$\begin{bmatrix}1&-1\\1&0\end{bmatrix}$ 将连续两步动作压缩为一次独立变换画面重点:最终网格与复合矩阵 [1, -1; 1, 0]
建立乘积等式:$\text{Shear}\cdot(\text{Rotation}\cdot\vec{v})=\text{Composition}\cdot\vec{v}$ 03:38
建立乘积等式:$\text{Shear}\cdot(\text{Rotation}\cdot\vec{v})=\text{Composition}\cdot\vec{v}$画面重点:剪切矩阵、旋转矩阵与复合矩阵并列等式
从右向左读(Read right to left):由函数记号决定先作用右侧矩阵、再作用左侧矩阵 04:15
从右向左读(Read right to left):由函数记号决定先作用右侧矩阵、再作用左侧矩阵画面重点:矩阵乘积上方醒目的黄色从右向左箭头
[02:02] ↗
很多时候你发现你想描述这样一种作用:一个变换之后再进行另一个变换
Oftentimes, you find yourself wanting to describe the effects of applying one transformation and then another.
[02:08] ↗
比如说,你想描述 将整个平面逆时针旋转90度后,再进行一次剪切变换会发生什么
For example, maybe you want to describe what happens when you first rotate the plane 90 degrees counterclockwise, then apply a shear.
[02:15] ↗
从头到尾的总体作用是另一个线性变换 它与旋转和剪切明显不同
The overall effect here, from start to finish, is another linear transformation, distinct from the rotation and the shear.
[02:22] ↗
这个新的线性变换通常被称为前两个独立变换的“复合变换”
This new linear transformation is commonly called the composition of the two separate transformations we applied.
[02:29] ↗
和其他线性变换一样 我们也能通过追踪i帽和j帽,并用矩阵完全描述这个复合变换
And like any linear transformation, it can be described with a matrix all of its own by following i-hat and j-hat.
[02:36] ↗
在这个例子中,i帽在两个线性变换之后的最终落点是(1, 1) 我们将它作为矩阵的第一列
In this example, the ultimate landing spot for i-hat after both transformations is 1,1, so let's make that the first column of a matrix.
[02:45] ↗
类似地,j帽最终落在(-1, 0) 我们将它作为矩阵的第二列
Likewise, j-hat ultimately ends up at the location negative 1,0, so we make that the second column of the matrix.
[02:53] ↗
这一新的矩阵捕捉到了旋转然后剪切的总体效应 但它是一个单独的作用,而不是两个相继作用的合成
This new matrix captures the overall effect of applying a rotation then a shear, but as one single action, rather than two successive ones.
[03:03] ↗
这里有种方法来考虑这个新矩阵
Here's one way to think about that new matrix.
[03:05] ↗
如果你有一个向量,将它进行旋转然后剪切 一个麻烦的计算方法是: 首先将它左乘旋转矩阵 然后将得到的结果再左乘剪切矩阵
If you were to take some vector and pump it through the rotation, then the shear, the long way to compute where it ends up is to first multiply it on the left by the rotation matrix, then take whatever you get and multiply that on the left by the shear matrix.
[03:20] ↗
从数值角度看,这意味着对一个给定向量进行旋转然后剪切
This is, numerically speaking, what it means to apply a rotation then a shear to a given vector.
[03:27] ↗
但是无论所选向量是什么,结果都应该与复合变换作用的结果完全相同 因为新矩阵应当捕捉到了旋转然后剪切的相同总体效应
But whatever you get should be the same as just applying this new composition matrix that we just found by that same vector, no matter what vector you chose, since this new matrix is supposed to capture the same overall effect as the rotation then shear action.
[03:42] ↗
根据我们这里所写下的内容 我认为将这个新矩阵称为最初两个矩阵的积是合理的,不是吗?
Based on how things are written down here, I think it's reasonable to call this new matrix the product of the original two matrices, don't you?
[03:50] ↗
我们很快就能搞清楚如何在更普遍的情况下计算这个乘积 但是这样太容易迷失在数字丛林当中
We can think about how to compute that product more generally in just a moment, but it's way too easy to get lost in the forest of numbers.
[03:57] ↗
时刻记得 两个矩阵相乘有着几何意义,也就是两个线性变换相继作用
Always remember that multiplying two matrices like this has the geometric meaning of applying one transformation then another.
[04:06] ↗
这里有件奇怪的事,就是这个乘积需要从右向左读
One thing that's kind of weird here is that this has us reading from right to left.
[04:10] ↗
首先应用右侧矩阵所描述的变换 然后再应用左侧矩阵所描述的变换
You first apply the transformation represented by the matrix on the right, then you apply the transformation represented by the matrix on the left.
[04:17] ↗
它起源于函数的记号,因为我们将函数写在变量左侧 所以每次将两个函数复合时,你总是要从右向左读
This stems from function notation, since we write functions on the left of variables, so every time you compose two functions, you always have to read it right to left.
[04:26] ↗
对希伯来读者是好消息,对其他人则是坏消息
Good news for the Hebrew readers, bad news for the rest of us.

脱离动画纯数值计算:两步追踪算出 $M_2 M_1$

⏱ 04:30 – 05:55

不看几何动画,能否仅凭两个矩阵的数字直接算出乘积?完全可以!设先作用的矩阵 $M_1 = \begin{bmatrix}1 & -2 \\ 1 & 0\end{bmatrix}$,后作用的矩阵 $M_2 = \begin{bmatrix}0 & 2 \\ 1 & 0\end{bmatrix}$,我们来计算复合矩阵 $M_2 M_1$。

📐 纯数值实例:用矩阵向量乘法逐列求 $M_2 M_1$
$$M_2 M_1 = \begin{bmatrix} 0 & 2 \\ 1 & 0 \end{bmatrix} \begin{bmatrix} 1 & -2 \\ 1 & 0 \end{bmatrix} = \begin{bmatrix} 2 & 0 \\ 1 & -2 \end{bmatrix}$$
第 1 列(追踪 $\hat{\imath}$):$M_1$ 先送 $\hat{\imath}\to\begin{bmatrix}1\\1\end{bmatrix}$,再经 $M_2\begin{bmatrix}1\\1\end{bmatrix} = 1\begin{bmatrix}0\\1\end{bmatrix}+1\begin{bmatrix}2\\0\end{bmatrix}=\begin{bmatrix}2\\1\end{bmatrix}$;第 2 列(追踪 $\hat{\jmath}$):$M_1$ 先送 $\hat{\jmath}\to\begin{bmatrix}-2\\0\end{bmatrix}$,再经 $M_2\begin{bmatrix}-2\\0\end{bmatrix} = -2\begin{bmatrix}0\\1\end{bmatrix}+0\begin{bmatrix}2\\0\end{bmatrix}=\begin{bmatrix}0\\-2\end{bmatrix}$
  • 算乘积第 1 列:取出右侧矩阵 $M_1$ 的第 1 列($\hat{\imath}$ 的中间落点),左乘 $M_2$ 得到最终落点。
  • 算乘积第 2 列:取出右侧矩阵 $M_1$ 的第 2 列($\hat{\jmath}$ 的中间落点),左乘 $M_2$ 得到最终落点。
第一步变换 $M_1 = \begin{bmatrix}1&-2\\1&0\end{bmatrix}$ 所对应的空间变形效果 04:36
第一步变换 $M_1 = \begin{bmatrix}1&-2\\1&0\end{bmatrix}$ 所对应的空间变形效果画面重点:M1 矩阵及其变换后的网格
第二步变换 $M_2 = \begin{bmatrix}0&2\\1&0\end{bmatrix}$,准备将其左乘在 $M_1$ 左侧 04:45
第二步变换 $M_2 = \begin{bmatrix}0&2\\1&0\end{bmatrix}$,准备将其左乘在 $M_1$ 左侧画面重点:紫框 M2 与 M1 并列构成 M2*M1
逐列求乘积(第一步):用 $M_2$ 左乘 $M_1$ 第 1 列 $\begin{bmatrix}1\\1\end{bmatrix}$,得到复合矩阵第 1 列 $\begin{bmatrix}2\\1\end{bmatrix}$ 05:28
逐列求乘积(第一步):用 $M_2$ 左乘 $M_1$ 第 1 列 $\begin{bmatrix}1\\1\end{bmatrix}$,得到复合矩阵第 1 列 $\begin{bmatrix}2\\1\end{bmatrix}$画面重点:圈出 M1 第一列 [1,1] 并展开线性组合计算
逐列求乘积(第二步):用 $M_2$ 左乘 $M_1$ 第 2 列 $\begin{bmatrix}-2\\0\end{bmatrix}$,得第 2 列 $\begin{bmatrix}0\\-2\end{bmatrix}$,完成 $M_2M_1=\begin{bmatrix}2&0\\1&-2\end{bmatrix}$ 05:53
逐列求乘积(第二步):用 $M_2$ 左乘 $M_1$ 第 2 列 $\begin{bmatrix}-2\\0\end{bmatrix}$,得第 2 列 $\begin{bmatrix}0\\-2\end{bmatrix}$,完成 $M_2M_1=\begin{bmatrix}2&0\\1&-2\end{bmatrix}$画面重点:圈出 M1 第二列 [-2,0] 完成整块乘积矩阵
[04:30] ↗
我们再看一个例子
Let's look at another example.
[04:32] ↗
一个矩阵,两列为(1, 1)和(-2, 0) 它所代表的变换长这样
Take the matrix with columns 1,1 and negative 2,0, whose transformation looks like this.
[04:38] ↗
我们称它为M1
And let's call it M1.
[04:40] ↗
另一个矩阵,两列为(0, 1)和(2, 0) 它所代表的变换长这样
Next, take the matrix with columns 0,1 and 2,0, whose transformation looks like this.
[04:48] ↗
我们称它为M2
And let's call that guy M2.
[04:50] ↗
M1和M2先后作用,总体效果是一个新的变换,我们来求解它的矩阵
The total effect of applying M1 then M2 gives us a new transformation, so let's find its matrix.
[04:56] ↗
但是这一次,我们来尝试一下不通过观看动画 只使用每个矩阵的数值来求解
But this time, let's see if we can do it without watching the animations, and instead just using the numerical entries in each matrix.
[05:05] ↗
首先,我们得算出i帽的去向
First, we need to figure out where i-hat goes.
[05:08] ↗
在M1作用之后 按照定义,i帽的新坐标由M1的第一列给出,也就是(1, 1)
After applying M1, the new coordinates of i-hat, by definition, are given by that first column of M1, namely 1,1.
[05:17] ↗
要看看M2作用之后会发生什么,将矩阵M2乘以向量(1, 1)
To see what happens after applying M2, multiply the matrix for M2 by that vector 1,1.
[05:25] ↗
用上期视频中我讲述的方法计算出结果,你会得到向量(2, 1)
Working it out, the way I described last video, you'll get the vector 2,1.
[05:31] ↗
这就是复合矩阵的第一列
This will be the first column of the composition matrix.
[05:35] ↗
类似地,M1的第二列告诉我们j帽首先落在(-2, 0)
Likewise, to follow j-hat, the second column of M1 tells us that it first lands on negative 2,0.
[05:43] ↗
然后将M2作用于这个向量 你能根据矩阵向量乘法计算得到(0, -2) 这就是复合矩阵的第二列
Then, when we apply M2 to that vector, you can work out the matrix-vector product to get 0, negative 2, which becomes the second column of our composition matrix.

一般符号推导:看懂“行乘列”口诀的底层来源

⏱ 05:57 – 07:26

把上面那套追踪基向量落点的逻辑换成一般字母矩阵 $\begin{bmatrix}a&b\\c&d\end{bmatrix}\begin{bmatrix}e&f\\g&h\end{bmatrix}$,就能彻底看穿传统“行乘列求点积”口诀为何成立:

📐 一般 2×2 矩阵乘法的符号推演
$$\begin{bmatrix} a & b \\ c & d \end{bmatrix} \begin{bmatrix} e & f \\ g & h \end{bmatrix} = \begin{bmatrix} \begin{bmatrix}a&b\\c&d\end{bmatrix}\begin{bmatrix}e\\g\end{bmatrix} & \begin{bmatrix}a&b\\c&d\end{bmatrix}\begin{bmatrix}f\\h\end{bmatrix} \end{bmatrix} = \begin{bmatrix} e\begin{bmatrix}a\\c\end{bmatrix}+g\begin{bmatrix}b\\d\end{bmatrix} & f\begin{bmatrix}a\\c\end{bmatrix}+h\begin{bmatrix}b\\d\end{bmatrix} \end{bmatrix} = \begin{bmatrix} ae+bg & af+bh \\ ce+dg & cf+dh \end{bmatrix}$$
右侧矩阵第 1 列 $\begin{bmatrix}e\\g\end{bmatrix}$ 是 $\hat{\imath}$ 的中间落点,左乘左侧矩阵后得乘积第 1 列;第 2 列 $\begin{bmatrix}f\\h\end{bmatrix}$ 同理得乘积第 2 列
💡 先建直觉框架,再记“行乘列”速算套路
视频中展示了经典的“左行点乘右列”算术例题 $\begin{bmatrix}-3&1\\2&5\end{bmatrix}\begin{bmatrix}5&3\\7&-3\end{bmatrix}$。直接死背“行乘列”虽然算得快,但会让你迷失在符号丛林里;反过来,一旦先建立“右侧提供基向量中间落点、左侧施加二次变换”的概念框架,再去记速算算法就顺理成章,且能轻松驾驭各种矩阵代数性质。
一般推导第 1 列:左侧矩阵作用在右侧第 1 列 $\begin{bmatrix}e\\g\end{bmatrix}$ 上,得到 $\begin{bmatrix}ae+bg\\ce+dg\end{bmatrix}$ 06:36
一般推导第 1 列:左侧矩阵作用在右侧第 1 列 $\begin{bmatrix}e\\g\end{bmatrix}$ 上,得到 $\begin{bmatrix}ae+bg\\ce+dg\end{bmatrix}$画面重点:字母矩阵第一列推导过程
一般推导第 2 列:同理得到 $\begin{bmatrix}af+bh\\cf+dh\end{bmatrix}$,拼出完整 $2\times 2$ 乘积公式 07:05
一般推导第 2 列:同理得到 $\begin{bmatrix}af+bh\\cf+dh\end{bmatrix}$,拼出完整 $2\times 2$ 乘积公式画面重点:完整字母矩阵乘积公式展示
传统“行乘列”速算法示例:$\begin{bmatrix}-3&1\\2&5\end{bmatrix}\begin{bmatrix}5&3\\7&-3\end{bmatrix}$,几何理解应优先于套路记忆 07:14
传统“行乘列”速算法示例:$\begin{bmatrix}-3&1\\2&5\end{bmatrix}\begin{bmatrix}5&3\\7&-3\end{bmatrix}$,几何理解应优先于套路记忆画面重点:圈出左行右列做点积的算术演示
[05:57] ↗
我再重复一次同样的过程,不过这次我们用变量代替数值 只是为了说明这一推理过程对于任意矩阵都适用
Let me talk through that same process again, but this time I'll show variable entries in each matrix, just to show that the same line of reasoning works for any matrices.
[06:06] ↗
这种方法符号繁多,也需要更多空间 但是那些曾经通过书面计算学习矩阵乘法的人来说是非常满足的
This is more symbol-heavy and will require some more room, but it should be pretty satisfying for anyone who has previously been taught matrix multiplication the more rote way.
[06:14] ↗
要跟踪i帽的去向,首先找右侧矩阵的第一列 因为这是i帽首先到达的地方
To follow where i-hat goes, start by looking at the first column of the matrix on the right, since this is where i-hat initially lands.
[06:22] ↗
将这一列左乘左侧的矩阵 结果就是i帽在第二个变换作用后的结果
Multiplying that column by the matrix on the left is how you can tell where the intermediate version of i-hat ends up after applying the second transformation.
[06:32] ↗
所以复合矩阵的第一列 就是左侧矩阵与右侧矩阵第一列的乘积
So the first column of the composition matrix will always equal the left matrix times the first column of the right matrix.
[06:42] ↗
类似地,j帽首先落在右侧矩阵第二列所代表的位置上
Likewise, j-hat will always initially land on the second column of the right matrix.
[06:49] ↗
左侧矩阵与这一列相乘就能得到j帽的最终位置 因此这一乘积就是复合矩阵的第二列
So multiplying the left matrix by this second column will give its final location, and hence that's the second column of the composition matrix.
[07:01] ↗
注意,这里有不少符号,通常学生需要记住这个公式 并通过一些特定的运算加强记忆
Notice there's a lot of symbols here, and it's common to be taught this formula as something to memorize, along with a certain algorithmic process to help remember it.
[07:09] ↗
但是在记忆这个过程前 我认为你应该养成思考矩阵乘法意义的习惯 也就是两个变换相继作用
But I really do think that before memorizing that process, you should get in the habit of thinking about what matrix multiplication really represents, applying one transformation after another.
[07:20] ↗
相信我,这能给你一个更好的概念性框架 并让你更容易理解矩阵乘积的性质
Trust me, this will give you a much better conceptual framework that makes the properties of matrix multiplication much easier to understand.

乘法的两大性质:非交换性与结合律的降维证明

⏱ 07:27 – 09:52

性质一:矩阵相乘的顺序重要吗?($M_1 M_2 \stackrel{?}{=} M_2 M_1$)——用刚才的水平剪切(Shear)和逆时针旋转 $90^\circ$ 在脑海里演练一下,无需算任何矩阵乘法就能当场判断:

📐 顺序对比:先剪切后旋转 vs 先旋转后剪切
$$\underbrace{\begin{bmatrix} 0 & -1 \\ 1 & 0 \end{bmatrix}}_{\text{后旋转}}\underbrace{\begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix}}_{\text{先剪切}} = \begin{bmatrix} 0 & -1 \\ 1 & 1 \end{bmatrix} \quad \neq \quad \underbrace{\begin{bmatrix} 1 & 1 \\ 0 & 1 \end{bmatrix}}_{\text{后剪切}}\underbrace{\begin{bmatrix} 0 & -1 \\ 1 & 0 \end{bmatrix}}_{\text{先旋转}} = \begin{bmatrix} 1 & -1 \\ 1 & 0 \end{bmatrix}$$
先剪切再旋转:$\hat{\imath}\to(0,1)$、$\hat{\jmath}\to(-1,1)$,两向量夹角很近;先旋转再剪切:$\hat{\imath}\to(1,1)$、$\hat{\jmath}\to(-1,0)$,两向量朝向截然不同、张角更大
⚠️ 易错提醒:矩阵乘法一般不满足交换律($AB \neq BA$)
把变换的先后顺序颠倒,整个空间的最终形态往往完全不同!在代数推导或代码矩阵链中,绝不能像实数那样随便调换两个矩阵的左右位置。

性质二:矩阵乘法满足结合律吗?($(AB)C \stackrel{?}{=} A(BC)$)——回想传统教科书上用代数展开硬证结合律的噩梦:

📐 结合律对比:代数暴力展开 vs 变换复合直觉
$$(AB)C = A(BC) \iff \left(\begin{bmatrix}a&b\\c&d\end{bmatrix}\begin{bmatrix}e&f\\g&h\end{bmatrix}\right)\begin{bmatrix}i&j\\k&l\end{bmatrix} = \begin{bmatrix}a&b\\c&d\end{bmatrix}\left(\begin{bmatrix}e&f\\g&h\end{bmatrix}\begin{bmatrix}i&j\\k&l\end{bmatrix}\right)$$
若硬做代数展开,两边各有 4 个矩阵元、每元展开成 $(ae+bg)i+(af+bh)k$ 等 4 项三元乘积之和再重新配凑重组,繁琐至极且毫无启发;而几何复合视角下:$(AB)C$ 是“先做 $C$,再做 $B$、最后做 $A$”,$A(BC)$ 也是“先做 $C$、再做 $B$、最后做 $A$”——两者对空间执行的完全是同一串操作,不言自明!
💡 这不是偷懒,而是真真正正的严格证明
把 $(AB)C$ 与 $A(BC)$ 都理解成线性映射的相继复合,括号只是决定先把哪相邻两步合并打包成一个中间矩阵,而每个向量从右向左依次经历 $C \to B \to A$ 的映射顺序丝毫未变。这不仅是 100% 合法的证明,更解释了结合律为什么必须成立。
顺序 A(先剪切再旋转):$\hat{\imath}$ 落于 $(0,1)$,$\hat{\jmath}$ 落于 $(-1,1)$,两者靠得很近 07:51
顺序 A(先剪切再旋转):$\hat{\imath}$ 落于 $(0,1)$,$\hat{\jmath}$ 落于 $(-1,1)$,两者靠得很近画面重点:First shear then rotation 的网格与基向量落点
顺序 B(先旋转再剪切):$\hat{\imath}$ 落于 $(1,1)$,$\hat{\jmath}$ 落于 $(-1,0)$,两者指向明显拉开 08:04
顺序 B(先旋转再剪切):$\hat{\imath}$ 落于 $(1,1)$,$\hat{\jmath}$ 落于 $(-1,0)$,两者指向明显拉开画面重点:First rotation then shear 对比不同的最终形态
非交换性铁证:$M_1 M_2 \neq M_2 M_1$,空间变换顺序决定最终结果 08:10
非交换性铁证:$M_1 M_2 \neq M_2 M_1$,空间变换顺序决定最终结果画面重点:大字公式 M1M2 ≠ M2M1
结合律的直观证明:无论是 $(AB)C$ 还是 $A(BC)$,本质都是按 $C\to B\to A$ 顺序施加三次相同变换 09:10
结合律的直观证明:无论是 $(AB)C$ 还是 $A(BC)$,本质都是按 $C\to B\to A$ 顺序施加三次相同变换画面重点:A(BC) 动画演示空间依次经历三次变换
[07:27] ↗
比如说下面这个问题
For example, here's a question.
[07:29] ↗
矩阵相乘时,它们的先后顺序影响结果吗?
Does it matter what order we put the two matrices in when we multiply them?
[07:34] ↗
我们先来想一个简单的例子,比如之前提到的
Well, let's think through a simple example, like the one from earlier.
[07:38] ↗
一个是剪切,它保持i帽不变,将j帽挤到右边 一个是90度旋转
Take a shear, which fixes i-hat and smooshes j-hat over to the right, and a 90 degree rotation.
[07:44] ↗
如果你首先剪切,然后旋转 你会发现i帽落在(0, 1),j帽落在(-1, 1)
If you first do the shear, then rotate, we can see that i-hat ends up at 0,1 and j-hat ends up at negative 1,1.
[07:51] ↗
它们彼此靠得很近
Both are generally pointing close together.
[07:54] ↗
如果你首先旋转,然后剪切 i帽落在(1, 1),而j帽落在一个不同的方向(-1, 0) 它们的指向分隔很远
If you first rotate, then do the shear, i-hat ends up over at 1,1, and j-hat is off in a different direction at negative 1,0, and they're pointing, you know, farther apart.
[08:06] ↗
二者总体效应明显不同,所以乘积顺序显然会有影响
The overall effect here is clearly different, so evidently, order totally does matter.
[08:12] ↗
注意,我们用在变换来思考 这一过程可以在脑中形象地进行
Notice, by thinking in terms of transformations, that's the kind of thing that you can do in your head by visualizing.
[08:18] ↗
完全不需要做矩阵乘法
No matrix multiplication necessary.
[08:21] ↗
我记得我首次学习线性代数时,有一道作业题是 让我们证明矩阵乘法具有结合性
I remember when I first took linear algebra, there was this one homework problem that asked us to prove that matrix multiplication is associative.
[08:30] ↗
这是在说,如果你有三个矩阵A B C,然后将它们相乘 无论是首先计算A乘以B,然后将结果乘以C 还是先算B乘以C,然后将结果左乘A,二者结果应该相同
This means that if you have three matrices, A, B, and C, and you multiply them all together, it shouldn't matter if you first compute A times B, then multiply the result by C, or if you first multiply B times C, then multiply that result by A on the left.
[08:45] ↗
换句话讲,添加括号与结果无关
In other words, it doesn't matter where you put the parentheses.
[08:48] ↗
现在如果你尝试用数值方法证明,就像我当时所做的 这个过程会非常糟糕,而且对你毫无启发
Now, if you try to work through this numerically, like I did back then, it's horrible, just horrible, and unenlightening for that matter.
[08:56] ↗
但是如果你用变换相继作用的思想去考虑矩阵乘积 这一性质就变得很平凡了
But when you think about matrix multiplication as applying one transformation after another, this property is just trivial.
[09:03] ↗
你能看出为什么吗?
Can you see why?
[09:05] ↗
这是在说,首先应用C变换和B变换,然后应用A变换 与先应用C变换,然后应用B变换和A变换的结果相同
What it's saying is that if you first apply C, then B, then A, it's the same as applying C, then B, then A.
[09:13] ↗
完全没有需要证明的东西
I mean, there's nothing to prove.
[09:15] ↗
你只是将同样的三个变换用同样的顺序依次作用而已
You're just applying the same three things one after the other, all in the same order.
[09:19] ↗
可能这看起来是在耍花招,但并不是
This might feel like cheating, but it's not.
[09:22] ↗
这是证明矩阵乘法具有结合性的一个实实在在的证明 它甚至很好地解释了为什么这个性质应该是正确的
This is an honest-to-goodness proof that matrix multiplication is associative, and even better than that, it's a good explanation for why that property should be true.
[09:32] ↗
我真的鼓励你在这种想法上多做尝试 想象两个不同的变换 思考他们依次作用后会发生什么 最后用数值方法计算出矩阵乘积
I really do encourage you to play around more with this idea, imagining two different transformations, thinking about what happens when you apply one after the other, and then working out the matrix product numerically.
[09:43] ↗
相信我,这段时间能让你完全理解这一想法
Trust me, this is the kind of playtime that really makes the idea sink in.
[09:47] ↗
下期视频中,我会将二维空间中的这些想法拓展至三维空间中 到时候再见!
In the next video, I'll start talking about extending these ideas beyond just two dimensions. See you then!

📝 几何直觉自测(点击题目展开解答)

Q1. 为什么矩阵乘积 $AB$ 作用在向量 $\vec{v}$ 上时,必须“从右向左”依次施加变换(先 $B$ 后 $A$)?▼
因为我们将矩阵写在输入向量的左侧,继承了数学中的函数记号风格:$(AB)\vec{v} = A(B\vec{v})$。离向量 $\vec{v}$ 更近的右侧矩阵 $B$ 先对 $\vec{v}$ 作用,再将结果交由外侧(左侧)矩阵 $A$ 处理。
Q2. 若不看动画,计算乘积 $\begin{bmatrix}0&2\\1&0\end{bmatrix}\begin{bmatrix}1&-2\\1&0\end{bmatrix}$ 的第一列和第二列各自在算什么几何量?结果是多少?▼
第一列计算的是 $\hat{\imath}$ 先被右侧矩阵送到 $\begin{bmatrix}1\\1\end{bmatrix}$ 后,再经左侧矩阵作用的结果 $\begin{bmatrix}0&2\\1&0\end{bmatrix}\begin{bmatrix}1\\1\end{bmatrix}=\begin{bmatrix}2\\1\end{bmatrix}$;第二列计算的是 $\hat{\jmath}$ 先到 $\begin{bmatrix}-2\\0\end{bmatrix}$ 后再经左侧矩阵作用的结果 $\begin{bmatrix}0\\-2\end{bmatrix}$。故乘积为 $\begin{bmatrix}2&0\\1&-2\end{bmatrix}$。
Q3. 请用变换复合的几何直觉分别解释:为什么 $AB \neq BA$,却恒有 $(AB)C = A(BC)$?▼
1) $AB \neq BA$:先剪切再旋转和先旋转再剪切对空间作用步骤颠倒,基向量最终落点不同(例如前者得 $\begin{bmatrix}0&-1\\1&1\end{bmatrix}$,后者得 $\begin{bmatrix}1&-1\\1&0\end{bmatrix}$)。2) $(AB)C = A(BC)$:两式都表示对空间依次施加“先 $C$、再 $B$、最后 $A$”这串相同顺序的变换,括号只是人为决定先合并哪两步,不改变空间变换的次序与终态。