owned this note
owned this note
Published
Linked with GitHub
# $\mathbb{R}^n$ 中的矩陣表示法
Matrix representation in $\mathbb{R}^n$

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_int_list, random_good_matrix
```
## Main idea
Recall that if $f : \mathbb{R}^n \rightarrow \mathbb{R}^m$ is a linear function and $\{ \be_1,\ldots, \be_n\}$ is the standard basis of $\mathbb{R}^n$.
Then the matrix
$$
[f] = \begin{bmatrix}
| & ~ & | \\
f(\be_1) & \cdots & f(\be_n) \\
| & ~ & | \\
\end{bmatrix}
$$
has the property that $f(\bb) = [f]\bb$ for all $\bb\in\mathbb{R}^n$.
Sometimes $f(\be_i)$ cannot be easily found, while the function $f$ is described by the bases of $\mathbb{R}^n$ and $\mathbb{R}^m$ instead.
Let $f : \mathbb{R}^n \rightarrow \mathbb{R}^m$ be a linear function,
$\alpha = \{ \bv_1, \ldots, \bv_n \}$ be a basis of $\mathbb{R}^n$, and
$\beta$ a basis of $\mathbb{R}^m$.
Then the matrix
$$
[f]_\alpha^\beta = \begin{bmatrix}
| & ~ & | \\
[f(\bv_1)]_\beta & \cdots & [f(\bv_n)]_\beta \\
| & ~ & | \\
\end{bmatrix}
$$
has the property that $[f(\bb)]_\beta = [f]_\alpha^\beta [\bb]_\alpha$.
Therefore, we call $[f]_\alpha^\beta$ the **matrix representation** of $f$ with respect to $\alpha$ and $\beta$.
The equality can be visualized by the following diagram.
$$
\begin{array}{ccc}
\bb & \xrightarrow{f} & f(\bb) \\
\downarrow & ~ & \downarrow \\
[\bb]_\alpha & \xrightarrow{[f]_\alpha^\beta\cdot\square} & [f(\bb)]_\beta \\
\end{array}
$$
Let $\mathcal{E}_n$ and $\mathcal{E}_m$ be the standard basis of $\mathbb{R}^n$ and $\mathbb{R}^m$, respectively. Since we know
- $[f]\bb =f(\bb)$,
- $[\idmap]_{\mathcal{E}_n}^\alpha \bb = [\bb]_\alpha$,
- $[\idmap]_{\mathcal{E}_m}^\beta f(\bb) = [f(\bb)]_\beta$.
We know $[f] = ([\idmap]_{\mathcal{E}_m}^\beta)^{-1}
[f]_\alpha^\beta
[\idmap]_{\mathcal{E}_n}^\alpha
= [\idmap]_\beta^{\mathcal{E}_m}
[f]_\alpha^\beta
([\idmap]_\alpha^{\mathcal{E}_n})^{-1}$.
## Side stories
- projection
## Experiments
##### Exercise 1
執行以下程式碼。
已知 $f$ 為 $\mathbb{R}^3$ 到 $\mathbb{R}^2$ 的線性函數﹐
而 $\alpha$ 和 $\beta$ 分別為 $\mathbb{R}^3$ 和 $\mathbb{R}^2$ 的一組基底。
<!-- eng start -->
Run the code below. Let $f: \mathbb{R}^3 \rightarrow \mathbb{R}^2$ be a linear function. Let $\alpha$ and $\beta$ be bases of $\mathbb{R}^3$ and $\mathbb{R}^2$, respectively.
<!-- eng end -->
```python
### code
set_random_seed(0)
print_ans = False
m,n = 2,3
alpha = random_good_matrix(n,n,n, bound=3)
beta = random_good_matrix(m,m,m, bound=3)
A = matrix(m, random_int_list(m*n))
v = vector(random_int_list(n, 3))
b = alpha * v
print("alpha contains %s vectors:"%n)
for j in range(n):
print("v%s ="%(j+1), alpha.column(j))
print("beta contains %s vectors:"%m)
for i in range(m):
print("u%s ="%(i+1), beta.column(i))
for j in range(n):
print( "f(v%s) = "%(j+1) + " + ".join("%s u%s"%(A[i,j],i+1) for i in range(m)) )
print("b =", b)
if print_ans:
print("[b]_alpha =", v)
print("[f(b)]_beta =", A*v)
print("f(b) =", beta * A * v)
print("[f]_alpha^beta =")
show(A)
print("[f] =")
show(beta * A * alpha.inverse())
```
**[由張永賦提供]**
By running the code above with `seed=0`, we obtain that
$$
\alpha=\left\{\bv_1,\bv_2,\bv_3\right\},\beta=\left\{\bu_1,\bu_2\right\}. \\
\bv_1=(1,-3,0),\bv_2=(3,-8,-1),\bv_3=(1,-1,-1). \\
\bu_1=(1,2),\bu_2=(1,3). \\
f(\bv_1)=4\bu_1+2\bu_2, \\
f(\bv_2)=-4\bu_1+4\bu_2, \\
f(\bv_3)=-3\bu_1-4\bu_2. \\
\bb=(6,-19,-1).
$$
##### Exercise 1(a)
求 $[\bb]_\alpha$、$[f(\bb)]_\beta$、及 $f(\bb)$。
<!-- eng start -->
Find $[\bb]_\alpha$, $[f(\bb)]_\beta$, and $f(\bb)$.
<!-- eng end -->
**[由張永賦提供]**
**Solution:**
Let
$$
A=
\begin{bmatrix}\
| & | & | \\
\bv_1 & \bv_2 & \bv_3 \\
| & | & | \\
\end{bmatrix}.
$$
We find $[\bb]_\alpha$, by solving the equation of $A[\bb]_\alpha=\bb$.
That is, solve the equation below
$$
\left[\begin{array}{ccc|c}\
1 & 3 & 1 & 6 \\
-3 & -8 & -1 & -19 \\
0 & -1 & -1 & -1
\end{array}\right].
$$
By using the Gaussian elimination, we get
$$
\left[\begin{array}{ccc|c}\
1 & 0 & 0 & -1 \\
0 & 1 & 0 & 3 \\
0 & 0 & 1 & -2
\end{array}\right].
$$
Thus, we know that
$$
[\bb]_\alpha=
\begin{bmatrix}\
-1 \\
3 \\
-2
\end{bmatrix}.
$$
Then we can write the equation $\bb=(-1)\bv_1+3\bv_2-2\bv_3$.
Since $f$ is linear function,
$$
f(\bb)=f((-1)\bv_1+3\bv_2-2\bv_3) \\
=-f(v_1)+3f(v_2)-2f(v_3) \\
=(-1)(4u_1+2u_2)+3(-4\bu_1+4\bu_2)-2(-3\bu_1-4\bu_2) \\
=(-10)u_1+18u_2 \\
=(-10)(1,2)+18(1,3)=(8,34).
$$
By $f(\bb)=(-10)u_1+18u_2$, we know that
$$
[f(b)]_\beta=
\begin{bmatrix}\
-10 \\
18
\end{bmatrix}.
$$
##### Exercise 1(b)
求 $[f]_\alpha^\beta$ 及 $[f]$。
<!-- eng start -->
Find $[f]_\alpha^\beta$ 及 $[f]$.
<!-- eng end -->
**[由張永賦提供]**
**Solution:**
Since
$$
\alpha=\left\{\bv_1,\bv_2,\bv_3\right\},\beta=\left\{\bu_1,\bu_2\right\}, \\
f(\bv_1)=4\bu_1+2\bu_2, \\
f(\bv_2)=-4\bu_1+4\bu_2, \\
f(\bv_3)=-3\bu_1-4\bu_2,
$$
we know that
$$
[f]_\alpha^\beta=
\begin{bmatrix}\
4 & -4 & -3 \\
2 & 4 & -4
\end{bmatrix}.
$$
We know that $[f] = ([\idmap]_{\mathcal{E}_m}^\beta)^{-1}
[f]_\alpha^\beta
[\idmap]_{\mathcal{E}_n}^\alpha
= [\idmap]_\beta^{\mathcal{E}_m}
[f]_\alpha^\beta
([\idmap]_\alpha^{\mathcal{E}_n})^{-1}$.
Find $[\idmap]_\beta^{\mathcal{E}_m}$ and $([\idmap]_\alpha^{\mathcal{E}_n})^{-1}$ :
$$
[\idmap]_\beta^{\mathcal{E}_m}=
\begin{bmatrix}\
1 & 1 \\
2 & 3
\end{bmatrix}.
$$
$$
([\idmap]_\alpha^{\mathcal{E}_n})^{-1}=
\begin{bmatrix}\
1 & 3 & 1 \\
-3 & -8 & -1 \\
0 & -1 & -1
\end{bmatrix}
^{-1}=
\begin{bmatrix}\
7 & 2 & 5 \\
-3 & -1 & -2 \\
3 & 1 & 1
\end{bmatrix}.
$$
Then we obtain $[f]$ by calculaing the equation $[\idmap]_\beta^{\mathcal{E}_m}
[f]_\alpha^\beta
([\idmap]_\alpha^{\mathcal{E}_n})^{-1}$.
$$
[f]=
\begin{bmatrix}\
1 & 1 \\
2 & 3
\end{bmatrix}
\begin{bmatrix}\
4 & -4 & -3 \\
2 & 4 & -4
\end{bmatrix}
\begin{bmatrix}\
1 & 3 & 1 \\
-3 & -8 & -1 \\
0 & -1 & -1
\end{bmatrix}=
\begin{bmatrix}\
21 & 5 & 23 \\
32 & 6 & 44
\end{bmatrix}.
$$
## Exercises
##### Exercise 2
令 $f : \mathbb{R}^n \rightarrow \mathbb{R}^m$ 為一線性函數、
$\alpha = \{\bv_1, \ldots, \bv_n\}$ 為 $\mathbb{R}^n$ 的一組基底、
$\beta = \{\bu_1, \ldots, \bu_m\}$ 為 $\mathbb{R}^m$ 的一組基底。
<!-- eng start -->
Let $f : \mathbb{R}^n \rightarrow \mathbb{R}^m$ be a linear function, $\alpha = \{\bv_1, \ldots, \bv_n\}$ a basis of $\mathbb{R}^n$, and $\beta = \{\bu_1, \ldots, \bu_m\}$ a basis of $\mathbb{R}^m$.
<!-- eng end -->
##### Exercise 2(a)
令 $m = n = 3$ 且
$\alpha = \beta$ 為
$$
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}
$$
的各行向量。
已知
$f(\bv_1) = \bu_1$、
$f(\bv_2) = \bu_2$、
$f(\bv_3) = \bzero$。
求 $[f]_\alpha^\beta$ 及 $[f]$ 並說明 $f$ 的作用。
<!-- eng start -->
Let $m = n = 3$ and $\alpha = \beta$ the columns of
$$
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}.
$$
Suppose $f(\bv_1) = \bu_1$, $f(\bv_2) = \bu_2$, and $f(\bv_3) = \bzero$. Find $[f]_\alpha^\beta$ and $[f]$. Then describe the effect of $f$.
<!-- eng end -->
##### Exercise 2(b)
令 $m = n = 3$ 且
$\alpha = \beta$ 為
$$
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}
$$
的各行向量。
已知
$f(\bv_1) = \bu_1$、
$f(\bv_2) = \bu_2$、
$f(\bv_3) = -\bu_3$。
求 $[f]_\alpha^\beta$ 及 $[f]$ 並說明 $f$ 的作用。
<!-- eng start -->
Let $m = n = 3$ and $\alpha = \beta$ the columns of
$$
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}.
$$
Suppose $f(\bv_1) = \bu_1$, $f(\bv_2) = \bu_2$, and $f(\bv_3) = -\bu_3$. Find $[f]_\alpha^\beta$ and $[f]$. Then describe the effect of $f$.
<!-- eng end -->
##### Exercise 2(c)
令 $m = n = 3$ 且
$\alpha = \beta$ 為
$$
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}
$$
的各行向量。
已知
$f(\bv_1) = \bu_2$、
$f(\bv_2) = -\bu_1$、
$f(\bv_3) = \bu_3$。
求 $[f]_\alpha^\beta$ 及 $[f]$ 並說明 $f$ 的作用。
<!-- eng start -->
Let $m = n = 3$ and $\alpha = \beta$ the columns of
$$
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}
$$
Suppose $f(\bv_1) = \bu_2$, $f(\bv_2) = -\bu_1$, and $f(\bv_3) = \bu_3$. Find $[f]_\alpha^\beta$ and $[f]$. Then describe the effect of $f$.
<!-- eng end -->
##### Exercise 2(d)
令 $m = 3$、$n = 2$ 且
$\alpha$ 為
$$
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}
$$
的各行向量、
$\beta$ 為
$$
B = \begin{bmatrix}
1 & 1 \\
0 & 1 \\
\end{bmatrix}
$$
的各行向量。
已知
$f(\bv_1) = 3\bu_1$、
$f(\bv_2) = 4\bu_2$、
$f(\bv_3) = \bzero$。
求 $[f]_\alpha^\beta$ 及 $[f]$。
<!-- eng start -->
Let $m = 3$, $n = 2$, $\alpha$ the columns of
$$
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}
$$
and $\beta$ the columns of
$$
B = \begin{bmatrix}
1 & 1 \\
0 & 1 \\
\end{bmatrix}
$$
Suppose $f(\bv_1) = 3\bu_1$, $f(\bv_2) = 4\bu_2$, and $f(\bv_3) = \bzero$. Find $[f]_\alpha^\beta$ and $[f]$. Then describe the effect of $f$.
<!-- eng end -->
##### Exercise 3
若 $f : \mathbb{R}^n \rightarrow \mathbb{R}^m$ 為一線性函數。
而 $\mathcal{E}_n$ 和 $\mathcal{E}_m$ 分別為 $\mathbb{R}^n$ 和 $\mathbb{R}^m$ 的一組基底。
說明 $[f]$ 就是 $[f]_{\mathcal{E}_n}^{\mathcal{E}_m}$。
<!-- eng start -->
Let $f : \mathbb{R}^n \rightarrow \mathbb{R}^m$ be a linear function. Let $\mathcal{E}_n$ and $\mathcal{E}_m$ be the standard bases of $\mathbb{R}^n$ and $\mathbb{R}^m$, respectively. Verify that $[f]$ is indeed $[f]_{\mathcal{E}_n}^{\mathcal{E}_m}$.
<!-- eng end -->