115 年 國立成功大學人工智慧科技碩士學位學程《計算機數學(含線性代數、離散數學)》

📄 試題原卷 免費註冊後即可對照原始考卷 PDF免費註冊

第 1 題10 分

Consider all simple (loop-free), undirected graphs on a set of 5 distinct labeled vertices V={1,2,3,4,5}V = \{1,2,3,4,5\}. Every edge connects two distinct vertices, and multiple edges are not allowed. Assume that no vertex is isolated (i.e., every vertex has degree at least 1).
(a) How many such graphs have exactly one connected component (i.e., the graph is connected)?
(b) How many such graphs have exactly two connected components?

登入後即可作答並保存紀錄。

這一題的完整詳解

核心觀念

本題考查離散數學中的標號圖計數(Labeled Graph Counting)、連通分支(Connected Components)與排容原理(Inclusion-Exclusion Principle)。

  1. 無孤立點限制(No Isolated Vertices):

    • 頂點集合 V={1,2,3,4,5}V = \{1, 2, 3, 4, 5\},頂點數 n=5n = 5。
    • 頂點 vv 若為孤立點,代表其度數 deg⁡(v)=0\deg(v) = 0。
    • 題目設定「沒有孤立點」(deg⁡(v)≥1,∀v∈V\deg(v) \ge 1, \forall v \in V),這意味著每一個連通分支(Connected Component)包含的頂點數量至少為 22。
  2. 連通分支的大小分拆(Component Partition):
    在頂點總數 n=5n = 5 且每個連通分支大小 ≥2\ge 2 的限制下,分支大小的加總分拆只有兩種可能:

    • 1 個連通分支:分支大小為 55。
    • 2 個連通分支:分支大小為 3+2=53 + 2 = 5(若為 4+14 + 1 則含有大小為 11 的分支,即孤立點,不合題意)。
    • 3 個或更多連通分支:若有 c≥3c \ge 3 個分支,總頂點數至少需要 2c≥6>52c \ge 6 > 5,故不可能存在。
  3. 標號連通圖數量的遞迴公式:
    設 Gn=2(n2)G_n = 2^{\binom{n}{2}} 為 nn 個標號頂點的所有簡單圖總數,CnC_n 為 nn 個標號頂點的連通圖總數。利用固定某一特定頂點所在連通分支大小的推導,可得以下標準遞迴關係式:
    Gn=∑k=1n(n−1k−1)CkGn−k  ⟹  Cn=Gn−∑k=1n−1(n−1k−1)CkGn−kG_n = \sum_{k=1}^n \binom{n-1}{k-1} C_k G_{n-k} \implies C_n = G_n - \sum_{k=1}^{n-1} \binom{n-1}{k-1} C_k G_{n-k}


解題方法

(a) 恰有 1 個連通分支(即連通圖)數量

由於當圖只有 1 個連通分支時,該分支涵蓋全部 5 個頂點(大小為 5),每個頂點的度數自動滿足 deg⁡(v)≥1\deg(v) \ge 1,因此所有 5 個頂點的標號連通圖都天然符合「無孤立點」的條件。
本小題即為求 5 個標號頂點的連通圖數量 C5C_5。

依序計算 n=1,2,3,4,5n = 1, 2, 3, 4, 5 的 GnG_n 與 CnC_n:

  1. n=1n = 1:
    G1=2(12)=1,C1=1G_1 = 2^{\binom{1}{2}} = 1, \quad C_1 = 1
  2. n=2n = 2:
    G2=2(22)=2,C2=G2−(10)C1G1=2−(1×1×1)=1G_2 = 2^{\binom{2}{2}} = 2, \quad C_2 = G_2 - \binom{1}{0} C_1 G_1 = 2 - (1 \times 1 \times 1) = 1
  3. n=3n = 3:
    G3=2(32)=8G_3 = 2^{\binom{3}{2}} = 8
    C3=G3−[(20)C1G2+(21)C2G1]=8−(1×1×2+2×1×1)=8−4=4C_3 = G_3 - \left[ \binom{2}{0} C_1 G_2 + \binom{2}{1} C_2 G_1 \right] = 8 - (1 \times 1 \times 2 + 2 \times 1 \times 1) = 8 - 4 = 4
  4. n=4n = 4:
    G4=2(42)=64G_4 = 2^{\binom{4}{2}} = 64
    C4=G4−[(30)C1G3+(31)C2G2+(32)C3G1]=64−(1×1×8+3×1×2+3×4×1)=64−26=38C_4 = G_4 - \left[ \binom{3}{0} C_1 G_3 + \binom{3}{1} C_2 G_2 + \binom{3}{2} C_3 G_1 \right] = 64 - (1 \times 1 \times 8 + 3 \times 1 \times 2 + 3 \times 4 \times 1) = 64 - 26 = 38
  5. n=5n = 5:
    G5=2(52)=1024G_5 = 2^{\binom{5}{2}} = 1024
🔒

後續完整解題步驟與【答案】

免費註冊,享三天全站完整詳解閱覽。

免費註冊

第 2 題10 分

