Jephian Lin
    • Create new note
    • Create a note from template
      • Sharing URL Link copied
      • /edit
      • View mode
        • Edit mode
        • View mode
        • Book mode
        • Slide mode
        Edit mode View mode Book mode Slide mode
      • Customize slides
      • Note Permission
      • Read
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Write
        • Only me
        • Signed-in users
        • Everyone
        Only me Signed-in users Everyone
      • Engagement control Commenting, Suggest edit, Emoji Reply
    • Invite by email
      Invitee

      This note has no invitees

    • Publish Note

      Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

      Your note will be visible on your profile and discoverable by anyone.
      Your note is now live.
      This note is visible on your profile and discoverable online.
      Everyone on the web can find and read all notes of this public team.
      See published notes
      Unpublish note
      Please check the box to agree to the Community Guidelines.
      View profile
    • Commenting
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
      • Everyone
    • Suggest edit
      Permission
      Disabled Forbidden Owners Signed-in users Everyone
    • Enable
    • Permission
      • Forbidden
      • Owners
      • Signed-in users
    • Emoji Reply
    • Enable
    • Versions and GitHub Sync
    • Note settings
    • Note Insights
    • Engagement control
    • Transfer ownership
    • Delete this note
    • Save as template
    • Insert from template
    • Import from
      • Dropbox
      • Google Drive
      • Gist
      • Clipboard
    • Export to
      • Dropbox
      • Google Drive
      • Gist
    • Download
      • Markdown
      • HTML
      • Raw HTML
Menu Note settings Versions and GitHub Sync Note Insights Sharing URL Create Help
Create Create new note Create a note from template
Menu
Options
Engagement control Transfer ownership Delete this note
Import from
Dropbox Google Drive Gist Clipboard
Export to
Dropbox Google Drive Gist
Download
Markdown HTML Raw HTML
Back
Sharing URL Link copied
/edit
View mode
  • Edit mode
  • View mode
  • Book mode
  • Slide mode
Edit mode View mode Book mode Slide mode
Customize slides
Note Permission
Read
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Write
Only me
  • Only me
  • Signed-in users
  • Everyone
