# 向量、長度、角度
Vector, length, and angle

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_vec, draw_two_vec
```
## Main idea
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:
1. $\|\bx\| \geq 0$ and the equality holds if and only if $\bx = \bzero$.
2. $\|k\bx\| = |k|\cdot\|\bx\|$.
3. $\|\bx\| + \|\by\| \geq \|\bx - \by\|$ (triangle inequality).
4. $\|\bx\|^2 = \inp{\bx}{\bx}$.
5. $\inp{\bx_1 + \bx_2}{\by} = \inp{\bx_1}{\by} + \inp{\bx_2}{\by}$.
6. $\inp{k\bx}{\by} = k\inp{\bx}{\by}$.
7. $\inp{\bx}{\by} = \inp{\by}{\bx}$.
8. $|\inp{\bx}{\by}| \leq \|\bx\|\cdot \|\by\|$ (Cauchy–Schwarz inequality).
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$.
## Side stories
- cosine law
- orthogonal
- projection
## Experiments
##### Exercise 1
執行下方程式碼。
令 $O$ 為原點、
$A$ 和 $B$ 分別為 `x`, `y` 的向量終點。
(可以選用自己喜好的 `ramdom_seed`)
<!-- eng start -->
Run the code below. Let $A$ and $B$ be the head of `x` and `y` , respectively.
(You may choose `ramdom_seed` as any integer.)
<!-- eng end -->
```python
### 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))
```
##### Exercise 1(a)
計算 $\overline{OA}$、$\overline{OB}$、和 $\overline{AB}$ 的長度,
並利用**餘絃定理**來計算 $\cos\angle AOB$。
<!-- eng start -->
Find the length of $\overline{OA}$, $\overline{OB}$, and $\overline{AB}$. Then find $\cos\angle AOB$ by the cosine law.
<!-- eng end -->
:::warning
- [x] Suppose ... . Then ... .
- [x] and the lenght of the $\lVert\overrightarrow{AB}\rVert = 3\sqrt{14}$ --> and the length of $\lVert\overrightarrow{AB}\rVert$ is $3\sqrt{14}$
- [x] Period in the end after the $0$.
:::
Suppose $\bx = (4, -1, -1, 4, 5, 0) = \overrightarrow{OA}$ and $\by = (-2, 5, 2, 0, 3, 5) = \overrightarrow{OB}$ . Then $\lVert\overrightarrow{OA}\rVert = \sqrt{59}$, $\lVert\overrightarrow{OB}\rVert = \sqrt{67}$.
Thus, $\by-\bx = \overrightarrow{OB}-\overrightarrow{OA} = \overrightarrow{AB} = (-6, 6, 3, -4, -2, 5)$, and the lengh of the $\lVert\overrightarrow{AB}\rVert$ is $3\sqrt{14}$.
According to the cosine law, $\cos\angle AOB = \frac{\lVert\overrightarrow{OA}\rVert^2 + \lVert\overrightarrow{OB}\rVert^2 - \lVert\overrightarrow{AB}\rVert^2}{2\lVert\overrightarrow{AB}\rVert\lVert\overrightarrow{OB}\rVert} = \frac{59 + 67 - 126}{2 \times\sqrt{59}\times\sqrt{67}} = 0$.
##### Exercise 1(b)
令 $\theta$ 為 `x`, `y` 之間用內積定出來的夾角﹐
求 $\cos\theta$。
<!-- eng start -->
Let $\theta$ be the angle between `x` and `y` . Find $\cos\theta$.
<!-- eng end -->
:::warning
- [x] $\bx = (4, -1, -1, 4, 5, 0), \by = (-2, 5, 2, 0, 3, 5).$ --> $\bx = (4, -1, -1, 4, 5, 0)$, $\by = (-2, 5, 2, 0, 3, 5)$. (see source code)
- [x] hence $\cos\angle AOB = 0$ --> we have $\cos\angle AOB = 0$
:::
We know that $\bx = (4, -1, -1, 4, 5, 0)$, $\by = (-2, 5, 2, 0, 3, 5)$.
Accroding to the law of dot product, $\inp{\bx}{\by} = - 8 - 5 - 2 + 0 + 15 + 0 = 0$.
According to the inner product formula $\lVert\overrightarrow{\bx}\rVert\lVert\overrightarrow{\by}\rVert\cos\angle AOB = \inp{\bx}{\by} = 0$
, we have $\cos\angle AOB = 0$.
##### Exercise 1(c)
前兩題算出來總是一樣嗎?
請用代數的方法證明。
<!-- eng start -->
Are the results from the previous two problems the same? Do some algebra to prove it.
<!-- eng end -->
:::success
Nice :thumbsup:
:::
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}}$
$= \frac{ {\|\bx\|}^2 + {\|\by\|}^2 - {\|\bx - \by\|}^2}{2\|\bx\| \|\by\|}= \frac{ {\|\bx\|}^2 + {\|\by\|}^2 - {\|\bx\|^2 - \|\by\|^2 + 2\inp{\bx}{\by}}}{2\|\bx\| \|\by\|}$
$= \frac{2\inp{\bx}{\by}}{2\|\bx\|\|\by\|} = \frac{\inp{\bx}{\by}}{\|\bx\|\|\by\|}$.
## Exercises
##### Exercise 2
將每個向量都展開
(像是 $\bx = (x_1,\ldots, x_n)$)﹐
把每個長度和內積的定義也都展開。
證明 Main idea 中最後列出來的那些性質
(除了三角不等式和柯西不等式以外)。
<!-- eng start -->
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.
<!-- eng end -->
**[Provided by 鄭宗祐]**
(1)
The **length** of a vector ${\bf x} = (x_1,\ldots, x_n)$ is defined as
$$\|{\bf x}\| = \sqrt{x_1^2 + \cdots + x_n^2}.
$$
For any $x\in\mathbb{R},$ $x^2\geq0.$
If $\|{\bf x}\| = \sqrt{x_1^2 + \cdots + x_n^2} = 0$, ${x_1^2 , \cdots, x_n^2}$ would be $0$, so ${\bf x} = {\bf 0}$.
(2)
$$\begin{aligned}\|k{\bf x}\|&=\sqrt{{(kx_1)^2}+ \cdots+{(kx_n)^2}}\\&=|k|\sqrt{x_1^2+\cdots+x_n^2} \\&=|k|\cdot\|{\bf x}\|.\end{aligned}
$$
The first line is using (1),
and the second line is taking $k$ out of the square root,
and the last line is replacing part of the formula with the length of $\bx$
(4)
$\|{\bf x}\| = \sqrt{x_1^2 + \cdots + x_n^2},$ this is the length of $\bx.$
By taking the square of both sides of the above formula, we get$\|{\bf x}\|^2 =x_1^2 + \cdots + x_n^2=\inp{\bx}{\bx}.$
(5)
Suppose $\bx_1=(x_{11},\cdots,x_{1n})$, $\bx_2=(x_{21},\cdots,x_{2n})$, and $\by = (y_1, \ldots, y_n)$.
Then
$$
\begin{aligned}
\inp{\bx_1 + \bx_2}{\by} &= ({x}_{11}+{x}_{21})y_1 + \cdots +({x}_{1n}+{x}_{2n})y_n \\
&= ({x}_{11}{y_1}+\cdots+{x}_{1n}{y_n})+({x}_{21}{y_1}+ \cdots+{x}_{2n}y_n) \\
&= \inp{x_1}{\by} + \inp{x_2}{\by}.
\end{aligned}
$$
(6)
$$
\begin{aligned}
\inp{k\bx}{\by} &= kx_1y_1 + \cdots + kx_ny_n \\
&= k(x_1y_1+\cdots+x_ny_n) \\
&= k\inp{\bf x}{\bf y}.
\end{aligned}
$$
Here we expand the formula by the definition of the inner product and take out $k$.
(7)
Suppose ${\bf x} = (x_1,\cdots,x_n),
{\bf y} = (y_1,\cdots,y_n).$
Then $\inp{\bf x}{\by}=
x_1y_1+\cdots+x_ny_n,
\inp{\by}{\bx}=
y_1x_1+\cdots+y_nx_n.$
And $x_iy_i=y_ix_i$ for $i=1,\cdots,n.$
Hence $\inp{\bx}{\by} = \inp{\by}{\bx}.$
##### Exercise 3
證明 $\|\bx \pm \by\|^2 = \|\bx\|^2 \pm 2\inp{\bx}{\by} + \|\by\|^2$。
<!-- eng start -->
:::warning
- [x] Let ... . Then ... .
Otherwise, it is good. :smiley:
:::
Prove $\|\bx \pm \by\|^2 = \|\bx\|^2 \pm 2\inp{\bx}{\by} + \|\by\|^2$.
<!-- eng end -->
Let ${\bf x} = (x_1,\ldots, x_n)$,${\bf y} = (y_1,\ldots, y_n)$.
Then $\|{\bf x} \pm {\bf y}\|^2=\sqrt{(x_1 \pm y_1)^2 + \cdots + (x_n \pm y_n)^2}^2 = (x_1^2 \pm 2x_1y_1 + y_1^2) + \cdots + (x_n^2 \pm 2x_ny_n + y_n^2)$.
Rearranging the formula, we get $\sqrt{x_1^2 + \cdots + x_n^2}^2 \pm 2(x_1y_1 + \cdots + x_ny_n) + \sqrt{y_1^2 + \cdots + y_n^2}^2 = \|{\bf x}\|^2 \pm 2\langle{\bf x},{\bf y}\rangle + \|{\bf y}\|^2.$
##### Exercise 4
給定兩個向量 $\bx,\by$。
若 $\by$ 可以寫成兩個分量相加 $\by = \bh + \bw$﹐
其中 $\bh$ 和 $\bx$ 垂直(所以 $\inp{\bh}{\bx} = 0$)、
而 $\bw$ 和 $\bx$ 平行(所以 $\bw = k\bx$)﹐
求 $\bh$ 和 $\bw$(用 $\bx$ 和 $\by$ 表示出來)。
<!-- eng start -->
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$.
<!-- eng end -->
:::success
Nice work!
:::
Suppose $\bw = k\bx$.
We know that $\by = \bh + \bw$, so $\bh = \by - \bw = \by - k\bx$.
Since $\inp{\bh}{\bx}$ $= 0 =$ $\inp{\by - k\bx}{\bx}$ $=$ $\inp{\by}{\bx} - k \inp{\bx}{\bx}, k = \frac{\inp{\by}{\bx}}{\inp{\bx}{\bx}}$.
Therefore, $\bw = k\bx = \frac{\inp{\by}{\bx}}{\inp{\bx}{\bx}}\bx$, and $\bh = \by - \frac{\inp{\by}{\bx}}{\inp{\bx}{\bx}}\bx$
##### Exercise 5
依照以下步驟證明三角不等式和柯西不等式等價。
**三角不等式**
對任意兩個向量 $\bx,\by\in\mathbb{R}^n$
不等式 $\|\bx\| + \|\by\| \geq \|\bx - \by\|$ 皆成立。
**柯西不等式**
對任意兩個向量 $\bx,\by\in\mathbb{R}^n$
不等式 $|\inp{\bx}{\by}| \leq \|\bx\|\cdot \|\by\|$ 皆成立。
<!-- eng start -->
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$.
<!-- eng end -->
##### Exercise 5(a)
證明若三角不等式成立則柯西不等式成立。
<!-- eng start -->
Prove that the triangle inequality implies the Cauchy–Schwarz inequality.
<!-- eng end -->
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$.
ans:
:::warning
Math:
- [x] To conclude $|\inp{\bx}{\by}| \leq \|\bx\|\cdot \|\by\|$, you need both $\|\bx\|\|\by\|\geq\inp{\bx}{\by}$ and $\|\bx\|\|\by\|\geq-\inp{\bx}{\by}$.
Writing issues:
- [x] is available --> is true
- [x] vectors,we --> vectors, we (missing space); please check this throughout
- [x] can be written to --> can be written as
- [x] Then we square both sides --> Then by taking the square of both sides,
- [x] Miss a period after the sentence of "In conclusion"
- [x] Put --> By putting
- [x] It is sufficient to show that $\|\bx\| + \|\by\| \geq \|\bx \pm\by\|$. --> Consider the inequality $\|\bx\| + \|\by\| \geq \|\bx \pm\by\|$.
:::
Let $\bx$ and $\by$ be any given vectors in $\mathbb{R}^n$.
By the triangle inequality, $\|\bx\| + \|\by\| \geq \|\bx - \by\|$.
Since the triangle inequality is true for all the vectors, we can choose two vectors $\bx$ and $-\by$.
By putting $\bx$ and $-\by$ into the triangle inequality, we can get $\|\bx\| + \|-\by\| \geq \|\bx +\by\|$.
And we know $\|-\by\|$ is equal to$\|\by\|$, so the triangle inequality can be written as
$\|\bx\| + \|\by\| \geq \|\bx +\by\|$.
Consider the inequality
$\|\bx\| + \|\by\| \geq \|\bx \pm\by\|$.
Then by taking the square of both sides, we can get $\|\bx\|^2+ \|\by\|^2+2\|\bx\|\|\by\| \geq\|\bx\|^2+ \|\by\|^2\pm2\inp{\bx}{\by}$.
In conclusion, $\|\bx\|\|\by\|\geq\pm\inp{\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$.
##### Exercise 5(b)
證明若柯西不等式成立則三角不等式成立。
<!-- eng start -->
Prove that the Cauchy–Schwarz inequality implies the triangle inequality.
<!-- eng end -->
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$.
**[Provided by 鄭宗祐]**
Let $\bx$ and $\by$ be any given vectors in $\mathbb{R}^n$.
By the Cauchy–Schwarz inequality, $|\inp{\bx}{\by}| \leq \|\bx\|\cdot \|\by\|$.
Removing the absolute value of $|\inp{\bx}{\by}|,$ we can get $\pm\inp{\bx}{\by} \leq \|\bx\|\cdot \|\by\|.$
Multiplying both sides by $2$, we get $\pm 2\inp{\bx}{\by} \leq 2\|\bx\|\cdot \|\by\|.$
Adding $\|\bx\|^2 + \|\by\|^2$ to both side, we get $\|\bx\|^2 + \|\by\|^2+2\|\bx\|\|\by\|\geq \|\bx\|^2+ \|{\by}\|^2 \pm\ 2\inp{\bx}{\by}$.
In particular, $\|\bx\|^2 + \|\by\|^2 + 2\|\bx\|\|\by\|\geq \|\bx\|^2+ \|\by\|^2 - 2\inp{\bx}{\by}$.
The above can be rewritten as
$(\|\bx\|+\|\by\|)^2\geq (\|\bx-\by\|)^2.$
Take the square root on both sides.
Therefore, $\|\bx\| + \|\by\| \geq \|\bx - \by\|$.
Since $\bx$ and $\by$ are arbitrary, the triangle inequality holds for any vectors $\bx$ and $\by$.
##### Exercise 6
依照以下步驟證明柯西不等式。
<!-- eng start -->
Prove the Cauchy–Schwarz inequality by the following steps.
<!-- eng end -->
##### Exercise 6(a)
證明當 $\|\bx\| = \|\by\| = 1$ 時柯西不等式成立。
<!-- eng start -->
Prove that the Cauchy–Schwarz inequality is true when $\|\bx\| = \|\by\| = 1$.
<!-- eng end -->
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$.
**[Provided by 鄭宗祐]**
Let $\bx$ and $\by$ be two vectors of length $1$.
Since $\|\bx - \by\|^2 \geq 0$, we have
$\|{\bx}\|^2+ \|{\by}\|^2 - 2\inp{\bx}{\by}\geq 0$.
Since $\|\bx + \by\|^2 \geq 0$, we have
$\|{\bx}\|^2+ \|{\by}\|^2+2\inp{\bx}{\by}\geq 0$.
Through the two inequalities above, we get $\pm2\inp{\bx}{\by}\geq -2,$
and rewrite it as $1\geq|\inp{\bx}{\by}|.$
Therefore, $|\inp{\bx}{\by}| \leq 1$ whenever $\|\bx\| = \|\by\| = 1$.
##### Exercise 6(b)
證明對任何非零向量 $\bx,\by\in\mathbb{R}^n$ 柯西不等式皆成立。
<!-- eng start -->
Prove that the Cauchy–Schwarz inequality is true for any nonzero $\bx,\by\in\mathbb{R}^n$.
<!-- eng end -->
Sample:
Suppose $\bx$ and $\by$ are arbitrary nonzero vectors in $\mathbb{R}^n$.
Let $\bx' = \bx/\|\bx\|$ and $\by' = \by/\|\by\|$. Then $\|\bx'\| = \|\by'\| = 1$.
By the previous claim, $|\langle {\bf x}',{\bf y}'\rangle| \leq \ 1$.
Thus, we know that $|\langle {\bf x}',{\bf y}'\rangle| = \frac{|\langle{\bf x}, {\bf y}\rangle|}{\|{\bf x}\|\|{\bf y}\|} \leq \ 1$.
Rearranging the formula, we get $|\langle {\bf x},{\bf y}\rangle| \leq \|{\bf x}\|\cdot \|{\bf y}\|$.
In conclusion, $|\inp{\bx}{\by}| \leq \|\bx\|\cdot \|\by\|$ for any nonzero vectors $\bx$ and $\by$.
##### Exercise 6(c)
考慮剩餘的可能性並完成柯西不等式的證明。
<!-- eng start -->
Finish the remaining cases and prove the Cauchy–Schwarz inequality.
<!-- eng end -->
**[Provided by 鄭宗祐]**
We have shown that the Cauchy–Schwarz inequality holds whenever $\bx$ and $\by$ are not zero vectors.
The remaining case is when either $\bx$ or $\by$ is $\bzero$.
If $\|\bx\|$ or $\|\by\|$ is $0,$ $\|\bx\|\cdot\|\by\|=0,$ and $\inp{\bx}{\by}=0.$
Thus $\|\bx\|\cdot\|\by\|=|\inp{\bx}{\by}|.$
Thus, the Cauchy–Schwarz inequality holds for any vectors $\bx$ and $\by$.
##### Exercise 7
複數向量的集合記作 $\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}$。
<!-- eng start -->
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}$.
<!-- eng end -->
##### Exercise 7(a)
證明複數向量有以下性質:
1. $\|\bx\| \geq 0$ and the equality holds if and only if $\bx = \bzero$.
2. $\|k\bx\| = |k|\cdot\|\bx\|$.
3. $\|\bx\| + \|\by\| \geq \|\bx - \by\|$ (triangle inequality).
4. $\|\bx\|^2 = \inp{\bx}{\bx}$.
5. $\inp{\bx_1 + \bx_2}{\by} = \inp{\bx_1}{\by} + \inp{\bx_2}{\by}$.
6. $\inp{k\bx}{\by} = k\inp{\bx}{\by}$ and $\inp{\bx}{k\by} = \overline{k}\inp{\bx}{\by}$.
7. $\inp{\bx}{\by} = \overline{\inp{\by}{\bx}}$.
8. $|\inp{\bx}{\by}| \leq \|\bx\|\cdot \|\by\|$ (Cauchy–Schwarz inequality).
提示:
可以先證明 $\|\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}|$。
<!-- eng start -->
Prove the properties above for vectors over $\mathbb{C}$.
1. $\|\bx\| \geq 0$ and the equality holds if and only if $\bx = \bzero$.
2. $\|k\bx\| = |k|\cdot\|\bx\|$.
3. $\|\bx\| + \|\by\| \geq \|\bx - \by\|$ (triangle inequality).
4. $\|\bx\|^2 = \inp{\bx}{\bx}$.
5. $\inp{\bx_1 + \bx_2}{\by} = \inp{\bx_1}{\by} + \inp{\bx_2}{\by}$.
6. $\inp{k\bx}{\by} = k\inp{\bx}{\by}$ and $\inp{\bx}{k\by} = \overline{k}\inp{\bx}{\by}$.
7. $\inp{\bx}{\by} = \overline{\inp{\by}{\bx}}$.
8. $|\inp{\bx}{\by}| \leq \|\bx\|\cdot \|\by\|$ (Cauchy–Schwarz inequality).
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}|$.
<!-- eng end -->
##### Exercise 7(b)
若 $\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\|}$。
<!-- eng start -->
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\|}$.
<!-- eng end -->
##### Exercise 7(c)
若 $\bx,\by\in\mathbb{C}^n$。
求 $\by$ 在 $\bx$ 上的投影。
注意 $\inp{\bx}{\by}$ 和 $\inp{\by}{\bx}$ 不一樣喔!
<!-- eng start -->
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}$!
<!-- eng end -->
**[Provided by 許豐有]**
Let $\bw$ is the projection of $\by$ onto the direction of $\bx$.
Suppose $\bw = k\bx$.
We know that $\by = \bh + \bw$, so $\bh = \by - \bw = \by - k\bx$.
Since $\inp{\bh}{\bx}$ $= 0 =$ $\inp{\by - k\bx}{\bx}$ $=$ $\inp{\by}{\bx} - k \inp{\bx}{\bx}, k = \frac{\inp{\by}{\bx}}{\inp{\bx}{\bx}}$.
Therefore, the projection of $\by$ onto the direction of $\bx$ is equal to $\bw = k\bx = \frac{\inp{\by}{\bx}}{\inp{\bx}{\bx}}\bx$.
:::info
:warning: You need 4 problems in Exerciese but I only see 3. Done!
:warning: The moderator needs to email/notify me one day before the comprehension test. Done!
Collaboration: 1
4 problems: 4 (all done)
moderator: 1
quality control: 1
:::