资源 · 指南或文章
Liu Hui's π Algorithm
数学史背景:刘徽如何通过不断倍增圆内接多边形的边数来确定圆周率的上下界。比起正在学习核心面试主题的人,更适合喜欢数值逼近类趣题的候选人。
审核日期
打开原站: Liu Hui's π Algorithm (在新标签页中打开原网站)添加到路线图
把这个资源放进你正在跟进的路线图。它会作为你自己的补充资源显示;路线图的步骤不会改变,也不计入你已记录的步骤。
来源内容语言:英语
Liu Hui remarked in his commentary to The Nine Chapters on the Mathematical Art, that the ratio of the circumference of an inscribed hexagon to the diameter of the circle was three, hence π must be greater than three. He went on to provide a detailed step-by-step description of an iterative algorithm to calculate π to any required accuracy based on bisecting polygons; he calculated π to between 3.141024 and 3.142708 with a 96-gon; he suggested that 3.14 was a good enough approximation, and expressed π as 157/50; he admitted that this number was a bit small. Later he invented an ingenious quick method to improve on it, and obtained π ≈ 3.1416 with only a 96-gon, with an accuracy comparable to that from a 1536-gon. His most important contribution in this area was his simple iterative π algorithm. Liu Hui's method of calculating the area of a circle. Further, Liu Hui proved that the area of a circle is half of its circumference multiplied by its radius. He said:
PrepKit 概览
本概览由 PrepKit 编辑根据源代码仓库撰写并审核,并非资源本身的文字。
- 适合人群
- 来源未说明适用级别
- 形式
- 课程
涵盖内容
- 开篇介绍刘徽的成果:由 96 边形得出的上下界、157/50 这一近似值,以及他更快的改进方法。
- 圆面积部分:为什么多边形面积会逼近圆面积,最终得到 A = r x C/2。
- 迭代算法部分:平分六边形的一条边,运用勾股定理(页面写作 Gou Gu)由 6 边形边长求出 12 边形边长。
使用建议
这是 PrepKit 的学习建议,并非来源的说法。
在纸上从六边形开始,把边数倍增的步骤一直推到 24 边形,然后写一个简短的循环重复这一步骤,并在每轮后打印圆周率估计值。能解释为什么每次倍增都会让估计更精确时,就算完成。
范围与局限
大部分是历史和几何内容,与面试的直接关联不大。关键公式只以来自 Wikimedia 的图片形式出现,唯一的参考资料是维基百科。没有练习或复杂度讨论。
获取方式与形式
GitHub 上的英文 Markdown README,免费阅读,位于采用 MIT 许可的 trekhleb/javascript-algorithms 仓库。
PrepKit 于 2026年10月2日 审核。 资源来源提交: 85293e3e2b88
本概览的依据
- src/algorithms/math/liu-hui/README.md
收录此条目的页面
订阅 PrepKit 通讯
可选。使用 PrepKit 并不需要订阅。