bookExamples.ch05ControlStructs
Class Pi
java.lang.Object
bookExamples.ch05ControlStructs.Pi
public class Pi
- extends java.lang.Object
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 specified
number of digits after the decimal point. |
static void |
arctanThread1(int inverseX,
int scale)
|
static void |
arctanThread2(int inverseX,
int scale)
|
static java.math.BigDecimal |
computePi(int digits)
Compute the value of pi to the specified number of
digits after the decimal point. |
static void |
main(java.lang.String[] args)
|
Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Pi
public Pi()
main
public static void main(java.lang.String[] args)
throws java.lang.NumberFormatException
- Throws:
java.lang.NumberFormatException
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.
arctanThread1
public static void arctanThread1(int inverseX,
int scale)
arctanThread2
public static void arctanThread2(int inverseX,
int scale)
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 specified
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 ...