计算π到“无限” C#中的二进制精度 [英] Computing π to "infinite" binary precision in C#

查看:136
本文介绍了计算π到“无限” C#中的二进制精度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

到目前为止,看起来Fabrice Bellard的基础2方程是要走的路



任何人都有一个Haskell版本?

解决方案

由于您要求提供Haskell版本,因此这是一篇论文作者:Jerzy Karczmarczuk,被称为世界上最不可靠的技术来计算π:


这篇论文是$ b中的一个非典型练习$ b懒惰的函数编码,为
编写的乐趣和指令。它可以被读为
,任何人都可以理解
理解编程语言
Haskell。我们展示了如何实现
Bailey-Borwein-Ploue公式,
以一种共递归增量方式
产生数字3,1,4,1,
5,9。 。直到内存
枯竭。如果有人需要许多
数字,这不是一种处理
的方法!我们的编码策略是
不正确和危险,而
可能会崩溃。它基于
算术
无穷序列位数
的域,表示适当的分数在整数基数中扩展
。我们演示如何操作
:添加乘以一个
的整数等等这样的序列,从
左边到右边的无限边,
,这显然不能在全部$ b中工作$ b案例由于含糊不清。在结论中讨论了一些
深的哲学后果。

它并不真正解决问题一个有效的或非常实用的方法,但是很有趣,并且显示了懒惰无限精度算术的一些问题。

然后还有本文由Jeremy Gibbons 撰写。




So far it looks like Fabrice Bellard's base 2 equation is the way to go

Ironically this will require a BigReal type; do we have this for .Net? .Net 4.0 has BigInteger.

Anyone have a Haskell version?

解决方案

Since you're asking for a Haskell version, here is a paper by Jerzy Karczmarczuk, called "The Most Unreliable Technique in the World to compute π":

This paper is an atypical exercice in lazy functional coding, written for fun and instruction. It can be read and understood by anybody who understands the programming language Haskell. We show how to implement the Bailey-Borwein-Ploue formula for π in a co-recursive, incremental way which produces the digits 3, 1, 4, 1, 5, 9. . . until the memory exhaustion. This is not a way to proceed if somebody needs many digits! Our coding strategy is perverse and dangerous, and it provably breaks down. It is based on the arithmetics over the domain of infinite sequences of digits representing proper fractions expanded in an integer base. We show how to manipulate: add, multiply by an integer, etc. such sequences from the left to the right ad infinitum, which obviously cannot work in all cases because of ambiguities. Some deep philosophical consequences are discussed in the conclusions.

It doesn't really solve the problem in an efficient or very practical way, but is entertaining and shows some of the problems with lazy infinite precision arithmetic.

Then there's also this paper by Jeremy Gibbons.

这篇关于计算π到“无限” C#中的二进制精度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