owned this note
owned this note
Published
Linked with GitHub
# 小型矩陣的行列式值
Determinant for small matrices

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}}
\newcommand{\sgn}{\operatorname{sgn}}
\newcommand{\idmap}{\operatorname{id}}
\newcommand{\am}{\operatorname{am}}
\newcommand{\gm}{\operatorname{gm}}
\newcommand{\mult}{\operatorname{mult}}
\newcommand{\iner}{\operatorname{iner}}$
```python
from lingeo import random_good_matrix
```
## Main idea
In this section we explore some basic properties of the determinant of a $2\times 2$ or a $3\times 3$ matrix.
Let
$$
A = \begin{bmatrix}
a & b \\
c & d
\end{bmatrix}
$$
be a $2\times 2$ matrix.
Then its **determinant** is defined as
$$
\det(A) = ad - bc.
$$
When
$$
A = \begin{bmatrix}
a & b & c \\
d & e & f \\
g & h & i
\end{bmatrix}
$$
is a $3\times 3$ matrix, the **determinant** is
$$
\begin{aligned}
\det(A) &= aei - afh - bdi + bfg + cdh - ceg \\
&= a(ei - fh) - b(di -fg) + c(dh - eg).
\end{aligned}
$$
Let $n = 2,3$ and $A$ an $n\times n$ matrix.
Then the determinant functions have the following basic properties.
(See Section 108 for the notations of row operations.)
- $\det(I_n) = 1$.
- If $B$ is obtained from $A$ by performing the row operation $\rho_i\leftrightarrow\rho_j$, then $\det(B) = -\det(A)$.
- If $B$ is obtained from $A$ by performing the row operation $\rho_i:\times k$, then $\det(B) = k\det(A)$.
- If $B$ is obtained from $A$ by performing the row operation $\rho_i:+k\rho_j$, then $\det(B) = \det(A)$.
When $A$ is a $2\times 2$ matrix, one may construct a _parallelogram_ spanned by its row vectors.
It is known that $\det(A)$ is the _signed area_ of this parallelogram.
When $A$ is a $3\times 3$ matrix, one may construct a _parallelepiped_ spanned by its row vectors.
It is known that $\det(A)$ is the _signed volume_ of this parallelepiped.
The same statement holds when the row vectors are replaced with the column vectors.
As a consequence, $\det(A) \neq 0$ if and only if $A$ is invertible.
For any sqaure matrices $A$ and $B$ of the same size,
the determinant function also has the following properties.
- $\det(A) = \det(A\trans)$.
- $\det(AB) = \det(A)\det(B)$.
## Side stories
- characteristic polynomial
## Experiments
##### Exercise 1
執行以下程式碼。
<!-- eng start -->
Run the code below.
<!-- eng end -->
```python
### code
set_random_seed(0)
print_ans = False
n = 2
k1 = 2
k2 = 3
A1 = random_good_matrix(n,n,n) * choice([-2,-1,1,2])
A2 = copy(A1)
A2.swap_rows(0,1)
A3 = copy(A2)
A3.rescale_row(1,k1)
A4 = copy(A3)
A4.add_multiple_of_row(1,0,k2)
print("A1")
pretty_print(A1)
print("A2")
pretty_print(A2)
print("A3")
pretty_print(A3)
print("A4")
pretty_print(A4)
if print_ans:
print("det(A1) =", A1.det())
print("A2 is obtained from A1 by swapping rows, so ")
print("det(A2) = - det(A1) =", A2.det())
print("A3 is obtained from A2 by rescaling a row, so ")
print("det(A3) = %s * det(A2) ="%k1, A3.det())
print("A4 is obtained from A3 by adding a multiple of a row to the other, so ")
print("det(A4) = det(A3) =", A4.det())
```
##### Exercise 1(a)
用定義計算 $\det(A_1)$。
<!-- eng start -->
Find $\det(A_1)$ by definition.
<!-- eng end -->
##### Exercise 1(a) -- answer here:)
Run the code above and get
$$
A_1 = \begin{bmatrix}
-2 & -6 \\
-10 & -32
\end{bmatrix}.
$$
According to the definition, $\det(A_1)$ equals to $(-2)(-32)-(-6)(-10)=4$
##### Exercise 1(b)
用定義計算 $\det(A_2)$。
已知 $A_2$ 可以由 $A_1$ 經過列運算得出,
利用 $\det(A_1)$ 再次計算 $\det(A_2)$ 來驗證答案。
<!-- eng start -->
Find $\det(A_2)$ by definition. Suppose we know that $A_2$ can be obtained from $A_1$ by some row operation. Use $\det(A_1)$ to find $\det(A_2)$ again to verify your previous answer.
<!-- eng end -->
##### Exercise 1(b) -- answer here:)
From the definition of the determinant, we can find $\det(A_2)=(-10)(-6)-(-2)(-32)=-4$.
We know that $A_2$ can be obtained from $A_1$ by row operation $\rho_1\leftrightarrow\rho_2$ so $\det(A_2)=-\det(A_1)$.
From Exercise 1(a) we know $\det(A_1)=4$, so we know that $\det(A_2)=-4$.
##### Exercise 1(c)
用定義計算 $\det(A_3)$。
已知 $A_3$ 可以由 $A_2$ 經過列運算得出,
利用 $\det(A_2)$ 再次計算 $\det(A_3)$ 來驗證答案。
<!-- eng start -->
Find $\det(A_3)$ by definition. Suppose we know that $A_3$ can be obtained from $A_2$ by some row operation. Use $\det(A_2)$ to find $\det(A_3)$ again to verify your previous answer.
<!-- eng end -->
##### Exercise 1(c) -- answer here:)
:::warning
- [x] $*2$ --> $\times 2$, replace other $*$ with $\times$ or $\cdot$
:::
Run the code above and get
$$
A_3 = \begin{bmatrix}
-10 & -32\\
-4 & -12
\end{bmatrix}.
$$
According to the definition, $\det(A_3)$ equals to $(-10)(-12)-(32)(-4)=-8$.
We know that $A_3$ can be obtained from $A_2$ by row operation $\rho_2:\times2$, so $\det(A_3)=2\times\det(A_2)=2\times(-4)=-8$.
##### Exercise 1(d)
用定義計算 $\det(A_4)$。
已知 $A_4$ 可以由 $A_3$ 經過列運算得出,
利用 $\det(A_3)$ 再次計算 $\det(A_4)$ 來驗證答案。
<!-- eng start -->
Find $\det(A_4)$ by definition. Suppose we know that $A_4$ can be obtained from $A_3$ by some row operation. Use $\det(A_3)$ to find $\det(A_4)$ again to verify your previous answer.
<!-- eng end -->
##### Exercise 1(d) -- answer here:)
Run the code above and get
$$
A_4 = \begin{bmatrix}
-10 & -32\\
-34 & -108
\end{bmatrix}.
$$
:::warning
- [x] $det$ --> $\det$
:::
According to the definition, $\det(A_3)$ equals to $(-10)(-108)-(32)(-34)=-8$.
We know that $A_4$ can be obtained from $A_3$ by row operation $\rho_2:+3\rho_1$, so $\det(A_4)=\det(A_3)=-8$.
:::warning
Please answer the question below.
:::
:::info
What do the experiments try to tell you? (open answer)
行列式值會隨著列運算有一定的改變
:::
## Exercises
##### Exercise 2
以下練習驗證行列式值和矩陣是否可逆的關係。
<!-- eng start -->
Through the following exercises, explore the relation between the determinant and the invertibility of a matrix.
<!-- eng end -->
##### Exercise 2(a)
寫出一個行列式值為 $0$
且矩陣中每項皆不為 $0$
的 $3\times 3$ 矩陣。
用列運算判斷其是否可逆。
<!-- eng start -->
Find a $3\times 3$ matrix with zero determinant such that all its entries are nonzero. Determine if it is invertible by row operations.
<!-- eng end -->
##### Exercise 2(a) -- answer here:
:::warning
- [x] $3\times 3$
- [x] Use $\rightarrow$ instead of "to".
- [x] REF and RREF are different. RREF requires you to kill all entries above a pivot.
:::
One example of a $3\times3$ matrix with zero determinant and all entries nonzero is:
$$
A = \begin{bmatrix}
1 & 2 & 3\\
4 & 5 & 6\\
7 & 8 & 9
\end{bmatrix}.
$$
To determine if this matrix is invertible by row operations, we can row-reduce it to row echelon form using elementary row operations:
$$
A = \begin{bmatrix}
1 & 2 & 3\\
4 & 5 & 6\\
7 & 8 & 9
\end{bmatrix}.
$$
$\rightarrow$
$$
A = \begin{bmatrix}
1 & 2 & 3\\
0 & -3 & -6\\
0 & 0 & 0
\end{bmatrix}.
$$
$\rightarrow$
$$
A = \begin{bmatrix}
1 & 2 & 3\\
0 & 1 & 2\\
0 & 0 & 0
\end{bmatrix}.
$$
The resulting matrix is in row echelon form, and has a row of zeros, which means its determinant is zero. Since the determinant is nonzero if and only if the matrix is invertible, we can conclude that this matrix is not invertible.
##### Exercise 2(b)
寫出一個行列式值不為 $0$
且矩陣中每項皆不為 $0$
的 $3\times 3$ 矩陣。
用列運算判斷其是否可逆。
<!-- eng start -->
Find a $3\times 3$ matrix with nonzero determinant such that all its entries are nonzero. Determine if it is invertible by row operations.
<!-- eng end -->
##### Exercise 2(b) -- answer here:
:::warning
Same as previous problem.
:::
Let matrix $A$:
$$
A = \begin{bmatrix}
1 & 3 & 6\\
5 & 2 & 7\\
9 & 8 & 4
\end{bmatrix}.
$$
(REF)
$$
A = \begin{bmatrix}
1 & 2 & 3\\
0 & -3 & -6\\
7 & 8 & 9
\end{bmatrix}.
$$
$\rightarrow$
$$
A = \begin{bmatrix}
1 & 2 & 3\\
0 & -12 & -23\\
0 & 0 & -95
\end{bmatrix}.
$$
$\rightarrow$
$$
A = \begin{bmatrix}
1 & 2 & 3\\
0 & 1 & 1\\
0 & 0 & 1
\end{bmatrix}.
$$
The resulting matrix is in row echelon form, and does not have a row of zeros. Therefore, we can conclude that the original matrix is invertible, since it has nonzero determinant.
##### Exercise 2(c)
令
$$
A_x = \begin{bmatrix}
2 - x & 3 \\
3 & 2 - x
\end{bmatrix}.
$$
找出所有會讓 $A_x$ 奇異(不可逆)的 $x$。
對每個這樣的 $x$,求出一個非零向量 $\bv_x$ 使得 $A_x\bv_x = \bzero$。
<!-- eng start -->
Let
$$
A_x = \begin{bmatrix}
2 - x & 3 \\
3 & 2 - x
\end{bmatrix}.
$$
Find all possible $x$ such that $A_x$ is singular (not invertible). For each of such $x$, find a nonzero vector $\bv_x$ such that $A_x\bv_x = \bzero$.
<!-- eng end -->
##### Exercise 2(c) -- answer here:
:::warning
- [x] $\times$
- [x] Fix the typo $A_($
:::
According to the definition, $\det(A) \neq 0$ if and only if $A$ is invertible.
We need to find $\det(A)=0$ such that $A_x$ is singular (not invertible).
$\det(A)=(2-x)(2-x)-3\times3=(2-x-3)(2-x+3)=(-1-x)(5-x)$
When $\det(A)=0$, $x=5$ or $x=-1$.
When $x=5$,
$$
A_5=\begin{bmatrix}
-3 & 3\\
3 & -3
\end{bmatrix}.
$$
Find
$$
\bv_5=\begin{bmatrix}
1 \\
1
\end{bmatrix}
$$
such that $A_5\bv_5=0$ .
When $x=-1$,
$$
A_{-1}=\begin{bmatrix}
3 & 3\\
3 & 3
\end{bmatrix}.
$$
Find
$$
\bv_{-1}=\begin{bmatrix}
1 \\
-1
\end{bmatrix}
$$
such that $A_{-1}\bv_{-1}=0$.
##### Exercise 2(d)
令
$$
A_x = \begin{bmatrix}
0 - x & 1 & 1 \\
1 & 0 - x & 0 \\
1 & 0 & 0 - x \\
\end{bmatrix}.
$$
找出所有會讓 $A_x$ 奇異(不可逆)的 $x$。
對每個這樣的 $x$,求出一個非零向量 $\bv_x$ 使得 $A_x\bv_x = \bzero$。
<!-- eng start -->
Let
$$
A_x = \begin{bmatrix}
0 - x & 1 & 1 \\
1 & 0 - x & 0 \\
1 & 0 & 0 - x \\
\end{bmatrix}.
$$
Find all possible $x$ such that $A_x$ is singular (not invertible). For each of such $x$, find a nonzero vector $\bv_x$ such that $A_x\bv_x = \bzero$.
<!-- eng end -->
##### Exercise 2(d) -- answer here:
:::warning
- [x] typo: knoe
:::
From the main idea we know that $\det(A) \neq 0$ if and only if $A$ is invertible, so if $A_x$ is singular $\det(A_x)=0$. From the definition $\det(A_x)=(-x)^3+0+0-(-x)-(-x)-0=-x^3+2x=0,$ $x=0, \sqrt2, -\sqrt2$.
$$
A_0 = \begin{bmatrix}
0 & 1 & 1 \\
1 & 0 & 0 \\
1 & 0 & 0 \\
\end{bmatrix},
A_\sqrt2 = \begin{bmatrix}
-\sqrt2 & 1 & 1 \\
1 & -\sqrt2 & 0 \\
1 & 0 & -\sqrt2 \\
\end{bmatrix},
A_{-\sqrt2} = \begin{bmatrix}
\sqrt2 & 1 & 1 \\
1 & \sqrt2 & 0 \\
1 & 0 & \sqrt2 \\
\end{bmatrix}.
$$
When $x=0$, we can find $\bv_x = \begin{bmatrix}
0 \\
1 \\
-1
\end{bmatrix}$.
When $x=\sqrt2$, we can find $\bv_x = \begin{bmatrix}
\sqrt2 \\
1 \\
1
\end{bmatrix}$.
When $x={-\sqrt2}$, we can find $\bv_x = \begin{bmatrix}
-\sqrt2 \\
1 \\
1
\end{bmatrix}$.
##### Exercise 3
令 $n = 2,3$、且 $A$ 為一 $n\times n$ 的矩陣。
利用定義證明以下性質:
- $\det(I_n) = 1$.
- If $B$ is obtained from $A$ by performing the row operation $\rho_i\leftrightarrow\rho_j$, then $\det(B) = -\det(A)$.
- If $B$ is obtained from $A$ by performing the row operation $\rho_i:\times k$, then $\det(B) = k\det(A)$.
- If $B$ is obtained from $A$ by performing the row operation $\rho_i:+k\rho_j\times$, then $\det(B) = \det(A)$.
<!-- eng start -->
Let $n = 2,3$ and $A$ an $n\times n$ matrix. Prove the following properties by definition:
- $\det(I_n) = 1$.
- If $B$ is obtained from $A$ by performing the row operation $\rho_i\leftrightarrow\rho_j$, then $\det(B) = -\det(A)$.
- If $B$ is obtained from $A$ by performing the row operation $\rho_i:\times k$, then $\det(B) = k\det(A)$.
- If $B$ is obtained from $A$ by performing the row operation $\rho_i:+k\rho_j\times$, then $\det(B) = \det(A)$.
<!-- eng end -->
**[由 :cloud: 提供]**
### Exercise 3 -- answer
* >$\det(I_n) = 1$
If $n=2$, let $I_2=\begin{bmatrix}
1 & 0 \\
0 & 1\\\end{bmatrix}.$
According to the definition of determinant, its determinant is $\det(I_2) = 1^2 - 0=1.$
If $n=3$, let $I_3=\begin{bmatrix}
1 & 0 & 0\\
0 & 1 & 0\\
0 & 0 & 1\\\end{bmatrix}.$
According to the definition of determinant, its determinant is $\det(I_3) = 1^3 - 0=1.$
* >If $B$ is obtained from $A$ by performing the row operation $\rho_i\leftrightarrow\rho_j$, then $\det(B) = -\det(A)$.
When $n=2$ let $A_1=\begin{bmatrix}
a & b \\
c & d\\\end{bmatrix}$; when $n=3$ let $A_2=\begin{bmatrix}
a & b & c\\
d & e & f\\
g & h & i\\\end{bmatrix}.$
Suppose $B_1$ is obtained from $A_1$ by performing the row operation $\rho_1\leftrightarrow\rho_2$, then
$B_1=\begin{bmatrix}
c & d\\
a & b\\\end{bmatrix}.$ Next, we calculate determinant, we found that $\det(B)=bc-ad=-(ad-bc)=-\det(A).$
Suppose $B_2$ is obtained from $A_2$ by performing the row operation $\rho_1\leftrightarrow\rho_3$, then
$B_2=\begin{bmatrix}
g & h & i\\
d & e & f\\
a & b & c\\\end{bmatrix}.$ Next, we calculate determinant, we found that
$$
\begin{aligned}
\det(B) &= afh+bdi+ceg-aei-cdh-bfg \\
&=-(aei+bfg+cdh-afh-bdi-ceg)\\
&=-\det(A)
\end{aligned}
$$
* >If $B$ is obtained from $A$ by performing the row operation $\rho_i:\times k$, then $\det(B) = k\det(A)$.
Suppose $B_1$ is obtained from $A_1$ by performing the row operation $\rho_1:\times k$, then
$B_1=\begin{bmatrix}
ka & kb\\
c & d\\\end{bmatrix}.$ Next, we calculate determinant, we found that $\det(B_1)=kad-kbc=k(ad-bc)=k\det(A_1).$
Suppose $B_2$ is obtained from $A_2$ by performing the row operation $\rho_2:\times k$, then $B_2=\begin{bmatrix}
a & b & c\\
kd & ke & kf\\
g & h & i\\\end{bmatrix}.$ Next, we calculate determinant, we found that $\det(B_2)=kaei+kbfg+kcdh-kafh-kbdi-kceg=k\det(A_2).$
* > If $B$ is obtained from $A$ by performing the row operation $\rho_i:+k\rho_j\times$, then $\det(B) = \det(A)$.
Suppose $B_1$ is obtained from $A_1$ by performing the row operation $\rho_1:+k\rho_2\times$, then
$B_1=\begin{bmatrix}
a+kc & b+kd\\
c & d\\\end{bmatrix}.$
Next, we calculate determinant, we found that $\det(B_1)=ad+kcd-bc-kcd=\det(A_1).$
Suppose $B_2$ is obtained from $A_2$ by performing the row operation $\rho_3:+k\rho_1\times$, then $B_2=\begin{bmatrix}
a & b & c\\
d & e & f\\
g+ka & h+kb & i+kc\\\end{bmatrix}.$
Next, we calculate determinant, we found that
$$
\begin{aligned}
\det(B_2) &= aei+kace+bfg+kabf+cdh+kbcd-afh-kabf-bdi-kbcd-ceg-kace \\
&=\det(A_2).
\end{aligned}
$$
##### Exercise 4
令 $n = 2,3$、且 $A$ 為一 $n\times n$ 的矩陣。
利用定義證明以下性質:
- $\det(A) = \det(A\trans)$.
- $\det(AB) = \det(A)\det(B)$.
<!-- eng start -->
Let $n = 2,3$ and $A$ an $n\times n$ matrix. Prove the following properties by definition:
- $\det(A) = \det(A\trans)$.
- $\det(AB) = \det(A)\det(B)$.
<!-- eng end -->
##### Exercise 4 -- answer here:
:::warning
- [x] typo: Thereform
- [x] add space after comma
Otherwise, the answer is nice.
:::
Question 1
Let matrix $A$:
$$
A = \begin{bmatrix}
a & b \\
c & d\\
\end{bmatrix}.
$$
then $A\trans$:
$$
A\trans = \begin{bmatrix}
a & c \\
b & d\\
\end{bmatrix}.
$$
According to the definition of determinant, we know that:
$$\det(A) = ad-bc$$
$$\det(A\trans) =ad-cb$$
Therefore,$\det(A) = \det(A\trans)$.
Question 2
Let matrices $A$ and $B:$
$$
A = \begin{bmatrix}
a & b \\
c & d\\
\end{bmatrix}.
$$
$$
B = \begin{bmatrix}
e & f \\
g & h\\
\end{bmatrix}.
$$
Then by the definition,
$$
AB=\begin{bmatrix}
a & b \\
c & d\\
\end{bmatrix} \begin{bmatrix}
e & f \\
g & h\\
\end{bmatrix}=\begin{bmatrix}
ae+bg & af+ bh\\
ce+dg & cf+dh\\
\end{bmatrix}
$$
and$$
\begin{aligned}
\det(AB) &= (ae+bg)(cf+dh)-(af+bh)(ce+dg) \\
&= aecf+aedh+bgcf+bgdh-afce-afdg-bhce-bhdg \\
&= aedh+bgcf-afdg-bhce \\
&= adeh-adfg-bceh+bcfg \\
&= (ad-bc)(eh-fg) \\
&=\det(A)\det(B).
\end{aligned}
$$
Thereform, $\det(AB) = \det(A)\det(B)$.
:::info
collaboration: 1
4 problems: 4
* 2a~d
extra: 1
* 4
moderator: 1
qc: 1
:::