Introduction to Linear Algebra, Chapter-2, Solving Linear Equations, Key Notes
本人在阅读MIT数学教授Gilbert Strang所著线性代数教材"Introduction to Linear Algebra(Fifth Edition)"过程中敲下的笔记
我是用的教学视频是BV1uK4y187ep
课后习题答案及其它相关资料可参照math.mit.edu/linearalgebra
2.1 Vectors and Linear Equations
从两种角度看待线性方程组
A x → = b → , 假设A是3 by 3的矩阵 A \overrightarrow{x} = \overrightarrow{b}, \text{假设A是3 by 3的矩阵} Ax=b,假设A是3 by 3的矩阵
-
从行的角度看待(row picture): A x → = b → A \overrightarrow{x} = \overrightarrow{b} Ax=b表示在三维空间中有三个平面交于一点(A的一行定义一个平面)
-
从列的角度看待(column picture): A x → = b → A \overrightarrow{x} = \overrightarrow{b} Ax=b表示要寻找一个关于 A A A的列的线性组合来表示出 b → \overrightarrow{b} b
两种方法计算 A x → A\overrightarrow{x} Ax
- A A A的每一行与 x → \overrightarrow{x} x的点积(dot product)
- A A A的列的线性组合
其它
For m m m by n n n matrices, A x → = 0 → A \overrightarrow{x} = \overrightarrow{0} Ax=0 may have many solutions, those solutions will go into a vector space, the rank of A A A leads to the dimension of that vector space.
2.2 The Idea of Elimination
这章基本就一句重点:forward elimination and back substitution.
elimination在遇到为0的pivot的时候有可能会失败,如果能通过行交换找到非0的pivot,则消元可以继续,如果找不到非0的pivot,则遇到了permanent breakdown,这时候方程组没有解或者有无数解。
2.3 Elimination Using Matrices
从行和列两个角度看待矩阵与向量相乘(再次强调)
A
x
→
A \overrightarrow{x}
Ax is a combination of the columns of
A
A
A;
Components of
A
x
→
A \overrightarrow{x}
Ax are the dot products with rows of
A
A
A;
Elimination Matrix(消元矩阵)
start with the identity matrix
I
I
I, change one of its zeros to the multiplier
−
l
-l
−l;
for a elimination matrix
E
i
j
E_{ij}
Eij, it has nonzero entry
−
l
-l
−l in the
(
i
,
j
)
(i, j)
(i,j) position, so
E
i
j
A
E_{ij}A
EijA will subtract
l
l
l times of row
j
j
j from row
i
i
i.
交换律和结合律
矩阵乘法满足结合律(associative law),即
A
(
B
C
)
=
(
A
B
)
C
A(BC)=(AB)C
A(BC)=(AB)C
矩阵乘法不满足交换律(commutative law),即
Often
A
B
≠
B
A
\text{Often } AB \neq BA
Often AB=BA
矩阵相乘(列视角)
Matrix Multiplication: A B = A [ b 1 → b 2 → b 3 → ] = [ A b 1 → A b 2 → A b 3 → ] \text{Matrix Multiplication: } AB = A[\overrightarrow{b_1} \; \overrightarrow{b_2} \; \overrightarrow{b_3}] = [A\overrightarrow{b_1} \; A\overrightarrow{b_2} \; A\overrightarrow{b_3}] Matrix Multiplication: AB=A[b1b2b3]=[Ab1Ab2Ab3]
The beauty of matrix multiplication is that all three approaches(rows, columns, whole matrices) come out right(其他视角后续小节讲解)
Permutation Matrix(置换矩阵)
Row Exchange Matrix: P i j P_{ij} Pij is the identity matrix with rows i i i and j j j reversed. When this “permutation matrix” P i j P_{ij} Pij multiplies a matrix, it exchanges rows i i i and j j j.
Argumented Matrix(增广矩阵)
We can include b → \overrightarrow{b} b as an extra column of A A A and follow it through elimination.
Argumented Matrix: [ A b → ] \text{Argumented Matrix: } [A \; \overrightarrow{b}] Argumented Matrix: [Ab]
Matrix multiplication works by rows and at the same time by columns:
ROWS: each row of
E
E
E acts on
[
A
b
→
]
[A \; \overrightarrow{b}]
[Ab] to give a row of
[
E
A
E
b
→
]
[EA \; E\overrightarrow{b}]
[EAEb];
COLUMNS:
E
E
E acts on each column of
[
A
b
→
]
[A \; \overrightarrow{b}]
[Ab] to give a column of
[
E
A
E
b
→
]
[EA \; E\overrightarrow{b}]
[EAEb];
2.4 Rules for Matrix Operations
看待矩阵乘法的第一种视角:每一个元素都是一个向量内积
The entry in row i column j of A B is (row i of A ) ⋅ (column j of B ) \text{The entry in row } i \text{ column } j \text{ of } AB \text{ is (row } i \text{ of } A) \cdot \text{(column } j \text{ of }B) The entry in row i column j of AB is (row i of A)⋅(column j of B)
看待矩阵乘法的第二种视角:Each column of AB is a combination of the columns of A
matrix A times every column of matrix B: A [ b 1 → b 2 → ⋯ b p → ] = [ A b 1 → A b 2 → ⋯ A b p → ] \text{matrix A times every column of matrix B: } A[\overrightarrow{b_1} \; \overrightarrow{b_2} \; \cdots \; \overrightarrow{b_p}] = [A\overrightarrow{b_1} \; A\overrightarrow{b_2} \; \cdots \; A\overrightarrow{b_p}] matrix A times every column of matrix B: A[b1b2⋯bp]=[Ab1Ab2⋯Abp]
看待矩阵乘法的第三种视角:Each row of AB is a combination of the rows of B
every row of A times matrix B: [ a 1 → a 2 → ⋯ a m → ] B = [ a 1 → B a 2 → B ⋯ a m → B ] \text{every row of A times matrix B: } \begin{bmatrix} \overrightarrow{a_1} \\ \overrightarrow{a_2} \\ \cdots \\ \overrightarrow{a_m} \end{bmatrix} B = \begin{bmatrix} \overrightarrow{a_1} B \\ \overrightarrow{a_2} B \\ \cdots \\ \overrightarrow{a_m} B \end{bmatrix} every row of A times matrix B: ⎣⎢⎢⎡a1a2⋯am⎦⎥⎥⎤B=⎣⎢⎢⎡a1Ba2B⋯amB⎦⎥⎥⎤
看待矩阵乘法的第四种视角:columns of A multiply rows of B
[ c o l 1 c o l 2 ⋯ c o l n ] × [ r o w 1 r o w 2 ⋯ r o w n ] = c o l 1 × r o w 1 + c o l 2 × r o w 2 + ⋯ + c o l n × r o w n \begin{bmatrix} col_1 \; col_2 \cdots \; col_n \end{bmatrix} \times \begin{bmatrix} row_1 \\ row_2 \\ \cdots \\ row_n \end{bmatrix} = col_1 \times row_1 + col_2 \times row_2 + \cdots + col_n \times row_n [col1col2⋯coln]×⎣⎢⎢⎡row1row2⋯rown⎦⎥⎥⎤=col1×row1+col2×row2+⋯+coln×rown
向量的内积和外积(inner product, outer product)
a row times a column is an inner product, or dot product(produce a single number), while a column times a row is an outer product(produce a matrix).
Laws for Matrix Operations
-
矩阵加法满足交换律(commutative law): A + B = B + A A + B = B + A A+B=B+A
-
矩阵加法满足分配律(distributive law): c ( A + B ) = c A + c B c(A+B)=cA+cB c(A+B)=cA+cB
-
矩阵加法满足结合律(associative law): A + ( B + C ) = ( A + B ) + C A+(B+C)=(A+B)+C A+(B+C)=(A+B)+C
-
矩阵乘法不满足交换律(the commutative law is usually broken): A B ≠ B A AB \neq BA AB=BA
-
矩阵乘法满足左分配律(distributive law from left): A ( B + C ) = A B + A C A(B+C)=AB+AC A(B+C)=AB+AC
-
矩阵乘法满足右分配律(distributive law from right): ( A + B ) C = A C + B C (A+B)C=AC+BC (A+B)C=AC+BC
-
矩阵乘法满足结合律(associative law): A ( B C ) = ( A B ) C A(BC)=(AB)C A(BC)=(AB)C
Matrix Power
( A p ) ( A q ) = A p + q , ( A p ) q = A p q (A^p)(A^q) = A^{p+q} \; , \; (A^p)^q = A^{pq} (Ap)(Aq)=Ap+q,(Ap)q=Apq
矩阵分块及分块相乘
if blocks of A can multiply blocks of B, then block multiplication of AB is allowed. Cuts between columns of A match cuts of rows of B.
[ A 11 A 12 A 21 A 22 ] [ B 11 B 21 ] = [ A 11 B 11 + A 12 B 21 A 21 B 11 + A 22 B 21 ] \begin{bmatrix} A_{11} \; A_{12} \\ A_{21} \; A_{22} \end{bmatrix} \begin{bmatrix} B_{11} \\ B_{21} \end{bmatrix} = \begin{bmatrix} A_{11} B_{11} + A_{12} B_{21} \\ A_{21} B_{11} + A_{22} B_{21} \end{bmatrix} [A11A12A21A22][B11B21]=[A11B11+A12B21A21B11+A22B21]
Block Elimination
[ I 0 → − C A − 1 I ] [ A B C D ] = [ A B 0 → D − C A − 1 B ] \begin{bmatrix} I & \overrightarrow{0} \\ -CA^{-1} & I \end{bmatrix} \begin{bmatrix} A & B \\ C & D \end{bmatrix} = \begin{bmatrix} A & B \\ \overrightarrow{0} & D - CA^{-1}B \end{bmatrix} [I−CA−10I][ACBD]=[A0BD−CA−1B]
the entry “ D − C A − 1 B D - CA^{-1}B D−CA−1B” is called Schur complement, 舒尔补
2.5 Inverse Matrices
Six Notes About A − 1 A^{-1} A−1
- the inverse exists if and onlt if the elimination produces n nonzero pivots(row exchange is allowed).
- the matrix A cannot have two different inverses.
- if A is invertible, the only solution to A x → = b → A\overrightarrow{x} = \overrightarrow{b} Ax=b is x → = A − 1 b → \overrightarrow{x} = A^{-1}\overrightarrow{b} x=A−1b
- if there exists a nonzero vector x → \overrightarrow{x} x such that A x → = 0 → A\overrightarrow{x} = \overrightarrow{0} Ax=0, A is not invertible.
- for a
2
×
2
2 \times 2
2×2 matrix, if is invertible onlt if
a
d
−
b
c
≠
0
ad - bc \neq 0
ad−bc=0
[ a b c d ] − 1 = 1 a d − b c [ d − b − c a ] \begin{bmatrix} a & b \\ c & d \end{bmatrix} ^ {-1} = \frac{1}{ad - bc} \begin{bmatrix} d & -b \\ -c & a \end{bmatrix} [acbd]−1=ad−bc1[d−c−ba] - a diagonal matrix has an inverse provided that no diagonal entries are zero.
Inverse of Matrix Product
if A and B are invertible, then:
(
A
B
)
−
1
=
B
−
1
A
−
1
(AB)^{-1} = B^{-1}A^{-1}
(AB)−1=B−1A−1
note that the order is reversed.
this works with three or more matrices:
(
A
B
C
)
−
1
=
C
−
1
B
−
1
A
−
1
(ABC)^{-1} = C^{-1}B^{-1}A^{-1}
(ABC)−1=C−1B−1A−1
Gauss-Jordan Elimination
A A − 1 = A [ x 1 → x 2 → x 3 → ] = [ e 1 → e 2 → e 3 → ] = I AA^{-1} = A \begin{bmatrix} \overrightarrow{x_1} & \overrightarrow{x_2} & \overrightarrow{x_3} \end{bmatrix} = \begin{bmatrix} \overrightarrow{e_1} & \overrightarrow{e_2} & \overrightarrow{e_3} \end{bmatrix} = I AA−1=A[x1x2x3]=[e1e2e3]=I
对于一个 n × n n \times n n×n的矩阵来说,求解其逆矩阵相当于求解n个n元方程组,我们可以同时列出包含了这n个方程组的增广矩阵:
[ 2 − 1 0 1 0 0 − 1 2 − 1 0 1 0 0 − 1 2 0 0 1 ] \begin{bmatrix} 2 & -1 & 0 & 1 & 0 & 0 \\ -1 & 2 & -1 & 0 & 1 & 0 \\ 0 & -1 & 2 & 0 & 0 & 1 \end{bmatrix} ⎣⎡2−10−12−10−12100010001⎦⎤
先进行一轮forward elimination:
[ 2 − 1 0 1 0 0 0 3 2 − 1 1 2 1 0 0 0 4 3 1 3 2 3 0 ] \begin{bmatrix} 2 & -1 & 0 & 1 & 0 & 0 \\ 0 & \frac{3}{2} & -1 & \frac{1}{2} & 1 & 0 \\ 0 & 0 & \frac{4}{3} & \frac{1}{3} & \frac{2}{3} & 0 \end{bmatrix} ⎣⎡200−12300−134121310132000⎦⎤
然后反过来向上消元,将矩阵变为reduced echelon form(最简行阶梯矩阵),这部分由Jordan贡献。
[ 2 0 0 3 2 1 1 2 0 3 2 0 3 4 3 2 3 4 0 0 4 3 1 3 2 3 0 ] \begin{bmatrix} 2 & 0 & 0 & \frac{3}{2} & 1 & \frac{1}{2} \\ 0 & \frac{3}{2} & 0 & \frac{3}{4} & \frac{3}{2} & \frac{3}{4} \\ 0 & 0 & \frac{4}{3} & \frac{1}{3} & \frac{2}{3} & 0 \end{bmatrix} ⎣⎡200023000342343311233221430⎦⎤
最后,divided each row by its pivots, then we finally get [ I A − 1 ] [I \; A^{-1}] [IA−1] in this argumented matrix;
[ 1 0 0 3 4 1 2 1 4 0 1 0 1 2 1 1 2 0 0 1 1 4 1 2 3 4 ] \begin{bmatrix} 1 & 0 & 0 & \frac{3}{4} & \frac{1}{2} & \frac{1}{4} \\ 0 & 1 & 0 & \frac{1}{2} & 1 & \frac{1}{2} \\ 0 & 0 & 1 & \frac{1}{4} & \frac{1}{2} & \frac{3}{4} \end{bmatrix} ⎣⎡10001000143214121121412143⎦⎤
the total cost for A − 1 A^{-1} A−1 is n 3 n^3 n3 multiplications and subtractions.
Diagonally dominant matrices are intertible
对角优势矩阵是可逆的(充分不必要);
对角优势矩阵,对角线上的每一个元素,都大于这一行上其余元素的绝对值的和;
对角优势矩阵之所以可逆,是因为其一定满足
A
x
→
=
0
→
A\overrightarrow{x} = \overrightarrow{0}
Ax=0没有非零向量解;
2.6 Elimination = Factorization: A = L U A = LU A=LU
矩阵的LU分解
A = L U A = LU A=LU
或者
A = L D U A = LDU A=LDU
其中,L代表下三角矩阵(lower triangular),储存了高斯消元时所有的
l
i
j
l_{ij}
lij;
D代表对角矩阵(diagonal matrix),储存了所有的pivots(如果愿意写成这种形式的话);
U代表上三角矩阵(upper triangular),储存了A高斯消元后的结果(LU形式)或者将高斯消元后的矩阵每一行除以其pivot的结果(LDU形式);
从LU分解的角度看待线性方程组的求解
方程组 A x → = b → A\overrightarrow{x} = \overrightarrow{b} Ax=b,如果写成 L U x → = b → LU\overrightarrow{x} = \overrightarrow{b} LUx=b,相当于解决两个三角形的方程组,先解决 L c → = b → L\overrightarrow{c} = \overrightarrow{b} Lc=b(forward substitution),再解决 U x → = c → U\overrightarrow{x} = \overrightarrow{c} Ux=c(backward substitution)。
The Cost of Elimination
Elimination on a n × n n \times n n×n square matrix A needs 1 3 n ( n + 1 2 ) ( n + 1 ) \frac{1}{3}n(n + \frac{1}{2})(n+1) 31n(n+21)(n+1) multiplications and 1 3 n ( n + 1 2 ) ( n + 1 ) \frac{1}{3}n(n + \frac{1}{2})(n+1) 31n(n+21)(n+1) subtractions.
To solve each right side of the equation, n 2 n^2 n2 muliplications and n 2 n^2 n2 substractions are needed.
对于带宽为 ω \omega ω的带状矩阵(band matrix)来说,消元只需要消耗 n ω 2 n \omega^2 nω2次乘法和减法,求解只需要消耗 2 n ω 2n\omega 2nω次乘法和减法。
2.7 Transposes and Permutations
转置矩阵(Transpose)的一些性质
Sum: ( A + B ) T = A T + B T Product: ( A B ) T = B T A T Inverse: ( A − 1 ) T = ( A T ) − 1 ( A B C ) T = C T B T A T if A is invertible, A T is invertible, too \text{Sum: } (A + B)^T = A^T + B^T \\ \text{Product: } (AB)^T = B^T A^T \\ \text{Inverse: } (A^{-1})^T = (A^T)^{-1} \\ (ABC)^T = C^T B^T A^T \\ \text{if A is invertible, } A^T \text{is invertible, too} Sum: (A+B)T=AT+BTProduct: (AB)T=BTATInverse: (A−1)T=(AT)−1(ABC)T=CTBTATif A is invertible, ATis invertible, too
使用矩阵转置表示向量的内积和外积
Inner Product: x → T y → , T is inside Outer Product: x → y → T , T is outside \text{Inner Product: } \overrightarrow{x}^T \overrightarrow{y} \text{ , T is inside} \\ \text{Outer Product: } \overrightarrow{x} \overrightarrow{y} ^ T \text{ , T is outside} Inner Product: xTy , T is insideOuter Product: xyT , T is outside
关于转置矩阵更加“数学”的定义
A
T
A^T
AT is the matrix that makes the following two inner product equal:
(
A
x
→
)
T
y
→
=
x
→
T
(
A
T
y
→
)
(A \overrightarrow{x})^T \overrightarrow{y} = \overrightarrow{x}^T (A^T \overrightarrow{y})
(Ax)Ty=xT(ATy)
because
(
A
x
→
)
T
y
→
=
x
→
T
A
T
y
→
(A\overrightarrow{x})^T \overrightarrow{y} = \overrightarrow{x}^T A^T \overrightarrow{y}
(Ax)Ty=xTATy, 使用转置矩阵表示的内积。
斜对称矩阵(Symmetric Matrix)
斜对称矩阵的转置等于本身 P T = P P^T = P PT=P;
对于任意矩阵, A A T A A^T AAT的结果是一个斜对称矩阵;
对斜对称矩阵进行高斯消元,计算量可以减半,因为: P = L D U = L D L T P = LDU = LDL^T P=LDU=LDLT;
置换矩阵(Permutation Matrix)
DEFINITION: A Permutation Matrix has the rows of an Indetity Matrix I in any order.
P − 1 P^{-1} P−1也是一个置换矩阵。
P − 1 = P T P^{-1} = P^T P−1=PT,置换矩阵的逆矩阵与转置矩阵相同。
带有行交换的矩阵的LU分解
两种形式:
P
A
=
L
U
A
=
L
P
U
PA = LU \\ A = LPU
PA=LUA=LPU
第一种形式更加常用;
课后习题
作业里的截图都缺了一角,问题应该出在使用CloudConvert将SVG图像转化成PNG图像的步骤上,先不管。