Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

I am interested in creating a Java program that generates digits of $\pi$ (in Binary though). To be clear, the number I'm looking for begins: $11.00100100 \dots$

I am unsure of the most efficient way to generate the number. I have looked at the Wikipedia page for this, and I cannot seem to tell which method would be most efficient. I am looking to generating digits of $\pi$ up to perhaps even the billionth digit, so I am looking for a method that is efficient even for such accurate approximations.

Thank you in advance for any help you might give.

share|improve this question

2 Answers 2

up vote 2 down vote accepted

I suggest to play with the algorithms given under the section "Spigot algorithms", esp. the Borwein-Pluffe formula, as it can generate hex digits without memory overhead for previous results.

share|improve this answer

Generating billions of digits is probably a job best left to the pros, but you might look at http://en.wikipedia.org/wiki/Approximations_of_%CF%80

share|improve this answer
    
Thanks! I have already looked at that Wikipedia page, but I couldn't quite figure out which might be best for my application (besides the ones that were obviously less efficient). –  Ben7005 Oct 18 '12 at 5:56
    
And perhaps such a task is foolish, but is this not why we have computers to overload? –  Ben7005 Oct 18 '12 at 5:57
1  
See the section "Efficient methods". The Machin-type formulas are probably easiest to implement, as they only require addition, and multiplication and division by small integers. –  Robert Israel Oct 18 '12 at 19:19

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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