计算PI -- 采用刘徽的割圆术方法
PI
https://www.mathsisfun.com/numbers/pi.html
Draw a circle with a diameter (all the way across the circle) of 1
Then the circumference (all the way around the circle) is 3.14159265... a number known as Pi
Pi (pronounced like "pie") is often written using the greek symbol π
The definition of π is:
The Circumference
divided by the Diameter
of a Circle.The circumference divided by the diameter of a circle is always π, no matter how large or small the circle is!
To help you remember what π is ... just draw this diagram.
Finding Pi Yourself
Draw a circle, or use something circular like a plate.
Measure around the edge (the circumference):
I got 82 cmMeasure across the circle (the diameter):
I got 26 cmDivide:
82 cm / 26 cm = 3.1538...
That is pretty close to π. Maybe if I measured more accurately?
割圆术
https://www.zhihu.com/question/342855331
作者:大的要来了
链接:https://www.zhihu.com/question/342855331/answer/2032705657
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
内割法公式推导
内割法代码实现
https://github.com/fanqingsong/code_snippet/blob/master/CPP/calc_pi.cpp
#include <iostream> #include <cmath> using namespace std; double getEdgeLen(int cutnum) { int halfCutnum = cutnum / 2; double edgeLen = 0; double halfEdgeLen = 0; if (cutnum == 6) { return 1; } halfEdgeLen = getEdgeLen(halfCutnum); edgeLen = sqrt(2 - sqrt(4 - pow(halfEdgeLen, 2))); return edgeLen; } bool checkCutnum(int cutnum) { if (cutnum < 6) { cout << "cutnum is a positive integer greater than and equal to 6, please correct." << endl; return false; } if (cutnum % 6 != 0) { cout << "cutnum must be times 6, please correct." << endl; return false; } while (true) { if (cutnum % 2 == 0) { cutnum /= 2; continue; } if (cutnum != 3) { cout << "cutnum must be 2 power times 6." << endl; return false; } } return true; } int main() { int cutnum = 0; double edgeLen = 0; double quasiPerimeter = 0; double quasiPI = 0; //printf("hello world\r\n"); cout << "please input cutnum for cutting circle, like 6, 12, 24, 48, ..." << endl; cin >> cutnum; cout << "cutnum is " << cutnum << endl; if (!checkCutnum(cutnum)) { return 0; } edgeLen = getEdgeLen(cutnum); quasiPerimeter = cutnum * edgeLen; quasiPI = quasiPerimeter / 2; cout << "the quasi PI is " << quasiPI << endl; return 0; }
开方手动计算方法
https://www.zhihu.com/question/347197295/answer/832181439
作者:曹力科
链接:https://www.zhihu.com/question/347197295/answer/832181439
来源:知乎
著作权归作者所有。商业转载请联系作者获得授权,非商业转载请注明出处。
那么如何在没有计算器的时候徒手开平方呢?
现代有一种方法的原理是这样的。
以求3的平方根為例子,方法如下:
![]()
一时没看懂没关系,可以收藏以后慢慢看。
好了,如果你能看到这里,那么恭喜你,你也可以像祖冲之一样,徒手去算圆周率了。
穿越回到那个时代,别忘了要一个大广场,再加连起来可以绕地球一圈的算筹。