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_vec, draw_two_vec
A vector over $\mathbb{R}$ of dimension $n$ is a sequence $\bx = (x_1, \ldots, x_n)$ of numbers in $\mathbb{R}$.
(In contrast, we often call a number in $\mathbb{R}$ a scalar.)
The collection of all vectors over $\mathbb{R}$ of dimension $n$ is denoted by $\mathbb{R}^n$.
We often use $\bzero$ and $\bone$ to refer to $(0,\ldots,0)$ and $(1,\ldots,1)$ of appropriate dimensions, respectively.
The length of a vector $\bx = (x_1,\ldots, x_n)$ is defined as
$$ \|\bx\| = \sqrt{x_1^2 + \cdots + x_n^2}. $$The inner product of two vectors $\bx = (x_1, \ldots, x_n)$ and $\by = (y_1, \ldots, y_n)$ is defined as
$$
\inp{\bx}{\by} = x_1y_1 + \cdots + x_ny_n.
$$
We have the following properties:
Thanks to the Cauchy–Schwarz inequality, we define the angle between two vectors $\bx$ and $\by$ as the angle $\theta$ such that $\cos\theta = \frac{\inp{\bx}{\by}}{\|\bx\|\|\by\|}$.
We say $\bx$ and $\by$ are orthogonal if $\inp{\bx}{\by} = 0$.
執行下方程式碼。
令 $O$ 為原點、
$A$ 和 $B$ 分別為 x
, y
的向量終點。
(可以選用自己喜好的 ramdom_seed
)
Run the code below. Let $A$ and $B$ be the head of x
and y
, respectively.
(You may choose ramdom_seed
as any integer.)
### code
set_random_seed(0)
print_ans = False
x = random_int_vec(6)
y = random_int_vec(6)
print("x =", x)
print("y =", y)
pic = draw_two_vec(x, y)
pic.axes(False)
show(pic)
if print_ans:
print("OA =", x.norm())
print("OB =", y.norm())
print("AB =", (x-y).norm())
cos_cos = (x.norm()**2 + y.norm()**2 - (x-y).norm()**2) / 2 / x.norm() / y.norm()
cos_inner = x.inner_product(y) / x.norm() / y.norm()
print("cos by cos law =",
cos_cos, "=",
N(cos_cos))
print("cos by inner product =",
cos_inner, "=",
N(cos_inner))
計算 $\overline{OA}$、$\overline{OB}$、和 $\overline{AB}$ 的長度,
並利用餘絃定理來計算 $\cos\angle AOB$。
Find the length of $\overline{OA}$, $\overline{OB}$, and $\overline{AB}$. Then find $\cos\angle AOB$ by the cosine law.
令 $\theta$ 為 x
, y
之間用內積定出來的夾角﹐
求 $\cos\theta$。
Let $\theta$ be the angle between x
and y
. Find $\cos\theta$.
前兩題算出來總是一樣嗎?
請用代數的方法證明。
Are the results from the previous two problems the same? Do some algebra to prove it.
Sample:
It is known that $\overline{OA} = \|\bx\|$, $\overline{OB} = \|\by\|$, and $\overline{AB} = \|\bx - \by\|$.
Thus,
$\frac{\overline{OA}^2 + \overline{OB}^2 - \overline{AB}^2}{2\overline{OA}\cdot \overline{OB}}$
$ = \cdots $
$\frac{\inp{\bx}{\by}}{\|\bx\|\|\by\|}$.
將每個向量都展開
(像是 $\bx = (x_1,\ldots, x_n)$)﹐
把每個長度和內積的定義也都展開。
證明 Main idea 中最後列出來的那些性質
(除了三角不等式和柯西不等式以外)。
Write down each vector by its entries, such as $\bx = (x_1, \ldots, x_n)$. Also, write down the formula of the lengths and the inner product of vectors by their entries. Prove the properties listed in Main idea (except for the triangle inequality and the Cauchy–Schwarz inequality.
證明 $\|\bx \pm \by\|^2 = \|\bx\|^2 \pm 2\inp{\bx}{\by} + \|\by\|^2$。
Prove $\|\bx \pm \by\|^2 = \|\bx\|^2 \pm 2\inp{\bx}{\by} + \|\by\|^2$.
給定兩個向量 $\bx,\by$。
若 $\by$ 可以寫成兩個分量相加 $\by = \bh + \bw$﹐
其中 $\bh$ 和 $\bx$ 垂直(所以 $\inp{\bh}{\bx} = 0$)、
而 $\bw$ 和 $\bx$ 平行(所以 $\bw = k\bx$)﹐
求 $\bh$ 和 $\bw$(用 $\bx$ 和 $\by$ 表示出來)。
Let $\bx$ and $\by$ be two vectors. Suppose $\by$ can be written as $\by = \bh + \bw$ such that $\bh$ is orthogonal to $\bx$ (i.e., $\inp{\bh}{\bx} = 0$), and $\bw$ is parallel to $\bx$. Find $\bh$ and $\bw$ as a formula of $\bx$ and $\by$.
依照以下步驟證明三角不等式和柯西不等式等價。
三角不等式
對任意兩個向量 $\bx,\by\in\mathbb{R}^n$
不等式 $\|\bx\| + \|\by\| \geq \|\bx - \by\|$ 皆成立。
柯西不等式
對任意兩個向量 $\bx,\by\in\mathbb{R}^n$
不等式 $|\inp{\bx}{\by}| \leq \|\bx\|\cdot \|\by\|$ 皆成立。
Following the steps below to prove the triangle inequality and the Cauchy–Schwarz inequality.
Triangle inequality
The inequality $\|\bx\| + \|\by\| \geq \|\bx - \by\|$ holds for any vectors $\bx,\by\in\mathbb{R}^n$.
Cauchy–Schwarz inequality The inequality $|\inp{\bx}{\by}| \leq \|\bx\|\cdot \|\by\|$ holds for any vectors $\bx,\by\in\mathbb{R}^n$.
證明若三角不等式成立則柯西不等式成立。
Prove that the triangle inequality implies the Cauchy–Schwarz inequality.
Sample:
Let $\bx$ and $\by$ be any given vectors in $\mathbb{R}^n$.
By the triangle inequality, $\|\bx\| + \|\by\| \geq \|\bx - \by\|$.
...
Therefore, $|\inp{\bx}{\by}| \leq \|\bx\|\cdot \|\by\|$.
Since $\bx$ and $\by$ are arbitrary, the Cauchy–Schwarz inequality holds for any vectors $\bx$ and $\by$.
證明若柯西不等式成立則三角不等式成立。
Prove that the Cauchy–Schwarz inequality implies the triangle inequality.
Sample:
Let $\bx$ and $\by$ be any given vectors in $\mathbb{R}^n$.
By the Cauchy–Schwarz inequality, $|\inp{\bx}{\by}| \leq \|\bx\|\cdot \|\by\|$.
...
Therefore, $\|\bx\| + \|\by\| \geq \|\bx - \by\|$.
Since $\bx$ and $\by$ are arbitrary, the triangle inequality holds for any vectors $\bx$ and $\by$.
證明當 $\|\bx\| = \|\by\| = 1$ 時柯西不等式成立。
Prove that the Cauchy–Schwarz inequality is true when $\|\bx\| = \|\by\| = 1$.
Sample:
Let $\bx$ and $\by$ be two vectors of length $1$.
Since $\|\bx - \by\|^2 \geq 0$, we have
...
Since $\|\bx + \by\|^2 \geq 0$, we have
...
Therefore, $|\inp{\bx}{\by}| \leq 1$ whenever $\|\bx\| = \|\by\| = 1$.
證明對任何非零向量 $\bx,\by\in\mathbb{R}^n$ 柯西不等式皆成立。
Prove that the Cauchy–Schwarz inequality is true for any nonzero $\bx,\by\in\mathbb{R}^n$.
Sample:
Now suppose $\bx$ and $\by$ be arbitrary nonzero vectors in $\mathbb{R}^n$.
Let $\bx' = \bx/\|\bx\|$ and $\by' = \by/\|\by\|$.
Thus, $\|\bx'\| = \|\by'\| = 1$.
By the previous claim, ...
...
Therefore, $|\inp{\bx}{\by}| \leq \|\bx\|\cdot \|\by\|$ for any nonzero vectors $\bx$ and $\by$.
考慮剩餘的可能性並完成柯西不等式的證明。
Finish the remaining cases and prove the Cauchy–Schwarz inequality.
複數向量的集合記作 $\mathbb{C}^n$。
若 $\bx = (x_1,\ldots,x_n)$ 為複數向量﹐
其長度定義為 $\|\bx\| = \sqrt{|x_1|^2 + \cdots |x_n|^2}$。
若 $\bx = (x_1,\ldots,x_n)$ 及 $\by = (y_1,\ldots,y_n)$ 為兩複數向量﹐
其內積定義為 $\inp{\bx}{\by} = x_1\overline{y_1} + \cdots + x_n\overline{y_n}$。
The set of all $n$-dimensional vectors over $\mathbb{C}$ is denoted by $\mathbb{C}^n$. Let $\bx = (x_1,\ldots,x_n)$ and $\by = (y_1,\ldots,y_n)$ be vectors in $\mathbb{C}^n$. The length of $\bx$ is $\|\bx\| = \sqrt{|x_1|^2 + \cdots |x_n|^2}$, while the inner product of $\bx$ and $\by$ is defined by $\inp{\bx}{\by} = x_1\overline{y_1} + \cdots + x_n\overline{y_n}$.
證明複數向量有以下性質:
提示:
可以先證明 $\|\bx\pm\by\|^2 = \|\bx\|^2 \pm 2\operatorname{Re}\inp{\bx}{\by} + \|\by\|^2$。
我們總是可以找到一個好的 $e^{i\theta}$
使得 $\operatorname{Re}\inp{e^{i\theta}\bx}{\by} = |\inp{\bx}{\by}|$。
Prove the properties above for vectors over $\mathbb{C}$.
Hint:
First show that $\|\bx\pm\by\|^2 = \|\bx\|^2 \pm 2\operatorname{Re}\inp{\bx}{\by} + \|\by\|^2$. Then find a $\theta$ such that $\operatorname{Re}\inp{e^{i\theta}\bx}{\by} = |\inp{\bx}{\by}|$.
若 $\bx,\by\in\mathbb{C}^n$。
證明
$$\frac{\operatorname{Re}\inp{\bx}{\by}}{\|\bx\|\|\by\|} =
\frac{\|\bx\|^2 + \|\by\|^2 - \|\bx - \by\|^2}{2\|\bx\|\|\by\|}.$$
因此我們可以把兩複數向量的夾角定義為 $\theta$﹐
而這個 $\theta$ 要滿足 $\cos\theta = \frac{\operatorname{Re}\inp{\bx}{\by}}{\|\bx\|\|\by\|}$。
Let $\bx,\by\in\mathbb{C}^n$. Prove that
$$ \frac{\operatorname{Re}\inp{\bx}{\by}}{\|\bx\|\|\by\|} = \frac{\|\bx\|^2 + \|\by\|^2 - \|\bx - \by\|^2}{2\|\bx\|\|\by\|}. $$Therefore, we may define the angle between the two vectors as the $\theta$ satisfying $\cos\theta = \frac{\operatorname{Re}\inp{\bx}{\by}}{\|\bx\|\|\by\|}$.
若 $\bx,\by\in\mathbb{C}^n$。
求 $\by$ 在 $\bx$ 上的投影。
注意 $\inp{\bx}{\by}$ 和 $\inp{\by}{\bx}$ 不一樣喔!
Let $\bx,\by\in\mathbb{C}^n$. Find the projection of $\by$ onto the direction of $\bx$.
Notice $\inp{\bx}{\by}$ and $\inp{\by}{\bx}$ are different for vectors over $\mathbb{C}$!