如何在多台机器上计算像 PI 这样的数字?
您会以什么方式尝试使用多台计算机来计算像 PI 这样的数字?
是否有现有的算法或解决方案可以轻松做到这一点? 如何分配工作并让其他机器的结果生效?
In what way would you try to use multiple computers to compute a number like PI, i.e.?
Are there existing algorithms or solutions that make this easy to do?
How do you split up the work and let the results from other machines come into effect?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
这里有一个简单的方法:
Pi,然后可以根据内点与外点的比例计算出。要接近 pi,需要大量的点,但如果你有很多机器,你可以让每台计算机生成任意数量的点,然后简单地将计数返回到某个领导机器,该机器将收集所有结果并计算最终比例。
此方法可用于计算 pi 到您想要的任何精度......点越多,精度越高。它被称为“蒙特卡罗”方法,因为它使用随机性。请参阅http://math.fullerton.edu/mathews/n2003/montecarlopimod.html 了解更多信息。
Here's one simple way:
Pi, then, can be calculated from the ratio of inside to outside points. A very large number of points is necessary for this to approach pi, but if you have many machines, you can have each computer generate as many as you like, then simply return the counts to some leader machine, which would collect all the results and calculate the final ratio.
This method can be used to calculate pi to any precision you want...the more points, the more precision. It's called a 'Monte Carlo' method because it uses randomness. See http://math.fullerton.edu/mathews/n2003/montecarlopimod.html for more information.
“简单”版本将使用 Bailey–Borwein–Plouffe 公式或其更快的变体 Bellard 公式< /a>.它允许计算 π 的各个(二进制)数字,而无需事先计算之前的数字。
这意味着您可以将计算工作分布在不同的计算机上,而无需进行太多通信。对于较大的数字索引,即使对于单个数字,您仍然需要分布计算(因为您正在对非常大的整数进行一些乘法和除法)。
PiHex 项目使用它来计算数字 5·10 周围的一些(二进制)数字< su>12,有些大约 4·1013,有些大约 1015。
An "easy" version would be using the Bailey–Borwein–Plouffe formula, or its faster variant Bellard Formula. It allows calculating individual (binary) digits of π without calculating the previous ones before.
This means that you can distribute your calculation effort on different computers, which do not have to communicate much. For larger digit indices, you still need distribute the calculation even for a single digit (since you are doing some multiplications and divisions of really large integers).
This was used by the PiHex project to calculate some (binary) digits around digit number 5·1012, some around 4·1013 and some around 1015.
在.Net平台上,您可以尝试.net remoting
On .Net platform, you can try .net remoting