Affine subspaces in $\mathbb{R}^n$
This work by Jephian Lin is licensed under a Creative Commons Attribution 4.0 International License.
$\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}}$
from lingeo import random_int_list, draw_span
An affine subspace in $\mathbb{R}^n$ is a subset of $\mathbb{R}^n$ of the form
$$\bp + V = \{\bp + \bv: \bv \in V\},$$
where $\bp$ is a vector and $V$ is a subspace in $\mathbb{R}^n$.
An affine subspace is a subspace if and only if it contains the origin $\bzero$.
Let $U$ be an affine subspace in $\mathbb{R}^n$.
Then $U = \bp + V$ for some vector $\bp$ and some subspace if and only if
$\bp$ is a vector in $U$ and $V = \{\bp_1 - \bp_2: \bp_1,\bp_2\in U\}$.
執行下方程式碼。
原點為橘色點、$\bp$ 為橘色向量、
從 $\bp$ 的終點延伸出去的紅色向量和淡藍色向量分別為 $\bu_1$ 和 $\bu_2$。
黑色向量為 $\bb$。
問 $\bb$ 是否是落在 $\bp + \vspan(\{\bu_1, \bu_2\})$?
若是,求 $c_1,c_2$ 使得 $\bb = \bp + c_1\bu_1 + c_2\bu_2$。
Run the code below. Let the origin be the orange point and $\bp$ the orange vector. Let $\bu_1$ and $\bu_2$ be the red and lightblue vectors whose tails at $\bp$. Is $\bb$ in $\bp + \vspan(\{\bu_1, \bu_2\})$? If yes, find $c_1$ and $c_2$ so that $\bb = \bp + c_1\bu_1 + c_2\bu_2$.
### code
set_random_seed(0)
print_ans = False
while True:
l = random_int_list(9)
A = matrix(3, l)
if A.det() != 0:
break
u1 = vector(A[0])
u2 = vector(A[1])
u3 = vector(A[2])
p = vector(random_int_list(3))
inside = choice([0,1,1])
coefs = random_int_list(2, 2)
if inside:
b = p + coefs[0]*u1 + coefs[1]*u2
else:
b = p + coefs[0]*u1 + coefs[1]*u2 + 3*u3
print("p =", p)
print("u1 =", u1)
print("u2 =", u2)
print("b =", b)
pic = draw_span([u1,u2], p)
pic += arrow((0,0,0), b, width=5, color="black")
show(pic)
if print_ans:
if inside:
print("b is on Col(A) since b = %s u1 + %s u2."%(coefs[0], coefs[1]))
else:
print("b is not on Col(A).")
若 $S$ 為一實數的集合、$p$ 為一實數。
我們定義 $p + S = \{p + s: s\in S\}$。
Let $S$ be a subset in $\mathbb{R}$ and $p$ a real number. Define $p + S = \{p + s: s\in S\}$.
### code
set_random_seed(0)
print_ans = False
nums = list(range(-20,21))
p = choice(nums)
while True:
S = [choice(nums) for _ in range(5)]
if len(set(S)) == len(S):
break
print("p =", p)
print("S =", S)
if print_ans:
print("p + S =", [p + s for s in S])
令 $3\mathbb{Z} = \{3k: k \in \mathbb{Z}\}$。
寫出 $1 + 3\mathbb{Z}$ 和 $-2 + 3\mathbb{Z}$﹐
並觀察它兩者是否一樣。
Let $3\mathbb{Z} = \{3k: k \in \mathbb{Z}\}$. Examine the sets $1 + 3\mathbb{Z}$ and $-2 + 3\mathbb{Z}$ and check if they are the same.
若 $U = 1 + 3\mathbb{Z}$。
說明 $\{p_1 - p_2: p_1, p_2 \in U\} = \mathbb{Z}$。
Let $U = 1 + 3\mathbb{Z}$. Show that $\{p_1 - p_2: p_1, p_2 \in U\} = \mathbb{Z}$.
令 $U = \left\{\begin{bmatrix}x\\y\\z\end{bmatrix} : x + y + z = 3\right\}$。
Let $U = \left\{\begin{bmatrix}x\\y\\z\end{bmatrix} : x + y + z = 3\right\}$.
找一群 $\mathbb{R}^3$ 中的向量 $\bp$、$\bu_1$、$\bu_2$﹐
使得 $U = \bp + \vspan(\{\bu_1, \bu_2\})$。
Find some vectors $\bp$, $\bu_1$, and $\bu_2$ such that $U = \bp + \vspan(\{\bu_1, \bu_2\})$.
驗證 $V = \{\bp_1 - \bp_2 : \bp_1,\bp_2 \in U\}$ 是一個子空間
(它非空、對純量乘法和向量加法有封閉性)。
因此 $U$ 可以寫成 $U = \bp + V$,
其中 $\bp$ 可以取為 $U$ 中的任一向量。
Show that $V = \{\bp_1 - \bp_2 : \bp_1,\bp_2 \in U\}$ is a subspace. (That is, verify it is an non-empty set closed under scalar multiplication and addition.) Therefore, $U$ can be written as $U = \bp + V$, where $\bp$ can be any vector in $U$.
證明任一個超平面
$$ \{ \bv\in\mathbb{R}^n : \inp{\br}{\bv} = b \} $$(其中 $\br\in\mathbb{R}^n$、$b\in\mathbb{R}$)
都是一個仿射子空間。
而且 $\bp$ 和 $V = \{\bp_1 - \bp_2 : \bp_1,\bp_2 \in U\}$ 中的所有向量垂直﹐
因此它是 $U$ 的法向量。
Show that any hyperplane
$$ \{ \bv\in\mathbb{R}^n : \inp{\br}{\bv} = b \}, $$where $\br\in\mathbb{R}^n$ and $b\in\mathbb{R}$, is an affine subspace. Moreover, $\bp$ is orthogonal to any vector in $V = \{\bp_1 - \bp_2 : \bp_1,\bp_2 \in U\}$. Therefore, $\bp$ is the normal vector of $U$.
令 $U = \left\{\begin{bmatrix}x\\y\\z\\w\end{bmatrix} :
\begin{array}{ccccc}
x & +y & & +w & = 3 \\
& & z & +w & = 2 \\
\end{array}\right\}$。
找一群 $\mathbb{R}^4$ 中的向量 $\bp$、$\bu_1$、$\bu_2$﹐
使得 $U = \bp + \vspan(\{\bu_1, \bu_2\})$。
(因此這組方程式的解形成一個仿射子空間。)
Let $U = \left\{\begin{bmatrix}x\\y\\z\\w\end{bmatrix} : \begin{array}{ccccc} x & +y & & +w & = 3 \\ & & z & +w & = 2 \\ \end{array}\right\}$. Find some vectors $\bp$, $\bu_1$, and $\bu_2$ in $\mathbb{R}^4$ so that $U = \bp + \vspan(\{\bu_1, \bu_2\})$. (Therefore, the solution set of this system of linear equations is an affine subspace.)
若 $V$ 為 $\mathbb{R}^n$ 中的一子空間、
$\bp_1$ 和 $\bp_2$ 為 $\mathbb{R}^n$ 中的向量。
證明以下敘述等價:
Let $V$ be a subspace in $\mathbb{R}^n$. Let $\bp_1$ and $\bp_2$ be vectors in $\mathbb{R}^n$. Show that the following are equivalent:
若 $U$ 可以寫為 $\bp + V$,
其中 $\bp\in\mathbb{R}^n$ 且 $V$ 為 $\mathbb{R}^n$ 中的一子空間。
證明 $V = \{\bp_1 - \bp_2 : \bp_1,\bp_2 \in U\}$
且 $\bp$ 可以選為 $U$ 中的任一元素。
Suppose $U$ can be written as $\bp + V$, where $\bp\in\mathbb{R}^n$ and $V$ a subspace in $\mathbb{R}^n$. Show that $V = \{\bp_1 - \bp_2 : \bp_1,\bp_2 \in U\}$. Also, $\bp$ can be chosen as any vector in $U$.