math
Class Pi

java.lang.Object
  extended by math.Pi

public class Pi
extends java.lang.Object


Constructor Summary
Pi(int digits)
          Construct a task to calculate pi to the specified precision.
 
Method Summary
static java.math.BigDecimal arctan(int inverseX, int scale)
          Compute the value, in radians, of the arctangent of the inverse of the supplied integer to the speficied number of digits after the decimal point.
static java.math.BigDecimal computePi(int digits)
          Compute the value of pi to the specified number of digits after the decimal point.
 java.lang.Object execute()
          Calculate pi.
static void main(java.lang.String[] args)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Pi

public Pi(int digits)
Construct a task to calculate pi to the specified precision.

Method Detail

execute

public java.lang.Object execute()
Calculate pi.


computePi

public static java.math.BigDecimal computePi(int digits)
Compute the value of pi to the specified number of digits after the decimal point. The value is computed using Machin's formula: pi/4 = 4*arctan(1/5) - arctan(1/239) and a power series expansion of arctan(x) to sufficient precision.


arctan

public static java.math.BigDecimal arctan(int inverseX,
                                          int scale)
Compute the value, in radians, of the arctangent of the inverse of the supplied integer to the speficied number of digits after the decimal point. The value is computed using the power series expansion for the arc tangent: arctan(x) = x - (x^3)/3 + (x^5)/5 - (x^7)/7 + (x^9)/9 ...


main

public static void main(java.lang.String[] args)