[Haskell-cafe] about integer and float operations

Henning Thielemann lemming at henning-thielemann.de
Thu Feb 5 17:19:35 EST 2009

Yitzchak Gale schrieb:
> Manlio Perillo wrote:
>> However there is still a *big* problem: it is inefficient.
>> Here is a Python version of the Chudnovsky algorithm [1] for computing Pi:
>> http://paste.pocoo.org/show/102800/
>> On my system it takes 10 seconds.
>> Here is an Haskell version:
>> http://paste.pocoo.org/show/102801/
>> On my system it takes 30 seconds.
> Ah, OK. Thanks. Now we have a well-defined problem. :)

You would not need to handle huge interim results, if you compute the
factorials incrementally. E.g. (n+1)!^3 = n!^3 * (n+1)^3 etc. 'scanl' is
your friend. This should also be faster.

More information about the Haskell-Cafe mailing list