or
or
By clicking below, you agree to our terms of service.
New to HackMD? Sign up
Syntax | Example | Reference | |
---|---|---|---|
# Header | Header | 基本排版 | |
- Unordered List |
|
||
1. Ordered List |
|
||
- [ ] Todo List |
|
||
> Blockquote | Blockquote |
||
**Bold font** | Bold font | ||
*Italics font* | Italics font | ||
~~Strikethrough~~ | |||
19^th^ | 19th | ||
H~2~O | H2O | ||
++Inserted text++ | Inserted text | ||
==Marked text== | Marked text | ||
[link text](https:// "title") | Link | ||
 | Image | ||
`Code` | Code |
在筆記中貼入程式碼 | |
```javascript var i = 0; ``` |
|
||
:smile: | ![]() |
Emoji list | |
{%youtube youtube_id %} | Externals | ||
$L^aT_eX$ | LaTeX | ||
:::info This is a alert area. ::: |
This is a alert area. |
On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?
Please give us some advice and help us improve HackMD.
Do you want to remove this version name and description?
Syncing
xxxxxxxxxx
向量、長度、角度
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}}\)
Main idea
A vector over \(\mathbb{R}\) of dimension \(n\) is a sequence \({\bf x} = (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 \({\bf 0}\) and \({\bf 1}\) to refer to \((0,\ldots,0)\) and \((1,\ldots,1)\) of appropriate dimensions, respectively.
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}. \]
The inner product of two vectors \({\bf x} = (x_1, \ldots, x_n)\) and \({\bf y} = (y_1, \ldots, y_n)\) is defined as
\[\langle{\bf x},{\bf y}\rangle = 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 \({\bf x}\) and \({\bf y}\) as the angle \(\theta\) such that \(\cos\theta = \frac{\langle{\bf x},{\bf y}\rangle}{\|{\bf x}\|\|{\bf y}\|}\).
We \({\bf x}\) and \({\bf y}\) are orthogonal if \(\langle{\bf x},{\bf y}\rangle = 0\).
Side stories
Experiments
Exercise 1
執行下方程式碼。
令 \(O\) 為原點、
\(A\) 和 \(B\) 分別為
x
,y
的向量終點。(可以選用自己喜好的
ramdom_seed
)Exercise 1(a)
計算 \(\overline{OA}\)、\(\overline{OB}\)、和 \(\overline{AB}\) 的長度,
並利用餘絃定理來計算 \(\cos\angle AOB\)。
令 \(\bx = (-4,3,5,-5,-5,0) = \overrightarrow{OA}\) 及
\({\bf y} = (3,-3,3,4,-4,-3) = \overrightarrow{OB}\)。
則 \(\|{\overrightarrow{OA}}\| = \sqrt{100} = 10\), \(\|{\overrightarrow{OB}}\| = \sqrt{68} = 2\sqrt{17}\)。
另一方面,\(\overrightarrow{AB} = \by - \bx = (7,-6,-2,9,1,-3)\)
所以 \(\|\overrightarrow{AB}\| = \sqrt{180} = 6\sqrt{5}\)。
最後我們得到 \(\cos\angle AOB = \frac{\|{\overrightarrow{OA}}\|^2 + \|{\overrightarrow{OB}}\|^2 - \|{\overrightarrow{AB}}\|^2}{2\|{\overrightarrow{OA}}\|\|{\overrightarrow{OB}}\|} = \frac{-3} {10\sqrt{17}}\)。
Exercise 1(b)
令 \(\theta\) 為
x
,y
之間用內積定出來的夾角﹐求 \(\cos\theta\)。
沿用 1(a) 之 \(\overrightarrow{OA}\)、\(\overrightarrow{OB}\): \[ \overrightarrow{OA} = (-4,3,5,-5,-5,0)\\ \overrightarrow{OB} = (3,-3,3,4,-4,-3) \] 由內積定義我們得到 \(\langle{\overrightarrow{OA}}, {\overrightarrow{OB}}\rangle = -6\)。
我們由內積的性質得知
\[-6 = \|{\overrightarrow{OA}}\|\|{\overrightarrow{OB}}\|\cos\angle AOB.\]
最後得到 \[\cos\angle AOB = \frac{-3}{10\sqrt{17}}.\]
Exercise 1©
前兩題算出來總是一樣嗎?
請用代數的方法證明。
Sample:
It is known that \(\overline{OA} = \|{\bf x}\|\), \(\overline{OB} = \|{\bf y}\|\), and \(\overline{AB} = \|{\bf x} - {\bf y}\|\).
Thus,
\[ \frac{\overline{OA}^2 + \overline{OB}^2 - \overline{AB}^2}{2\overline{OA}\cdot \overline{OB}} = \frac{\|{\bf x}\|^2 + \|{\bf y}\|^2 - \|{\bf x} - {\bf y}\|^2}{2\|{\bf x}\|\|{\bf y}\|}=\frac{2\langle {\bf x},{\bf y}\rangle}{2\|{\bf x}\|\|{\bf y}\|}=\frac{\langle {\bf x},{\bf y}\rangle}{\|{\bf x}\|\|{\bf y}\|}. \]
Exercises
Exercise 2
將每個向量都展開
(像是 \({\bf x} = (x_1,\ldots, x_n)\))﹐
把每個長度和內積的定義也都展開。
證明 Main idea 中最後列出來的那些性質
(除了三角不等式和柯西不等式以外)。
(1)
Recall 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}. \]
Also, we know \(x^2\geq 0\) for any \(x\in\mathbb{R}\) and the equality holds if and only if \(x = 0\).
Since \(x_1^2 , \cdots, x_n^2 \geq{\bf 0}\), we have \(\|\bx\| \geq 0\).
Moveover, when \(\|{\bf x}\| = \sqrt{x_1^2 + \cdots + x_n^2} = 0\), \({x_1^2 , \cdots, x_n^2}\) must all be \(0\), which made \({\bf x} = {\bf 0}\).
aligned
對齊(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} \] 其中 \(\bx = (x_1,\ldots, x_n)\)。
(4)
藉由代數計算,可以直接驗證
\[ \langle{\bf x},{\bf x} \rangle = {x_1^2 + \cdots + x_n^2} = \|{\bf x}\|^2. \]
(5)
藉由代數計算,可以直接驗證 \[ \begin{aligned} \langle {\bf x}_1 + {\bf x}_2,{\bf y}\rangle &=({\bf x}_{11} + {\bf x})_{21}{\bf y} + \cdots + ({\bf x}_{1n} + {\bf x}_{2n})\by_n \\ &=({\bf x}_{11}{\bf y} + \cdots + {\bf x}_{1n}{\bf y}_n) + ({\bf x}_{21}{\bf y} + \cdots + {\bf x}_{2n}{\bf y}_{n})\\ &=\langle \bx_1 , \by \rangle + \langle \bx_2 , \by \rangle. \end{aligned} \]
(6)我們要驗證 \(\langle k{\bf x},{\bf y}\rangle = k\langle{\bf x},{\bf y}\rangle\)。
令 \({\bf x} = (x_1,\ldots, x_n)\),\({\bf y} = (y_1,\ldots, y_n)\)。
藉由代數運算,可以直接驗證 \[ \begin{aligned} \langle k{\bf x},{\bf y}\rangle &= kx_1y_1 + \cdots + kx_ny_n\\ &= k(x_1y_1 + \cdots + x_ny_n)\\ &=k\langle{\bf x},{\bf y}\rangle. \end{aligned} \]
(7)我們要驗證 \(\langle{\bf x},{\bf y}\rangle = \langle{\bf y},{\bf x}\rangle\)。
令 \({\bf x} = (x_1,\ldots, x_n)\),\({\bf y} = (y_1,\ldots, y_n)\)。
將 \(\langle{\bf x},{\bf y}\rangle\) 展開得到 \(x_1y_1+\cdots+x_ny_n\),
再利用乘法交換律將式子改寫成 $y_1x_1+\cdots+y_nx_n = \langle{\bf y},{\bf x}\rangle. $
Exercise 3
證明 \(\|{\bf x} \pm {\bf y}\|^2 = \|{\bf x}\|^2 \pm 2\langle{\bf x},{\bf y}\rangle + \|{\bf y}\|^2\)。
aligned
令 \({\bf x} = (x_1,\ldots, x_n)\),\({\bf y} = (y_1,\ldots, y_n)\),
則\(\|{\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)\),
再將式子整理後得到
\[ \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
給定兩個向量 \({\bf x},{\bf y}\)。
若 \({\bf y}\) 可以寫成兩個分量相加 \({\bf y} = {\bf h} + {\bf w}\)﹐
其中 \({\bf h}\) 和 \({\bf x}\) 垂直(所以 \(\langle{\bf h},{\bf x}\rangle = 0\))、
而 \({\bf w}\) 和 \({\bf x}\) 平行(所以 \({\bf w} = k{\bf x}\)),
求 \({\bf h}\) 和 \({\bf w}\)(用 \({\bf x}\) 和 \({\bf y}\) 表示出來)。
frac{}{}
假設 \({\bf w} = k{\bf x}\) 而 \({\bf y} - {\bf w} ={\bf h}\)。
已知 \(\langle{\bf h},{\bf x}\rangle = 0 = \langle{\bf y} - {\bf w},{\bf x}\rangle = \langle{\bf y} - k{\bf x},{\bf x}\rangle\)。
藉由代數運算得 \(0 = \langle{\bf y} - k{\bf x},{\bf x}\rangle = \langle{\bf y},{\bf x}\rangle - k\langle{\bf x},{\bf x}\rangle\),所以 \(k = \frac{\langle{\bf y},{\bf x}\rangle}{\langle{\bf x},{\bf x}\rangle}\)。
將 \(k\) 帶入原式得 \({\bf w} = {\bf x}\)\(\frac{\langle{\bf y},{\bf x}\rangle}{\langle{\bf x},{\bf x}\rangle}\)
以及 \({\bf h} = {\bf y} - {\bf x}\)\(\frac{\langle{\bf y},{\bf x}\rangle}{\langle{\bf x},{\bf x}\rangle}\)。
Exercise 5
依照以下步驟證明三角不等式和柯西不等式等價。
三角不等式
對任意兩個向量 \({\bf x},{\bf y}\in\mathbb{R}^n\)
不等式 \(\|{\bf x}\| + \|{\bf y}\| \geq \|{\bf x} - {\bf y}\|\) 皆成立。
柯西不等式
對任意兩個向量 \({\bf x},{\bf y}\in\mathbb{R}^n\)
不等式 \(|\langle {\bf x},{\bf y}\rangle| \leq \|{\bf x}\|\cdot \|{\bf y}\|\) 皆成立。
Exercise 5(a)
證明若三角不等式成立則柯西不等式成立。
Sample:
Let \({\bf x}\) and \({\bf y}\) be any given vectors in \(\mathbb{R}^n\).
By the triangle inequality, \(\|{\bf x}\| + \|{\bf y}\| \geq \|{\bf x} - {\bf y}\|\).
因為三角不等式對所有 \(\bx\) 和 \(\by\) 都成立,我們可以把 \(\by\) 的位置代入 \(-\by\) 得到 \(\|\bx\| + \|\by\| \geq \|\bx + \by\|\),因此 \[\|\bx\| + \|\by\| \geq \|\bx \pm \by\|.\] 把三角不等式的兩邊同時平方得到
(\(\|{\bf x}\| + \|{\bf y}\|)^2 \geq (\|{\bf x} \pm {\bf y}\|)^2\),
這等價於
\(\|{\bf x}\|^2 + \|{\bf y}\|^2+2\|{\bf x}\|\|{\bf y}\|\geq \|{\bf x}\|^2+ \|{\bf y}\|^2\pm 2\langle {\bf x},{\bf y}\rangle\)。
因此 \(2\|{\bf x}\|\|{\bf y}\|\geq \pm2\langle {\bf x},{\bf y}\rangle\),
也就是 \(\|{\bf x}\|\|{\bf y}\|\geq \pm\langle {\bf x},{\bf y}\rangle\)。
Therefore, \(|\langle {\bf x},{\bf y}\rangle| \leq \|{\bf x}\|\cdot \|{\bf y}\|\).
Since \({\bf x}\) and \({\bf y}\) are arbitrary, the Cauchy–Schwarz inequality holds for any vectors \({\bf x}\) and \({\bf y}\).
Exercise 5(b)
證明若柯西不等式成立則三角不等式成立。
Sample:
Let \({\bf x}\) and \({\bf y}\) be any given vectors in \(\mathbb{R}^n\).
By the Cauchy–Schwarz inequality, \(|\langle {\bf x},{\bf y}\rangle| \leq \|{\bf x}\|\cdot \|{\bf y}\|\).
Thus, \(\|{\bf x}\|\|{\bf y}\|\geq \pm\langle {\bf x},{\bf y}\rangle\).
By adding \(\|{\bf x}\|^2 + \|{\bf y}\|^2\) on both sides, we get \(\|{\bf x}\|^2 + \|{\bf y}\|^2+2\|{\bf x}\|\|{\bf y}\|\geq \|{\bf x}\|^2+ \|{\bf y}\|^2 \pm\ 2\langle {\bf x},{\bf y}\rangle\).
By completing the squares, we have (\(\|{\bf x}\| + \|{\bf y}\|)^2 \geq (\|{\bf x} - {\bf y}\|)^2\).
While both \(\|{\bf x}\| + \|{\bf y}\|\) and \(\|{\bf x} - {\bf y}\|\) are positive, \(\|{\bf x}\| + \|{\bf y}\| \geq \|{\bf x} - {\bf y}\|\).
Since \({\bf x}\) and \({\bf y}\) are arbitrary, the triangle inequality holds for any vectors \({\bf x}\) and \({\bf y}\).
Exercise 6
依照以下步驟證明柯西不等式。
Exercise 6(a)
證明當 \(\|{\bf x}\| = \|{\bf y}\| = 1\) 時柯西不等式成立。
Sample:
Let \({\bf x}\) and \({\bf y}\) be two vectors of length \(1\).
Since \(\|{\bf x} - {\bf y}\|^2 \geq 0\), we have
\(\|{\bf x}\|^2+ \|{\bf y}\|^2 - 2\langle {\bf x},{\bf y}\rangle\geq 0\).
Since \(\|{\bf x} + {\bf y}\|^2 \geq 0\), then
\(\|{\bf x}\|^2+ \|{\bf y}\|^2\)+\(2\langle {\bf x},{\bf y}\rangle\geq 0\).
Therefore, \(\pm2\langle {\bf x},{\bf y}\rangle\geq -2\) and \(2 \geq\pm2\langle {\bf x},{\bf y}\rangle\).
Therefore, \(|\langle{\bf x},{\bf y}\rangle| \leq 1\) whenever \(\|{\bf x}\| = \|{\bf y}\| = 1\).
Exercise 6(b)
證明對任何非零向量 \({\bf x},{\bf y}\in\mathbb{R}^n\) 柯西不等式皆成立。
Sample:
Now suppose \({\bf x}\) and \({\bf y}\) be arbitrary nonzero vectors in \(\mathbb{R}^n\).
Let \({\bf x}' = {\bf x}/\|{\bf x}\|\) and \({\bf y}' = {\bf y}/\|{\bf y}\|\).
Thus, \(\|{\bf x}'\| = \|{\bf y}'\| = 1\).
帶回 (a) 得到 \(|\langle {\bf x}',{\bf y}'\rangle| \leq \ 1\),
也就是\(\frac{|\langle{\bf x}, {\bf y}\rangle|}{\|{\bf x}\|\|{\bf y}\|} \leq \ 1\)。
故\(|\langle {\bf x},{\bf y}\rangle| \leq \|{\bf x}\|\cdot \|{\bf y}\|\)。
Therefore, \(|\langle {\bf x},{\bf y}\rangle| \leq \|{\bf x}\|\cdot \|{\bf y}\|\) for any nonzero vectors \({\bf x}\) and \({\bf y}\).
Exercise 6©
考慮剩餘的可能性並完成柯西不等式的證明。
當 \(\|{\bf x}\|\) 或 \(\|{\bf y}\|\) 等於 \(0\) 時,\(\|{\bf x}\|\cdot \|{\bf y}\|=0\) 且 \(\inp{\bx}{\by} = 0\)。
所以 \(|\langle {\bf x},{\bf y}\rangle| =\|{\bf x}\|\cdot \|{\bf y}\|\)。
第七題太長所以被移到別區
Exercise 7
差第七題
目前得分 5/5