线性代数
矩阵消元
矩阵行变化, 相当于左乘矩阵.
如下矩阵乘法为对第一行进行行变化row1:=row1+2∗row2−row3row1 := row1 + 2*row2 - row3row1:=row1+2∗row2−row3.
[12−1010001][−.row1−−.row2−−.row3−]
\begin{bmatrix}
1 & 2 & -1\\
0 & 1 & 0\\
0 & 0 & 1\\
\end{bmatrix}
\begin{bmatrix}
-. & row1 & - \\
-. & row2 & - \\
-. & row3 & - \\
\end{bmatrix}
⎣⎡100210−101⎦⎤⎣⎡−.−.−.row1row2row3−−−⎦⎤
矩阵乘法的几种理解
An×m⋅Bm×p=Cn×p A_{n \times m}\cdot B_{m \times p} = C_{n \times p} An×m⋅Bm×p=Cn×p
从单个元素的角度
Ci,j=∑k=1mAi,k⋅Bk,j C_{i,j} = \sum_{k=1}^m{A_{i,k} \cdot B_{k,j}} Ci,j=k=1∑mAi,k⋅Bk,j
列角度
[∣∣⋯col1col2⋯∣∣⋯]⋅[∣⋯col1⋯∣⋯]=[∣⋯col1⋯∣⋯] \begin{bmatrix} | & | & \cdots \\ col1 & col2 & \cdots \\ | & | & \cdots \\ \end{bmatrix} \cdot \begin{bmatrix} | & \cdots \\ col1 & \cdots \\ | & \cdots \\ \end{bmatrix}= \begin{bmatrix} | & \cdots \\ col1 & \cdots \\ | & \cdots \\ \end{bmatrix} ⎣⎡∣col1∣∣col2∣⋯⋯⋯⎦⎤⋅⎣⎡∣col1∣⋯⋯⋯⎦⎤=⎣⎡∣col1∣⋯⋯⋯⎦⎤
col1 of Ccol1\ of\ Ccol1 of C是AAA的每一列的线性组合, 每一列的权重为col1 of Bcol1\ of\ Bcol1 of B.
行角度
[−.row1−⋯⋯⋯⋮⋮⋮]⋅[−.row1−−.row2−⋮⋮⋮]=[−.row1−⋯⋯⋯⋮⋮⋮]
\begin{bmatrix}
-. & row1 & - \\
\cdots & \cdots & \cdots \\
\vdots & \vdots & \vdots \\
\end{bmatrix}
\cdot
\begin{bmatrix}
-. & row1 & - \\
-. & row2 & - \\
\vdots & \vdots & \vdots \\
\end{bmatrix}=
\begin{bmatrix}
-. & row1 & - \\
\cdots & \cdots & \cdots \\
\vdots & \vdots & \vdots \\
\end{bmatrix}
⎣⎢⎡−.⋯⋮row1⋯⋮−⋯⋮⎦⎥⎤⋅⎣⎢⎡−.−.⋮row1row2⋮−−⋮⎦⎥⎤=⎣⎢⎡−.⋯⋮row1⋯⋮−⋯⋮⎦⎥⎤
row1 of Crow1\ of\ Crow1 of C是BBB的每一行的线性组合, 每一行的权重为row1 of Arow1\ of\ Arow1 of A.
列乘行的角度
A=[col1col2⋯],B=[row1row2⋮]A⋅B=∑i=1mcoli⋅rowi A = \begin{bmatrix} col1 & col2 & \cdots \end{bmatrix}, B = \begin{bmatrix} row1 \\ row2 \\ \vdots \end{bmatrix}\\ A \cdot B = \sum_{i=1}^m{col_i \cdot row_i} A=[col1col2⋯],B=⎣⎢⎡row1row2⋮⎦⎥⎤A⋅B=i=1∑mcoli⋅rowi
例子
col1=[234],row1=[16]col1⋅row1=[234]⋅[16]=[212318424]
col1 = \begin{bmatrix}2 \\ 3 \\ 4 \end{bmatrix},row1=\begin{bmatrix}1 & 6\end{bmatrix}\\
col1 \cdot row1 = \begin{bmatrix}2 \\ 3 \\ 4 \end{bmatrix} \cdot \begin{bmatrix}1 & 6\end{bmatrix}=
\begin{bmatrix}
2 & 12\\
3 & 18\\
4 & 24\\
\end{bmatrix}
col1=⎣⎡234⎦⎤,row1=[16]col1⋅row1=⎣⎡234⎦⎤⋅[16]=⎣⎡234121824⎦⎤
分块角度
以上三种角度都可以用分块角度很直观地看出.
矩阵的逆
可逆
若存在x≠0, A⋅x=0x \neq 0,\ A \cdot x = 0x=0, A⋅x=0, 则AAA是奇异矩阵, 不可逆.
证明:
假设存在B⋅A=IB \cdot A = IB⋅A=I, 则有
A⋅x=0B⋅Ax=0I⋅x=0x=0
A\cdot x = 0\\
B \cdot Ax = 0\\
I \cdot x = 0\\
x = 0
A⋅x=0B⋅Ax=0I⋅x=0x=0
矛盾. 故B不存在B不存在B不存在.
逆的计算
Gauss-Jordan消元法对[AI]\begin{bmatrix}A & I\end{bmatrix}[AI]进行消元, 最后100左边消为III, 右边即为A−1A^{-1}A−1. 由于矩阵行变化相当于左乘矩阵, 故
∵E⋅A=I∴E⋅I=A−1E⋅[AI]=[IA−1]
\because E \cdot A = I\\
\therefore E \cdot I = A^{-1}\\
E \cdot \begin{bmatrix}A & I\end{bmatrix} =
\begin{bmatrix}I & A^{-1}\end{bmatrix}
∵E⋅A=I∴E⋅I=A−1E⋅[AI]=[IA−1]
LU分解
把A进行行变化, 得到上三角矩阵U.(不使用行交换).
A3×3A_{3\times 3}A3×3例子
E2,1⋅E3,1⋅E3,2⋅A=UA=E3,2−1⋅E3,1−1⋅E2,1−1⋅U=LU
E_{2,1}\cdot E_{3,1}\cdot E_{3,2}\cdot A = U\\
A = E_{3,2}^{-1}\cdot E_{3,1}^{-1}\cdot E_{2,1}^{-1}\cdot U = LU
E2,1⋅E3,1⋅E3,2⋅A=UA=E3,2−1⋅E3,1−1⋅E2,1−1⋅U=LU
转置、置换、向量空间
置换矩阵
置换矩阵(permutations)是指可以让矩阵进行 行交换(row exchanges)的矩阵。n×nn\times nn×n的置换矩阵就是通过单位矩阵行交换的得到,个数为n!n!n!。他们的逆矩阵都在这个群里。进一步来说,逆矩阵相当于把做的交换逆回去,故有
P−1=PT
P^{-1} = P^{T}
P−1=PT
所以,当需要行交换的时候, LU分解应该写成
PA=LU
PA=LU
PA=LU
转置
对于任意矩阵RRR,RTRR^{T}RRTR是对称矩阵恒成立。即(RTR)T=RTR(R^TR)^T=R^TR(RTR)T=RTR.
向量空间
满足数乘和加法封闭性。最小的向量空间只有零向量。
列空间和零空间
两个子空间SSS和TTT的交集也是一个子空间。因为v,w∈S∩Tv,w\in S\cap Tv,w∈S∩T,所以v+w∈S,v+w∈Tv+w\in S, v+w\in Tv+w∈S,v+w∈T,即v+w∈S∩Tv+w\in S\cap Tv+w∈S∩T
列向量空间
A=[112213314415] A=\begin{bmatrix}1 & 1 & 2 \\ 2 & 1 & 3 \\ 3 & 1 & 4 \\ 4 & 1 & 5\end{bmatrix} A=⎣⎢⎢⎡123411112345⎦⎥⎥⎤
A的列向量子空间是4维空间中的子空间,不能覆盖整个4维空间。用方程组来说,就是Ax=bAx=bAx=b并不是对于所有的bbb都有解,xxx是各个列向量线性组合的权重。有解的bbb是各列的线性组合,即bbb 属于AAA的列空间C(A)C(A)C(A)。
A⋅x=[112213314415]⋅[x1x2x3]=[b1b2b3b4] A \cdot x = \begin{bmatrix}1 & 1 & 2 \\ 2 & 1 & 3 \\ 3 & 1 & 4 \\ 4 & 1 & 5\end{bmatrix}\cdot \begin{bmatrix}x_1 \\ x_2 \\ x_3 \end{bmatrix}= \begin{bmatrix} b_1\\ b_2\\ b_3\\ b_4 \end{bmatrix} A⋅x=⎣⎢⎢⎡123411112345⎦⎥⎥⎤⋅⎣⎡x1x2x3⎦⎤=⎣⎢⎢⎡b1b2b3b4⎦⎥⎥⎤
零空间
Ax=0Ax=0Ax=0的所有解x∈R4x\in R^4x∈R4组成零空间N(A)N(A)N(A)。至少包含零向量。
用上面的例子,零空间的向量形如以下形式,是一条直线。
[cc−c]
\begin{bmatrix}
c\\
c\\
-c\\
\end{bmatrix}
⎣⎡cc−c⎦⎤
证明为什么Ax=0Ax=0Ax=0得到的所有向量一定构成一个向量空间
设x,x∗为两个解x,x^*为两个解x,x∗为两个解,则有
Ax=0, Ax∗=0
Ax=0,\ Ax^*=0\\
Ax=0, Ax∗=0
则
A(x+x∗)=Ax+Ax∗=0+0=0A(kx)=kAx=0
A(x + x^*) =Ax+Ax^*=0+0=0\\
A(kx)=kAx=0
A(x+x∗)=Ax+Ax∗=0+0=0A(kx)=kAx=0
故向量加法和数乘都在向量空间内,故符合向量空间的定义。
Ax=0Ax=0Ax=0的主元和特解
Ax=0Ax=0Ax=0 的解不会因对AAA矩阵进行初等行变化而改变。可以从两个角度得到这个结论。
- 进行行变化时,只是对A矩阵每一列内部的行之间进行变化,每列的变化相同。列与列之间的关系不变。
- 进行初等行变化相当于左乘一个矩阵EEE,而EAx=0EAx=0EAx=0仍然成立。
矩阵的秩就是矩阵进行行变化之后的主元的个数。
A=[1222246836810]=>U=[122200240000]=>R=[120−200120000]
A=\begin{bmatrix}1 & 2 & 2 & 2\\ 2 & 4 & 6 & 8 \\ 3 & 6 & 8 & 10\end{bmatrix}\\
=>\\
U=\begin{bmatrix}1 & 2 & 2 & 2\\ 0& 0& 2 & 4 \\ 0 & 0& 0 & 0\end{bmatrix}\\
=>\\
R=\begin{bmatrix}1 & 2 & 0 & -2\\ 0& 0& 1 & 2 \\ 0 & 0& 0 & 0\end{bmatrix}\\
A=⎣⎡1232462682810⎦⎤=>U=⎣⎡100200220240⎦⎤=>R=⎣⎡100200010−220⎦⎤
AAA的秩r=2r=2r=2。UUU的第一列和第三列为主列(pivot columns),第二列和第四列为自由列(free columns)。Ax=0Ax=0Ax=0的自由元的个数为n−r=4−2=2n-r=4-2=2n−r=4−2=2。零空间就是让自由元逐一等于1得到的向量之间的线性组合。
x=c⋅[−2100]+d⋅[20−21]
x=c\cdot
\begin{bmatrix}
-2\\
1\\
0\\
0
\end{bmatrix}
+d \cdot
\begin{bmatrix}
2\\
0\\
-2\\
1
\end{bmatrix}
x=c⋅⎣⎢⎢⎡−2100⎦⎥⎥⎤+d⋅⎣⎢⎢⎡20−21⎦⎥⎥⎤
把RRR矩阵中的主列凑在一起,把自由列组合在一起,就可以得到rref形式的RRR矩阵。
I=[1001],F=[2−202]R=[[1001][2−202]0000]
I=\begin{bmatrix}1&0\\0&1\end{bmatrix},F=\begin{bmatrix}2&-2\\0&2\end{bmatrix}
R=\begin{bmatrix}\begin{bmatrix}1&0\\0&1\end{bmatrix}&\begin{bmatrix}2&-2\\0&2\end{bmatrix}\\
\begin{matrix}0&0\end{matrix}&\begin{matrix}0&0\end{matrix}\end{bmatrix}
I=[1001],F=[20−22]R=⎣⎡[1001]00[20−22]00⎦⎤
则可以通过解RN=0RN=0RN=0来得到列向量为Ax=0Ax=0Ax=0的n−rn-rn−r个特解,即得到了零基。
N=[−FI]
N=\begin{bmatrix}
-F\\
I\\
\end{bmatrix}
N=[−FI]