org.jscience.mathematics
Class MathUtils

java.lang.Object
  extended by org.jscience.mathematics.MathUtils

public final class MathUtils
extends java.lang.Object

The extra math library. Provides extra functions not in java.lang.Math class. This class cannot be subclassed or instantiated because all methods are static.


Method Summary
static double acosh(double x)
          Returns the arc hyperbolic cosine of a double, in the range of 0.0 through infinity.
static double asinh(double x)
          Returns the arc hyperbolic sine of a double, in the range of -infinity through infinity.
static double atanh(double x)
          Returns the arc hyperbolic tangent of a double, in the range of -infinity through infinity.
static double binomial(double n, double k)
          Returns the binomial coefficient (n k).
static int binomial(int n, int k)
          Returns the binomial coefficient (n k).
static double cosh(double x)
          Returns the hyperbolic cosine of a double.
static double factorial(double x)
          Returns the factorial.
static int GCD(int a, int b)
           
static double hypot(double x, double y)
          Returns sqrt(x2+y2).
static int LCM(int a, int b)
           
static double log10(double x)
          Returns the base 10 logarithm of a double.
static double log2(double d)
           
static double logB(double d, double d1)
           
static double logFactorial(double x)
          Returns the natural logarithm of the factorial.
static double maxOf3(double a, double b, double c)
          �O�‚̎�?
static double midOf3(double a, double b, double c)
          �O�‚̎�?
static double minOf3(double a, double b, double c)
          �O�‚̎�?
static double[] pascalTriangle(int n)
          ���R?
static double polynomialExpansion(double n, double[] k)
          Returns the multinomial coefficient (n k[]).
static int pow(int a, int b)
          Returns ab.
static int pow2(int a)
          Returns 2a.
static double round(double x, int significant)
          Rounds a number to so many significant figures.
static double sigmoid(double x)
          produces a double between 0 and 1 with (sigmoid(0.5) == 0) being true
static double sigmoid(double x, double flatteningFactor)
          sigmoid(double x) is the same as sigmoid(double x, 1), large flatteningFactor flattens the curve
static int sign(double x)
           
static double sinh(double x)
          Returns the hyperbolic sine of a double.
static int sumOfDigits(long number)
          returns the sum of all individual digits.
static double tanh(double x)
          Returns the hyperbolic tangent of a double.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

round

public static double round(double x,
                           int significant)
Rounds a number to so many significant figures.

Parameters:
x - a number to be rounded.
significant - number of significant figures to round to.

hypot

public static double hypot(double x,
                           double y)
Returns sqrt(x2+y2).


pow

public static int pow(int a,
                      int b)
Returns ab.

Parameters:
a - an integer.
b - a positive integer.

pow2

public static int pow2(int a)
Returns 2a.

Parameters:
a - a positive integer.

factorial

public static double factorial(double x)
Returns the factorial. (Wrapper for the gamma function).

Parameters:
x - a double.
See Also:
SpecialMathUtils.gamma(double)

logFactorial

public static double logFactorial(double x)
Returns the natural logarithm of the factorial. (Wrapper for the log gamma function).

Parameters:
x - a double.
See Also:
SpecialMathUtils.logGamma(double)

binomial

public static int binomial(int n,
                           int k)
Returns the binomial coefficient (n k). Uses Pascal's recursion formula.

Parameters:
n - an integer.
k - an integer.

binomial

public static double binomial(double n,
                              double k)
Returns the binomial coefficient (n k). Uses gamma functions.

Parameters:
n - a double.
k - a double btween 0 and n.

polynomialExpansion

public static double polynomialExpansion(double n,
                                         double[] k)
Returns the multinomial coefficient (n k[]). Uses gamma functions.

Parameters:
n - a double.
k[] - a double array such that k1 + k2 + k3 + ... + km = n (unchecked).

GCD

public static int GCD(int a,
                      int b)

LCM

public static int LCM(int a,
                      int b)

log10

public static double log10(double x)
Returns the base 10 logarithm of a double.

Parameters:
x - a double.

logB

public static double logB(double d,
                          double d1)

log2

public static double log2(double d)

sinh

public static double sinh(double x)
Returns the hyperbolic sine of a double.

Parameters:
x - a double.

cosh

public static double cosh(double x)
Returns the hyperbolic cosine of a double.

Parameters:
x - a double.

tanh

public static double tanh(double x)
Returns the hyperbolic tangent of a double.

Parameters:
x - a double.

asinh

public static double asinh(double x)
Returns the arc hyperbolic sine of a double, in the range of -infinity through infinity.

Parameters:
x - a double.

acosh

public static double acosh(double x)
Returns the arc hyperbolic cosine of a double, in the range of 0.0 through infinity.

Parameters:
x - a double.

atanh

public static double atanh(double x)
Returns the arc hyperbolic tangent of a double, in the range of -infinity through infinity.

Parameters:
x - a double.

sign

public static int sign(double x)

maxOf3

public static double maxOf3(double a,
                            double b,
                            double c)
�O�‚̎�?��̓��?ő�l��Ԃ�?B

Parameters:
a - ��?�
b - ��?�
c - ��?�
Returns:
�O�‚̎�?��̓��?ő�l
See Also:
midOf3(double,double,double), minOf3(double,double,double)

midOf3

public static double midOf3(double a,
                            double b,
                            double c)
�O�‚̎�?��̓�̂܂񒆂̒l��Ԃ�?B

Parameters:
a - ��?�
b - ��?�
c - ��?�
Returns:
�O�‚̎�?��̓�̂܂񒆂̒l
See Also:
maxOf3(double,double,double), minOf3(double,double,double)

minOf3

public static double minOf3(double a,
                            double b,
                            double c)
�O�‚̎�?��̓��?�?��l��Ԃ�?B

Parameters:
a - ��?�
b - ��?�
c - ��?�
Returns:
�O�‚̎�?��̓��?�?��l
See Also:
maxOf3(double,double,double), midOf3(double,double,double)

sigmoid

public static double sigmoid(double x)
produces a double between 0 and 1 with (sigmoid(0.5) == 0) being true


sigmoid

public static double sigmoid(double x,
                             double flatteningFactor)
sigmoid(double x) is the same as sigmoid(double x, 1), large flatteningFactor flattens the curve


sumOfDigits

public static int sumOfDigits(long number)
returns the sum of all individual digits. Example: sumOfDigits(123045) returns 15 (1+2+3+4+0+5).


pascalTriangle

public static double[] pascalTriangle(int n)
���R?� N �ɑ΂���p�X�J���̎O�p�`�̌W?���Ԃ�?B

Parameters:
n - ���R?� N
Returns:
n �ɑ΂���p�X�J���̎O�p�`�̌W?��̔z��