[Haskell-cafe] about integer and float operations
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  for computing Pi:
>> On my system it takes 10 seconds.
>> Here is an Haskell version:
>> 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