# 点积

点积（又称标量积）是作用于两个同维向量、返回一个数的一种运算：从代数上看，它是相应分量乘积之和；从几何上看，它是两个向量的长度之积乘以它们夹角的余弦。<sup>[1](https://ocw.mit.edu/ans7870/18/18.013a/textbook/HTML/chapter03/section03.html)</sup><sup> • </sup><sup>[2](https://web.mit.edu/wwmath/vectorc/3d/dotp.html)</sup> 对于向量 \( \mathbf{v} = (v_1, v_2, v_3) \) 与 \( \mathbf{w} = (w_1, w_2, w_3) \)，

\[ \mathbf{v} \cdot \mathbf{w} = v_1 w_1 + v_2 w_2 + v_3 w_3 = |\mathbf{v}|\,|\mathbf{w}|\cos\theta, \]

其中 \( \theta \) 是两向量之间的夹角。这两个公式始终一致，是这门学问的核心事实；麻省理工学院（MIT）的 World Web Math 把几何定义与代数定义的这种等价称为“一个奇迹”，因为单从任何一边看，这一点都绝非显而易见。<sup>[2](https://web.mit.edu/wwmath/vectorc/3d/dotp.html)</sup>

| 关键事实 | 说明 |
|---|---|
| 代数定义 | 相应分量乘积之和，\( \mathbf{v} \cdot \mathbf{w} = \sum_i v_i w_i \)<sup>[1](https://ocw.mit.edu/ans7870/18/18.013a/textbook/HTML/chapter03/section03.html)</sup> |
| 几何形式 | \( |\mathbf{v}|\,|\mathbf{w}|\cos\theta \)，即两向量长度之积乘以它们夹角的余弦<sup>[2](https://web.mit.edu/wwmath/vectorc/3d/dotp.html)</sup> |
| 垂直判定 | 若其中一个向量为零向量，或两个非零向量互相垂直，则点积为零<sup>[3](https://mathworld.wolfram.com/DotProduct.html)</sup> |
| 长度 | \( \mathbf{v} \) 的长度是 \( \mathbf{v} \cdot \mathbf{v} \) 的正平方根<sup>[1](https://ocw.mit.edu/ans7870/18/18.013a/textbook/HTML/chapter03/section03.html)</sup> |
| 旋转不变性 | 坐标旋转下其值不变，这正是几何公式在任意旋转坐标系中都成立的原因<sup>[1](https://ocw.mit.edu/ans7870/18/18.013a/textbook/HTML/chapter03/section03.html)</sup> |
| 功 | 恒力 \( \mathbf{F} \) 使物体发生位移 \( \mathbf{s} \) 所做的功为 \( W = \mathbf{F} \cdot \mathbf{s} = \|\mathbf{F}\|\,\|\mathbf{s}\|\cos\theta \)<sup>[4](https://openstax.org/books/calculus-volume-3/pages/2-3-the-dot-product)</sup> |
| 记号来源 | 符号 \( \mathbf{a} \cdot \mathbf{b} \) 由约西亚·威拉德·吉布斯（Josiah Willard Gibbs）与埃德温·比德韦尔·威尔逊（Edwin Bidwell Wilson）引入；奥利弗·亥维赛（Oliver Heaviside）则写作 \( \mathbf{a}\mathbf{b} \)<sup>[5](https://proofwiki.org/wiki/Definition%3ADot_Product/Historical_Note)</sup> |

## 两种定义，一种运算

代数定义可以推广到任意维数：对于两个具有相同数目实分量的向量，点积就是相应分量乘积之和。<sup>[1](https://ocw.mit.edu/ans7870/18/18.013a/textbook/HTML/chapter03/section03.html)</sup> 几何定义则只用长度和夹角：\( \mathbf{v} \cdot \mathbf{w} = |\mathbf{v}|\,|\mathbf{w}|\cos\theta \)。<sup>[2](https://web.mit.edu/wwmath/vectorc/3d/dotp.html)</sup>

二者之间的桥梁是旋转不变性。由于坐标旋转时点积不变，我们可以旋转坐标系，使第一个基向量沿 \( \mathbf{v} \) 方向，第二个基向量在 \( \mathbf{v} \) 与 \( \mathbf{w} \) 所张成的平面内与它垂直。在这个坐标系中，\( \mathbf{v} \) 的坐标为 \( (|\mathbf{v}|, 0) \)，\( \mathbf{w} \) 的坐标为 \( (|\mathbf{w}|\cos\theta, |\mathbf{w}|\sin\theta) \)，于是分量乘积之和化为 \( |\mathbf{v}|\,|\mathbf{w}|\cos\theta \)，而该结果在由旋转得到的每一个坐标系中都成立。<sup>[1](https://ocw.mit.edu/ans7870/18/18.013a/textbook/HTML/chapter03/section03.html)</sup>

## 性质

点积对每个自变量都是线性的，且关于两个自变量对称，因此分配律对任一处都适用：和或差的点积可以展开为点积的和或差。<sup>[1](https://ocw.mit.edu/ans7870/18/18.013a/textbook/HTML/chapter03/section03.html)</sup>

点积的几何意义主要体现在两条推论中。其一，向量与自身的点积给出其长度的平方：\( |\mathbf{v}| = \sqrt{\mathbf{v} \cdot \mathbf{v}} \)。<sup>[1](https://ocw.mit.edu/ans7870/18/18.013a/textbook/HTML/chapter03/section03.html)</sup> 其二，由于 \( \cos 90^\circ = 0 \)，两个非零向量垂直，当且仅当它们的点积为零。<sup>[3](https://mathworld.wolfram.com/DotProduct.html)</sup> 两个非零向量的点积的符号，还表明它们之间的夹角是锐角（正）、钝角（负）还是直角（零）。

## 投影与功

点积衡量的是一个向量有多少指向另一个向量的方向。标量 \( |\mathbf{v}|\cos\theta \)，即 \( \mathbf{v} \cdot \mathbf{w} \) 除以 \( |\mathbf{w}| \)，称为 \( \mathbf{v} \) 在 \( \mathbf{w} \) 方向上的分量；与之对应的向量是 \( \mathbf{v} \) 在 \( \mathbf{w} \) 上的投影，从 \( \mathbf{v} \) 中减去它，剩下的就是 \( \mathbf{v} \) 垂直于 \( \mathbf{w} \) 的那一部分。<sup>[1](https://ocw.mit.edu/ans7870/18/18.013a/textbook/HTML/chapter03/section03.html)</sup> 用分量形式写，\( \mathbf{v} \) 在 \( \mathbf{u} \) 上的向量投影为

\[ \mathrm{proj}_{\mathbf{u}}\mathbf{v} = \frac{\mathbf{u} \cdot \mathbf{v}}{\|\mathbf{u}\|^2}\,\mathbf{u}, \]

其标量投影为 \( \mathrm{comp}_{\mathbf{u}}\mathbf{v} = (\mathbf{u} \cdot \mathbf{v})/\|\mathbf{u}\| \)。<sup>[4](https://openstax.org/books/calculus-volume-3/pages/2-3-the-dot-product)</sup> 当 \( \mathbf{u} \) 与 \( \mathbf{v} \) 的夹角为钝角时，投影的方向与 \( \mathbf{u} \) 相反。<sup>[4](https://openstax.org/books/calculus-volume-3/pages/2-3-the-dot-product)</sup>

最常见的物理应用是功。当恒力 \( \mathbf{F} \) 使物体沿直线发生位移 \( \mathbf{s} \) 时，所做的功就是点积 \( W = \mathbf{F} \cdot \mathbf{s} \)：只有沿运动方向的力分量才有贡献。OpenStax 的例子计算了一个孩子以 8 磅的力、成 55 度角拉着小车走过 50 英尺所做的功，得到 \( W = 8 \times 50 \times \cos 55^\circ \approx 229 \) 英尺-磅。<sup>[4](https://openstax.org/books/calculus-volume-3/pages/2-3-the-dot-product)</sup>

## 复向量与内积

对复向量而言，直接将相应分量的乘积求和不能充当长度的度量，因为像 \( i^2 = -1 \) 这样的项不是正数。补救的办法是对其中一个因子取共轭：在 \( \mathbb{C}^n \) 上，标准内积为

\[ \langle \mathbf{z}, \mathbf{w} \rangle = z_1\overline{w}_1 + z_2\overline{w}_2 + \cdots + z_n\overline{w}_n, \]

当向量为实向量时，它化为普通的点积。<sup>[6](https://ximera.osu.edu/oerlinalg/LinearAlgebra/RTH-0050/main)</sup> 经过这一改动，\( \langle \mathbf{z}, \mathbf{z} \rangle = |z_1|^2 + \cdots + |z_n|^2 \) 是一个非负实数，且仅当向量为零向量时才为零，因此范数 \( \|\mathbf{z}\| = \sqrt{\langle \mathbf{z}, \mathbf{z} \rangle} \) 有良好定义。<sup>[6](https://ximera.osu.edu/oerlinalg/LinearAlgebra/RTH-0050/main)</sup> 代价是失去对称性：交换两个自变量的位置会使值取共轭，这一性质称为共轭对称性。<sup>[7](https://theory.stanford.edu/~blynn/linear/ortho.html)</sup> 抽象地说，点积是内积的原型——内积是定义在向量对上的函数，具有正定性、可加性与齐次性；带有这种运算的向量空间称为内积空间，而点积是 \( \mathbb{R}^n \) 上使标准基成为标准正交基的那个特殊内积。<sup>[8](https://ximera.osu.edu/oerlinalg/LinearAlgebra/VSP-0070/main)</sup>

## 历史

点积作为现代向量分析的一部分进入数学，而向量分析是从威廉·罗恩·哈密顿（William Rowan Hamilton）的四元数中脱胎出来的。约西亚·威拉德·吉布斯于 1881 年和 1884 年在纽黑文（New Haven）印行了他的《向量分析基础》（*Elements of Vector Analysis*），私下分发给他在耶鲁（Yale）的班级和部分通信者；奥利弗·亥维赛则独立地得到了一个本质相同的体系，并将其应用于电磁理论。<sup>[9](https://library.si.edu/digital-library/book/elementsvectora00gibb?height=60%25&inline=true&width=80%25)</sup><sup> • </sup><sup>[10](https://www.encyclopedia.com/people/science-and-technology/physics-biographies/josiah-willard-gibbs)</sup> 吉布斯这一版本直到 1901 年才正式出版，那一年他的学生威尔逊根据吉布斯的讲课编写了教科书《向量分析》（*Vector Analysis*）；点积的记号 \( \mathbf{a} \cdot \mathbf{b} \) 出自吉布斯与威尔逊，而亥维赛则把两个向量并排书写，不加任何符号。<sup>[10](https://www.encyclopedia.com/people/science-and-technology/physics-biographies/josiah-willard-gibbs)</sup><sup> • </sup><sup>[5](https://proofwiki.org/wiki/Definition%3ADot_Product/Historical_Note)</sup> 吉布斯-亥维赛体系是在十九世纪末与四元数拥护者争论了数十年之后，才获得承认的。<sup>[11](https://books.google.com/books/about/A_History_of_Vector_Analysis.html?hl=en&id=y5-S5dmVqGIC&output=html_text)</sup>

## 实际计算

点积是 BLAS（基础线性代数子程序，Basic Linear Algebra Subprograms）标准中的一级例程，大多数数值线性代数库都建立在它之上：实数例程 \( \mathrm{xDOT} \) 计算 \( x^T y \)，复数例程 \( \mathrm{xDOTC} \) 计算共轭形式 \( x^H y \)。<sup>[12](https://www.netlib.org/lapack/lug/node145.html)</sup> 参考实现在一个循环中累加乘积，并对单位步长采用循环展开。<sup>[13](https://netlib.org/lapack/explore-html/d5/df6/ddot_8f_source.html)</sup>

在浮点运算中，求和的次序是有影响的。英伟达（NVIDIA）的 CUDA 文档给出了一个四元素算例：串行求和、使用融合乘加的串行求和，以及并行树形归约，三者给出的结果都与精确的数学值略有差异；在这个例子中，融合乘加版本最为精确，而并行归约比串行求和更精确。<sup>[14](https://docs.nvidia.com/cuda/archive/11.0/floating-point/index.html)</sup> GPU 还为这一运算增加了专用硬件：英伟达的 DP4A 与 DP2A 指令以 32 位整数累加，快速完成 4 路和 2 路的 8 位与 16 位整数点积。<sup>[15](https://developer.nvidia.com/blog/mixed-precision-programming-cuda-8/)</sup>

## 应用

**计算机图形学。** 漫反射光照使用表面法线 \( \mathbf{N} \) 与光照方向 \( \mathbf{L} \) 的点积：对单位向量而言，这就是光线射到表面时的夹角的余弦，反射颜色按该值缩放。点积为负意味着法线背向光源，因此该方向的光照不到这个表面。<sup>[16](https://math.hws.edu/graphicsbook/c7/s2.html)</sup>

**相似度搜索与机器学习。** 嵌入把文本或条目表示为向量，点积则充当相似度得分。余弦相似度是归一化的点积，\( K(X,Y) = \langle X, Y \rangle / (\|X\|\,\|Y\|) \)，在经 L2 归一化的数据上它就等于普通的点积。<sup>[17](https://scikit-learn.org/stable/modules/generated/sklearn.metrics.pairwise.cosine_similarity.html)</sup> 这两种度量所奖励的东西不同：点积随向量长度增长，因此偏爱嵌入较长的条目，在推荐场景中这反映的是热度；而余弦相似度只取决于夹角。<sup>[18](https://developers.google.com/machine-learning/clustering/dnn-clustering/supervised-similarity)</sup> 举例来说，OpenAI 的文本相似度嵌入就是用点积来比较、得出 -1 到 1 之间的相似度得分的；又因为它的嵌入向量都被归一化为长度 1，余弦相似度可以直接作为点积计算。<sup>[19](https://openai.com/index/introducing-text-and-code-embeddings/)</sup><sup> • </sup><sup>[20](https://developers.openai.com/api/docs/guides/embeddings)</sup>

## References

1. [3.3 The Dot Product, MIT OpenCourseWare 18.013A Calculus with Applications](https://ocw.mit.edu/ans7870/18/18.013a/textbook/HTML/chapter03/section03.html)
2. [Dot Product, MIT World Web Math: Vector Calculus](https://web.mit.edu/wwmath/vectorc/3d/dotp.html)
3. [Dot Product, Wolfram MathWorld](https://mathworld.wolfram.com/DotProduct.html)
4. [2.3 The Dot Product, OpenStax Calculus Volume 3](https://openstax.org/books/calculus-volume-3/pages/2-3-the-dot-product)
5. [Definition:Dot Product/Historical Note, ProofWiki](https://proofwiki.org/wiki/Definition%3ADot_Product/Historical_Note)
6. [Complex Matrices, Ximera Open Linear Algebra (Ohio State)](https://ximera.osu.edu/oerlinalg/LinearAlgebra/RTH-0050/main)
7. [Linear Algebra: Orthogonality, Complex Inner Product Spaces, Stanford](https://theory.stanford.edu/~blynn/linear/ortho.html)
8. [Inner Product Spaces, Ximera Open Linear Algebra (Ohio State)](https://ximera.osu.edu/oerlinalg/LinearAlgebra/VSP-0070/main)
9. [Elements of Vector Analysis, J. Willard Gibbs, Smithsonian Libraries](https://library.si.edu/digital-library/book/elementsvectora00gibb?height=60%25&inline=true&width=80%25)
10. [Josiah Willard Gibbs, Encyclopedia of World Biography](https://www.encyclopedia.com/people/science-and-technology/physics-biographies/josiah-willard-gibbs)
11. [A History of Vector Analysis, Michael J. Crowe, Google Books](https://books.google.com/books/about/A_History_of_Vector_Analysis.html?hl=en&id=y5-S5dmVqGIC&output=html_text)
12. [Quick Reference Guide to the BLAS, Netlib](https://www.netlib.org/lapack/lug/node145.html)
13. [BLAS/SRC/ddot.f Source File, LAPACK/Netlib](https://netlib.org/lapack/explore-html/d5/df6/ddot_8f_source.html)
14. [Floating Point and IEEE 754, CUDA Toolkit Documentation](https://docs.nvidia.com/cuda/archive/11.0/floating-point/index.html)
15. [Mixed-Precision Programming with CUDA 8, NVIDIA Technical Blog](https://developer.nvidia.com/blog/mixed-precision-programming-cuda-8/)
16. [Introduction to Computer Graphics, Section 7.2: Lighting and Material](https://math.hws.edu/graphicsbook/c7/s2.html)
17. [cosine_similarity, scikit-learn documentation](https://scikit-learn.org/stable/modules/generated/sklearn.metrics.pairwise.cosine_similarity.html)
18. [Measuring similarity from embeddings, Google Machine Learning Crash Course](https://developers.google.com/machine-learning/clustering/dnn-clustering/supervised-similarity)
19. [Introducing text and code embeddings, OpenAI](https://openai.com/index/introducing-text-and-code-embeddings/)
20. [Vector embeddings guide, OpenAI API documentation](https://developers.openai.com/api/docs/guides/embeddings)

---
*Initially written Sep 17, 2026 · Reviewed: Sep 17, 2026; Sep 30, 2026; Oct 15, 2026 · Edited: Sep 30, 2026; Oct 15, 2026 · Last review: Oct 15, 2026*

Topic: 物质世界与数学 › 数学与统计学 › 数与代数 › Linear and multilinear algebra › Multilinear and tensor algebra › Bilinear forms and inner products

Copyright 2026 Edgepedia

License: Edgepedia Community License 1.0, https://www.edgepedia.org/edgepedia/license

Source: https://www.edgepedia.org/zh/dot-product

English original: https://www.edgepedia.org/dot-product
