本节是Gilbert Strang的MIT线性代数Linear Algebra公开课中【第三讲 矩阵乘法和逆矩阵(lecture 3 Multiplication and Inverse Matrices)】的笔记,参考他在 MIT Linear Algebra课程网站上公开分享的 lecture summary (PDF) & Lecture video transcript (PDF)等文档,整理笔记如下,笔记中的大部分内容是从 MIT Linear Algebra课程网站上的资料中直接粘贴过来的,本人只是将该课程视频中讲述的内容整理为文字形式,前面的章节可在本人的其他博客中找到(此处戳第一讲,第二讲,后面的章节会按照视频顺序不断更新~
文章目录
lecture 3 Multiplication and Inverse Matrices
Matrix Multiplication(4 ways)
1. Standard (row times column) 单个元素求法
若矩阵乘积为 A B = C AB=C AB=C,其中 A : m × n , B : n × p , C : m × p A:m×n, B:n×p, C:m×p A:m×n,B:n×p,C:m×p。
在
C
C
C的第
i
i
i行第
j
j
j列处的元素 记为
c
i
j
c_{ij}
cij,如求C的第三行第四列元素
c
34
c_{34}
c34 :
c
34
=
(
row3 of
A
)
∗
(
column4 of
B
)
=
a
31
b
14
+
a
32
b
24
+
⋯
=
∑
k
=
1
n
a
3
k
b
k
4
\begin{aligned} c_{34}&=(\text{row3 of} \; A)*(\text{column4 of} \; B)\\ &=a_{31}b_{14}+a_{32}b_{24}+\cdots \\ &=\sum_{k=1}^{n} a_{3k}b_{k4} \end{aligned}
c34=(row3 ofA)∗(column4 ofB)=a31b14+a32b24+⋯=k=1∑na3kbk4
2.Columns
矩阵 A A A 乘以矩阵 B B B的第 p p p列等于矩阵 C C C的第 p p p列,由于矩阵乘以列向量相当于矩阵各列的线性组合,对应的组合系数为该列向量的各元素值,因此,the columns of C C C are combinations of columns of A A A.
3.Rows
矩阵 A A A 的第 i i i 行乘以矩阵 B B B 等于矩阵 C C C 的第 i i i 行. So the rows of C C C are combinations of rows of B B B.
4.Column times row
A column of A A A is an m × 1 m×1 m×1 vector and a row of B B B is a 1 × p 1×p 1×p vector, and their product is a matrix.
Example 1:
[
2
3
4
]
[
1
6
]
=
[
2
12
3
18
4
24
]
\left[\begin{array}{l} {2} \\ {3} \\ {4} \end{array}\right]\left[\begin{array}{ll} {1} & {6} \end{array}\right]=\left[\begin{array}{ll} {2} & {12} \\ {3} & {18} \\ {4} & {24} \end{array}\right]
⎣⎡234⎦⎤[16]=⎣⎡234121824⎦⎤
结果矩阵的各列是左面
[
2
3
4
]
\left[\begin{array}{l}{2} \\{3} \\{4}\end{array}\right]
⎣⎡234⎦⎤的倍数,这是因为等式右边矩阵是等式左边矩阵
[
2
3
4
]
\left[\begin{array}{l}{2} \\{3} \\{4}\end{array}\right]
⎣⎡234⎦⎤各列的线性组合,由于只有一列,因此是倍数(如果画出各列,他们都是同一方向);结果矩阵的各行都是左面
[
1
6
]
\left[\begin{array}{ll}{1} & {6}\end{array}\right]
[16]的倍数(如果画出各行,他们都是同一方向),延续这种思想得到矩阵相乘的第四种方法:
A
B
=
sum of
{
(
cols of
A
)
×
(
rows of
B
)
}
AB=\text{sum of}\; \{(\text{cols of} \; A) × (\text{rows of} \; B)\}
AB=sum of{(cols ofA)×(rows ofB)}
即
A
B
=
∑
k
=
1
n
[
a
1
k
⋮
a
m
k
]
[
b
k
1
⋯
b
k
n
]
A B=\sum_{k=1}^{n}\left[\begin{array}{c} {a_{1 k}} \\ {\vdots} \\ {a_{m k}} \end{array}\right]\left[\begin{array}{lll} {b_{k 1}} & {\cdots} & {b_{k n}} \end{array}\right]
AB=k=1∑n⎣⎢⎡a1k⋮amk⎦⎥⎤[bk1⋯bkn]
Example 2:
[
2
7
3
8
4
9
]
[
1
6
0
0
]
=
[
2
3
4
]
[
1
6
]
+
[
7
8
9
]
[
0
0
]
\left[ \begin{matrix} 2& 7\\ 3& 8\\ 4& 9 \end{matrix} \right ] \left[ \begin{matrix} 1 & 6\\ 0 & 0\\ \end{matrix} \right ] =\left[ \begin{matrix} 2\\ 3\\ 4 \end{matrix} \right] \left[ \begin{matrix} 1 & 6\\ \end{matrix} \right] + \left[ \begin{matrix} 7\\ 8\\ 9 \end{matrix} \right] \left[ \begin{matrix} 0 & 0\\ \end{matrix} \right]
⎣⎡234789⎦⎤[1060]=⎣⎡234⎦⎤[16]+⎣⎡789⎦⎤[00]
行空间:矩阵的行的所有线性组合(Example 1中结果矩阵的行空间是向量
[
1
6
]
\left[\begin{array}{ll}{1} & {6}\end{array}\right]
[16]上的直线)
列空间同理。
5.Blocks Multiplication
If we subdivide
A
A
A and
B
B
B into blocks that match properly, we can write the product
A
B
=
C
AB = C
AB=C in terms of products of the blocks:
[
A
1
A
2
A
3
A
4
]
[
B
1
B
2
B
3
B
4
]
=
[
C
1
C
2
C
3
C
4
]
\left[\begin{array}{ll} {A_{1}} & {A_{2}} \\ {A_{3}} & {A_{4}} \end{array}\right]\left[\begin{array}{ll} {B_{1}} & {B_{2}} \\ {B_{3}} & {B_{4}} \end{array}\right]=\left[\begin{array}{ll} {C_{1}} & {C_{2}} \\ {C_{3}} & {C_{4}} \end{array}\right]
[A1A3A2A4][B1B3B2B4]=[C1C3C2C4]
Here
C
1
=
A
1
B
1
+
A
2
B
3
C_{1}=A_{1} B_{1}+A_{2} B_{3}
C1=A1B1+A2B3.
Inverses(Square matrices方阵)
1.Nonsingular or Invertible
If A is a square matrix, the most important question you can ask about it is whether it has an inverse A − 1 A^{-1} A−1, If it does, then A − 1 A = I = A A − 1 A^{-1} A=I=A A^{-1} A−1A=I=AA−1 and we say that A A A is invertible or nonsingular.
对于方阵来说,左逆矩阵等于右逆矩阵(在 A A A左边的是左逆矩阵,在 A A A右边的是右逆矩阵),即如果方阵左乘某矩阵等到单位阵,那么把它放到方阵的右边相乘,结果同样是单位阵;但是,如果是非方阵,左逆不等于右逆,因为形状不同无法相乘。
Example 3:求A的逆矩阵
[
1
3
2
7
]
[
a
c
b
d
]
=
[
1
0
0
1
]
\left[\begin{array}{ll}{1} & {3} \\{2} & {7}\end{array}\right] \quad\left[\begin{array}{ll}{a} & {c} \\{b} & {d}\end{array}\right]=\left[\begin{array}{ll}{1} & {0} \\{0} & {1}\end{array}\right]
[1237][abcd]=[1001]
A
A
A
A
−
1
A^{-1}
A−1
I
I
I
Finding the inverse of a matrix is closely related to solving systems of linear equations:
A
A
A times column
j
j
j of
A
−
1
A^{−1}
A−1 equals column
j
j
j of the identity matrix。这些方程具有相同的系数矩阵
A
A
A,但是右侧向量是单位阵的不同列,即
[
1
3
2
7
]
[
a
b
]
=
[
1
0
]
[
1
3
2
7
]
[
c
d
]
=
[
0
1
]
\left[\begin{array}{ll} {1} & {3} \\ {2} & {7} \end{array}\right]\left[\begin{array}{r} {a} \\ {b} \end{array}\right]=\left[\begin{array}{l} {1} \\ {0} \end{array}\right]\\ \left[\begin{array}{ll} {1} & {3} \\ {2} & {7} \end{array}\right]\left[\begin{array}{r} {c} \\ {d} \end{array}\right]=\left[\begin{array}{l} {0} \\ {1} \end{array}\right]
[1237][ab]=[10][1237][cd]=[01]
This is just a special form of the equation A x = b Ax = b Ax=b,此问题可以用Gauss-Jordan Elimination法来解。(可直接看后面的Gauss-Jordan Elimination部分,该方法以本问题为例进行讲解)
2.Singular case: No inverse
Example 4:
A
=
[
1
3
2
6
]
A= \left[\begin{array}{ll} {1} & {3} \\ {2} & {6} \end{array}\right]
A=[1236] 该矩阵没有逆矩阵,因为:
解释一:它的行列式为0;
解释二:假设矩阵 A A A乘以某矩阵得到单位阵,是否有可能? 若考虑列,矩阵 A A A与某矩阵相乘,结果中的列都来自于 A A A的列,而单位阵的第一列是 [ 1 0 ] \left[\begin{array}{l} {1} \\{0} \end{array}\right] [10],不可能是 A A A中各列的组合,因为 A A A的两列共线,所有线性组合均在此直线上,而 [ 1 0 ] \left[\begin{array}{l} {1} \\{0} \end{array}\right] [10] 不在此直线上。
解释三: If no inverse, you can find a vector
x
(
x
≠
0
)
x \; (x \not= 0)
x(x=0) with
A
x
=
0
A \mathbf{x}=0
Ax=0. (即其列能通过线性组合得到0)
[
1
3
2
6
]
[
3
−
1
]
=
[
0
0
]
\left[\begin{array}{ll} {1} & {3} \\ {2} & {6} \end{array}\right]\left[\begin{array}{r} {3} \\ {-1} \end{array}\right]=\left[\begin{array}{l} {0} \\ {0} \end{array}\right]
[1236][3−1]=[00] 假设本例中的矩阵
A
A
A存在逆矩阵,则用逆矩阵乘以这个方程,即
A
−
1
A
x
=
0
A^{-1}A \mathbf{x}=0
A−1Ax=0 , 则结论是
x
=
0
x=0
x=0 ,但是
x
≠
0
x \not= 0
x=0 ,因此假设不成立,因此矩阵
A
A
A不可逆。
如果矩阵的其中一列对线性组合毫无贡献,矩阵不可能有逆。
Gauss-Jordan Elimination
Gauss-Jordan Elimination can solve two or more linear equations at the same time.
Gauss-Jordan消元法过程
以Example 3:求A的逆矩阵为例,在Example 3中所需求解的两个方程组如下:
[
1
3
2
7
]
[
a
b
]
=
[
1
0
]
[
1
3
2
7
]
[
c
d
]
=
[
0
1
]
\left[\begin{array}{ll} {1} & {3} \\ {2} & {7} \end{array}\right]\left[\begin{array}{r} {a} \\ {b} \end{array}\right]=\left[\begin{array}{l} {1} \\ {0} \end{array}\right]\\ \left[\begin{array}{ll} {1} & {3} \\ {2} & {7} \end{array}\right]\left[\begin{array}{r} {c} \\ {d} \end{array}\right]=\left[\begin{array}{l} {0} \\ {1} \end{array}\right]
[1237][ab]=[10][1237][cd]=[01] 将两个方程组一起求解,即将系数矩阵与右侧向量(单位阵)放在一起,即构成增广阵,然后进行消元,通过消元,将左侧的系数矩阵变为单位阵,而原来的单位阵处(右侧向量)则变成了逆矩阵,具体步骤如下:
[
1
3
1
0
2
7
0
1
]
⟶
[
1
3
1
0
0
1
−
2
1
]
⟶
[
1
0
7
−
3
0
1
−
2
1
]
\left[\begin{array}{ll|ll} {1} & {3} & {1} & {0} \\ {2} & {7} & {0} & {1} \end{array}\right] \longrightarrow\left[\begin{array}{rr|rr} {1} & {3} & {1} & {0} \\ {0} & {1} & {-2} & {1} \end{array}\right] \longrightarrow\left[\begin{array}{rr|rr} {1} & {0} & {7} & {-3} \\ {0} & {1} & {-2} & {1} \end{array}\right]
[12371001]⟶[10311−201]⟶[10017−2−31]
A
A
A
I
I
I
I
I
I
A
−
1
A^{-1}
A−1
故
A
−
1
=
[
7
−
3
−
2
1
]
A^{-1}=\left[\begin{array}{rr} {7} & {-3} \\ {-2} & {1} \end{array}\right]
A−1=[7−2−31] 注意:利用Gauss消元法时,只需消元为上三角矩阵即可,即做完上面第一步得到
[
1
3
1
0
0
1
−
2
1
]
\left[\begin{array}{rr|rr}{1} & {3} & {1} & {0} \\ {0} & {1} & {-2} & {1}\end{array}\right]
[10311−201] 即可;但是如果利用Gauss-Jordan Elimination法,需要再进行一步,使得左半部分变为单位阵,即得到
[
1
0
7
−
3
0
1
−
2
1
]
\left[\begin{array}{rr|rr}{1} & {0} & {7} & {-3} \\ {0} & {1} & {-2} & {1}\end{array}\right]
[10017−2−31] 才结束。
解释Gauss-Jordan Elimination法的变化:
增广矩阵的消元过程相当于在增广矩阵左侧乘以一串消元矩阵,即消元法的矩阵形式;若将所有消元过程考虑到一起,即将消元矩阵全部乘在一起,综合考虑为
E
E
E,则上述消元过程可以表示为:
E
[
A
∣
I
]
=
[
I
∣
E
]
E[A | I]=[I | E]
E[A∣I]=[I∣E] 由左半部分知:
E
A
=
I
EA=I
EA=I,则
E
=
A
−
1
E=A^{-1}
E=A−1,因此
E
[
A
∣
I
]
=
[
I
∣
A
−
1
]
E[A | I]=[I | A^{-1}]
E[A∣I]=[I∣A−1]成立。
故,若要求某方阵的逆矩阵,只需在其右侧插入单位阵,然后进行Gauss-Jordan Elimination即可,最终,原单位阵变为所求的逆矩阵。