Linear algebra,
learned by doing
用操作理解
線性代數

先猜結果、改一個數,再看圖與算式。從向量空間(vector space)到線性獨立(linear independence),再看矩陣(matrix)如何讓平面變形,最後看看矩陣如何用在語言模型中。

Predict, change one number, then read the picture and the equations. Start with vector spaces, move to linear independence, watch a matrix reshape the plane, and finish by seeing how matrices are used in a language model.

uvu + vO
u=(4,1)、v=(1,3),相加得到 u+v=(5,4),正好是平行四邊形的對角線。第 1 章可以自己改這兩個向量。Adding u=(4,1) and v=(1,3) gives u+v=(5,4), the diagonal of the parallelogram. In Chapter 1 you can change both vectors yourself.

Contents目錄

第一次接觸建議依 1 → 2 → 3 → 4 的順序;已會向量運算,可以直接跳到需要的章節。First time? Follow 1 → 2 → 3 → 4. If you already know vector operations, go straight to the chapter you need.

Vector Space Lab向量空間實驗室

25–30 minutes25–30 分鐘8 core exercises + learning missions8 個基礎練習+探索任務

學會把向量相加、乘上純量,並判斷一個集合是否符合向量空間的規則。

Combine vectors and decide whether a set satisfies the vector-space rules.

Prerequisite先備知識
會算正負數,並能讀懂平面座標 (x,y)。
Signed-number arithmetic and coordinates in the plane.
First experiment第一個操作
把 a 從 1 改成 −1,觀察 au 的方向與 au+bv 的結果。
Change a from 1 to −1 and compare the scaled vector and the sum.
What you can explain完成後你能…
能寫出一個線性組合,並用反例解釋封閉性為何失敗。
Calculate a linear combination and justify a closure counterexample.
VectorVector 向量ScalarScalar 純量ClosureClosure 封閉性AxiomAxiom 公理
Open chapter 1 →開始第 1 章 →

Linear Independence Lab線性相依與線性獨立

30–35 minutes30–35 分鐘8 core exercises + learning missions8 個基礎練習+探索任務

了解「能不能用不全為零的係數,把向量組合成零向量」,以及這與重複資訊的關係。

Find out whether a nontrivial linear combination can cancel to zero.

Prerequisite先備知識
先懂向量加法、純量乘法與線性組合;會解兩個未知數的聯立方程式更好。
Vector operations and linear combinations; simultaneous equations are helpful.
First experiment第一個操作
選「兩個成比例的向量」,試 c₁=−2、c₂=1,看看和是否為零。
Choose proportional vectors and test coefficients −2 and 1.
What you can explain完成後你能…
能給出相依關係,並知道「全部係數是 0」為何不算證明相依。
Give a dependence relation and know why the trivial relation is insufficient.
IndependenceIndependence 線性獨立DependenceDependence 線性相依SpanSpan 張成空間CoefficientCoefficient 係數
Open chapter 2 →開始第 2 章 →

Matrix Transformation Lab矩陣即線性變換

25–30 minutes25–30 分鐘8 core exercises + learning missions8 個基礎練習+探索任務

把 2×2 矩陣看成讓平面變形的函數:看 e₁、e₂ 被送到哪裡,並用行列式解釋面積與方向。

See a 2×2 matrix as a function that reshapes the plane: track e₁ and e₂, and read area and orientation from the determinant.

Prerequisite先備知識
先完成第 1、2 章:會算線性組合,知道兩個向量相依代表成比例。
Chapters 1–2: linear combinations, and dependence of two vectors as proportionality.
First experiment第一個操作
從 A=I 開始,先預測把右上角改成 1 後 e₂ 會去哪裡,再看方格網變斜。
Start at A=I, predict where e₂ goes when the top-right entry becomes 1, then watch the grid shear.
What you can explain完成後你能…
能從矩陣讀出 e₁、e₂ 的像,算出 Av,並用 det 解釋面積倍率、翻面與壓扁。
Read the images of e₁ and e₂ from a matrix, compute Av, and use det to explain area, flips and collapse.
Linear transformationLinear transformation 線性變換ColumnColumn 欄DeterminantDeterminant 行列式OrientationOrientation 方向(定向)
Open chapter 3 →開始第 3 章 →

Transformer Vector LabTransformer 向量與矩陣

20–25 minutes (beginner route)20–25 分鐘(基礎路線)4 core exercises + learning missions4 個基礎練習+探索任務

用小型語言模型範例,理解向量如何表示 token,以及矩陣乘法如何算出候選 token 的分數。

See how token vectors and matrix multiplication produce candidate-token scores.

Prerequisite先備知識
知道向量的座標,會做乘法與加法;不需要先學人工智慧或微積分。
Vector coordinates, multiplication and addition; no AI or calculus background needed.
First experiment第一個操作
先看 token 向量,再按「從矩陣範例開始」,手算 mat 的分數 1×2+2×1=4。
Inspect token vectors, then start the matrix example and calculate the mat score.
What you can explain完成後你能…
能解釋 W 的一列如何和 x 相乘,以及分數與機率有何不同。
Explain one row of Wx and distinguish a score from a probability.
TokenToken 詞元EmbeddingEmbedding 嵌入向量MatrixMatrix 矩陣Attention (optional)Attention 注意力(選讀)
Open chapter 4 →開始第 4 章 →

每章都能獨立使用。表列時間為基礎路線;探索新任務與整理筆記可另預留 15–20 分鐘。先走基礎路線,再展開修理、精簡、出題或控制任務;每章最後都有一題不顯示即時答案的新題,以及可列印的學習筆記。標示「選讀」的內容可以之後再看。Each chapter works on its own. Listed times cover the core route; allow another 15–20 minutes for new missions and notes. Follow the core route, then expand repair, minimal-set, question-design or intervention missions. Finish with a new problem without live answers and printable learning notes. Optional sections can wait.

A simple learning routine怎樣學得更清楚

  1. 先預測:改數字之前,先說你認為會發生什麼。Predict: Before changing a number, say what you expect to happen.
  2. 一次只改一個值:比較前後差異,才知道是哪個改動造成結果。Change one value at a time: Compare before and after, so you know which change caused the result.
  3. 核對一個算式:自己算一個座標或一列乘法,不只相信圖。Verify one calculation: Work out one coordinate or one row product yourself; do not rely on the picture alone.
  4. 答錯就找原因:每題有說明,可修改答案再試。Learn from a wrong answer: Every question explains the idea; edit your answer and try again.
  5. 分清楚證據:這是一次成功的例子、反例,還是對所有情況的證明?Know your evidence: Is this a single example, a counterexample, or a proof for every case?

Before you begin操作小提醒

  • 「列 row」是橫向;「欄 column」是縱向。A row runs across; a column runs down.
  • 前三章可輸入整數、小數或分數,例如 −1/2。Transformer 的數值欄請用小數。Chapters 1–3 accept integers, decimals and fractions such as −1/2. The Transformer lab uses decimals.
  • 圖的刻度可能自動縮放;比較方向時,也要查看旁邊的座標。Diagram axes may rescale; check the coordinates as well as the picture.
  • 練習一次顯示一題,可用選單跳題。重設範例不代表作答失敗。Practice shows one question at a time; use the menu to jump. Resetting an example does not count against you.
  • 不需帳號或網路。作答與筆記會自動存在這台電腦的瀏覽器;公用電腦離開前請按「清除本頁紀錄」。No account or internet needed. Answers and notes are saved in this browser; on a shared computer, use Clear saved work on this page before leaving.
  • 每頁都有術語表(glossary),忘記名詞時可以隨時查閱。Every page has a glossary for when you forget a term.