3

I want to calculate Pi digits from 13 trillion to 13.1 trillion.

What is the fastest tool for this?

Requirements:

  • Runs on Linux
  • Open source
  • Does NOT calculate the first 13 trillions (only calculates from the given offset)
  • Output text file(s)
1

You can computing the nth binary digit of pi using the Plouffe formula:

enter image description here

The algorithm is the fastest way to compute the nth digit (or a few digits in a neighborhood of the nth); because of this, by using multiple machines, it is the fastest way to compute all the digits from 1 to n. Also, on a single machine If the memory size of all the digits from 1 – n causes thrashing on the machine, it is the fastest way to compute all the digits from 1 to n.

In Python:

>>> from decimal import Decimal as d, getcontext
>>> def bbp(n):
...    return sum( 1/d(16**k)                                      \
...                * (4/d(8*k+1)-2/d(8*k+4)-1/d(8*k+5)-1/d(8*k+6)) \
...                for k in xrange(n))
...
>>> print bbp(50)
3.141592653589793238462643381
>>>
>>> getcontext().prec = 70
>>> print bbp(50)
3.141592653589793238462643383279502884197169399375105820974944592246655

As a result, it seems like you are looking for the fastest implementation of the Plouffe formula. I haven't seen any benchmark and it depends on your hardware (especially GPU).

  • Thanks! Could you please modify the Python code to calculate the digits from 13 trillion to 13 trillion + 10? For now bbp only takes one argument which means no offset. – Nicolas Raoul Nov 19 '14 at 0:00
  • @NicolasRaoul The formula as stated calculates Pi and not the nth digit of pi. Also, from Wikipedia I read that it calculates the binary digit, which is not a base 10 digit. How many binary digits do we need to calculate a numeric digit? And how to know which binary digits are needed? – Thomas Weller Jun 1 '16 at 9:45
  • Like in 0x0100: this is only 1 binary digit, but it affects 3 decimal digits: 2, 5 and 6 – Thomas Weller Jun 1 '16 at 10:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.