---
# System prepended metadata

title: '李宏毅_Linear Algebra Lecture 15: Inverse of Matrix'
tags: [NTU, Hung-yi Lee, Linear Algebra Lecture]

---

# 李宏毅_Linear Algebra Lecture 15: Inverse of Matrix
###### tags:  `Hung-yi Lee` `NTU` `Linear Algebra Lecture`
[課程撥放清單](https://www.youtube.com/playlist?list=PLJV_el3uVTsNmr39gwbyV-0KjULUsN7fW)
## Linear Algebra Lecture 15: Inverse of Matrix
[課程連結](https://www.youtube.com/watch?v=fOK-bLERPUM&list=PLJV_el3uVTsNmr39gwbyV-0KjULUsN7fW&index=16&t=0s)

課程主要說明矩陣的Inverse
### Inverse of Function
![](https://i.imgur.com/gMSlBC0.png)

假設有兩個function-f、g，它們互為inverse，那麼它滿足以下條件：
* input-$v$經過function-f得到$x$，再經過function-g會得到$y$，這個$y$就是原始的$v$
* 相反的先經過function-g再經過function-f也可以得到原始的結果
* 不管你的順序為何，只要經過兩個function就一定可以還原為原始的輸入

這時候我們說，f與g互為inverse，也就是f=g^-1^，g=f^-1^，而矩陣的inverse其道理一樣，因為我們可以將matrix視為一個linear function。
### Inverse of Matrix
![](https://i.imgur.com/SuINp8L.png)

相同於function，matrix的互為inverse也是一樣的道理。只要經過兩個function，不管順序都會得到原始的輸入。

以另一種角度來說，$AB=I$且$BA=I$~(I為identity matrix)~，那它們就互為inverse。
### Inverse of Matrix
![](https://i.imgur.com/Z7szmPE.png)

如果有一個matrix-B，而$AB=I$且$BA=I$，那A是invertible(可逆的)，而B就是A的inverse，即$B=A^{-1}$，而inverse是互相的，也就是$A=B^{-1}$。

如果matrix是invertible，那它就是non-singular，這只是一個換句話說，singular有單獨的意思，而invertible代表它有一個伴，也就non-singular了。
### Inverse of Matrix
![](https://i.imgur.com/cezxT0W.png)

特別注意到的是，如果matrix並非方形(即nxm且n<>m)，那它就一定不是invertible，也就是一定不可逆。
### Inverse of Matrix
![](https://i.imgur.com/4KujeSM.png)

這邊用一個案例說明非方形一定不可逆，主要在於低維轉高維的時候是無法還原的，這種情況下相乘是不會產生identity matrix，自然也就不可逆。
### Inverse of Matrix
![](https://i.imgur.com/m7SdNDW.png)

上圖的上方案例說明著，並非所有方形的矩陣都是可逆的。

上圖的下方案例說明著，inverse是唯一的，也代表著$AB=I, BA=I$，不會出現$AB=I, AC=I$的情況。
### Inverse for matrix product
![](https://i.imgur.com/uhRud8b.png)

這邊是更多性質的說明：
* 當AB皆為invertible的nxn矩陣的時候，那AB也會是invertible
    * 證明：$(AB)^{-1} = B^{-1} A^{-1}$，然後乘上$AB$，$B^{-1} A^{-1}(AB)=B^{-1}(A^{-1}A)B=B^{-1}B=I$，反過來也是一樣，$(AB)B^{-1}A^{-1}=A(BB^{-1})A^{-1}=AA^{-1}=I$
* 相同的證明可以推廣到$K$個invertible matrix
    * $(A_1A_2A_3...A_K)^{-1}=(A_K)^{-1}(A_{K-1})^{-1}...(A_1)^{-1}$
### Inverse for matrix product
![](https://i.imgur.com/964MPi5.png)

* 如果A是invertible，那A^T^也會是invertible，也就是$(A^T)^{-1}=(A^{-1})^T$
    * 證明：$A^{-1}A \rightarrow I=(A^{-1}A)^T=I \rightarrow A^T(A^{-1})^T=I$
        * 對identity matrix做transpose還是identity matrix
    * 反過來證明：$AA^{-1}=I \rightarrow (AA^{-1})^T=I \rightarrow (A^{-1})^TA^T=I$
### Inverse for matrix transpose
![](https://i.imgur.com/IW2212O.png)

* 如果$A$是invertible，那$A^T$也是invertible，即$(A^T)^{-1} = (A^{-1})^T$
    * 這只要證明$A^T(A^{-1})^T$是否為identity matrix就可以
    * 證明：$(A^{-1}A)=I \rightarrow (A^{-1}A)^T=I \rightarrow A^T(A^{-1})^T=I$
    * 反過來證明：$AA^{-1}=I \rightarrow (AA^{-1})^T=I \rightarrow (A^{-1})^TA^T=I$

### Solving Linear Equations
![](https://i.imgur.com/html8xX.png)

matrix的逆比較直觀的作用是拿來解system of linear equation：
* 假設$Ax=b$，並且$A$是可逆的~(invertible)~
* 兩邊同乘$A^{-1}$，即$A^{-1}A(Ax)=A^{-1}b$
* 然後抵消$A^{-1}A$，就可以得到$I_nx=a^{-1}b$，也就是$x = A^{-1}b$

概念上類似於代數運算，左右同時做某種數值上的操作，只是因為matrix沒有倒數，因此以inverse作為倒數。

實務上並不會用這種方法來求解，因為求inverse的過程需要執行RREF，既然還要執行RREF那就一開始直接用RREF求解即可。
### Input-output Model
![](https://i.imgur.com/NIPlR5I.png)

上面給出一個應用範例，可自行參閱。

其中將生產每單位需求的資源做為矩陣，稱為Consumption matrix-$C$，想生產的為$x$，須投入的資源則為$Cx$。
### Input-output Model
![](https://i.imgur.com/IqZdcox.png)

利用模型可以很快速的計算須投入的成本，但考量產出所投入的成本之後，淨收益為$x - Cx$，稱為Demand Vector
### Input-output Model
![](https://i.imgur.com/dtKgkrJ.png)

實務上我們可能會希望直接求得淨收益的部份，即$x - Cx = d$：
* $x$乘上identity matrix，這並不影響結果，$Ix - Cx = d$
* 提出$x$，$(I - C)x =d$
* 而$Ax = b$，將$I-C$視為$A$，$A=I-C$，而$b = d$，$x$為$(I-C)^{-1}d$
### Input-output Model
![](https://i.imgur.com/gtj0yGS.png)

如果想提升一單位食物的淨產值，需要多生產多少資源?
* 已知$(I-C)x=d \rightarrow x = (I-C)^{-1}d$
* $d$則需要加上一個standard vector，即$d+e_1$
* 代入公式，$x'=(I-C)^{-1}(d+e_1)$
* 分別乘開，得$(I-C)^{-1}d + (I-C)^{-1}e_1$
* $(I-C)^{-1}d$是原本的$x$，而$(I-C)^{-1}e_1$是多出來的部份，也就是要是升一單位食物的淨產值所需要的資源，也就是$x$的第一個column
