# 矩陣的行空間
Column space of a matrix

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, draw_span
```
## Main idea
##### Matrix-vector multiplication (by column)
Let
$$A = \begin{bmatrix}
| & ~ & | \\
\bu_1 & \cdots & \bu_n \\
| & ~ & | \\
\end{bmatrix}$$
be an $m\times n$ matrix and
$$\bv = \begin{bmatrix} c_1 \\ \vdots \\ c_n \end{bmatrix}$$
a vector in $\mathbb{R}^n$.
Then
$$A\bv = c_1\bu_1 + \cdots + c_n\bu_n.
$$
Thus,
$$\{A\bv: \bv\in\mathbb{R}^n\} = \vspan(\{\bu_1, \ldots, \bu_n\}),
$$
which is called the **column space** $\Col(A)$ of $A$.
Therefore,
the equation $A\bv = \bb$ has a solution if and only if $\bb\in\Col(A)$.
## Side stories
- redundant vectors for span
- `A \ b`
## Experiments
##### Exercise 1
執行下方程式碼。
令 $\bu_1$ 及 $\bu_2$ 為 $A$ 的行向量。
原點為橘色點、
從原點延伸出去的紅色向量和淡藍色向量分別為 $\bu_1$ 和 $\bu_2$。
黑色向量為 $\bb$。
問 $A\bv = \bb$ 的 $\bv$ 是否有解?
若有解﹐求 $\bv$。
<!-- eng start -->
Run the code below. Let $\bu_1$ and $\bu_2$ be the column vectors of $A$. Let the origin be the orange point. Let $\bu_1$ and $\bu_2$ be the red and blue vectors with its tails at the origin. Let $\bb$ be the black vector. Is there a solution for $\bv$ to $A\bv = \bb$? If yes, find $\bv$.
<!-- eng end -->
```python
### code
set_random_seed(0)
print_ans = False
while True:
l = random_int_list(9)
Ae = matrix(3, l)
if Ae.det() != 0:
break
u1 = vector(Ae[:,0])
u2 = vector(Ae[:,1])
u3 = vector(Ae[:,2])
A = Ae[:,:2]
inside = choice([0,1,1])
coefs = random_int_list(2, 2)
if inside:
b = coefs[0]*u1 + coefs[1]*u2
else:
b = coefs[0]*u1 + coefs[1]*u2 + 3*u3
print("A =")
print(A)
print("b =", b)
pic = draw_span([u1,u2])
pic += arrow((0,0,0), b, width=5, color="black")
show(pic)
if print_ans:
if inside:
print("It has a solution v = %s."%vector(coefs[:2]))
else:
print("It has no solution.")
```
:::warning
You have to paste the output of the code here and type your answers.
:::
**Answer**

$$
A = \begin{bmatrix}
-4&3\\
-5&-5\\
3&-3
\end{bmatrix}\text { and }
\bb= \begin{bmatrix}-14\\0\\12\end{bmatrix}.
$$
If there is a solution for $\bv$ to $A\bv=\bb$, then $\bb$ can be written as a linear combination of the columns of $A$.
Find $\bv$:
Let
$$
\bv= \begin{bmatrix}
p\\
q\\
\end{bmatrix}.
$$
Based on the equation $A\bv=\bb$, we get
$$
\begin{cases}
-4p+3q=-14 \\
-5p-5q=0 \\
3p-3q=12 \\
\end{cases}.
$$
After simplifying the equations, we get
$$
\begin{cases}
p=2 \\
q=-2 \\
\end{cases}.
$$
Therefore we have
$$
\bv=\begin{bmatrix}
2\\
-2\\
\end{bmatrix}.
$$
Since there is a $\bv$ such that $A\bv=\bb$, we know there is a solution for $A\bv=\bb$, and
$$
\bv=\begin{bmatrix}
2\\
-2\\
\end{bmatrix}.
$$
## Exercises
##### Exercise 2(a)
令
$$
A = \begin{bmatrix}
1 & 2 & 3 \\
4 & 5 & 6 \\
7 & 8 & 9
\end{bmatrix}\text{ and }
\bb = \begin{bmatrix}3\\9\\15\end{bmatrix}.
$$
判斷 $\bb$ 是否在 $\Col(A)$ 中、
並給出說明。
<!-- eng start -->
Let
$$
A = \begin{bmatrix}
1 & 2 & 3 \\
4 & 5 & 6 \\
7 & 8 & 9
\end{bmatrix}\text{ and }
\bb = \begin{bmatrix}3\\9\\15\end{bmatrix}.
$$
Determine if $\bb$ is in $\Col(A)$. Provide your reasons.
<!-- eng end -->
:::warning
- [x] $Exercise2(a)-Answer$ --> **Answer**
- [x] $b$ --> $\bb$, make it bold for all vectors
- [x] Capitalize the first letter of each sentence.
- [x] then there exist $\bb$ such that $A\bv = \bb$.
- [x] from $Av=b$, we get $$\left[\begin{array}{c|c}
A&b\\
\end{array}\right].$$ --> Based on the equation $A\bv = \bb$, we get the augmented matrix ... .
- [x] By row operation --> The we use row operations to get the reduced echelon form (also, make your matrix into rref)
- [x] By assuming $r = k$, we have
- [x] Since there is a vector $\bv$ such that $A\bv = \bb$, we know $\bb\in\Col(A)$.
$$
\bv = \begin{bmatrix} k+1 \\ 1-2k \\ k \end{bmatrix}.
$$
:::
Exercise2(a)-**Answer**
If $\bb$ is in $\Col(A)$, then there exist a $\bb$ such that $A\bv=\bb$.
Find $\bv$:
Let
$$
\bv = \begin{bmatrix}p\\q\\r\end{bmatrix}.
$$
Based on the equation $A\bv=\bb$, we get the augmented matrix
$$
\left[\begin{array}{c|c}
A&\bb\\
\end{array}\right].
$$
Then we get
$$
\left[\begin{array}{ccc|c}
1&2&3&3\\
4&5&6&9\\
7&8&9&15\\
\end{array}\right].
$$
Then we use row operaiotns to get the reduced row echelon form
$$
\left[\begin{array}{ccc|c}
1&0&-1&1\\
0&1&2&1\\
0&0&0&0\\
\end{array}\right].
$$
By assuming $r=k$, we have
$$
\bv=\begin{bmatrix}k+1\\1-2k\\k\end{bmatrix}.
$$
Since there is a vector $\bv$ such that $A\bv=\bb$, we know $\bb\in \Col(A)$.
##### Exercise 2(b)
令
$$
A = \begin{bmatrix}
1 & 2 & 3 \\
4 & 5 & 6 \\
7 & 8 & 9
\end{bmatrix}\text{ and }
\bb = \begin{bmatrix}1\\1\\1\end{bmatrix}.
$$
判斷 $\bb$ 是否在 $\Col(A)$ 中、
並給出說明。
<!-- eng start -->
Let
$$
A = \begin{bmatrix}
1 & 2 & 3 \\
4 & 5 & 6 \\
7 & 8 & 9
\end{bmatrix}\text{ and }
\bb = \begin{bmatrix}1\\1\\1\end{bmatrix}.
$$
Determine if $\bb$ is in $\Col(A)$. Provide your reasons.
<!-- eng end -->
:::warning
Revise according to the comments in 2(a).
:::
Exercise2(b)-**Answer**
If $\bb$ is in $\Col(A)$, then there exists $\bb$ such that $A\bv=\bb$.
Find $\bv$:
Let
$$
\bv = \begin{bmatrix}p\\q\\r\end{bmatrix}.
$$
Base on the equation $A\bv=\bb$, we get the augmented matrix
$$\left[\begin{array}{c|c}
A&\bb\\
\end{array}\right].$$
Then we get
$$
\left[\begin{array}{ccc|c}
1&2&3&1\\
4&5&6&1\\
7&8&9&1\\
\end{array}\right].
$$
Then we use row operations to get the reduced row echelon form.
$$\left[\begin{array}{ccc|c}
1&0&-1&-1\\
0&1&2&1\\
0&0&0&0\\
\end{array}\right].
$$
By assuming $r=k$, we have
$$
\bv=\begin{bmatrix}k-1\\1-2k\\k\end{bmatrix}.
$$
Since there is a vector $\bv$ such that $A\bv=\bb$, we know $\bb\in\Col(A)$.
##### Exercise 2(c)
令
$$
A = \begin{bmatrix}
0 & 1 & 0 & 1 \\
1 & 0 & 1 & 0 \\
0 & 1 & 0 & 1 \\
1 & 0 & 1 & 0 \\
\end{bmatrix}\text{ and }
\bb = \begin{bmatrix}2\\2\\2\\2\end{bmatrix}.
$$
判斷 $\bb$ 是否在 $\Col(A)$ 中、
並給出說明。
<!-- eng start -->
Let
$$
A = \begin{bmatrix}
0 & 1 & 0 & 1 \\
1 & 0 & 1 & 0 \\
0 & 1 & 0 & 1 \\
1 & 0 & 1 & 0 \\
\end{bmatrix}\text{ and }
\bb = \begin{bmatrix}2\\2\\2\\2\end{bmatrix}.
$$
Determine if $\bb$ is in $\Col(A)$. Provide your reasons.
<!-- eng end -->
---
Exercise 2(c) **Answer** by Kevin:
Let $\bv$ be a vector $(x, y, z, w)$ in which its every element is a real number.
To testify if $\bb$ is in $\Col(A)$,
we need to find at least one solution of the following equation:
$A\bv=\bb$
We use row operation to get the reduced echlon form of $A$, then we get:
$$
\begin{bmatrix}
1 & 0 & 1 & 0 \\
0 & 1 & 0 & 1 \\
0 & 0 & 0 & 0 \\
0 & 0 & 0 & 0 \\
\end{bmatrix}\
•
\begin{bmatrix}x\\y\\z\\w\end{bmatrix}
= \begin{bmatrix}2\\2\\2\\2\end{bmatrix}.
$$
By writting the above matrices into an equation set, we get:
$x+z=2$
$y+w=2$
As we can find at least one solution to the above equation set, for example: $(x, y, z, w)=(2, 3, 0, -1)$, we now know that $\bb$ is in $\Col(A)$.
---
:::warning
Revise according to the comments of 2(a).
:::
##### Exercise 3(a)
令
$$
A = \begin{bmatrix}
1 & 2 \\
1 & 2 \\
\end{bmatrix}\text{ and }
\bb = \begin{bmatrix}3\\4\end{bmatrix}.
$$
給出一些直覺的敘述﹐說明 $\bb\notin\Col(A)$。
<!-- eng start -->
Let
$$
A = \begin{bmatrix}
1 & 2 \\
1 & 2 \\
\end{bmatrix}\text{ and }
\bb = \begin{bmatrix}3\\4\end{bmatrix}.
$$
Give some intuitive reason showing that $\bb\notin\Col(A)$.
<!-- eng end -->
Answer:
Note that $\Col(A) = \vspan\{(1,1),(2,2)\}$.
If vector $\bb$ is in $\Col(A)$,
by the definition we can find $x, y$ that are real numbers such that
$\bb = x(1,1)+y(2,2)=(x+2y,x+2y)$.
But
$\bb=(4,3)=(x+2y,x+2y)$
has no solution.
Therefore $x,y$ don't exist.
Hence, $\bb\notin\Col(A)$.
:::warning
I don't understand what you are talking about.
:::
##### Exercise 3(b)
令
$$
A = \begin{bmatrix}
1 & 1 \\
1 & 1 \\
-1 & -1 \\
-1 & -1 \\
\end{bmatrix}\text{ and }
\bb = \begin{bmatrix}0\\0\\1\\2\end{bmatrix}.
$$
給出一些直覺的敘述﹐說明 $\bb\notin\Col(A)$。
<!-- eng start -->
Let
$$
A = \begin{bmatrix}
1 & 1 \\
1 & 1 \\
-1 & -1 \\
-1 & -1 \\
\end{bmatrix}\text{ and }
\bb = \begin{bmatrix}0\\0\\1\\2\end{bmatrix}.
$$
Give some intuitive reason showing that $\bb\notin\Col(A)$.
<!-- eng end -->
**[由鄭宗祐提供]**
**Answer**
We observe that the third and the fourth row of $A$ are the same.
Thus, no matter which linear combination of columns of $A$ we choose, its last two entries should all be the same.
However, the last two entries of $\bb$ are not the same, so $\bb\notin\Col(A).$
##### Exercise 3(c)
令
$$
A = \begin{bmatrix}
-1 & -1 & -1 \\
1 & 0 & 0 \\
0 & 1 & 0 \\
0 & 0 & 1 \\
\end{bmatrix}\text{ and }
\bb = \begin{bmatrix}-4\\1\\1\\1\end{bmatrix}.
$$
給出一些直覺的敘述﹐說明 $\bb\notin\Col(A)$。
<!-- eng start -->
Let
$$
A = \begin{bmatrix}
-1 & -1 & -1 \\
1 & 0 & 0 \\
0 & 1 & 0 \\
0 & 0 & 1 \\
\end{bmatrix}\text{ and }
\bb = \begin{bmatrix}-4\\1\\1\\1\end{bmatrix}.
$$
Give some intuitive reason showing that $\bb\notin\Col(A)$.
<!-- eng end -->
**[由鄭宗祐提供]**
**Answer**
We observe that if we want to get last three entries of $\bb$,
the only way is to take $\bu_1 + \bu_2 + \bu_3$, where $\bu_i$'s are the columns of $A$,
but the calculation would be $\begin{bmatrix}-3\\1\\1\\1\end{bmatrix},$
while $\bb=\begin{bmatrix}-4\\1\\1\\1\end{bmatrix}.$
Hence, $\bb\notin\Col(A).$
##### Exercise 4
以下的小題探討哪些向量刪除以後不會影響生成出來的子空間。
令
$$
A = \begin{bmatrix}
1 & -1 & 1 & 0 \\
1 & 1 & 0 & -1 \\
1 & 0 & -1 & 1 \\
\end{bmatrix}
$$
且 $S = \{\bu_1,\ldots,\bu_4\}$ 為 $A$ 的所有行向量。
<!-- eng start -->
The following problems studies the columns whose removal will not change the column space. Let
$$
A = \begin{bmatrix}
1 & -1 & 1 & 0 \\
1 & 1 & 0 & -1 \\
1 & 0 & -1 & 1 \\
\end{bmatrix}
$$
and $S = \{\bu_1,\ldots,\bu_4\}$ the columns of $A$.
<!-- eng end -->
##### Exercise 4(a)
對 $S$ 中的每一個 $\bu_i$ 逐個檢查﹐
哪一個 $\bu_i \in \vspan(S\setminus\{\bu_i\})$。
根據上一節的練習﹐
如果扣掉一個這樣的 $\bu_i$ 並不會影響生成出來的子空間。
<!-- eng start -->
For each vector $\bu_i$ in $S$, check if $\bu_i$ is in $\vspan(S\setminus\{\bu_i\})$.
According to the previous section, the removal of such $\bu_i$ will not change the column space.
<!-- eng end -->
:::warning
How do you know that?
:::
Answer:
Observe that
$$
\left\{
\begin{aligned}
\bu_2 &= -\bu_3-\bu_4 \ \\\bu_3 &= -\bu_2-\bu_4 \\
\bu_4 &= -\bu_2-\bu_3 \\
\end{aligned}
\right.
$$
Then $\bu_i\in\vspan(S\setminus\{{\bf u}_i\})$ for $i = 2,3,4$.
We also notice that $\vspan(\{\bu_2,\bu_3,\bu_4\})$ is the plane defined by $x+y+z = 0$, so $\bu_1$ is not on the plane.
##### Exercise 4(b)
經過計算﹐
$$
A \begin{bmatrix}0\\1\\1\\1\end{bmatrix} = \bzero.
$$
也就是 $1\bu_2 + 1\bu_3 + 1\bu_4 = \bzero$。
用這個等式來說明
$\bu_2, \bu_3, \bu_4$ 中刪掉任何一個都不會影響生成出來的子空間。
<!-- eng start -->
By direct computation, we know
$$
A \begin{bmatrix}0\\1\\1\\1\end{bmatrix} = \bzero.
$$
That is, $1\bu_2 + 1\bu_3 + 1\bu_4 = \bzero$. Use this equality to explain that the removal of any of $\bu_2$, $\bu_3$, or $\bu_4$ will not change the column space.
<!-- eng end -->
##### Exercise 4(c)
令 $A'$ 為 $A$ 的前三行組成的矩陣。
我們己知 $\Col(A') = \Col(A)$。
經過解方程式的計算可以發現 $\ker(A') = \{\bzero\}$。
利用這個性質說明 $A'$ 的行之中
沒辦法再拿掉任何一行
但同時保持行空間。
<!-- eng start -->
Let $A'$ be the matrix induced on the first three columns of $A$. Recall that $\Col(A') = \Col(A)$. By solving the equation $A\bx = \bzero$, we know that $\ker(A') = \{\bzero\}$. Use this property to show that the removal of any column in $A'$ will change the column space.
<!-- eng end -->
##### Exercise 4(d)
令 $A$ 為任一矩陣且
$S = \{\bu_1,\ldots,\bu_n\}$ 為其所有行向量。
證明以下敘述等價:
1. $\ker(A) = \{\bzero\}$.
2. $\vspan(S\setminus\bu_i) \subsetneq \vspan(S)$ for all $i=1, \ldots, n$.
<!-- eng start -->
Let $A$ be a matrix and $S = \{\bu_1,\ldots,\bu_n\}$ its columns. Prove that the following are equivalent:
1. $\ker(A) = \{\bzero\}$.
2. $\vspan(S\setminus\bu_i) \subsetneq \vspan(S)$ for all $i=1, \ldots, n$.
<!-- eng end -->
##### Exercise 5(a)
令 $A = \begin{bmatrix}
a & b \\
c & d \\
\end{bmatrix}$。
定義 $\det(A) = ad - bc$。
說明若 $\det(A) \neq 0$﹐則 $\Col(A) = \mathbb{R}^2$ 。
<!-- eng start -->
Let $A = \begin{bmatrix}
a & b \\
c & d \\
\end{bmatrix}$. Define $\det(A) = ad - bc$. Show that if $\det(A) \neq 0$ then $\Col(A) = \mathbb{R}^2$.
<!-- eng end -->
##### Exercise 5(b)
令 $A = \begin{bmatrix}
a & b & c \\
d & e & f \\
i & j & k \\
\end{bmatrix}$。
定義 $\det(A) = aek + bfi + cdj - cei - dbk - afj$。
說明若 $\det(A) \neq 0$﹐則 $\Col(A) = \mathbb{R}^3$ 。
<!-- eng start -->
Let $A = \begin{bmatrix}
a & b & c \\
d & e & f \\
i & j & k \\
\end{bmatrix}$. Define $\det(A) = aek + bfi + cdj - cei - dbk - afj$. Show that if $\det(A) \neq 0$ then $\Col(A) = \mathbb{R}^3$.
<!-- eng end -->
:::info
collaboration: 1
4 problems: 4
extra: 0.5
quality control: 1
moderator: 1
:::