# 基本矩陣與列超平行體

This work by Jephian Lin is licensed under a [Creative Commons Attribution 4.0 International License](http://creativecommons.org/licenses/by/4.0/).
$\newcommand{\trans}{^\top}
\newcommand{\adj}{^{\rm adj}}
\newcommand{\cof}{^{\rm cof}}
\newcommand{\inp}[2]{\left\langle#1,#2\right\rangle}
\newcommand{\dunion}{\mathbin{\dot\cup}}
\newcommand{\bzero}{\mathbf{0}}
\newcommand{\bone}{\mathbf{1}}
\newcommand{\ba}{\mathbf{a}}
\newcommand{\bb}{\mathbf{b}}
\newcommand{\bc}{\mathbf{c}}
\newcommand{\bd}{\mathbf{d}}
\newcommand{\be}{\mathbf{e}}
\newcommand{\bh}{\mathbf{h}}
\newcommand{\bp}{\mathbf{p}}
\newcommand{\bq}{\mathbf{q}}
\newcommand{\br}{\mathbf{r}}
\newcommand{\bx}{\mathbf{x}}
\newcommand{\by}{\mathbf{y}}
\newcommand{\bz}{\mathbf{z}}
\newcommand{\bu}{\mathbf{u}}
\newcommand{\bv}{\mathbf{v}}
\newcommand{\bw}{\mathbf{w}}
\newcommand{\tr}{\operatorname{tr}}
\newcommand{\nul}{\operatorname{null}}
\newcommand{\rank}{\operatorname{rank}}
%\newcommand{\ker}{\operatorname{ker}}
\newcommand{\range}{\operatorname{range}}
\newcommand{\Col}{\operatorname{Col}}
\newcommand{\Row}{\operatorname{Row}}
\newcommand{\spec}{\operatorname{spec}}
\newcommand{\vspan}{\operatorname{span}}
\newcommand{\Vol}{\operatorname{Vol}}$
```python
from lingeo import random_int_list, row_operation_process
```
## Main idea
Each $n\times n$ matrix can be viewed as a list of row vectors $\{\br_1,\ldots, \br_n\}$.
We define the **row parallelotope** of $A$ as the polytope
$$
\{c_1\br_1 + \cdots + c_n\br_n : c_i\in [0,1] \text{ for all }i = 1,\ldots, n\}
$$
spanned by the rows $\{\br_1,\ldots, \br_n\}$ of $A$.
Let $\Vol_R(A)$ be the **signed volume** of the row parallelotope.
Then $\Vol_R(A)$ can be defined through the following rules.
- $\Vol_R(I_n) = 1$.
- If $E$ is the elementary matrix of $\rho_i\leftrightarrow\rho_j$, then $E$ **swaps** the $i$-th and $j$-th rows of $A$.
Thus, $\Vol_R(EA) = -\Vol_R(A)$ and we define $\Vol_R(E) = -1$.
- If $E$ is the elementary matrix of $\rho_i:\times k$, then $E$ **rescales** the $i$-th row of $A$.
Thus, $\Vol_R(EA) = k\Vol_R(A)$ and we define $\Vol_R(E) = k$.
(Note that this statement still holds even when $k = 0$.)
- If $E$ is the elementary matrix of $\rho_i:+k\rho_j$, then $E$ **slants** the $i$-th row of $A$ to the direction of $j$-th row.
Thus, $\Vol_R(EA) = \Vol_R(A)$ and we define $\Vol_R(E) = 1$.
As a consequence, if a matrix $A$ is invertible and
can be written as the product a sequence of elementary matrices $F_1\cdots F_k$,
then $\Vol_R(A) = \Vol_R(F_1)\cdots\Vol_R(F_k)\Vol_R(I_n) = \Vol_R(F_1)\cdots\Vol_R(F_k)$.
In contrast, if $A$ is not invertible,
then row parallelotope collapses and is flat $\Vol_R(A) = 0$.
From this point of view,
the value of $\Vol_R(A)$ can be both
the signed volume and
the **scaling factor** changing $\Vol_R(B)$ to $\Vol_R(AB)$ for any $B$.
## Side stories
- operations on spanning vectors
## Experiments
##### Exercise 1
執行以下程式碼。
已知 $A = F_1\cdots F_k$ 是一群單位矩陣的乘積。
```python
### code
set_random_seed(0)
print_ans = False
n = 2
while True:
A = matrix(n, random_int_list(n^2, 3))
if A.det() != 0:
break
elems = row_operation_process(A, inv=True)
pretty_print(A, LatexExpr("="), *elems)
R = identity_matrix(n)
k = 1
vols = [1]
for elem in elems[::-1]:
R = elem * R
vols.append(R.det())
vecs = R.rows()
P = polytopes.parallelotope(vecs).plot(
xmin=-3,
xmax=3,
ymin=-3,
ymax=3,
wireframe="black",
fill="lightgreen"
)
for v in vecs:
P += text("%s"%v, v + vector([0,0.5]), fontweight=1000).plot()
show(P, title="$V_{%s}$"%k)
k += 1
if print_ans:
for k,vol in enumerate(vols):
print("The signed volumn (area) of V%s is"%k, vol)
```
`set_random_seed(0)`
$\begin{bmatrix}-3&3\\1&2\end{bmatrix}=\begin{bmatrix}-3&0\\0&1\end{bmatrix}\begin{bmatrix}1&0\\1&1\end{bmatrix}\begin{bmatrix}1&0\\0&3\end{bmatrix}\begin{bmatrix}1&-1\\0&1\end{bmatrix}$
##### Exercise 1(a)
令 $V_0$ 為單位矩陣的列超平行體。
說明如何從 $V_0$ 得到 $V_1$ 並求出 $V_1$ 的面積。
:::warning
- [x] $V_1$ 為 $\begin{bmatrix}1&-1\\0&1\end{bmatrix}=\begin{bmatrix}1&-1\\0&1\end{bmatrix}\begin{bmatrix}1&0\\0&1\end{bmatrix}$ 的列超平行體。可以由 $V_0$ 的一邊傾斜得來,所以面積不變。 <-- $V_1$ 是幾何形狀,不是矩陣,不要寫等號。下一題也用同樣方式改。
- [x] 有行列式的那行可以去掉
:::
$Ans$
$V_1$ 為$\begin{bmatrix}1&-1\\0&1\end{bmatrix}=\begin{bmatrix}1&-1\\0&1\end{bmatrix}\begin{bmatrix}1&0\\0&1\end{bmatrix}$ 的列超平行體。可以由 $V_0$ 的一邊傾斜得來,所以面積不變。
因為 $\Vol_R(V_0) = 1$,所以 $\Vol_R(V_1) = 1$。
##### Exercise 1(b)
依序說明如何從 $V_i$ 得到 $V_{i+1}$,
並求出 $V_2,\ldots, V_k$ 的面積。
**[由陳冠綸提供]**
$V_2$ 為$\begin{bmatrix}1&-1\\0&3\end{bmatrix}=\begin{bmatrix}1&0\\0&3\end{bmatrix}\begin{bmatrix}1&-1\\0&1\end{bmatrix}$
的列超平行體。可以由 $V_1$ 的一邊伸縮 $3$ 倍得來,所以面積變為 $3$ 倍。
所以 $\Vol_R(V_2) = 3$。
$V_3$ 為$\begin{bmatrix}1&-1\\1&2\end{bmatrix}=\begin{bmatrix}1&0\\1&1\end{bmatrix}\begin{bmatrix}1&-1\\0&3\end{bmatrix}$
的列超平行體。可以由 $V_2$ 的一邊傾斜得來,所以面積不變。
所以 $\Vol_R(V_3) = 3$。
$V_4$ 為$\begin{bmatrix}-3&3\\1&2\end{bmatrix}=\begin{bmatrix}-3&0\\0&1\end{bmatrix}\begin{bmatrix}1&-1\\1&2\end{bmatrix}$
的列超平行體。
為 $V_3$ 的一邊反向伸縮 $3$ 倍,所以面積變為 $-3$ 倍。
所以 $\Vol_R(V_3) = -9$。
## Exercises
##### Exercise 2
對以下矩陣 $A$,
用文字描述它的列平行體,並用求出它的有向體積。
##### Exercise 2(a)
$$
A = \begin{bmatrix}
1 & 0 & 0 \\
0 & 2 & 0 \\
0 & 0 & 3
\end{bmatrix}.
$$
:::warning
- [x] 行列式值等於體積還沒證明,不要使用它。這裡問你直觀的感覺:它是一個長方體,三邊長為...
:::
此平形體是由 $(1,0,0),(0,2,0),(0,0,3)$ 三個向量所組成的立體平行體,
它是一個長方體,三邊長為$1,2,3$。
所以 $\Vol_R(A) =6$
##### Exercise 2(b)
$$
A = \begin{bmatrix}
0 & 1 & 0 \\
2 & 0 & 0 \\
0 & 0 & 3
\end{bmatrix}.
$$
**[由汪駿佑同學提供]**
此平行體是由 $(0,1,0),(2,0,0),(0,0,3)$ 三個向量所組成的立體平行體,
它是一個長方體,三邊長分別為 $1,2,3$,所以 $\Vol_R(A)$ 的體積為 $6$。
然而跟 $2(a)$ 的 $A$ 比較,發現這個矩陣是由 $2(a)$ 的 $A$ 用列運算:$\rho_i \leftrightarrow \rho_j$ 得來,根據定義我們知道
$$
\Vol_R(A_{2(b)}) = -\Vol_R(A_{2(a)}).
$$
即 $2(b)$ 的 $A$ 的列超平行體之 "有向體積" 為 $-6$。
##### Exercise 2(c)
$$
A = \begin{bmatrix}
1 & 1 & 1 \\
1 & 2 & 3 \\
0 & 0 & 0
\end{bmatrix}.
$$
**[由汪駿佑同學提供]**
此平行體是由 $(1,1,1),(1,2,3),(0,0,0)$ 所組成的平行體,
但此平行體扁平地落在 $x - 2y + z = 0$ 的平面上,
所以 $\Vol_R(A) =0$。
##### Exercise 2(d)
$$
A = \begin{bmatrix}
1 & 1 & 0 \\
1 & 2 & 0 \\
1 & 3 & 0
\end{bmatrix}.
$$
**[由汪駿佑同學提供]**
此平行體是由 $(1,1,0),(1,2,0),(1,3,0)$ 所組成的平行體,
但此平行體扁平地落在 $z=0$ 的平面上,
所以 $\Vol_R(A) =0$。
##### Exercise 2(e)
$$
A = \begin{bmatrix}
1 & 2 & 0 \\
3 & 4 & 0 \\
0 & 0 & 5
\end{bmatrix}.
$$
**[由汪駿佑同學提供]**
此平行體是由 $(1,2,0),(3,4,0),(0,0,5)$ 所組成的立體平行體,
我們可以想成先用 $(1,2,0),(3,4,0)$ 組合成此長方形體的底面積,$(0,0,5)$ 則為高。那麼因為
$$
\det\begin{bmatrix} 1 & 2 \\ 3 & 4 \end{bmatrix}
$$
的面積為 $4-6=-2$,所以 $\Vol_R(A) = -2×5 = -10$。
##### Exercise 3
在 $\Vol_R$ 的定義中,假設我們已經接受了
- If $E$ is the elementary matrix of $\rho_i:\times k$, then $E$ **rescales** the $i$-th row of $A$.
Thus, $\Vol_R(EA) = k\Vol_R(A)$ and we define $\Vol_R(E) = k$.
- If $E$ is the elementary matrix of $\rho_i:+k\rho_j\times$, then $E$ **slants** the $i$-th row of $A$ to the direction of $j$-th row.
Thus, $\Vol_R(EA) = \Vol_R(A)$ and we define $\Vol_R(E) = 1$.
說明為什麼
- If $E$ is the elementary matrix of $\rho_i\leftrightarrow\rho_j$, then $E$ **swaps** the $i$-th and $j$-th rows of $A$.
Thus, $\Vol_R(EA) = -\Vol_R(A)$ and we define $\Vol_R(E) = -1$.
中的 $-1$ 是合理的。
**[由汪駿佑同學提供]**
令 $A$ 為一個 $m \times n$ 矩陣 ( 其中 $m$ 可以等於 $n$ ),其中第 $i$ 列為 $\ba_i$ 向量,第 $j$ 列為 $\ba_j$ 向量,即
$$
A = \begin{bmatrix}
~ & \cdots & ~ \\
- & \ba_i & - \\
~ & \cdots & ~ \\
- & \ba_j & - \\
~ & \cdots & ~
\end{bmatrix}.
$$
我們將此兩列互換得到
$$
\begin{bmatrix}
~ & \cdots & ~ \\
- & \ba_j & - \\
~ & \cdots & ~ \\
- & \ba_i & - \\
~ & \cdots & ~
\end{bmatrix}.
$$
不過這個動作可以被其他兩個動作取代,即
$$
\begin{bmatrix}
~ & \cdots & ~ \\
- & \ba_i & - \\
~ & \cdots & ~ \\
- & \ba_j & - \\
~ & \cdots & ~
\end{bmatrix} \xrightarrow{\rho_i:+1\rho_j}
\begin{bmatrix}
~ & \cdots & ~ \\
- & \ba_i + \ba_j & - \\
~ & \cdots & ~ \\
- & \ba_j & - \\
~ & \cdots & ~
\end{bmatrix} \xrightarrow{\rho_j:+(-1)\rho_i}
\begin{bmatrix}
~ & \cdots & ~ \\
- & \ba_i + \ba_j & - \\
~ & \cdots & ~ \\
- & -\ba_i & - \\
~ & \cdots & ~
\end{bmatrix} \xrightarrow{\rho_i:+1\rho_j}
\begin{bmatrix}
~ & \cdots & ~ \\
- & \ba_j & - \\
~ & \cdots & ~ \\
- & -\ba_i & - \\
~ & \cdots & ~
\end{bmatrix} \xrightarrow{\rho_i:\times(-1)}
\begin{bmatrix}
~ & \cdots & ~ \\
- & \ba_j & - \\
~ & \cdots & ~ \\
- & \ba_i & - \\
~ & \cdots & ~
\end{bmatrix}.
$$
根據列運算與列超平行體體積的關係我們可以知道以上四個動作讓新矩陣的值對比 $\Vol_R(A)$ 的值分別為不變,不變,不變,乘 $(-1)$,也就是讓 $\Vol_R(A)$ 乘 $(-1)$。因此我們得知兩列互換這個動作得到新的矩陣 $EA$ 後,$\Vol_R(EA)$ 會是原 $\Vol_R(A)$ 的 $(-1)$ 倍。
因此表現出兩列互換這個動作的基本矩陣 $E$ 之 $\Vol_R$ 值為 $-1$。
**[由黃秋雲同學提供]**
__rule 1__
If $B$ is obtained from $A$ by the row operation $\rho_i:\times k$, then $\Vol_R(B) = k\Vol_R(A)$.
__rule 2__
If $B$ is obtained from $A$ by the row operation $\rho_1:+k \rho_2$ , then $\Vol_R(B) = \Vol_R(A)$.
__rule 3__
If $B$ is obtained from $A$ by the row operation $\rho_1\leftrightarrow\rho_2$ , then $\Vol_R(B) = -\Vol_R(A)$.
Based on the three rules above, the main purpose of this question is to show that "swap" can be done by a sequence of "rescale" and "slant". This can be done by the following actions.
$$
\begin{bmatrix}
\br_i \\ \br_j \\
\end{bmatrix}
\xrightarrow{\rho_i:+\rho_j}
\begin{bmatrix}
\br_i + \br_j \\ \br_j \\
\end{bmatrix}
\xrightarrow{\rho_j:-1\rho_i}
\begin{bmatrix}
\br_i + \br_j \\ -\br_i \\
\end{bmatrix}
\xrightarrow{\rho_j:+1\rho_i}
\begin{bmatrix}
\br_j \\ -\br_i \\
\end{bmatrix}
\xrightarrow{\rho_j:\times (-1)}
\begin{bmatrix}
\br_j \\ \br_i \\
\end{bmatrix}.
$$
Note that the outcome of these actions is the same as swapping the $i$-th and the $j$-th rows. The first action does not change the signed volume because the action belongs to __rule 2__. In the second and third actions it also uses __rule 2__. But it's different in the fourth action because the position of the-i and the-j row in the fourth act changes and it belongs to __rule 1__. So we can see that __rule 3__ is a combination of __rule 1__ and __rule 2__.
If we combine from action 1 to action 4 then the result is $-1$.
Therefore, swapping two rows will make the volume become negative.
##### Exercise 4
利用 $\Vol_R$ 定義中的四條準則,說明以下性質。
##### Exercise 4(a)
若 $A$ 中有一列為零向量,說明 $\Vol_R(A) = 0$。
**[由汪駿佑同學提供]**
因為 $A$ 中有一列零向量,我們可以使用列運算 $\rho_i:\times k$ 讓這一個零列每項的值乘 $k$ 倍,並令這一個新矩陣為 $B$。然而由於 $0$ 乘上任何數字還是 $0$,故 $A = B$。
另外,從 $\Vol_R$ 的定義中得知
$$\Vol_R(B) = k\Vol_R(A).
$$
然而我們也知道 $A=B$,故 $\Vol_R(B) = \Vol_R(A)$。因此我們得到
$$
\Vol_R(B) = \Vol_R(A) = k\Vol_R(A),
$$
所以 $\Vol_R(A) = 0$。(我們可以取 $k = 2$。)
##### Exercise 4(b)
若 $A$ 中有兩列向量相等,說明 $\Vol_R(A) = 0$。
**[由汪駿佑同學提供]**
因為 $A$ 中有兩列向量相等 ( 假定這兩列為第 $i$ 列與第 $j$ 列 ),我們可以使用列運算 $\rho_i:+(-1)\rho_j$ 讓這一列成為零列,從而得到與上面相同的結論。
所以 $\Vol_C(A) = 0$。
##### Exercise 4(c)
若 $A$ 中的列向量集合線性相依,說明 $\Vol_R(A) = 0$。
**[由汪駿佑同學提供]**
假設 $A$ 為 $n \times n$ 矩陣,其列向量為 ${\{\ba_1,\ba_2,\cdots,\ba_n}\}$。
則其中一個向量可以寫成其它向量的線性組合,不失一般性,我們假設 $\ba_i$ 可以寫成
$$
\ba_i = c_1\ba_1 + c_2\ba_2 + \cdots + c_n\ba_n,c_1,c_2,\ldots,c_n \in \mathbb R.
$$
那麼我們可以利用列運算 $\rho_i:+(-c_1)\rho_1$、$\rho_i:+(-c_2)\rho_2$ $\cdots$ 等等運算使得第 $i$ 列成為零列,從而得到與上面相同的結論。
所以 $\Vol_R(A) = 0$。
##### Exercise 5(a)
令
$$
A = \begin{bmatrix}
\frac{1}{\sqrt{3}} & \frac{1}{\sqrt{2}} & \frac{1}{\sqrt{6}}\\
\frac{1}{\sqrt{3}} & -\frac{1}{\sqrt{2}} & \frac{1}{\sqrt{6}}\\
\frac{1}{\sqrt{3}} & 0 & -\frac{2}{\sqrt{6}}\\
\end{bmatrix}.
$$
已知 $A$ 的列向量彼此互相垂直
且長度皆為 $1$。
以直觀的方式猜測 $\Vol_R(A)$。
真的計算看看你的猜測是否正確。
:::info
這個題組的「真的計算看看」指的是用列運算算出答案。
但最終我們會知道 $\Vol_R(A) = \det(A)$,所以也可以。
:::
$Ans:$
猜測 $A$ 的各列向量可張開成一個邊長為 $1$ 的正立方體,
$\Vol_R(A)$ 應為 $1$。
經計算,
$\Vol_R(A) = \det(A) = \frac{1}{3} + \frac{1}{6} + 0 + \frac{1}{6} + 0 + \frac{1}{3} = 1$,
故知猜測正確。
##### Exercise 5(b)
將 $A$ 矩陣的
第一個列向量伸縮為原來的 $3$ 倍,
第二個列向量伸縮為原來的 $4$ 倍,
第三個列向量伸縮為原來的 $5$ 倍,
並得到 $B$ 矩陣。
以直觀的方式猜測 $\Vol_R(B)$。
真的計算看看你的猜測是否正確。
$Ans:$
$$B = \begin{bmatrix}
\frac{3}{\sqrt{3}} & \frac{3}{\sqrt{2}} & \frac{3}{\sqrt{6}}\\
\frac{4}{\sqrt{3}} & -\frac{4}{\sqrt{2}} & \frac{4}{\sqrt{6}}\\
\frac{5}{\sqrt{3}} & 0 & -\frac{10}{\sqrt{6}}\\
\end{bmatrix}.
$$
猜測 $\Vol_R(B)$ 為 $\Vol_R(A)$ 的 $3 \times 4 \times 5$ 倍,即 $60$。
經計算,
$\Vol_R(B) = \det(B) = 20 + 10 + 0 + 10 + 0 + 20 = 60$,
故知猜測正確。
##### Exercise 6
令 $\bx$、$\by$、及 $\bz$ 為 $\mathbb{R}^3$ 中的向量。
令 $V_1$ 為 $\bx, \by, \bz$ 所張出來的平行六面體,
而 $V_2$ 為 $\bx + \by, \by + \bz, \bz + \bx$ 所張出來的平行六面體。
問 $V_2$ 的有向體積是 $V_1$ 的有向體積的幾倍?
**[由汪駿佑同學提供]**
令
$$
A = \begin{bmatrix}
- & \bx & - \\
- & \by & - \\
- & \bz & - \\
\end{bmatrix},
B = \begin{bmatrix}
- & \bx + \by & - \\
- & \by + \bz & - \\
- & \bz + \bx & - \\
\end{bmatrix}.
$$
那麼 $A$ 可以經過以下六個列運算得到 $B$,依序為
$$
A = \begin{bmatrix}
- & \bx & - \\
- & \by & - \\
- & \bz & - \\
\end{bmatrix} \xrightarrow{\rho_1:+\rho_2}
\begin{bmatrix}
- & \bx + \by & - \\
- & \by & - \\
- & \bz & - \\
\end{bmatrix} \xrightarrow{\rho_2:+\rho_3}
\begin{bmatrix}
- & \bx + \by & - \\
- & \by + \bz & - \\
- & \bz & - \\
\end{bmatrix} \xrightarrow{\rho_3:\times 2}
\begin{bmatrix}
- & \bx + \by & - \\
- & \by + \bz & - \\
- & 2 \bz & - \\
\end{bmatrix},
$$
$$
\begin{bmatrix}
- & \bx + \by & - \\
- & \by + \bz & - \\
- & 2 \bz & - \\
\end{bmatrix} \xrightarrow{\rho_3:+(-2)\rho_2}
\begin{bmatrix}
- & \bx + \by & - \\
- & \by + \bz & - \\
- & -2 \by & - \\
\end{bmatrix} \xrightarrow{\rho_3:+\rho_1}
\begin{bmatrix}
- & \bx + \by & - \\
- & \by + \bz & - \\
- & \bx - \by & - \\
\end{bmatrix} \xrightarrow{\rho_3:+\rho_2}
\begin{bmatrix}
- & \bx + \by & - \\
- & \by + \bz & - \\
- & \bz + \bx & - \\
\end{bmatrix} = B.
$$
根據列運算與列超平行體體積的關係我們知道以上動作使得 $\Vol_R(B)$ 的值為 $\Vol_R(A)$ 的兩倍,即 $V_2$ 的有向體積是 $V_1$ 的有向體積的兩倍。
:::info
目前分數 = 4 ± 檢討 = 4
:::