org.apache.hadoop.examples.pi.math
Class Bellard

java.lang.Object
  extended by org.apache.hadoop.examples.pi.math.Bellard

public final class Bellard
extends Object

Bellard's BBP-type Pi formula 1/2^6 \sum_{n=0}^\infty (-1)^n/2^{10n} (-2^5/(4n+1) -1/(4n+3) +2^8/(10n+1) -2^6/(10n+3) -2^2/(10n+5) -2^2/(10n+7) +1/(10n+9)) References: [1] David H. Bailey, Peter B. Borwein and Simon Plouffe. On the Rapid Computation of Various Polylogarithmic Constants. Math. Comp., 66:903-913, 1996. [2] Fabrice Bellard. A new formula to compute the n'th binary digit of pi, 1997. Available at http://fabrice.bellard.free.fr/pi .


Nested Class Summary
static class Bellard.Parameter
          Parameters for the sums
static class Bellard.Sum
          The sums in the Bellard's formula
 
Constructor Summary
Bellard()
           
 
Method Summary
static long bit2terms(long b)
          Estimate the number of terms.
static double computePi(long b)
          Compute bits of Pi in the local machine.
static
<T extends Container<Summation>>
double
computePi(long b, Map<Bellard.Parameter,T> results)
          Compute bits of Pi from the results.
static
<T extends Container<Summation>>
Map<Bellard.Parameter,Bellard.Sum>
getSums(long b, int partsPerSum, Map<Bellard.Parameter,List<T>> existing)
          Get the sums for the Bellard formula.
static void main(String[] args)
          main
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Bellard

public Bellard()
Method Detail

getSums

public static <T extends Container<Summation>> Map<Bellard.Parameter,Bellard.Sum> getSums(long b,
                                                                                          int partsPerSum,
                                                                                          Map<Bellard.Parameter,List<T>> existing)
Get the sums for the Bellard formula.


computePi

public static <T extends Container<Summation>> double computePi(long b,
                                                                Map<Bellard.Parameter,T> results)
Compute bits of Pi from the results.


computePi

public static double computePi(long b)
Compute bits of Pi in the local machine.


bit2terms

public static long bit2terms(long b)
Estimate the number of terms.


main

public static void main(String[] args)
                 throws IOException
main

Throws:
IOException


Copyright © 2009 The Apache Software Foundation