Only me Signed-in users Everyone
Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       owned this note    owned this note      
    Published Linked with GitHub
    Subscribed
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    Subscribe
    # 投影與鏡射 ![Creative Commons License](https://i.creativecommons.org/l/by/4.0/88x31.png) This work by Jephian Lin is licensed under a [Creative Commons Attribution 4.0 International License](http://creativecommons.org/licenses/by/4.0/). {%hackmd 5xqeIJ7VRCGBfLtfMi0_IQ %} ```python from lingeo import random_int_list ``` ## Main idea ##### Matrix-matrix multiplication (by entry) Let $$ A = \begin{bmatrix} a_{11} & \cdots & a_{1n} \\ \vdots & ~ & \vdots \\ a_{m1} & \cdots & a_{mn} \\ \end{bmatrix} \text{ and } B = \begin{bmatrix} b_{11} & \cdots & b_{1\ell} \\ \vdots & ~ & \vdots \\ b_{n1} & \cdots & b_{n\ell} \\ \end{bmatrix}$$ be $m\times n$ and $n\times \ell$ matrices, respectively. Then the $ij$-entry of $AB$ is $$(AB)_{ij} = \sum_{k = 1}^n a_{ik}b_{k\ell}.$$ Let $A$ be an $m\times n$ matrix. The **transpose** of $A$ is the $n\times m$ matrix $A^\top$ whose $ij$-entry is the $ji$-entry of $A$. The $n\times n$ **identity matrix** is the matrix whose diagonal entries are one and other entries are zero, usually denoted as $I_n$. The $m\times n$ **zero matrix** is the matrix whose entries are zero, usually denoted as $O_{m,n}$. If $A$ is an $n\times n$ matrix and there is a matrix $B$ such that $AB = BA = I_n$, then $B$ is called the **inverse** of $A$, denoted as $A^{-1} = B$. A matrix with an inverse is **invertible**. Suppose $A$ is an $n\times k$ matrix with $\operatorname{ker}(A) = \{{\bf 0}\}$. Then every vector ${\bf b}\in\mathbb{R}^n$ can be written as $${\bf b} = {\bf w} + {\bf h}$$ where ${\bf w}\in\operatorname{Col}(A)$ and ${\bf h}\in\operatorname{Col}(A)^\perp$. Moreover, $$\begin{aligned} {\bf w} &= A(A^\top A)^{-1}A^\top {\bf b}, \\ {\bf h} &= {\bf b} - {\bf w}. \end{aligned}$$ We say ${\bf w}$ is the **projection** of ${\bf b}$ onto the subspace $\operatorname{Col}(A)$, and ${\bf w} - {\bf h}$ the **reflection** of ${\bf b}$ along the subspace $\operatorname{Col}(A)$. Both action can be done by matrices. That is, $$\begin{aligned} {\bf w} &= A(A^\top A)^{-1}A^\top {\bf b}, \\ {\bf w} - {\bf h} &= 2{\bf w} - {\bf b} = (2A(A^\top A)^{-1}A^\top - I_n){\bf b}. \end{aligned} $$ ## Side stories - $\langle{\bf x},{\bf y}\rangle = {\bf y}^\top{\bf x}$ - matrix algbra ## Experiments ##### Exercise 1 執行下方程式碼。 依照步驟求出 ${\bf b}$ 在 $\operatorname{Col}(A)$ 上的投影。 ```python ### code set_random_seed(0) print_ans = False while True: A = matrix(2, random_int_list(8)).transpose() if (A.transpose() * A).is_invertible(): break b = vector(random_int_list(4)) print("A =") print(A) print("b =", b) if print_ans: AT = A.transpose() ATA = AT * A w = A * ATA.inverse() * AT * b print("The projection is %s."%w) ``` ##### Exercise 1(a) 假設 ${\bb} = {\bw} + {\bh}$ 使得 ${\bf w}\in\operatorname{Col}(A)$(也就是有某一個 ${\bv}$ 使得 ${\bf w} = A{\bv}$)、 ${\bf h}\in\operatorname{Col}(A)^\perp = \operatorname{Row}(A^\top)^\perp = \operatorname{ker}(A^\top)$(也就是 $A^\top{\bf h} = {\bf 0}$)。 將 ${\bb} = {\bw} + {\bh}$ 兩邊前乘 $A^\top$﹐ 並用 $A$、${\bb}$、和 ${\bv}$ 表示出來。 :::warning - [ ] 不要把所有數學式變粗體,粗體是為了區別向量(粗)和純量;題目裡的 ${\bf A}\trans$ 是我打錯,己經改掉了 - [x] ${\bf b} = {\bf w} + {\bf h}$ 兩邊同乘 ${\bf A\trans}$ --> 在 ${\bf b} = {\bf w} + {\bf h}$ 兩邊的前面同乘 ${\bf A\trans}$(不要用數學式當句子開頭,矩陣乘法前乘後乘不一樣) ::: 在 ${\bf b} = {\bf w} + {\bf h}$ 兩邊前方同乘 ${A\trans}$ 得到 $A\trans \bb = A\trans \bw + A\trans\bh$ 。 而 ${\bf w}\in\operatorname{Col}(A)$, 換句話說必定會有一個向量 ${\bf v}$ 使得 ${\bf w} = A{\bf v}$ 。 因此 $A\trans\bb = A\trans\bw + A\trans \bh$ 又可以寫成 $A\trans\bb = A\trans A \bv + A\trans \bh$。 而由於 ${\bf h}\in\operatorname{Col}(A)^\perp = \operatorname{Row}(A^\top)^\perp = \operatorname{ker}(A^\top)$, 則 $A\trans \bh = {\bf 0}$ 。 因此 $A\trans \bb = A\trans A \bv + A\trans \bh$ 又可寫成 $A\trans\bb = A\trans A \bv$。 ##### Exercise 1(b) 將 $A$ 和 ${\bf b}$ 的數字代入並解方程式求出 ${\bf v}$ 。 (如果 $A^\top A$ 可逆﹐ 則可以把上一題的式子寫成 ${\bf v} = (A^\top A)^{-1} A^\top {\bf b}$ 。) :::warning - [x] 經過計算 ${\bf dot(A)}$ 的值不為 ${\bf 0}$ 。--> 經過計算,發現 $\det(A)$ 的值不為 $0$。 - [x] ${\bf dot}$ --> $\det$ - [x] 因此可以代入公式-若以代入公式:若今有一矩陣 $A$ 且 $\det(A)$ 的值不為 $0$,則矩陣 ... 的反矩陣為 ... . ::: 執行程式碼後得到 $$ A = \begin{bmatrix} 0 & 0 \\ -1 & 0 \\ 0 & 0 \\ -3 & -1 \end{bmatrix} $$ 及 $$ \bb = (-1,-2,-3,2). $$ 有了 $A$ 便可以得出 $A\trans$ $$ {A\trans} = \begin{bmatrix} 0 & -1 & 0 & -3 \\ 0 & 0 & 0 & -1 \end{bmatrix} 。 $$ 而計算 $A\trans A$ 得到 $$ {A\trans A} = \begin{bmatrix} 10 & 3 \\ 3 & 1 \end{bmatrix} 。 $$ 經過計算,發現 $\det(A)$ 的值不為 $0$。 因此可以代入公式:若今有一矩陣 $A$ 且 $\det(A)$ 的值不為 $0$,則矩陣 $$ A = \begin{bmatrix} a & b \\ c & d \end{bmatrix} $$ 的反矩陣為 $$ A^{-1} = \frac{{\bf 1}}{{\det(A)}} \begin{bmatrix} d & -b \\ -c & a \end{bmatrix}. $$ 代入公式後得到 $$ {(A\trans A) ^{-1}} = \begin{bmatrix} 1 & -3 \\ -3 & 10 \end{bmatrix} 。$$ 此時回到之前的式子, ${A\trans \bb} = { A\trans A \bv}$ 。 因 ${ (A\trans A)^{-1}}$ 有意義,則可兩邊同乘於 ${(A\trans A)^{-1}}$ , 得到${(A\trans A)^{-1}A\trans \bb} = {(A\trans A)^{-1}(A\trans A) \bv}$ 。 因為任何矩陣與其反矩陣相乘皆得到 ${I_n}$ 。 因此上述式子又可寫成 ${(A\trans A)^{-1}A\trans \bb} = {\bf v}$ 。 將 ${\bb}$ 寫成矩陣的形式,得到 $$ {\bb} = \begin{bmatrix} -1 \\ -2 \\ -3 \\ 2 \end{bmatrix} 。 $$ 將 ${\bf (A\trans A)^{-1} 、 A\trans 、 b}$ 的值代入, 得到 $$ {\bf v} = \begin{bmatrix} {\bf 1} & {\bf -3} \\ {\bf -3} & {\bf 10} \end{bmatrix} \begin{bmatrix} {\bf 0} & {\bf -1} & {\bf 0} & {\bf -3} \\ {\bf 0} & {\bf 0} & {\bf 0} & {\bf -1} \end{bmatrix} \begin{bmatrix} {\bf -1} \\ {\bf -2} \\ {\bf -3} \\ {\bf 2} \end{bmatrix} 。 $$ 將算式的結果寫成向量的形式便會得到 ${\bf v} = {\bf (2,-8)} 。$ ##### Exercise 1(c) 因此我們知道 $$\begin{aligned} {\bf w} &= A{\bf v}, \\ {\bf h} &= {\bf b} - {\bf w}. \end{aligned} $$ 以題目給的 $A$ 和 ${\bf b}$ 將 ${\bf w}$ 和 ${\bf h}$ 求出來﹐ 並確認 $A^\top{\bf h} = {\bf 0}$。 :::warning - [x] 目前已知 ${\bf w = Av}$ --> 後面加逗點 - [x] ${\bf A\trans h = 0}$ 成立 --> 因此 ${\bf A\trans h = 0}$ 確實成立(不要用數學當開頭) ::: 目前已知 ${\bf w = Av}$, 將先前得到的 ${\bf v}$ 寫成矩陣的形式, 並將 ${\bf A 、 v}$ 的值代入算式中。 得到 $$ {\bf w =} \begin{bmatrix} {\bf 0} & {\bf 0} \\ {\bf -1} & {\bf 0} \\ {\bf 0} & {\bf 0} \\ {\bf -3} & {\bf -1} \end{bmatrix} \begin{bmatrix} {\bf 2} \\ {\bf -8} \end{bmatrix} {\bf =} \begin{bmatrix} {\bf 0} \\ {\bf -2} \\ {\bf 0} \\ {\bf 2} \end{bmatrix} 。 $$ 若將 ${\bf w}$ 寫成向量的形式,則 $$ {\bf w = (0, -2, 0, 2)} 。 $$ 目前也知道 ${\bf h = b - w}$ 。 將 ${\bf b}$ 和 ${\bf w}$ 的值代入後得 $$ {\bf h = (-1,-2,-3,2) - (0,-2,0,2) = (-1,0,-3,0)} 。 $$ 驗證 ${\bf A\trans h = 0}$ 。 將 ${\bf h}$ 寫成矩陣的形式,並將 ${\bf A\trans}$ 和 ${\bf h}$ 的值代入, 得到 $$ {\bf A\trans h = } \begin{bmatrix} {\bf 0} & {\bf -1} & {\bf 0} & {\bf -3} \\ {\bf 0} & {\bf 0} & {\bf 0} & {\bf -1} \end{bmatrix} \begin{bmatrix} {\bf -1} \\ {\bf 0} \\ {\bf -3} \\ {\bf 0} \end{bmatrix} {\bf =} \begin{bmatrix} {\bf 0} \\ {\bf 0} \end{bmatrix} 。 $$ 因此 ${\bf A\trans h = 0}$ 成立。 ## Exercises ##### Exercise 2 以下小題說明為何 $A^\top A$ 可逆。 ##### Exercise 2(a) 若 ${\bf x}$ 和 ${\bf y}$ 為 $\mathbb{R}^n$ 中的兩向量。 驗證 $\langle{\bf x},{\bf y}\rangle = {\bf y}^\top{\bf x}$。 (這裡的右式把 ${\bf x}$ 和 ${\bf y}$ 都當成 $n\times 1$ 的矩陣 而算出來的 $1\times 1$ 的矩陣 ${\bf y}^\top{\bf x}$ 被當成一個數字。) :::warning - [x] $n\times 1$ 前面留空 ::: 假設 ${\bf x}$ 與 ${\bf y}$ 都為 $n\times 1$ 的矩陣,則 ${\by\trans}$ 會為$1\times n$ 的矩陣。 將 ${\bf x}$ 與 ${\bf y}$ 帶入 $\langle{\bf x},{\bf y}\rangle$, $\langle{\bf x},{\bf y}\rangle$ = $({\bx_{1}\by_{1}+\bx_{2}\by_{2}+....+\bx_{n}\by_{n}})$。 將 ${\bf x}$ 與 ${\by\trans}$ 帶入 ${\bf y}^\top{\bf x}$, ${\bf y}^\top{\bf x}$ = $({\by_{1}\bx_{1} + \by_{2}\by_{2} +.... + \by_{n}\bx_{n}})$。 由上兩個式子的結果可以得證 $\langle{\bf x},{\bf y}\rangle = {\bf y}^\top{\bf x}$ 。 ##### Exercise 2(b) 若 $A$ 和 $B$ 分別為 $m\times n$ 和 $n\times \ell$ 的兩矩陣。\ 驗證 $(AB)^\top$ = $B^\top A^\top$ 。 :::warning - [x] 這題是要驗證 $(AB)^\top$ 和 $B^\top A^\top$ 的每一項都相同。你可以令 $A = \begin{bmatrix} a_{ij} \end{bmatrix}$ 且 $B = \begin{bmatrix} b_{ij} \end{bmatrix}$。則 $(AB)\trans$ 的第 $i,j$-項為 ... 。而 $B\trans A\trans$ 的第 $i,j$-項為 ...。所以 ... 。 ::: 若 $A$ 和 $B$ 分別為 $m\times n$ 和 $n\times \ell$ 的兩矩陣。\ 則 $$ A = \begin{bmatrix} a_{11} & \cdots & a_{1n} \\ \vdots & ~ & \vdots \\ a_{m1} & \cdots & a_{mn} \\ \end{bmatrix} \text{ and } B = \begin{bmatrix} b_{11} & \cdots & b_{1\ell} \\ \vdots & ~ & \vdots \\ b_{n1} & \cdots & b_{n\ell} \\ \end{bmatrix} 。 $$ 而 $$ AB = C_{m \ell} = \begin{bmatrix} c_{11} & \cdots & c_{1j} \\ \vdots & ~ & \vdots \\ c_{i1} & \cdots & c_{ij} \end{bmatrix} i=1...m, j=1...\ell 。 $$ 其中 $C_{ij} = \sum\limits_{k = 1}^n a_{ik}b_{kj}$ 。\ 而 $C\trans$ 為一 $\ell\times m$ 的矩陣,且 $C\trans$ 可表示為 $$ (AB)\trans = C\trans = \begin{bmatrix} c_{11} & \cdots & c_{i1} \\ \vdots & ~ & \vdots \\ c_{1j} & \cdots & c_{ij} \end{bmatrix}, i=1...m, j=1...\ell 。 $$ 且 $C\trans$ 滿足 $C\trans_{ij} = C_{ji} = \sum\limits_{k = 1}^n a_{jk}b_{ki}$ 。 因目前已知 $A$ 和 $B$ 分別為 $m\times n$ 和 $n\times \ell$ 的兩矩陣。\ 則 $A\trans$ 和 $B\trans$ 分別為 $n\times m$ 和 $\ell\times n$ 的兩矩陣,且 $A\trans 、B\trans$ 可表示為 $$ A\trans = \begin{bmatrix} a_{11} & \cdots & a_{m1} \\ \vdots & ~ & \vdots \\ a_{1n} & \cdots & a_{mn} \\ \end{bmatrix} \text{ and } B\trans = \begin{bmatrix} b_{11} & \cdots & b_{n1} \\ \vdots & ~ & \vdots \\ b_{1\ell} & \cdots & b_{n\ell} \\ \end{bmatrix} 。 $$ 而 $B\trans A\trans$ 為一 $\ell\times m$ 的矩陣,且 $B\trans A\trans$可表示為 $$ B\trans A\trans = \begin{bmatrix} b_{11} & \cdots & b_{n1} \\ \vdots & ~ & \vdots \\ b_{1\ell} & \cdots & b_{n\ell} \\ \end{bmatrix} \begin{bmatrix} a_{11} & \cdots & a_{m1} \\ \vdots & ~ & \vdots \\ a_{1n} & \cdots & a_{mn} \\ \end{bmatrix} = \begin{bmatrix} d_{11} & \cdots & d_{m1} \\ \vdots & ~ & \vdots \\ d_{1\ell} & \cdots & d_{m \ell} \\ \end{bmatrix} = D. $$ 而 $D_{ij} = \sum\limits_{k = 1}^n a_{j k}b_{ki}$ 。 因此,矩陣 $C$ 和矩陣 $D$ 相等。 等價於 $(AB)\trans = B\trans A\trans$。 ##### Exercise 2(c) 驗證 $\langle A{\bf x}, {\bf y}\rangle = {\bf y}^\top A{\bf x} = \langle {\bf x}, A^\top{\bf y}\rangle$。 :::warning - [x] 經過以下計算可以得到 ... ,以及 ...。故得證。(不要用數學式開頭) ::: ANS:\ 經過以下計算可得到 $\langle A{\bf x}, {\bf y}\rangle= (A\bf x)^\top \bf y =(\bf x^\top A^\top)\bf y=\langle {\bf x},A^\top{\bf y}\rangle$,\ 以及 $\langle {\bf x},A^\top{\bf y}\rangle=(A^\top\bf y)^\top (\bf x)= {\bf y}^\top A{\bf x}$。\ 故得證。 ##### Exercise 2(d) 證明 $\operatorname{ker}(A) = \operatorname{ker}(A^\top A)$。 因為 $A^\top A$ 是一個方陣, 後面會證明一個方陣 $M$ 可逆的等價條件就是 $\ker(M) = \{{\bf 0}\}$。 因此 $\operatorname{ker}(A) = \{{\bf 0}\}$ 足以保證 $A^\top A$ 可逆。 另一方面, 如果 $\operatorname{ker}(A) \neq \{{\bf 0}\}$, 表示 $A$ 中的行向量有一些可以去掉並不會影響到行空間。 重覆這個步驟直到沒有任何多餘的行向量時 (這時行空間都還是同一個) 就保證有 $\operatorname{ker}(A)$。 (參考【矩陣的行向量】中的練習。) :::warning Nice work! - [x] $\ker(A)$表示$A \bf x = 0$ , --> 若 $\bx\in\ker(A)$,則 $A \bx = \bzero$。 - [x] 第一句最後 + 因此 $\bx\in\ker(A\trans A)$。 - [x] 中和英數之間空格 - [x] 而$\ker(A^\top A)$表示$A^\top A \bf x = 0$, --> 而$\bx\in\ker(A^\top A)$ 表示 $A^\top A \bx = \bzero$。 - [x] 展式數學裡是 $y_i^2$(少平方、純量不要粗體) ::: ANS:\ 若 $\bx\in\ker(A)$, 則 $A \bx = \bzero$, 兩邊同乘 $A^\top$ 可得 $A^\top A \bf x = A^\top 0=0$。 因此 $\bx\in\ker(A\trans A)$。 而 $\bx\in\ker(A^\top A)$ 表示 $A^\top A \bx = \bzero$, 兩邊同乘 $\bf x^\top$ 可得 $\bf x^\top A^\top A\bf x = (Ax)^\top Ax=0$, 經整理後可得 $\|{A\bf x}\|^2 = 0$。 另一方面,令 $\bf y=A \bf x$ 可得 $$\|\by\|^2 = \sum_{i = 1}^{n} y_i^2=0 $$ 及 $\by = A\bx = \bzero$。 由此可知 $\operatorname{ker}(A) = \operatorname{ker}(A^\top A)$。 ##### Exercise 3(a) 想像矩陣乘法就是一個動作(像是投影、或是鏡射)。 若 $A$ 是一個投影矩陣、 ${\bf b}$ 是一個向量。 猜看看 $A^2{\bf b}$會是什麼? 猜看看 $A^2$ 會是什麼? (下方程式碼中的矩陣是一個投影矩陣。可以試試看。) :::warning - [x] 標點 - [x] 中和英數之間空格 - [x] 結論應該是 $A^2 = A$。"而$A^2$為${\bf b}$的反矩陣" 不合邏輯,矩陣 $A^2$ 不會是向量 $\bb$ 的反矩陣。 ::: 將 $A^2{\bf b}$ 可以先拆解成 $AA{\bf b},$ 再透過矩陣乘法的性質,結合律得 $A(A{\bf b})$。 因此一共進行了兩次投影的矩陣乘法。 而不管投影幾次都會跟投影一次落在同一個向量, 因此 $A^2{\bf b}=A{\bf b}$, 又得 $A^2=A$。 ```python ### code set_random_seed(0) a = vector(random_int_list(3)) A = a.outer_product(a) / a.norm()**2 b = vector(random_int_list(3)) print("A =") show(A) print("b =", b) ``` ##### Exercise 3(b) 想像矩陣乘法就是一個動作(像是投影、或是鏡射) 若 $A$ 是一個鏡射矩陣、 ${\bf b}$ 是一個向量。 猜看看 $A^2{\bf b}$ 會是什麼? 猜看看 $A^2$ 會是什麼? (下方程式碼中的矩陣是一個投影矩陣。 可以試試看。) :::warning - [x] 標點、空格 - [x] $A^2 = I$ ::: $A^2{\bf b}$ 可以先拆解成成 $AA{\bf b}$, 再透過矩陣乘法的性質,結合律得 : $A(A{\bf b})$。 因此一共進行了兩次鏡射的矩陣乘法, 而鏡射兩次則會回到原本的向量。 因此 $A^2{\bf b}={\bf b}$, 得 $A^2=I$,所以 $A^2$ 是一個單位矩陣。 ```python ### code set_random_seed(0) a = vector(random_int_list(3)) A = 2*a.outer_product(a) / a.norm()**2 - identity_matrix(3) b = vector(random_int_list(3)) print("A =") show(A) print("b =", b) ``` ##### Exercise 4 令 $A$、$B$、$C$ 為矩陣 ${\bf x}$ 和 ${\bf y}$ 為向量、$k$ 為純量。 驗證以下的矩陣運算等式。 ##### Exercise 4(a) 1. $(AB)C = A(BC)$. 2. $A(B + C) = AB + AC$. 3. $A(kB) = k(AB)$. 4. $A({\bf x} + {\bf y}) = A{\bf x} + A{\bf y}$. 5. $A(k{\bf x}) = k(A{\bf x})$. :::warning - [x] 第 4 有少刮號 ::: 答: 1.$((AB)C)_{ij}=[\sum\limits_{s = 1}^n{A_{is}}{B_{st}}]\sum\limits_{t = 1}^p{C_{tj}}=\sum\limits_{s = 1}^n{A_{is}}[\sum\limits_{t = 1}^p{B_{st}}{C_{tj}}]=(A(BC))_{ij}.$ 2.$(A(B + C))_{ij} = \sum\limits_{s = 1}^n{A_{is}}(B_{sj}+C_{sj})=\sum\limits_{s = 1}^n{A_{is}}B_{sj}+\sum\limits_{s = 1}^n{A_{is}}C_{sj}=(AB)_{ij}+(AC)_{ij}.$ 3.$(A(kB))_{ij}=\sum\limits_{s = 1}^n{A_{is}}(kB_{sj})=k\sum\limits_{s = 1}^n{A_{is}}B_{sj}=k(AB)_{ij}.$ ${\bf x} , {\bf y}$向量可視為$s\times 1$之矩陣, 4.$(A({\bf x} + {\bf y}))_{i1} = \sum\limits_{s = 1}^n{A_{is}}({\bf x}_{s1}+{\bf y}_{s1})=\sum\limits_{s = 1}^n{A_{is}}{\bf x}_{s1}+\sum\limits_{s = 1}^n{A_{is}}{\bf y}_{s1}=(A{\bf x})_{i1}+(A{\bf y})_{i1}.$ 5.$(A(k{\bf x}))_{i1}=\sum\limits_{s = 1}^n{A_{is}}(k{\bf x}_{s1})=k\sum\limits_{s = 1}^n{A_{is}}{\bf x}_{s1}=k(A{\bf x})_{i1}.$ ##### Exercise 4(b) 給一組例子使得 $AB \neq BA$。 :::warning - [x] 中與英數空格 - [ ] 粗體位置不對 - [ ] 以下幾題都有空格或粗體的問題 - [x] 設 --> 令 ::: 答: 令 $A$ 為 ${\ 2\times 2}$ 方陣, $B$ 為 ${\ 2\times 3}$ 矩陣, $AB$ 為 ${\ 2\times 3}$ 矩陣,而 $BA$ 無法相乘。 故 $AB \neq BA$; 令 $A$ , $B$ 皆為 ${\ 2\times 2}$ 方陣, $${\bf A }= \begin{bmatrix} 1 & 1 \\ 0 & 1 \\ \end{bmatrix}\text{ and } {\bf B} = \begin{bmatrix} 0 & 1 \\ 1 & 0 \\ \end{bmatrix}. $$ $$ {\bf AB} = \begin{bmatrix} 1 & 1 \\ 1 & 0 \\ \end{bmatrix}\text{ and } {\bf BA} = \begin{bmatrix} 0 & 1 \\ 1 & 1 \\ \end{bmatrix}, $$ $AB \neq BA$,得證。 ##### Exercise 4(c) 若 $A$、$B$、$C$ 皆為可逆矩陣。 則 $(AB)^{-1} = B^{-1}A^{-1}$。 :::warning - [x] c ...。(不要用數學開頭) - [x] AB 要放在數學式,而且應該是 "因 $A$ 和 $B$ 都可逆" - [x] 最長那個式子改成 ::: 答: 已知 $(AB)(AB)^{-1}= I_n$。 因 $AB$ 可逆, $$B^{-1}A^{-1} = B^{-1}A^{-1}I_n = B^{-1}A^{-1}(AB)(AB)^{-1} = (AB)^{-1}. $$ 則$(AB)^{-1} = B^{-1}A^{-1}$,得證。 ##### Exercise 4(d) 定義一個方陣 $M$ 的**跡數**(trace)為其對角線上的所有元素相加,記作 $\operatorname{tr}(M)$。 則 $\operatorname{tr}(A +B) = \operatorname{tr}(A) + \operatorname{tr}(B)$。 :::warning - [x] 等號要進數學模式 ::: 答: 設方陣$A$與$B$可相加。 依定義,$\operatorname{tr}(A)= \sum\limits_{i = 1}^n{A_{ii}}$且$\operatorname{tr}(B)= \sum\limits_{i = 1}^n{B_{ii}}$, 則 $$\begin{aligned} \tr(A+B) &= \sum_{i = 1}^n{({A_{ii}}+{B_{ii}})} \\ &= \sum_{i = 1}^n{A_{ii}}+\sum_{i = 1}^n{B_{ii}} \\ &= \tr(A) + \tr(B), \end{aligned} $$ 得證。 ##### Exercise 4(e) 若 $A$ 是一個 $2\times 2$ 的方陣。 則 $\operatorname{det}(AB) = \operatorname{det}(A) \cdot \operatorname{det}(B)$。 答: 設$B$亦為$2\times 2$ 的方陣。$$A = \begin{bmatrix} a & b \\ c & d \\ \end{bmatrix}\text{ and } {\bf B} = \begin{bmatrix} q & w \\ e & r \\ \end{bmatrix},AB = \begin{bmatrix} aq+eb & aw+br \\ cq+de & cw+dr \\ \end{bmatrix}$$ 則 $$\begin{aligned} \det(AB) &= -bcqr+adqr+bcwe-adwe \\ &=(ad-bc)\times(qr-we) \\ &=\det(A) \cdot \det(B), \end{aligned} $$ 得證。 (實際上 $n\times n$ 都對,但我們還沒學到 $n\times n$ 方陣的行列式值怎麼算。) :::success Good! 一些格式我幫你們改好了。 不過其實這個證明還要講清楚為什麼當 $E_i$ 是基本矩陣時會有 $\det(\prod_i E_i) = \prod_i \det(E_i)$。 ::: 補: 如 $\det(B)=0$,$B$不可逆,則 $\operatorname{ker}(B)$ 不為 $\{\bzero\}$,存在非零向量 $\bx$ 使$B\bx=\bzero$。 又 $A(B\bx)=0=(AB)\bx$,存在非零解使$(AB)\bx=\bzero$, 故 $\det(AB)=0=\det(A) \cdot \det(B)$。 如 $B$ 可逆,則 $B$ 可表示為 $n$ 個基本矩陣之積$B=\prod_{i=1}^{n}E_{i}$。 因此 $$\begin{aligned} \det(AB) = \det(A\prod_{i=1}^{n}E_{i}) &= \det(A)\det(E_1)\det(E_2)\cdots\det(E_n) \\ &= \det(A)\det(\prod_{i=1}^{n}E_{i})=\det(A) \cdot \det(B), \end{aligned} $$ 得證。 :::info 只有一題半是數學錯 其它格式還算不錯(句子都很完整!) 目前分數 5/5 :::

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password

    or

    By clicking below, you agree to our terms of service.

    Sign in via Facebook Sign in via Twitter Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully