> For the complete documentation index, see [llms.txt](https://blog.baizesz.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://blog.baizesz.com/develop.md).

# develop

\
数学基础
----

### 向量

#### 定义：

在编程过程中，我们经常会用（0，0）来表示屏幕上的一个坐标，这个坐标的 X 值和 Y 值都为0，此时这个坐标就称为屏幕空间里的一个点，这个点是空间的维数来决定的，如果是二维空间，那一个点可能是（100，100），但如果是三维空间，那么一个点可能是（100，100，100）。

![向量的基础](https://blog-1257063273.cos.ap-chengdu.myqcloud.com/2020/%E5%90%91%E9%87%8F%E7%9A%84%E5%9F%BA%E7%A1%80.png)

一个坐标仅代表所在空间的位置，没有方向和大小之分，表示点的数值代表这个点距离数轴的大小，并且大小是相对于原点的

向量是一个有方向、有大小、但没有位置的量，在表现方式上和点类似，都是通过多个数值组成的一组数据来表示的：

$$\
\begin{pmatrix} 100\\\ 100\\\ \end{pmatrix} 和 \begin{pmatrix} 100\\\ 100\\\ 100 \end{pmatrix} \\\ 排列形式二 \\\ \begin{pmatrix} 100, 100 \\\ \end{pmatrix} \begin{pmatrix} 100, 100, 100 \\\ \end{pmatrix}\
$$<br>

一个是横排列，一个竖提成列，其实就里向量只是书写形式不一样，如果写成横排列形式，向量就叫作“行向量”，竖排形式叫作列向量。在向理的每组数据中，单个数据称为分量，通常用分量的个数来代表向量的维度：二维和三维向量。

#### 向量的图形表示

向量在同何中可以表示为带箭头的线段，箭头代表向量的方向，线段的长度代表向量的大小，注意：**点的坐标是相对原点的，但向量的坐标是相对起始点的**，如下图所示，左侧是单个向量，包含起始点和方向，右侧是把多个向量的起始点固定在一个位置，而方向都不同。

![向量表示](https://blog-1257063273.cos.ap-chengdu.myqcloud.com/2020/%E5%90%91%E9%87%8F%E8%A1%A8%E7%A4%BA.png)

在物理学中也称为矢量，一个运行物体的位移、速度、加速度都可以使用矢量来描述，比如，一个人骑自行车向北10km/h 的速度骑行，此时10km/h 就代表一个矢量，既有方向又有大小。

#### 向量的模

向量的大小就是它自身的长度，也称为模，向量的标记作 | 𝛎 |，假设我们要求二维向量（100，100）和三维向量（100，100，100）的模，方法如下：

$$\
|(100,100)| =\sqrt{100^2+100^2}\approx 141.42 \\\ |(100,100,100)| =\sqrt{100^2+100^2+100^2}\approx 173.21\
$$<br>

通过计算方法也可以看出规律，如果要求向量的 𝛎 的模，则公式为：

$$\
𝛎 = |(x\_1 \cdots x\_n)| = \sqrt{x\_1^2+ ⋯ + x\_n^2}\
$$<br>

#### 向量的运算

1. 加减法：

$$\
\begin{pmatrix} x\_1 \\\ \vdots \\\ x\_n\end{pmatrix} + \begin{pmatrix} y\_1 \\\ \vdots \\\ y\_n\end{pmatrix}=\begin{pmatrix} x\_1+y\_1 \\\ \vdots \\\ x\_n+y\_n\end{pmatrix} \quad\quad\quad\quad\quad\quad\quad \begin{pmatrix} x\_1 \\\ \vdots \\\ x\_n\end{pmatrix} - \begin{pmatrix} y\_1 \\\ \vdots \\\ y\_n\end{pmatrix}=\begin{pmatrix} x\_1-y\_1 \\\ \vdots \\\ x\_n-y\_n\end{pmatrix}\
$$<br>

上面说的是列向量的运算，如是行向量，则也是相同的运算方法，行向量的加减法如下：

$$\
\begin{pmatrix} x\_1 \cdots x\_n \end{pmatrix}+ \begin{pmatrix} y\_1 \cdots y\_n \end{pmatrix}= \begin{pmatrix} x\_1 + y\_1 \cdots x\_n + y\_n \end{pmatrix} \\\ \begin{pmatrix} x\_1 \cdots x\_n \end{pmatrix}- \begin{pmatrix} y\_1 \cdots y\_n \end{pmatrix}= \begin{pmatrix} x\_1 - y\_1 \cdots x\_n - y\_n \end{pmatrix}\
$$<br>

2. 标量的乘除法：

   标量的乘除法的规则为：

   $$\
   k \begin{pmatrix} x\_1 \\\ \vdots \\\ x\_n \end{pmatrix}= \begin{pmatrix}kx\_1 \\\ \vdots \\\ kx\_n\end{pmatrix} \quad\quad\quad\quad\quad\quad\quad \frac{1}{k} \begin{pmatrix} x\_1 \\\ \vdots \\\ x\_n \end{pmatrix}= \begin{pmatrix} \frac{x\_1}{k} \\\ \vdots \\\ \frac{x\_n}{k} \end{pmatrix}\
   $$<br>

   行向量的标量乘除法规则为：

   $$\
   k\begin{pmatrix} x\_1 \cdots x\_n \end{pmatrix}= \begin{pmatrix} kx\_1 \cdots kx\_n \end{pmatrix}\\\ \frac{1}{k}\begin{pmatrix} x\_1 \cdots x\_n \end{pmatrix}= \begin{pmatrix} \frac{x\_1}{k} \cdots \frac{x\_n}{k} \end{pmatrix}\\\\\
   $$<br>

   因为x1、x2、x3…….xn众数为n，而众数kx1、kx2、kx3……. kxn这一组数据中，每一个数都扩大了k倍，故其众数为kn
3. 点积：

   向量之间也可以进行乘法运算，但是和普通标量的乘法运算区别较大，向量的乘法运算分为两种：**点积**和**叉积**。

   **点积（内积）**：又称数量积也称内积，点积有两个计算公式，先看第一个公式：

   $$\
   a \cdot b = (a\_1, a\_2,\cdots, a\_n)\cdot(b\_1, b\_2, \cdots, b\_n) = a\_1b\_1+a\_2b\_2+\cdots+a\_nb\_n\
   $$<br>

   从公式中可以看到，两个向量的点积运算就是两个向量对应的每个分量相乘并把结果相加，最后会得到一个标量，例如：

   $$\
   a \cdot b = (50, 50)\cdot(60, 70) = 3000+3500=6500\
   $$<br>

   再来看第二个公式，这个公式与两个向量的角度有关，有两个向量的点积就等于各自的模相乘，最后再与两个向量夹角的 \cos0值相乘，如下：

   $$\
   a \cdot b = \begin{vmatrix} a\end{vmatrix}\begin{vmatrix} b\end{vmatrix}\cos0\
   $$<br>

   **叉积（外积）**：说完点积，再来看看叉积。叉积和点积不同的是，其结果还是向量。并且叉积有一个特性，就是只针对三维向量运算，其他维度的向量运算在几何上没有意义，公式为：

   $$\
   a \times b = (a\_x, a\_y, a\_z)\times(b\_x, b\_y, b\_z) = (a\_yb\_z - a\_zb\_y, a\_xb\_z - a\_xb\_z,a\_xb\_y-a\_yb\_a)\
   $$<br>

   公式看起来复杂，仔细观察，是有规律的。在公式最后推导出来的算式中，第一组的下标是\_y和\_z，第二个下标是 \_z和\_x，第三组下标是\_x和\_y

   ![xiangliangchaji](https://blog-1257063273.cos.ap-chengdu.myqcloud.com/2020/xiangliangchaji.png)

#### 单位向量

每一个向量都包含一个单位向量，它具有确定的方向，和原向量方向相同，把一个向量转换成单位向量的过程叫**向量归一化**。

对于任意非零向量 a（起点为 A，终点为 B），需要它的单位向量，公式如下：

$$\
\to \\\ AB = \frac{AB}{\begin{vmatrix} AB \end{vmatrix}}\
$$<br>

例如：

$$\
\frac{(50, 50)}{\begin{vmatrix}(50, 50)\end{vmatrix}}= \frac{(50, 50)}{\sqrt{50\_2+50\_2}} \approx \frac{(50, 50)}{70.711} \approx (\frac{50}{70.711},\frac{50}{70.711}) \approx (0.707,0.707)\
$$<br>

长度为0的向量叫作**零向量**，记作0，零向量的始点和终点重合，所以零向量没有确定的方向，或者说零向量的方向是任意的。

### 矩阵

<br>


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://blog.baizesz.com/develop.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