A network engineer is designing a fault-tolerant routing backbone for a data-center fabric. The backbone consists of 20 routers, arranged physically in a 4×5 cylindrical grid: There are 4 horizontal layers ("rings"), each containing 5 routers. Horizontally, each layer forms a 5-router cycle (i.e., the leftmost and rightmost routers are connected). Vertically, each of the 5 columns also forms a 4-router cycle (i.e., the top and bottom switches are connected). Thus, every router has degree 4: two connections within its horizontal ring, and two within its vertical ring. Determine whether this cylindrical multi-ring backbone H can be embedded on a flat PCB without wiring intersections. Justify your answer using only Euler's formula and girth-based edge bounds. In graph theory, the girth of an undirected graph is the length of the shortest cycle contained in the graph.

登入後即可作答並保存紀錄。

這一題的完整詳解

核心觀念

  1. 平面圖(Planar Graph)與平面嵌入(Planar Embedding):
    若一個圖形可以畫在平面上且邊與邊之間沒有交叉(non-intersecting edges),則稱該圖為平面圖。在 PCB(印刷電路板)單層佈線問題中,無交叉佈線等價於該網路圖 HH 為平面圖。
  2. 頂點數與邊數關係(握手定理, Handshaking Lemma):
    對於簡單圖 G=(V,E)G = (V, E),所有頂點的度數之和等於邊數的兩倍,即 ∑v∈Vdeg⁡(v)=2e\sum_{v \in V} \deg(v) = 2e。
  3. 圖的圍長(Girth, gg):
    無向圖中最短圈(cycle)的長度稱為圍長 gg。
  4. 歐拉公式(Euler's Formula)與圍長邊數上界定理:
    對任何連通平面圖,頂點數 vv、邊數 ee、面數 ff 滿足歐拉公式:
    v−e+f=2v - e + f = 2
    若圖的圍長為 gg(其中 g≥3g \ge 3),由於每個面至少由 gg 條邊圍成,且每條邊至多被 2 個面共用,可得面數與邊數的限制關係 2e≥g⋅f  ⟹  f≤2eg2e \ge g \cdot f \implies f \le \frac{2e}{g}。
    將 f=2−v+ef = 2 - v + e 代入前式,可推導出含圍長條件之平面圖邊數上界公式:
    e≤gg−2(v−2)e \le \frac{g}{g - 2} (v - 2)

解題方法

步驟一:計算網路圖 HH 的頂點數 vv 與邊數 ee

  • 頂點數 vv:
    網路由 4×54 \times 5 的圓柱網格組成,共有 4 層、每層 5 個路由器,因此頂點總數為:
    v=4×5=20v = 4 \times 5 = 20
  • 邊數 ee:
    題目給定每個路由器度數皆為 4(即 4-正則圖, 4-regular graph)。依據握手定理:
    2e=∑v∈Vdeg⁡(v)=20×4=80  ⟹  e=402e = \sum_{v \in V} \deg(v) = 20 \times 4 = 80 \implies e = 40

步驟二:確定圖 HH 的圍長(Girth, gg)

  • 水平方向之環圈長度為 5(C5C_5)。
  • 垂直方向之環圈長度為 4(C4C_4)。
  • 網格中相鄰兩層與相鄰兩欄對應的 4 個頂點可構成長度為 4 的矩形圈。
  • 圖中不存在長度為 3 的圈(三角形),故最短圈長度(圍長)為:
    g=4g = 4

步驟三:運用圍長邊數上界進行平面性推導

假設圖 HH 可嵌入於平面而不交叉(即 HH 為平面圖),則必須滿足圍長 g=4g = 4 之平面圖邊數上界公式:
e≤gg−2(v−2)e \le \frac{g}{g - 2} (v - 2)

將 v=20v = 20 與 g=4g = 4 代入公式右端計算最大許容邊數:
e≤44−2(20−2)=2×18=36e \le \frac{4}{4 - 2} (20 - 2) = 2 \times 18 = 36

🔒

後續完整解題步驟與【答案】

免費註冊,享三天全站完整詳解閱覽。

免費註冊

第 3 題10 分

A self-organizing ad-hoc satellite network consists of multiple satellites placed at arbitrary integer coordinates in 3-dimensional space. Each satellite is modeled as a point Ai∈Z3A_i \in \mathbb{Z}^3. A secure communication link may be established between satellites AiA_i and AjA_j only if the midpoint of the segment AiAjA_iA_j also lies on an integer lattice point. Equivalently, all three coordinate-wise averages must be integers:
xi+xj2,yi+yj2,zi+zj2∈Z.\frac{x_i + x_j}{2}, \frac{y_i + y_j}{2}, \frac{z_i + z_j}{2} \in \mathbb{Z}.
The Space Agency wants to guarantee that even without knowing the positions of the satellites beforehand, there must exist at least one secure link.
(a) Determine the smallest integer NN such that: No matter how the NN satellites are placed in Z3\mathbb{Z}^3, there is always at least one pair whose midpoint is a lattice point (i.e., at least one secure link always exists).
(b) Now modify the secure-link condition: A link is allowed if the total coordinate sum of the two satellites is even, i.e. xi+xj+yi+yj+zi+zj≡0(mod2)x_i + x_j + y_i + y_j + z_i + z_j \equiv 0 \pmod{2}. Under this new rule, determine the new minimum number of satellites guaranteeing that at least one secure link must exist.

登入後即可作答並保存紀錄。

這一題的完整詳解

核心觀念

本題考查**離散數學(Discrete Mathematics)中的鴿籠原理(Pigeonhole Principle / Dirichlet's Box Principle)與同餘關係(Congruence Relation)**之綜合應用。

  1. 中點為晶格點的充要條件:
    三維空間中兩整數點 Ai=(xi,yi,zi)A_i = (x_i, y_i, z_i) 與 Aj=(xj,yj,zj)A_j = (x_j, y_j, z_j) 的中點座標為 (xi+xj2,yi+yj2,zi+zj2)\left(\frac{x_i + x_j}{2}, \frac{y_i + y_j}{2}, \frac{z_i + z_j}{2}\right)。此中點為整數晶格點(Lattice Point)之充要條件為三個分量和皆為偶數:
    xi+xj≡0(mod2),yi+yj≡0(mod2),zi+zj≡0(mod2)x_i + x_j \equiv 0 \pmod{2}, \quad y_i + y_j \equiv 0 \pmod{2}, \quad z_i + z_j \equiv 0 \pmod{2}
    等價於兩點的各對應座標分量具有相同的奇偶性(Parity):
    xi≡xj(mod2),yi≡yj(mod2),zi≡zj(mod2)x_i \equiv x_j \pmod{2}, \quad y_i \equiv y_j \pmod{2}, \quad z_i \equiv z_j \pmod{2}

  2. 座標總和為偶數的充要條件:
    兩點座標總和為偶數:(xi+yi+zi)+(xj+yj+zj)≡0(mod2)(x_i + y_i + z_i) + (x_j + y_j + z_j) \equiv 0 \pmod{2},其充要條件為兩點各自的座標總和同為偶數或同為奇數,即:
    (xi+yi+zi)≡(xj+yj+zj)(mod2)(x_i + y_i + z_i) \equiv (x_j + y_j + z_j) \pmod{2}

  3. 鴿籠原理(Pigeonhole Principle):
    若將 k+1k+1 個物件放入 kk 個盒子(同餘類別)中,則至少有一個盒子包含至少 2 個物件。


解題方法

(a) 子題 (a) 推導過程

  • 步驟一:建立等價類(鴿籠)
    根據三維整數座標各分量的奇偶性(奇數以 11 表示,偶數以 00 表示),每一個整數點 Ai=(xi,yi,zi)A_i = (x_i, y_i, z_i) 可以唯一映射至模 2(Z23\mathbb{Z}_2^3)下的三元組奇偶模式 (xi mod 2,yi mod 2,zi mod 2)(x_i \bmod 2, y_i \bmod 2, z_i \bmod 2)。
    由於每個座標分量只有奇數(1)或偶數(0)兩種可能,故三維空間中共有 2×2×2=23=82 \times 2 \times 2 = 2^3 = 8 種不同的奇偶型態(鴿籠):
    S={(0,0,0),(0,0,1),(0,1,0),(0,1,1),(1,0,0),(1,0,1),(1,1,0),(1,1,1)}\mathcal{S} = \{ (0,0,0), (0,0,1), (0,1,0), (0,1,1), (1,0,0), (1,0,1), (1,1,0), (1,1,1) \}

  • 步驟二:證明充分性(N=9N = 9 必定存在安全鏈結)
    當衛星數量 N=9N = 9 時,由於鴿籠數量為 8,根據鴿籠原理,至少有 2 顆衛星 AiA_i 與 AjA_j 會落入同一個奇偶型態的鴿籠中。
    當 AiA_i 與 AjA_j 具有相同的奇偶型態時:
    xi≡xj(mod2)  ⟹  xi+xj≡0(mod2)  ⟹  xi+xj2∈Zx_i \equiv x_j \pmod{2} \implies x_i + x_j \equiv 0 \pmod{2} \implies \frac{x_i + x_j}{2} \in \mathbb{Z}
    yi≡yj(mod2)  ⟹  yi+yj≡0(mod2)  ⟹  yi+yj2∈Zy_i \equiv y_j \pmod{2} \implies y_i + y_j \equiv 0 \pmod{2} \implies \frac{y_i + y_j}{2} \in \mathbb{Z}
    zi≡zj(mod2)  ⟹  zi+zj≡0(mod2)  ⟹  zi+zj2∈Zz_i \equiv z_j \pmod{2} \implies z_i + z_j \equiv 0 \pmod{2} \implies \frac{z_i + z_j}{2} \in \mathbb{Z}
    因此,AiAjA_i A_j 的中點必定為整數晶格點,即安全鏈結必然存在。

  • 步驟三:證明必要性(N=8N = 8 可能無法建立安全鏈結)
    若衛星數量為 8 顆,我們可以從 8 種奇偶型態中各挑選 1 顆衛星放置。例如:
    A1=(0,0,0), A2=(0,0,1), A3=(0,1,0), A4=(0,1,1)A_1 = (0,0,0), \, A_2 = (0,0,1), \, A_3 = (0,1,0), \, A_4 = (0,1,1)
    A5=(1,0,0), A6=(1,0,1), A7=(1,1,0), A8=(1,1,1)A_5 = (1,0,0), \, A_6 = (1,0,1), \, A_7 = (1,1,0), \, A_8 = (1,1,1)

🔒

後續完整解題步驟與【答案】

免費註冊,享三天全站完整詳解閱覽。

免費註冊

第 4 題10 分

Consider the recurrence: En=4En−1−4En−2+2n+3nE_n = 4E_{n-1}-4E_{n-2} + 2^n + 3n, with initial values, E0=2,E1=10E_0 = 2, E_1 = 10. Estimate the smallest nn such that En>109E_n > 10^9.

登入後即可作答並保存紀錄。

這一題的完整詳解

核心觀念

本題考查**二階常係數非齊次線性遞迴關係式(Non-homogeneous Linear Recurrence Relation)**的求解與指數級數估算。主要使用的數學觀念與公式包含:

  1. 齊次解(Homogeneous Solution):利用特徵方程式(Characteristic Equation)求得二重根(Repeated Root)狀況下的齊次解形式。
  2. 特解(Particular Solution):利用**待定係數法(Method of Undetermined Coefficients)**針對指數項與一次多項式項設出對應特解形式。當非齊次項的底數與特徵根重複(二重根,重數 m=2m=2)時,特解須額外乘以 n2n^2。
  3. 通解與初始條件:通解為齊次解與特解之和(En=En(h)+En(p)E_n = E_n^{(h)} + E_n^{(p)}),利用初始條件求出待定常數。
  4. 數量級估算:利用指數函數 2n2^n 的成長速度進行精確邊界判定。

解題方法

步驟一:求解齊次解 En(h)E_n^{(h)}

考慮對應的齊次遞迴關係式:
En−4En−1+4En−2=0E_n - 4E_{n-1} + 4E_{n-2} = 0

其特徵方程式為:
r2−4r+4=0  ⟹  (r−2)2=0r^2 - 4r + 4 = 0 \implies (r-2)^2 = 0
解得特徵根為 r=2r = 2(二重根)。

故齊次解的形式為:
En(h)=(c1+c2n)2nE_n^{(h)} = (c_1 + c_2 n) 2^n

步驟二:求解特解 En(p)E_n^{(p)}

非齊次項分為兩部分:f1(n)=2nf_1(n) = 2^n 與 f2(n)=3nf_2(n) = 3n。

  1. 針對 f1(n)=2nf_1(n) = 2^n 的特解 En(p1)E_n^{(p1)}:
    因為底數 22 為二重特徵根,特解形式需設定為:
    En(p1)=An22nE_n^{(p1)} = A n^2 2^n
    代回原遞迴關係式中非齊次項 2n2^n 的部分:
    An22n−4A(n−1)22n−1+4A(n−2)22n−2=2nA n^2 2^n - 4 A (n-1)^2 2^{n-1} + 4 A (n-2)^2 2^{n-2} = 2^n
    兩邊同除以 2n−22^{n-2}:
    4An2−8A(n−1)2+4A(n−2)2=44 A n^2 - 8 A (n-1)^2 + 4 A (n-2)^2 = 4
    展開並整理:
    4A[n2−2(n2−2n+1)+(n2−4n+4)]=44 A \left[ n^2 - 2(n^2 - 2n + 1) + (n^2 - 4n + 4) \right] = 4
    4A⋅2=4  ⟹  8A=4  ⟹  A=124 A \cdot 2 = 4 \implies 8A = 4 \implies A = \frac{1}{2}
    得 En(p1)=12n22nE_n^{(p1)} = \frac{1}{2} n^2 2^n。

  2. 針對 f2(n)=3nf_2(n) = 3n 的特解 En(p2)E_n^{(p2)}:
    此項為一次多項式,底數 11 非特徵根,設特解為:
    En(p2)=Bn+CE_n^{(p2)} = B n + C
    代回原遞迴關係式中非齊次項 3n3n 的部分:
    (Bn+C)−4[B(n−1)+C]+4[B(n−2)+C]=3n(B n + C) - 4\left[B(n-1) + C\right] + 4\left[B(n-2) + C\right] = 3n
    展開整理得:
    Bn+(C−4B)=3nB n + (C - 4B) = 3n
    對比係數可得:
    B=3B = 3
    C−4B=0  ⟹  C=12C - 4B = 0 \implies C = 12
    得 En(p2)=3n+12E_n^{(p2)} = 3n + 12。

綜合以上,總特解為:
En(p)=12n22n+3n+12E_n^{(p)} = \frac{1}{2} n^2 2^n + 3n + 12

步驟三:求通解並帶入初始條件

將齊次解與特解相加得到通解:
En=(c1+c2n)2n+12n22n+3n+12E_n = (c_1 + c_2 n) 2^n + \frac{1}{2} n^2 2^n + 3n + 12

帶入初始條件 E0=2,E1=10E_0 = 2, E_1 = 10:

  • 當 n=0n = 0:
    E0=c1+12=2  ⟹  c1=−10E_0 = c_1 + 12 = 2 \implies c_1 = -10
  • 當 n=1n = 1:
🔒

後續完整解題步驟與【答案】

免費註冊,享三天全站完整詳解閱覽。

免費註冊

第 5 題10 分

You are designing the firmware logic for a high-security electronic lock. The lock receives a stream of binary signals (0 or 1) from a keypad. You need to draw the state transition diagrams for two different versions of the security protocol. Use Moore Machine model for both versions. Specifically, use circles to represent states with labels Si where i is the index starting from 0, use arrows to represent transitions, use an arrow to point to the start state, and mark the "Unlock" state as double circles.

(a) The Standard "Header-Trailer" Protocol Specification

  1. Start-up Check: When the system first turns on, it must check for a specific "Header." The very first two signals received must be a 1 followed by another 1.
  2. Security Violation: If the first two signals are anything other than a pair of 1s, the system detects a hack. It must immediately enter a Permanent Lockout state where it ignores all future input and never unlocks.
  3. Monitoring: Once the valid header (11) is received, the system waits. It ignores the specific pattern of the signals in the middle.
  4. Unlocking: The door should unlock if and only if the last two signals received were a 0 followed by another 0.
  5. Relocking: If the system receives more signals after unlocking that break the "00" ending, the door must lock again and go back to monitoring for a new "00" ending.

(b) The Advanced "Strict Rhythm" Protocol Specification
We request a security update to the logic designed in (a). Please modify your Finite State Machine to incorporate the following three specific changes. All other behaviors (like the "11" start-up check) remain the same.

  1. Enforce Alternating Data: Instead of ignoring the signals between the header and the unlock command, the system must now strictly enforce an alternating "0, 1, 0, 1..." pattern.
  2. Immediate Lockout on Error: If this alternating rhythm is broken (for example, if two 1s appear consecutively after the header), the system must immediately enter the Permanent Lockout state.
  3. One-Time Access: The "Relock" feature is removed. Once the door unlocks (upon receiving the "00" suffix), any further input signals are considered a security violation and must trigger the Permanent Lockout state.

登入後即可作答並保存紀錄。

這一題的完整詳解

(a) 標準「 Header-Trailer 」協定規範 (Standard "Header-Trailer" Protocol Specification)

觀念說明

採用 Moore Machine 模型的狀態設計:

  • S0S_0:初始狀態 (Start State)。
  • S1S_1:接收到第 1 個訊號 1。
  • S2S_2:成功驗證 Header 11,進入監控/等待狀態 (Monitoring)。
  • S3S_3:接收到 0(準備解鎖的中介狀態)。
  • S4S_4:成功接收到 Trailer 00,進入解鎖狀態 (Unlock)(雙圓圈)。
  • SLS_L:永久鎖定狀態 (Permanent Lockout)。

狀態轉移邏輯與表單

  1. Header 檢查 (S0→S1→S2S_0 \to S_1 \to S_2):
    • S0S_0: 輸入 1 轉至 S1S_1;輸入 0 轉至 SLS_L。
    • S1S_1: 輸入 1 轉至 S2S_2;輸入 0 轉至 SLS_L。
  2. 監控與解鎖 (S2→S3→S4S_2 \to S_3 \to S_4):
    • S2S_2: 輸入 0 轉至 S3S_3;輸入 1 保持在 S2S_2。
    • S3S_3: 輸入 0 轉至 S4S_4 (Unlock);輸入 1 回到 S2S_2。
    • S4S_4 (Unlock): 輸入 0 保持在 S4S_4 (繼續保持 00 結尾);輸入 1 破壞 00 結尾,退回 S2S_2 重新監控 (Relocking)。
  3. 永久鎖定 (SLS_L):
    • SLS_L: 忽略所有後續輸入,輸入 0 或 1 皆保持在 SLS_L。
目前狀態 Si輸入 0輸入 1輸出 (Output)→S0SLS1LockS1SLS2LockS2S3S2LockS3S4S2Lock((S4))S4S2UnlockSLSLSLLock\begin{array}{c|c|c|c} \text{目前狀態 } S_i & \text{輸入 } 0 & \text{輸入 } 1 & \text{輸出 (Output)} \\ \hline \to S_0 & S_L & S_1 & \text{Lock} \\ S_1 & S_L & S_2 & \text{Lock} \\ S_2 & S_3 & S_2 & \text{Lock} \\ S_3 & S_4 & S_2 & \text{Lock} \\ ((S_4)) & S_4 & S_2 & \text{Unlock} \\ S_L & S_L & S_L & \text{Lock} \\ \end{array}

狀態轉移圖 (State Transition Diagram)

stateDiagram-v2
    direction LR
    [*] --> S0
    S0 --> S1: 1
    S0 --> SL: 0
    S1 --> S2: 1
    S1 --> SL: 0
    S2 --> S2: 1
    S2 --> S3: 0
    S3 --> S2: 1
    S3 --> S4: 0
    S4 --> S4: 0
    S4 --> S2: 1
    SL --> SL: 0, 1

    classDef unlock fill:#e6ffe6,stroke:#00aa00,stroke-width:3px;
    class S4 unlock;

(b) 進階「 Strict Rhythm 」協定規範 (Advanced "Strict Rhythm" Protocol Specification)

觀念說明

依據題目三項修改要求:

  1. 交替節奏:Header 11 之後,資料必須嚴格遵守 0, 1, 0, 1... 之交替順序。
  2. 違規即鎖:若破壞交替節奏(例如出現連續 11),直接轉至永久鎖定狀態 SLS_L。
  3. 單次存取 (One-Time Access):一旦輸入 00 進入解鎖狀態 S4S_4,後續任何輸入(0 或 1)皆視為違規,直接進入 SLS_L。

狀態意義調整:

  • S0,S1,S2S_0, S_1, S_2:Header 11 驗證與 (a) 相同。
  • S3S_3:交替資料中,最後一個輸入為 0 的狀態。
  • S4S_4:成功接收 00 結尾,進入解鎖狀態 (Unlock)(雙圓圈)。
  • S5S_5:交替資料中,最後一個輸入為 1 的狀態。
🔒

後續完整解題步驟與【答案】

免費註冊,享三天全站完整詳解閱覽。

免費註冊

第 6 題20 分

  1. By factoring A into LU, the LU decomposition allows solving Ax = b by first solving Ly = b, followed by Ux = y, each requiring only a single triangular solve. Thus, computing A = LU is crucial in large-scale computer engineering applications.
    (a) Give the complexity of the classic LU decomposition, shown in Algorithm 1. (10%)
    Algorithm 1 LU Decomposition Without Pivoting
    Require: Matrix A ∈ Rnxn
    Ensure: Lower triangular matrix L, Upper triangular matrix U such that A = LU
    1: Initialize L = In, U = O nxn
    2: for k = 1 to n do
    3: for j = k to n do
    4: U_kj = A_kj - Σ(l=1 to k-1) L_ks * U_sk
    5: end for
    6: for i = k+1 to n do
    7: L_ik = (A_ik - Σ(l=1 to k-1) L_il * U_lk) / U_kk
    8: end for
    9: end for
    10: return (L, U)

(b) An improvement of (a) based on the block matrix multiplication is shown in Algorithm 2. Give the complexity of the speed-improved LU decomposition. (10%)
Algorithm 2 Speed-Improved Block LU Decomposition
Require: Matrix A ∈ Rnxn, n is a power of 2
Ensure: Matrices L, U with A = LU
1: function SPEEDIMPROVEDBLOCKLU(A)
2: n = size of A
3: if n = 1 then
4: return ([1], [A11])
5: end if
6: Partition A into blocks: A = [[A11, A12], [A21, A22]]
7: (L11, U11) = SPEEDIMPROVEDBLOCKLU(A11)
8: U12 = SOLVE(L11, A12, lower)
9: L21 = SOLVE(U11, A21, upper)
10: S = A22 - SIMULTIPLY(L21, U12)
11: (L22, U22) = SPEEDIMPROVEDBLOCKLU(S)
12: Construct: L = [[L11, 0], [L21, L22]], U = [[U11, U12], [0, U22]]
13: return (L, U)
14: end function

(c) Given A = [[4, 3], [6, 3]], compute the LU decomposition A = LU using the speed-improved LU decomposition method in (b). (Note: List the key intermediate results from Algorithm 2 to receive full credit.)

登入後即可作答並保存紀錄。

這一題的完整詳解

核心觀念

  1. LU 分解(LU Decomposition)與 Doolittle 演算法:
    將 n×nn \times n 可逆矩陣 AA 分解為下三角矩陣 LL(對角線元素皆為 11 的單位下三角矩陣)與上三角矩陣 UU 的乘積 A=LUA = LU。利用 LU 分解,可將求解 Ax=bA \mathbf{x} = \mathbf{b} 拆解為前向替換(Forward Substitution)Ly=bL \mathbf{y} = \mathbf{b} 與後向替換(Backward Substitution)Ux=yU \mathbf{x} = \mathbf{y} 兩個階段,使大型線性方程組的求解效率大幅提升。

  2. 古典 LU 分解複雜度(Scalar-oriented LU):
    傳統逐個元素求解的 LU 分解(如 Doolittle 演算法)包含三重迴圈,其時間複雜度由浮點運算次數(FLOPs: Floating Point Operations,包含乘法與加減法)決定。

  3. 分塊 LU 分解(Block LU Decomposition)與分治法(Divide-and-Conquer):
    將矩陣分割為 2×22 \times 2 個大小為 n2×n2\frac{n}{2} \times \frac{n}{2} 的子矩陣,利用分治遞迴求解。其關鍵運算包括:

    • 遞迴分解子矩陣
    • 解下/上三角矩陣方程組
    • 計算 Schur 補集(Schur Complement)S=A22−L21U12S = A_{22} - L_{21} U_{12}
  4. 快取區域性與硬體加速(Cache Locality & BLAS-3):
    分塊 LU 分解能將純量運算轉化為塊矩陣乘法(BLAS Level 3 運算),大幅提高 Cache 重用率與記憶體頻寬利用率;若搭配快速矩陣乘法(如 Strassen 演算法),亦可降低理論時間複雜度。


解題方法

(a) 古典 LU 分解演算法(Algorithm 1)的時間複雜度推導

分析 Algorithm 1 的迴圈運算量:
外層迴圈 kk 從 11 執行至 nn:

  1. 第 3–5 行(計算 UU 的第 kk 列):
    jj 從 kk 執行至 nn,共 (n−k+1)(n - k + 1) 次疊代。
    每次內層求和 ∑l=1k−1LklUlj\sum_{l=1}^{k-1} L_{kl} U_{lj} 包含 (k−1)(k-1) 次乘法與 (k−1)(k-1) 次減法,共 2(k−1)2(k-1) 次浮點運算。
  2. 第 6–8 行(計算 LL 的第 kk 行):
    ii 從 k+1k+1 執行至 nn,共 (n−k)(n - k) 次疊代。
    每次包含 (k−1)(k-1) 次乘法、(k−1)(k-1) 次減法及 11 次除法,共 2(k−1)+12(k-1) + 1 次浮點運算。

總運算量求和:
W(n)=∑k=1n[(n−k+1)⋅2(k−1)+(n−k)⋅(2(k−1)+1)]W(n) = \sum_{k=1}^{n} \left[ (n - k + 1) \cdot 2(k - 1) + (n - k) \cdot (2(k - 1) + 1) \right]

展開最高次項(n3n^3 項):

W(n)≈∑k=1n4(n−k)(k−1)=4∫0n(nk−k2) dk=4(n32−n33)=23n3 FLOPs\begin{aligned} W(n) &\approx \sum_{k=1}^{n} 4(n - k)(k - 1) \\ &= 4 \int_{0}^{n} (nk - k^2) \, dk = 4 \left( \frac{n^3}{2} - \frac{n^3}{3} \right) = \frac{2}{3} n^3 \text{ FLOPs} \end{aligned}

其中包含 13n3\frac{1}{3} n^3 次乘法與 13n3\frac{1}{3} n^3 次加減法。
因此,古典 LU 分解的時間複雜度為 Θ(n3)\Theta(n^3)(或 O(n3)O(n^3))。


(b) 改進型分塊 LU 分解演算法(Algorithm 2)的時間複雜度推導

設大小為 n×nn \times n 矩陣的分塊 LU 分解時間複雜度為 T(n)T(n)。分析 Algorithm 2 各步驟之複雜度:

  1. 第 7 行:呼叫 SPEEDIMPROVEDBLOCKLU(A11),子矩陣大小為 n2×n2\frac{n}{2} \times \frac{n}{2},耗時 T(n/2)T(n/2)。
  2. 第 8 行:解 L11U12=A12L_{11} U_{12} = A_{12}(三角方程組求解),大小為 n2×n2\frac{n}{2} \times \frac{n}{2},耗時 Θ((n/2)3)\Theta((n/2)^3)。
  3. 第 9 行:解 L21U11=A21L_{21} U_{11} = A_{21}(三角方程組求解),大小為 n2×n2\frac{n}{2} \times \frac{n}{2},耗時 Θ((n/2)3)\Theta((n/2)^3)。
  4. 第 10 行:計算 Schur 補集 S=A22−L21U12S = A_{22} - L_{21} U_{12},包含一次 n2×n2\frac{n}{2} \times \frac{n}{2} 的矩陣乘法與一次矩陣減法。
  5. 第 11 行:呼叫 SPEEDIMPROVEDBLOCKLU(S),子矩陣大小為 n2×n2\frac{n}{2} \times \frac{n}{2},耗時 T(n/2)T(n/2)。

複雜度分析與遞迴關係式:

  • 情況一:採用標準矩陣乘法
    矩陣乘法與三角求解的時間複雜度均為 Θ(n3)\Theta(n^3)。遞迴關係式為:
    T(n)=2T(n2)+Θ(n3)T(n) = 2 T\left(\frac{n}{2}\right) + \Theta(n^3)
    根據主定理(Master Theorem),其中 a=2,b=2a = 2, b = 2,log⁡ba=log⁡22=1\log_b a = \log_2 2 = 1。
    因為 f(n)=Θ(n3)=Ω(nlog⁡22+ϵ)f(n) = \Theta(n^3) = \Omega(n^{\log_2 2 + \epsilon})(取 ϵ=2>0\epsilon = 2 > 0),故時間複雜度為:
    T(n)=Θ(n3)T(n) = \Theta(n^3)
    (註:此方法稱為 Speed-Improved 是因為將純量運算改為塊矩陣運算後,大幅減少記憶體存取瓶頸與 Cache Miss,實際執行速度比古典 LU 分解快數倍。)

  • 情況二:結合快速矩陣乘法(如 Strassen 演算法)
    若矩陣乘法與三角求解採用複雜度為 Θ(nω)\Theta(n^\omega) 的快速演算法(其中 ω=log⁡27≈2.807\omega = \log_2 7 \approx 2.807),則遞迴關係式為:
    T(n)=2T(n2)+Θ(nω)T(n) = 2 T\left(\frac{n}{2}\right) + \Theta(n^\omega)
    由主定理可得整體理論時間複雜度降低為:
    T(n)=Θ(nω)=Θ(nlog⁡27)≈Θ(n2.807)T(n) = \Theta(n^\omega) = \Theta(n^{\log_2 7}) \approx \Theta(n^{2.807})


(c) 實例計算:求解 A=[4363]A = \begin{bmatrix} 4 & 3 \\ 6 & 3 \end{bmatrix} 之 LU 分解

按照 Algorithm 2 步驟詳細推導:

  1. 矩陣分塊(第 6 行):
    n=2n = 2。將 AA 拆分為四個 1×11 \times 1 的塊:
    A11=[4],A12=[3],A21=[6],A22=[3]A_{11} = [4], \quad A_{12} = [3], \quad A_{21} = [6], \quad A_{22} = [3]
🔒

後續完整解題步驟與【答案】

免費註冊,享三天全站完整詳解閱覽。

免費註冊

第 7 題20 分

  1. Let A∈Rm×nA \in \mathbb{R}^{m \times n} with m>nm > n, and assume that AA is rank-deficient, i.e., rank(A)<n\text{rank}(A) < n. ATAA^T A is positive semi-definite.
    (a) Let λ>0\lambda > 0. Show that the matrix ATA+λIA^T A + \lambda I is positive definite. (10%)
    (b) Derive the closed-form solution for x∗=arg⁡min⁡x∈Rn∥Ax−b∥2+λ∥x∥2x^* = \arg \min_{x \in \mathbb{R}^n} \|Ax - b\|^2 + \lambda \|x\|^2, λ>0\lambda > 0. (10%)

登入後即可作答並保存紀錄。

這一題的完整詳解

核心觀念

  1. 正定矩陣(Positive Definite Matrix)定義與性質:
    對於實對稱矩陣 M∈Rn×nM \in \mathbb{R}^{n \times n},若對所有非零向量 x∈Rnx \in \mathbb{R}^n(x≠0x \neq 0),二次形式均滿足 xTMx>0x^T M x > 0,則稱 MM 為正定矩陣。正定矩陣的所有特徵值皆為嚴格正數,且必為可逆矩陣(Non-singular)。
  2. 正半定矩陣(Positive Semi-Definite Matrix):
    對任意矩陣 A∈Rm×nA \in \mathbb{R}^{m \times n},ATAA^T A 必為實對稱矩陣,且對任意向量 x∈Rnx \in \mathbb{R}^n,滿足 xTATAx=(Ax)T(Ax)=∥Ax∥2≥0x^T A^T A x = (Ax)^T (Ax) = \|Ax\|^2 \ge 0,故 ATAA^T A 為正半定矩陣。
  3. 脊回歸(Ridge Regression / Tikhonov Regularization):
    當矩陣 AA 秩虧(Rank-deficient,即 rank(A)<n\text{rank}(A) < n)時,ATAA^T A 為奇異矩陣不可逆,傳統最小平方法(Least Squares)無唯一解。加入 L2L_2 正則化項 λ∥x∥2\lambda \|x\|^2(λ>0\lambda > 0)後,能保證海森矩陣嚴格正定,從而導出唯一的閉形式解(Closed-form Solution)。
  4. 向量微分與嚴格凸函數極值條件:
    多元二次目標函數的梯度(Gradient)為零向量且海森矩陣(Hessian Matrix)正定時,對應的臨界點(Critical Point)必為全域唯一最小值。

解題方法

  • (a) 小題切入點:
    依據正定矩陣的兩大要素進行證明:

    1. 證明 ATA+λIA^T A + \lambda I 為實對稱矩陣。
    2. 對任意非零向量 x≠0x \neq 0,展開二次形式 xT(ATA+λI)xx^T (A^T A + \lambda I) x,利用範數非負性 ∥Ax∥2≥0\|Ax\|^2 \ge 0 以及 λ∥x∥2>0\lambda \|x\|^2 > 0,證明其結果必大於零。
  • (b) 小題切入點:
    將範數展開為向量內積形式 J(x)=(Ax−b)T(Ax−b)+λxTxJ(x) = (Ax - b)^T (Ax - b) + \lambda x^T x。對向量 xx 計算梯度並令其為零向量 ∇xJ(x)=0\nabla_x J(x) = 0。結合 (a) 小題所得 ATA+λIA^T A + \lambda I 為正定矩陣(故逆矩陣存在且目標函數為嚴格凸函數),即可解出唯一的閉形式解 x∗x^*。


選項分析

(本題為計算推導題,以下針對 (a)、(b) 兩小題進行詳細的數學推導與分析)

(a) 證明矩陣 ATA+λIA^T A + \lambda I 為正定矩陣

  1. 驗證對稱性:
    (ATA+λI)T=(ATA)T+(λI)T=AT(AT)T+λI=ATA+λI(A^T A + \lambda I)^T = (A^T A)^T + (\lambda I)^T = A^T (A^T)^T + \lambda I = A^T A + \lambda I
    證明 ATA+λIA^T A + \lambda I 為實對稱矩陣。

  2. 驗證二次形式(Quadratic Form)正定性:
    任取一非零向量 x∈Rnx \in \mathbb{R}^n(即 x≠0x \neq 0):
    xT(ATA+λI)x=xTATAx+λxTIx=(Ax)T(Ax)+λxTx=∥Ax∥2+λ∥x∥2x^T (A^T A + \lambda I) x = x^T A^T A x + \lambda x^T I x = (Ax)^T (Ax) + \lambda x^T x = \|Ax\|^2 + \lambda \|x\|^2

    • 根據向量範數性質,對任意向量 AxAx 均有 ∥Ax∥2≥0\|Ax\|^2 \ge 0。
    • 因為 x≠0x \neq 0,其歐式範數平方 ∥x∥2>0\|x\|^2 > 0;又題目給定 λ>0\lambda > 0,故 λ∥x∥2>0\lambda \|x\|^2 > 0。
      將兩項相加可得:
      xT(ATA+λI)x=∥Ax∥2+λ∥x∥2>0x^T (A^T A + \lambda I) x = \|Ax\|^2 + \lambda \|x\|^2 > 0
  3. 結論:
    由實對稱性與對所有 x≠0x \neq 0 皆滿足二次形式大於零之定義,矩陣 ATA+λIA^T A + \lambda I 必為正定矩陣。(證畢)


(b) 推導 x∗=arg⁡min⁡x∈Rn∥Ax−b∥2+λ∥x∥2x^* = \arg \min_{x \in \mathbb{R}^n} \|Ax - b\|^2 + \lambda \|x\|^2 的閉形式解

🔒

後續完整解題步驟與【答案】

免費註冊,享三天全站完整詳解閱覽。

免費註冊

其他考古題

115 年成功大學的其他科目

成功大學《計算機數學》其他年度