# 余弦定理

余弦定理是欧几里得几何中的一个定理，它把三角形的三条边长与其中一个角的余弦联系起来：对于边长为 \( a \)、\( b \)、\( c \) 的三角形，其中 \( c \) 是角 \( \gamma \) 所对的边，

\[ c^{2} = a^{2} + b^{2} - 2ab\cos\gamma. \]

它把勾股定理推广到任意三角形，并与正弦定理一起，构成解三角形的两件标准工具——所谓解三角形，就是由部分已知数据确定全部边长和角。<sup>[1](https://faculty.curgus.wwu.edu/Courses/Math_pages/Math_304/Law_of_cos.html)</sup>

| 关键事实 | 详情 |
|---|---|
| 表述 | \( c^{2} = a^{2} + b^{2} - 2ab\cos\gamma \)，对其他两个角有相应的两个循环置换形式<sup>[1](https://faculty.curgus.wwu.edu/Courses/Math_pages/Math_304/Law_of_cos.html)</sup> |
| 特例 | 当 \( \gamma = 90^{\circ} \) 时，\( \cos\gamma = 0 \)，公式化为勾股定理 \( c^{2} = a^{2} + b^{2} \)<sup>[2](https://odp.library.tamu.edu/math150-2nd-ed/chapter/8-5-law-of-cosines/)</sup> |
| 解出形式 | \( \cos\gamma = \dfrac{a^{2}+b^{2}-c^{2}}{2ab} \)，用于在已知三边时求角<sup>[2](https://odp.library.tamu.edu/math150-2nd-ed/chapter/8-5-law-of-cosines/)</sup> |
| 适用场合 | 边角边（SAS）与边边边（SSS）两类情形，此时正弦定理找不到可供起步的对边对角对<sup>[2](https://odp.library.tamu.edu/math150-2nd-ed/chapter/8-5-law-of-cosines/)</sup> |
| 歧义性 | 与正弦定理不同，余弦定理没有歧义情况，因为余弦在锐角为正、在钝角为负<sup>[3](https://opentextbc.ca/intermediatealgebraberg/chapter/sine-and-cosine-laws/)</sup> |
| 弯曲空间中的类比 | 球面：\( \cos a = \cos b\cos c + \sin b\sin c\cos A \)；双曲：\( \cosh c = \cosh a\cosh b - \sinh a\sinh b\cos\gamma \)<sup>[4](https://www.math.stonybrook.edu/~tony/bintet/law_of_coss.html)</sup><sup> • </sup><sup>[5](https://rimanyi.web.unc.edu/wp-content/uploads/sites/9870/2021/12/RR_Geometry.pdf)</sup> |

## 证明

**经典证明。** 从边 \( b \) 所对的顶点向 \( b \) 作高 \( h \)，把 \( b \) 分成与边 \( a \) 相邻的一段 \( x \) 和余下的一段 \( y = b - x \)。对两个直角三角形分别施用勾股定理，并利用 \( \cos\gamma = x/a \)，得

\[ c^{2} = y^{2} + h^{2} = (b-x)^{2} + h^{2} = b^{2} - 2bx + x^{2} + h^{2} = a^{2} + b^{2} - 2ab\cos\gamma. \]

这个证明两次用到勾股定理，正因如此，该定理常被说成是勾股定理的推广。<sup>[1](https://faculty.curgus.wwu.edu/Courses/Math_pages/Math_304/Law_of_cos.html)</sup> 坐标证明则把一个角的顶点放在原点，让一条邻边沿 \( x \) 轴正方向，再施用距离公式——而距离公式本身也立足于勾股定理。<sup>[2](https://odp.library.tamu.edu/math150-2nd-ed/chapter/8-5-law-of-cosines/)</sup>

**向量证明。** 若两个向量 \( \vec{a} \) 与 \( \vec{b} \) 自同一顶点出发，夹角为 \( \gamma \)，则第三边为 \( \vec{b} - \vec{a} \)。用点积展开其范数的平方，得

\[ \|\vec{b} - \vec{a}\|^{2} = \|\vec{a}\|^{2} + \|\vec{b}\|^{2} - 2\,\vec{a}\cdot\vec{b}. \]

与余弦定理相比较，即得 \( \vec{a}\cdot\vec{b} = \|\vec{a}\|\,\|\vec{b}\|\cos\gamma \)，这正是点积的几何公式。两种表述可以互相推出：既可以把余弦定理当作点积的定义，也可以用点积来证明余弦定理。<sup>[1](https://faculty.curgus.wwu.edu/Courses/Math_pages/Math_304/Law_of_cos.html)</sup><sup> • </sup><sup>[6](https://tutorial.math.lamar.edu/classes/calcii/DotProduct.aspx)</sup> 正因这一联系，该定理不仅出现在三角学课程中，也出现在线性代数与向量微积分课程里。

## 解三角形

余弦定理覆盖了正弦定理无法起步的两类解三角形情形。在边角边（SAS）情形中，已知两边及其夹角，未知的第三边可直接求出，例如 \( b^{2} = 7^{2} + 2^{2} - 2(7)(2)\cos(50^{\circ}) \)，得 \( b \approx 5.92 \) 个单位。<sup>[2](https://odp.library.tamu.edu/math150-2nd-ed/chapter/8-5-law-of-cosines/)</sup> 在边边边（SSS）情形中，用解出形式可由三边长度求出每个角的余弦。<sup>[2](https://odp.library.tamu.edu/math150-2nd-ed/chapter/8-5-law-of-cosines/)</sup>

**为什么没有歧义情况。** 正弦定理用于两边及其中一边的对角（SSA）时，可能产生两个合法的三角形，因为正弦函数在第一、第二象限都取正值，所以一个角与其补角有相同的正弦值。<sup>[7](https://math.libretexts.org/Bookshelves/Algebra/College_Algebra_and_Trigonometry_%28Beveridge%29/11%3A_The_Law_of_Sines_and_The_Law_of_Cosines/11.02%3A_The_Law_of_Sines_-_the_ambiguous_case)</sup> 余弦函数没有这个问题：它在锐角为正、在钝角为负，因此算出的余弦值唯一确定该角。有鉴于此，教科书建议在解边边边（SSS）三角形时，先用余弦定理求最大的角——钝角若存在，必在此处——再用正弦定理求其余各锐角。<sup>[3](https://opentextbc.ca/intermediatealgebraberg/chapter/sine-and-cosine-laws/)</sup><sup> • </sup><sup>[2](https://odp.library.tamu.edu/math150-2nd-ed/chapter/8-5-law-of-cosines/)</sup>

## 弯曲空间中的类比

余弦定理在非欧几何中有对应物，那里直线所扮演的角色由大圆（球面几何）或测地线（双曲几何）承担。

在单位球面上，边 \( a \)、\( b \)、\( c \) 以它们所张的球心角来度量，\( A \) 为 \( a \) 所对的角，球面余弦定理写作

\[ \cos a = \cos b\cos c + \sin b\sin c\cos A. \]

当 \( A \) 为直角时，它化为 \( \cos a = \cos b\cos c \)，有时称为球面勾股定理。当各边趋于零时，展开 \( \cos a \approx 1 - a^{2}/2 \) 与 \( \sin b \approx b \)，并舍去高阶项，便还原出平面余弦定理，可见欧几里得公式是球面公式在小三角形下的极限。<sup>[4](https://www.math.stonybrook.edu/~tony/bintet/law_of_coss.html)</sup><sup> • </sup><sup>[8](https://www.ams.org/bookstore/pspdf/text-44-prev.pdf)</sup>

在双曲平面 \( H^{2} \) 中，相应的表述要用双曲函数：

\[ \cosh c = \cosh a\cosh b - \sinh a\sinh b\cos\gamma. \]

令 \( \gamma = \pi/2 \)，得双曲勾股定理 \( \cosh c = \cosh a\cosh b \)。该公式还能推出双曲三角不等式：与恒等式 \( \cosh(a+b) = \cosh a\cosh b + \sinh a\sinh b \) 相比较，可知 \( \cosh c < \cosh(a+b) \)，从而 \( c < a + b \)。<sup>[5](https://rimanyi.web.unc.edu/wp-content/uploads/sites/9870/2021/12/RR_Geometry.pdf)</sup>

## 数值上的谨慎

对于针状三角形——两边之和仅略大于第三边——教科书上的公式在浮点运算中可能损失精度。当 \( c \) 相对于几乎相等的 \( a \) 与 \( b \) 非常小时，量 \( a^{2} + b^{2} - 2ab\cos C \) 是两个相近数之差，舍入误差可能淹没结果。加州大学伯克利分校数学与计算机科学教授威廉·卡汉（William Kahan）推荐代数上等价的形式

\[ c = \sqrt{(a-b)^{2} + 4ab\sin^{2}(C/2)}, \]

它避开了相消，对这类形状仍能保持精度。<sup>[9](https://people.eecs.berkeley.edu/~wkahan/Triangle.pdf)</sup>

## 历史

波斯数学家和天文学家贾姆希德·卡西（Jamshīd al-Kāshī，卒于…… 至于球面版本，已知最早的表述由雷格蒙塔努斯（Regiomontanus）于 1464 年给出，仍用早期天文学家所用的类似正矢的函数来写；更早的天文学家巴塔尼（al-Battani）在计算中使用过与余弦等价的函数，但并未表述球面余弦定理。<sup>[11](https://www.math.stonybrook.edu/~tony/archive/336f06/spher-trig.html)</sup>

## References

1. [Law of cosines, Branko Ćurgus, Western Washington University](https://faculty.curgus.wwu.edu/Courses/Math_pages/Math_304/Law_of_cos.html)
2. [8.5 Law of Cosines, Functions, Trigonometry, and Systems of Equations (Second Edition), Texas A&M University Open Education Library](https://odp.library.tamu.edu/math150-2nd-ed/chapter/8-5-law-of-cosines/)
3. [11.8 Sine and Cosine Laws, Intermediate Algebra, BCcampus Open Textbooks](https://opentextbc.ca/intermediatealgebraberg/chapter/sine-and-cosine-laws/)
4. [The Law of Cosines in Spherical Trigonometry, Stony Brook University](https://www.math.stonybrook.edu/~tony/bintet/law_of_coss.html)
5. [Hyperbolic Geometry, Chapter 5: Laws of Cosines and Sines, University of North Carolina (R. Rimányi)](https://rimanyi.web.unc.edu/wp-content/uploads/sites/9870/2021/12/RR_Geometry.pdf)
6. [Calculus II: Dot Product, Paul's Online Math Notes, Lamar University](https://tutorial.math.lamar.edu/classes/calcii/DotProduct.aspx)
7. [11.2: The Law of Sines, the Ambiguous Case, Mathematics LibreTexts](https://math.libretexts.org/Bookshelves/Algebra/College_Algebra_and_Trigonometry_%28Beveridge%29/11%3A_The_Law_of_Sines_and_The_Law_of_Cosines/11.02%3A_The_Law_of_Sines_-_the_ambiguous_case)
8. [Note to the Instructor, Spherical Trigonometry, American Mathematical Society textbook preview](https://www.ams.org/bookstore/pspdf/text-44-prev.pdf)
9. [Miscalculating Area and Angles of a Needle-like Triangle, W. Kahan, University of California, Berkeley](https://people.eecs.berkeley.edu/~wkahan/Triangle.pdf)
10. [Al-Kashi (1390–1450), MacTutor History of Mathematics, University of St Andrews](https://mathshistory.st-andrews.ac.uk/Biographies/Al-Kashi/)
11. [Spherical Trigonometry course notes, Stony Brook University](https://www.math.stonybrook.edu/~tony/archive/336f06/spher-trig.html)

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

Topic: 物质世界与数学 › 数学与统计学 › 几何学与拓扑学 › Elementary and Euclidean geometry › Plane figures

Copyright 2026 Edgepedia

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

Source: https://www.edgepedia.org/zh/law-of-cosines

English original: https://www.edgepedia.org/law-of-cosines
