Class Functions

java.lang.Object
org.bzdev.math.Functions

public class Functions extends Object
Class implementing elementary and special functions.

Nested classes are used to define classes associated with particular functions. Methods directly implemented in this class are provided for common cases. In some cases, the usual Java convention in which methods begin with a lower-case letter is not followed, favoring standard mathematical notation instead.

The functions provided are

  • Airy functions:
    • Ai(x) - computes the Airy function Ai(x).
    • Bi(x) - computes the Airy function Bi(x).
    • dAidx(x) - computes the derivative Ai'(x) of the Airy function Ai(x).
    • dBidx(x) - computes the derivative Bi'(x) of the Airy function Bi(x).
  • Bernstein Polynomials:
    • B(i,n,x) - computes a Bernstein polynomial of degree n and order i at a point x. These polynomials are defined as follows: $$ B_{i,n}(x) = \left(\begin{array}{c}n\\i\end{array}\right) x^i(1-x)^{n-i}$$
    • dBdx(i,n,x) - computes the first derivative with respect to x of Bernstein(i,n,x).
    • d2Bdx2(i,n,x) - computes the second derivative with respect to x of B(i,n,x).
    • B(n, λ, τ...) - computes a Bernstein polynomial for barycentric coordinates, given by $$ B^n_{\mathbf{\lambda}}(\tau) = \frac{n!}{\lambda_0!\lambda_1!\ldots\lambda_{n-1} \tau_0^{\lambda_0}\tau_1^{\lambda_1} \cdots \tau_{n-1}^{\lambda_{n-1}}
                   n!
      Bnλ(τ) = __________ τ0λ0τ1λ1...τm-1λm-1
              λ12!...λm!
      where n is the length of the vectors λ and τ, and where the sum of the components of λ must be n. Barycentric coordinates are also defined so that the sum of the components of τ is 1, but this constraint must be satisfied by the caller.
    • dBdx(i, n, λ, τ...) - computes ∂Bnλ(τ) / ∂τi.
    • d2Bdxdy(i, j n, λ, τ...) - computes ∂2Bnλ(τ) / ∂τi∂τj. If i = j, the value is ∂2Bnλ(τ) / ∂τi2
  • Bessel functions, spherical Bessel functions, and modified Bessel functions, each of the first and second kind:
    • J(n,x) - computes Jn(x) for integer and real values of n.
    • dJdx(n,x) - computes $\frac{d}{dx}J_n(x)$ for integer and real values of x
    • Y(n,x) - computes Yn(x) for integer and real values of n.
    • dYdx(n,x) - computes $\frac{d}{dx}Y_n(x)$ for integer and real values of x.
    • j(n,x) - computes jn(x) for integer and real values of n.
    • djdx(n,x) - computes $\frac{d}{dx}j_n(x)$ for integer and real values of x
    • y(n,x) - computes yn(x) for integer and real values of n.
    • dydx(n,x) - computes $\frac{d}{dx}y_n(x)$ for integer and real values of x
    • I(n,x) - computes In(x) for integer and real values of n.
    • dIdx(n,x) - computes $\frac{d}{dx}I_n(x)$ for integer and real values of x
    • K(n,x) - computes Kn(x) for integer and real values of n.
    • dKdx(n,x) - computes $\frac{d}{dx}K_n(x)$ for integer and real values of x
  • the beta function Β(x,y), which is defined as Γ(x)Γ(y)/Γ(x+y). In addition, the incomplete beta function, defined as $B_x(a,b) = \int_{t=0}^x t^{a-1}(1-t)^{b-1} dt$, along with the regularized incomplete beta function Ix(a, b) are provided.
  • confluent hypergeometric functions:
    • M(a, b, x) - Kummer's function of the first kind.
    • dMdx(a, b, x) - the derivative of M with respect to its third argument.
    • d2Mdx2(a, b, x) - the second derivative of M with respect to its third argument.
    An alternate notation is 1F1(a;b;z) = M(a,b,z).
  • elliptical integrals in both Legendre and Carlson forms:
    • eK(k) and eF(φ, k) - Legendre form for complete and incomplete elliptical integrals of the first kind.
    • eE(k) and eE(φ, k) - Legendre form for complete and incomplete elliptical integrals of the second kind.
    • ePI(n, k) and ePI(n, φ, k) - Legendre form for complete and incomplete elliptical integrals of the third kind.
    • RF(x, y, z) - Carlson's elliptic integral of the first kind.
    • RD(x, y, z) - Carlson's elliptic integral of the second kind.
    • RJ(x, y, z, p) - Carlson's elliptic integral of the third kind.
    • RC(x, y) - Carlson's degenerate elliptic integral.
    For the Legendre forms, φ is the "amplitude", representing an angle in units of radians, k is the modulus, and n is the characteristic. The notation used in publications is not consistent.
  • the error function $\mathrm{erf}(x) = \frac{2}{\sqrt{\pi}\int_{t=0}{x} e^{-t^2} dt$ and the complementary error function erfc(x) = 1 - erf(x). Both are provided because for large x, erf(x) asymptotically approaches 1.0.
  • factorials:
    • factorial(n) - n! (as a double-precision value).
    • logFactorial(n) - log n! (provided as a method to avoid overflow errors that would occur if the expression Math.log(Functions.factorial(n)) was used instead.)
    • longFactorial(n) - n! (as a long integer value).
    • exactFactorial - n! (as a BigInteger to provide whatever number of bits are necessary).
  • the gamma function and the digamma function:
    • Gamma(x) - Γ(x).
    • logGamma(x) - log Γ(x) (to avoid the overflow errors that would occur if Math.log(Functions.Gamma(n)) was used).
    • digamma(x) - ψ(x) (the digamma function ψ(x) is defined as Γ'(x) / Γ(x)).
    • poch(x,n) computes Pochhammer's symbol (x)n defined as 1 when n=0 and x(x+1)(x+2)...(x+n-1) for n > 0. Except at points where the gamma function diverges, (x)n = Γ(x+n)/Γ(x).
  • the hypergeometric function:
    • hgF(a,b,c,z) computes 2F1(a, b; c; z).
    • hgF(an,ad,b,c,z) computes 2F1(an/ad, b; c; z) with two integer arguments used to represent the first argument as a rational number an/ad. This form is useful for some special cases in which z > 1.
    • hgF(an,ad,bn,bd,c,z) computes 2F1(an/ad, bn/bd; c; z) with four integer arguments used to represent the first two arguments as rational numbers an/ad and bn/bd. This form is useful for some special cases in which z > 1.
  • inverse hyperbolic functions:
    • asinh(x) - sinh-1(x).
    • acosh(x) - cosh-1(x).
    • atanh(x) - tanh-1(x).
  • Laguerre polynomials and associated Laguerre polynomials:
    • L(n,x) - computes the value of the Laguerre polynomial Ln(x).
    • dLdx(n,x) - computes the value of derivative $\frac{dL_n(x)}{dx}$ of a Laguerre polynomial with respect to x.
    • L(n, α, x) - computes the value of the associated Laguerre polynomial Ln(α)(x).
    • dLdx(n,α,x) - computes the value of derivative $\frac{dL_n^\alpha(x)}{dx}$ of an associated Laguerre polynomial with respect to x.
  • Legendre polynomials and associated Legendre functions with integer coefficients:
    • P(n,x) computes Pn(x).
    • dPdx(n,x) - computes dPn/dx (the derivative of Legendre polynomials of degree n with respect to x).
    • P(n,m,x) computes the associated Legendre function $P^m_n(x)$ for integer values of n and m.
    • dPdx(n,m,x) computes $\frac{dP^m_n(x)}{dx}$ (the derivative of the associated Legendre polynomial of degree n and order m with respect to x).
  • A function pow(x, n) to raise a real number x to an integer power n and a function pow(x, xn, xd) to raise a real number x to a power given by the rational number xn/xd (in this case '/' denotes floating-point division although xn and xd are integers).
  • Spherical harmonics are represented by a function Yamp(l,m,θ) giving the "amplitude" of a spherical harmonic. The amplitude is a real-valued function whose absolute value is the magnitude of a complex number. The value of Yamp(l,m,θ) is numerically equal to Ylm(θ, 0).
  • the Riemann zeta function: zeta(x) computes ζ(x).
The notation for these functions, aside from Bernstein polynomials, is that used in the Handbook of Mathematical Functions (Abramowitz and Stegun) and Classical Electrodynamics (Jackson). For Bernstein Polynomials, the notation used is described in Bernstein Polynomials.

There are additionally a series of nested classes that provide additional capabilities (for example, computing the roots of Legendre polynomials) and computing both a Legendre function and its derivative simultaneously).

Many of the methods are based on formulas provided in Abramowitz and Stegun, "Handbook of Mathematical Functions" (10th printing [1972], 9th Dover printing). Any reference to Abramowitz and Stegun in the documentation for specific methods refers to this specific edition.

  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Class
    Description
    static class 
    Class containing methods specific to Bernstein polynomials.
    static class 
    This class does a high-precision computation of erfc, which fills in a table used to create a spline to allow us to interpolate over a range of values where accuracy is a problem: values high enough that erf(x) is too close to 1.0 for erfc(x) = 1 - erf(x) to be an accurate approximation, but too low for the asymptotic expansion to be accurate to one part in 10 to the 10th.
    static class 
    Class providing static methods for computing Gamma functions, their logarithms, and asymptotic values.
    static class 
    Class representing Legendre polynomials.
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    acosh(double x)
    Compute the inverse hyperbolic cosine.
    static double
    Ai(double x)
    Compute the Airy function of the first kind.
    static double
    asinh(double x)
    Compute the inverse hyperbolic sin.
    static double
    atanh(double x)
    Compute the inverse hyperbolic tangent.
    static double
    B(int n, int[] lambda, double... tau)
    Bernstein polynomials for a barycentric basis.
    static double
    B(int i, int n, double x)
    Compute a Bernstein polynomial Bi,n(x).
    static double
    Beta(double x, double y)
    Compute the Beta function.
    static double
    Beta(double x, double a, double b)
    Compute the incomplete beta function Βx(a,b).
    static double
    BetaI(double x, double a, double b)
    Compute the regularized incomplete beta function Ix(a,b).
    static double
    Bi(double x)
    Compute the Airy function of the second kind.
    static double
    d2Bdx2(int i, int n, double x)
    Compute the second derivative of a Bernstein polynomial Bi,n(x)with respect to x.
    static double
    d2Bdxdy(int tauInd1, int tauInd2, int n, int[] lambda, double... tau)
    Second derivative of Bernstein polynomials for a barycentric basis.
    static double
    d2Betadx2(double x, double a, double b)
    Compute the second derivative with respect to x of the incomplete beta function Βx(a,b).
    static double
    d2BetaIdx2(double x, double a, double b)
    Compute the second derivative with respect to x of the regularized incomplete beta function Ix(a,b).
    static double
    d2hgFdx2(double a, double b, double c, double z)
    Compute the second derivative of the hypergeometric function F(a, b; c; z) = 2F1(a, b; c; z) with respect to z.
    static double
    d2hgFdx2(int an, int ad, double b, double c, double z)
    Compute the second derivative of the hypergeometric function F(a, b; c; z) = 2F1(a, b; c; z) with respect to z when a is a rational number.
    static double
    d2hgFdx2(int an, int ad, int bn, int bd, double c, double z)
    Compute the second derivative of the hypergeometric function F(a, b; c; z) = 2F1(a, b; c; z) with respect to z when a and b are rational numbers.
    static double
    d2Mdx2(double a, double b, double x)
    Compute the second derivative with respect to the third argument of the confluent hypergeometric function.
    static double
    d2Mdx2(long a, double b, double x)
    Compute the second derivative with respect to the third argument of the confluent hypergeometric function when the first argument is an integer..
    static double
    d2Mdx2(long a, long b, double x)
    Compute the second derivative with respect to the third argument of the confluent hypergeometric function when the first two arguments are integers..
    static double
    dAidx(double x)
    Compute the first derivative of the Airy function of the first kind.
    static double
    dBdx(int i, int n, double x)
    Compute the derivative of a Bernstein polynomial Bi,n(x) with respect to x.
    static double
    dBdx(int tauInd, int n, int[] lambda, double... tau)
    First partial derivatives of Bernstein polynomials for a barycentric basis.
    static double
    dBetadx(double x, double a, double b)
    Compute the derivative with respect to x of the incomplete beta function Βx(a,b).
    static double
    dBetaIdx(double x, double a, double b)
    Compute the derivative with respect to x of the regularized incomplete beta function Ix(a,b).
    static double
    dBidx(double x)
    Compute the first derivative of the Airy function of the second kind.
    static double
    dhgFdx(double a, double b, double c, double z)
    Compute the derivative of the hypergeometric function F(a, b; c; z) = 2F1(a, b; c; z) with respect to z.
    static double
    dhgFdx(int an, int ad, double b, double c, double z)
    Compute the derivative of the hypergeometric function F(a, b; c; z) = 2F1(a, b; c; z) with respect to z when a is a rational number.
    static double
    dhgFdx(int an, int ad, int bn, int bd, double c, double z)
    Compute the derivative of the hypergeometric function F(a, b; c; z) = 2F1(a, b; c; z) with respect to z when a and b are rational numbers.
    static double
    dIdx(double nu, double x)
    Compute the derivative of the modified Bessel function of the first kind (I) for a real-valued order.
    static double
    dIdx(int nu, double x)
    Compute the derivative of modified Bessel function of the first kind (I) for an integer-valued order.
    static double
    digamma(double x)
    Compute the digamma function.
    static double
    digamma(int i)
    Compute the digamma function for an integral argument.
    static double
    djdx(int n, double x)
    Compute the derivative of a spherical Bessel function of the first kind.
    static double
    dJdx(double nu, double x)
    Compute the derivative of Bessel function of the first kind for an real-valued order.
    static double
    dJdx(int nu, double x)
    Compute the derivative of Bessel function of the first kind for an integer-valued order.
    static double
    dKdx(double nu, double x)
    Compute the derivative of modified Bessel function of the second kind (K) for a real-valued order.
    static double
    dKdx(int nu, double x)
    Compute the derivative of modified Bessel function of the second kind (K) for an integer-valued order.
    static double
    dLdx(int n, double x)
    Compute the value of the derivative of a Laguerre polynomial.
    static double
    dLdx(int n, double alpha, double x)
    Compute the value of the derivative of an associated Laguerre polynomial.
    static double
    dMdx(double a, double b, double x)
    Compute the derivative with respect to the third argument of the confluent hypergeometric function.
    static double
    dMdx(long a, double b, double x)
    Compute the derivative with respect to the third argument of the confluent hypergeometric function when the first argument is an integer.
    static double
    dMdx(long a, long b, double x)
    Compute the derivative with respect to the third argument of the confluent hypergeometric function when the first two arguments are integers.
    static double
    dPdx(int n, double x)
    Evaluate the derivative of a Legendre polynomial.
    static double
    dPdx(int n, int m, double x)
    Compute the derivative of an associated Legendre function of degree n and order m.
    static double
    dydx(int n, double x)
    Compute the derivative of a spherical Bessel function of the second kind.
    static double
    dYdx(double nu, double x)
    Compute the derivative of Bessel function of the second kind for a real-valued order.
    static double
    dYdx(int nu, double x)
    Compute the derivative of Bessel function of the second kind for an integer-valued order.
    static double
    eE(double k)
    Compute a complete elliptic integral of the second kind.
    static double
    eE(double phi, double k)
    Compute an incomplete elliptic integral of the second kind.
    static double
    eF(double phi, double k)
    Compute the incomplete elliptic integral of the first kind.
    static double
    eK(double k)
    Compute the complete elliptic integral of the first kind.
    static double
    ePI(double n, double k)
    Compute the complete elliptic integral of the third kind.
    static double
    ePI(double n, double phi, double k)
    Compute an incomplete elliptic integral of the third kind.
    static double
    erf(double x)
    Compute the error function.
    static double
    erf(double arg, int scale)
    Compute the error function using fixed-point arithmetic
    static double
    erfc(double x)
    Complementary error function.
    static double
    erfc(double arg, int scale)
    Compute the error function complement using fixed-point arithmetic
    static BigInteger
    Compute a factorial exactly.
    static double
    factorial(int n)
    Compute a factorial.
    static double
    Gamma(double x)
    Compute the Gamma function.
    static int
    gcd(int a, int b)
    Deprecated.
    This method has been moved to the class MathOps to eliminate a module dependency.
    static long
    gcd(long a, long b)
    Deprecated.
    This method has been moved to the class MathOps to eliminate a module dependency.
    static double
    hgF(double a, double b, double c, double z)
    Compute the hypergeometric function F(a, b; c; z) = 2F1(a, b; c; z).
    static double
    hgF(int an, int ad, double b, double c, double z)
    Compute the hypergeometric function F(a, b; c; z) = 2F1(a, b; c; z) when a is a rational number.
    static double
    hgF(int an, int ad, int bn, int bd, double c, double z)
    Compute the hypergeometric function F(a, b; c; z) = 2F1(a, b; c; z) when a and b are rational numbers.
    static double
    I(double nu, double x)
    Compute a modified Bessel function of the first kind (I) for a real-valued order.
    static double
    I(int nu, double x)
    Compute a modified Bessel function of the first kind (I) for an integer-valued order.
    static double
    j(int n, double x)
    Compute the value of a spherical Bessel function of the first kind.
    static double
    J(double nu, double x)
    Compute a Bessel function of the first kind for a real-valued order.
    static double
    J(int nu, double x)
    Compute a Bessel function of the first kind for an integer-valued order.
    static double
    K(double nu, double x)
    Compute a modified Bessel function of the second kind (K) for a real-valued order.
    static double
    K(int nu, double x)
    Compute a modified Bessel function of the second kind (K) for an integer-valued order.
    static double
    L(int n, double x)
    Compute the value of a Laguerre polynomial.
    static double
    L(int n, double alpha, double x)
    Compute the value of an associated Laguerre polynomial.
    static double
    log2(int n)
    Deprecated.
    This method has been moved to the class MathOps to eliminate a module dependency.
    static double
    log2(int n, double accuracy)
    Deprecated.
    This method has been moved to the class MathOps to eliminate a module dependency.
    static double
    log2(long n)
    Deprecated.
    This method has been moved to the class MathOps to eliminate a module dependency.
    static double
    log2(long n, double accuracy)
    Deprecated.
    This method has been moved to the class MathOps to eliminate a module dependency.
    static double
    logFactorial(int n)
    Compute the logarithm of a factorial.
    static double
    logGamma(double x)
    Compute the logarithm of the Gamma function
    static long
    Compute a factorial, returning the results as a long integer.
    static long
    lPow(int x, int n)
    Deprecated.
    This method has been moved to the class MathOps to eliminate a module dependency.
    static double
    M(double a, double b, double z)
    Compute the confluent hypergeometric function M(a, b, z).
    static double
    M(long a, double b, double z)
    Compute the confluent hypergeometric function M(a, b, z) when a is a long integer.
    static double
    M(long a, long b, double z)
    Compute the confluent hypergeometric function M(a, b, z) when a and b are long integers.
    static int
    modInverse(int a, int m)
    Compute the multiplicative inverse of an integer modulo m.
    static long
    modInverse(long a, long m)
    Compute the multiplicative inverse of a long integer modulo m.
    static double
    oddFactorial(int n)
    Compute the product of all odd positive integers less than or equal to n.
    static double
    P(int n, double x)
    Evaluate a Legendre polynomial.
    static double
    P(int n, int m, double x)
    Evaluate the derivative of an associated Legendre function.
    static double
    poch(double x, int n)
    Compute Pochhammer's symbol (x)n.
    static double
    poch(int x, int n)
    Compute Pochhammer's symbol (x)n when x is an integer.
    static double
    pow(double x, int n)
    Deprecated.
    This method has been moved to the class MathOps to eliminate a module dependency.
    static double
    pow(double z, int xn, int xd)
    Deprecated.
    This method has been moved to the class MathOps to eliminate a module dependency.
    static double
    pow(double x, long n)
    Deprecated.
    This method has been moved to the class MathOps to eliminate a module dependency.
    static double
    RC(double x, double y)
    Carlson symmetric form RC for elliptic integrals.
    static double
    RD(double x, double y, double z)
    Carlson symmetric form RD for elliptic integrals.
    static double
    RF(double x, double y, double z)
    Carlson symmetric form RF for elliptic integrals.
    static double
    RJ(double x, double y, double z, double p)
    Carlson symmetric form RJ for elliptic integrals.
    static double
    root(int n, double x)
    Deprecated.
    This method has been moved to the class MathOps to eliminate a module dependency.
    static double
    y(int n, double x)
    Compute the value of a spherical Bessel function of the second kind.
    static double
    Y(double nu, double x)
    Compute a Bessel function of the second kind for a real-valued order.
    static double
    Y(int nu, double x)
    Compute a Bessel function of the second kind for an integer-valued order.
    static double
    Yamp(int ell, int m, double theta)
    Compute the amplitude of of spherical harmonics.
    static double
    zeta(double x)
    Compute the Riemann zeta function.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • gcd

      @Deprecated public static int gcd(int a, int b) throws IllegalArgumentException
      Deprecated.
      This method has been moved to the class MathOps to eliminate a module dependency.
      Compute the greatest common divisor of two integers
      Parameters:
      a - the first integer
      b - the second integer
      Returns:
      the greatest common divisor of a and b
      Throws:
      IllegalArgumentException - both arguments were zero
    • gcd

      @Deprecated public static long gcd(long a, long b) throws IllegalArgumentException
      Deprecated.
      This method has been moved to the class MathOps to eliminate a module dependency.
      Compute the greatest common divisor of two non-negative long integers
      Parameters:
      a - the first integer
      b - the second integer
      Returns:
      the greatest common divisor of a and b
      Throws:
      IllegalArgumentException - both arguments were zero
    • modInverse

      public static int modInverse(int a, int m) throws IllegalArgumentException
      Compute the multiplicative inverse of an integer modulo m.
      Parameters:
      a - the integer whose inverse modulo m is to be computed
      m - the modulus
      Returns:
      the multiplicative inverse of a (mod m)
      Throws:
      IllegalArgumentException - the arguments are not relatively prime
    • modInverse

      public static long modInverse(long a, long m) throws IllegalArgumentException
      Compute the multiplicative inverse of a long integer modulo m.
      Parameters:
      a - the integer whose inverse modulo m is to be computed
      m - the modulus
      Returns:
      the multiplicative inverse of a (mod m)
      Throws:
      IllegalArgumentException - the arguments are not relatively prime
    • log2

      @Deprecated public static double log2(int n) throws IllegalArgumentException
      Deprecated.
      This method has been moved to the class MathOps to eliminate a module dependency.
      Compute the base-2 logarithm of an integer n.
      Parameters:
      n - an integer that is larger than 0
      Returns:
      the base-2 logarithm of n
      Throws:
      IllegalArgumentException - an argument was out of range
    • log2

      @Deprecated public static double log2(int n, double accuracy) throws IllegalArgumentException
      Deprecated.
      This method has been moved to the class MathOps to eliminate a module dependency.

      One use of this method is in estimating the time or space needed by an algorithm, where precise values are not needed.

      Note: when the accuracy is set to 1.0, the value returned is floor(log2(n)).

      Compute the base-2 logarithm of an integer n, specifying its accuracy.
      Parameters:
      n - an integer that is larger than 0
      accuracy - the accuracy of the fractional part of the returned value (values should be in the range (0.0, 1.0])
      Returns:
      the base-2 logarithm of n
      Throws:
      IllegalArgumentException - an argument was out of range
    • log2

      @Deprecated public static double log2(long n) throws IllegalArgumentException
      Deprecated.
      This method has been moved to the class MathOps to eliminate a module dependency.
      Compute the base-2 logarithm of a long integer n.
      Parameters:
      n - an integer that is larger than 0
      Returns:
      the base-2 logarithm of n
      Throws:
      IllegalArgumentException - an argument was out of range
    • log2

      @Deprecated public static double log2(long n, double accuracy) throws IllegalArgumentException
      Deprecated.
      This method has been moved to the class MathOps to eliminate a module dependency.

      One use of this method is in estimating the time or space needed by an algorithm, where precise values are not needed.

      Compute the base-2 logarithm of a long integer n, specifying its accuracy.
      Parameters:
      n - a long integer that is larger than 0
      accuracy - the accuracy of the fractional part of the returned value (values should be in the range (0.0, 1.0])
      Returns:
      the base-2 logarithm of n
      Throws:
      IllegalArgumentException - an argument was out of range
    • B

      public static double B(int i, int n, double x) throws IllegalArgumentException
      Compute a Bernstein polynomial Bi,n(x). Please see Bernstein Polynomials for definitions.
      Parameters:
      i - the order of the Bernstein polynomial
      n - the degree of the Bernstein polynomial
      x - the point at which to evaluate the Bernstein polynomial
      Returns:
      the value Bi,n(x)
      Throws:
      IllegalArgumentException - the second argument was out of range
    • dBdx

      public static double dBdx(int i, int n, double x) throws IllegalArgumentException
      Compute the derivative of a Bernstein polynomial Bi,n(x) with respect to x. Please see Bernstein Polynomials for definitions, and the expression used to compute the derivative.
      Parameters:
      i - the order of the Bernstein polynomial
      n - the degree of the Bernstein polynomial
      x - the point at which to evaluate the Bernstein polynomial's derivative
      Returns:
      the value of $\frac{d}{dx}B_{i,n}(x)
      Throws:
      IllegalArgumentException - the second argument was out of range
    • d2Bdx2

      public static double d2Bdx2(int i, int n, double x)
      Compute the second derivative of a Bernstein polynomial Bi,n(x)with respect to x. Please see Bernstein Polynomials for definitions.
      Parameters:
      i - the order of the Bernstein polynomial
      n - the degree of the Bernstein polynomial
      x - the point at which to evaluate the Bernstein polynomial's derivative
      Returns:
      the value of $\frac{d^2}{dx^2}B_{i,n}(x)$
      Throws:
      IllegalArgumentException - the second argument was out of range
    • B

      public static double B(int n, int[] lambda, double... tau) throws IllegalArgumentException
      Bernstein polynomials for a barycentric basis. A barycentric basis is one in which there are m coordinates τ = (τ0, τ1, ... , τn-1) with the constraint τ0 + τ1 + ... + τn-1 = 1.

      Bernstein polynomials for a barycentric basis are given by the equation

                       n!
          Bnλ(τ) = __________ τ0λ0τ1λ1...τm-1λm-1
                   λ12!...λm!
       
      subject to the constraint λ0 + λ1 + ... + λm-1 = n.

      Please see Gerald Farin, "Triangular Bernstein-Bézier patches", which restricts m to 3.

      Parameters:
      n - the degree of the polynomial
      lambda - the order of the polynomial, with each component in the range [0, n] listed in the order λ0, λ1, ... , λn-1
      tau - barycentric coordinates at which to evaluate the polynomial, with these arguments in the order τ0, τ1, ... , τm-1
      Returns:
      the value of the Bernstein polynomial.
      Throws:
      IllegalArgumentException - an argument was out of bounds
    • dBdx

      public static double dBdx(int tauInd, int n, int[] lambda, double... tau) throws IllegalArgumentException
      First partial derivatives of Bernstein polynomials for a barycentric basis. The derivatives are partial derivatives with no constraints on the values of the tau components (barycentric coordinates are usually normalized so that ∑iτi = 1.) Please Gerald Farin, "Triangular Bernstein-Bézier patches" and B(int, int[], double...) for additional details about the arguments.
      Parameters:
      tauInd - the index of the component of the argument tau for which the partial derivative should be computed.
      n - the degree of the polynomial
      lambda - the order of the polynomial, with each component in the range [0, n] listed in the order λ0, λ1, ... , λn-1
      tau - barycentric coordinates at which to evaluate the polynomial, with these arguments in the order τ0, τ1, ... , τm-1
      Returns:
      the value of the derivative of a Bernstein polynomial $\frac{\partial}{\partial x_i} B^n_{\mathbf{\lambda}}(\mathbf{\tau})$ where i is the value of the argument named tauInd
      Throws:
      IllegalArgumentException - an argument was out of bounds
    • d2Bdxdy

      public static double d2Bdxdy(int tauInd1, int tauInd2, int n, int[] lambda, double... tau) throws IllegalArgumentException
      Second derivative of Bernstein polynomials for a barycentric basis. The derivatives are partial derivatives with no constraints on the values of the tau components (barycentric coordinates are usually normalized so that ∑iτi = 1.) Please Gerald Farin, "Triangular Bernstein-Bézier patches" and B(int, int[], double...) for additional details about the arguments.
      Parameters:
      tauInd1 - the index of the component of the argument tau for which the initial partial derivative should be computed.
      tauInd2 - the index of the component of the argument tau for which the final partial derivative should be computed.
      n - the degree of the polynomial
      lambda - the order of the polynomial, with each component in the range [0, n] listed in the order λ0, λ1, ... , λm-1
      tau - barycentric coordinates at which to evaluate the polynomial, with these arguments in the order τ0, τ1, ... , τn-1
      Returns:
      the value of the derivative of a Bernstein polynomial $\frac{\partial^2}{\partial \tau_i \partial \tau_j} B^n_{\mathbf{\lambda}}(\mathbf{\tau})$ where i is the value of the argument named tauInd1 and j is the value of the argument named tauInd2 (both may have the same value)
      Throws:
      IllegalArgumentException - an argument was out of bounds
    • J

      public static double J(double nu, double x) throws IllegalArgumentException
      Compute a Bessel function of the first kind for a real-valued order.
      Parameters:
      nu - the order of the function
      x - the function's argument.
      Returns:
      the value of the Bessel function at the specified arguments
      Throws:
      IllegalArgumentException - the argument was negative when the order was not an integer
    • J

      public static double J(int nu, double x)
      Compute a Bessel function of the first kind for an integer-valued order.
      Parameters:
      nu - the order of the function
      x - the function's argument.
      Returns:
      the value of the Bessel function at the specified arguments
    • dJdx

      public static double dJdx(double nu, double x)
      Compute the derivative of Bessel function of the first kind for an real-valued order.
      Parameters:
      nu - the order of the function
      x - the function's argument.
      Returns:
      the value of $\frac{d}{dx}J_\nu(x)$
    • dJdx

      public static double dJdx(int nu, double x)
      Compute the derivative of Bessel function of the first kind for an integer-valued order.
      Parameters:
      nu - the order of the function
      x - the function's argument.
      Returns:
      the value of $\frac{d}{dx}J_\nu(x)$
    • Y

      public static double Y(double nu, double x) throws IllegalArgumentException
      Compute a Bessel function of the second kind for a real-valued order.
      Parameters:
      nu - the order of the function
      x - the function's argument.
      Returns:
      the value of the function at the specified arguments
      Throws:
      IllegalArgumentException - the argument was negative when the order was not an integer
    • Y

      public static double Y(int nu, double x)
      Compute a Bessel function of the second kind for an integer-valued order.
      Parameters:
      nu - the order of the function
      x - the function's argument.
      Returns:
      the value of function for the given argument and order
    • dYdx

      public static double dYdx(double nu, double x)
      Compute the derivative of Bessel function of the second kind for a real-valued order.
      Parameters:
      nu - the order of the function
      x - the function's argument.
      Returns:
      the value of $\frac{d}{dx}Y_\nu(x)$
    • dYdx

      public static double dYdx(int nu, double x)
      Compute the derivative of Bessel function of the second kind for an integer-valued order.
      Parameters:
      nu - the order of the function
      x - the function's argument.
      Returns:
      the value of $\frac{d}{dx}Y_\nu(x)$
    • I

      public static double I(double nu, double x) throws IllegalArgumentException
      Compute a modified Bessel function of the first kind (I) for a real-valued order.
      Parameters:
      nu - the order of the function
      x - the function's argument
      Returns:
      the value of Iν(x)
      Throws:
      IllegalArgumentException - the argument was negative when the order was not an integer
    • I

      public static double I(int nu, double x)
      Compute a modified Bessel function of the first kind (I) for an integer-valued order.
      Parameters:
      nu - the order of the function
      x - the function's argument.
      Returns:
      the value of Iν(x)
    • dIdx

      public static double dIdx(double nu, double x)
      Compute the derivative of the modified Bessel function of the first kind (I) for a real-valued order.
      Parameters:
      nu - the order of the function
      x - the function's argument.
      Returns:
      the value of the derivative for the specified arguments
    • dIdx

      public static double dIdx(int nu, double x)
      Compute the derivative of modified Bessel function of the first kind (I) for an integer-valued order.
      Parameters:
      nu - the order of the function
      x - the function's argument.
      Returns:
      the value of the derivative for the specified arguments
    • K

      public static double K(double nu, double x) throws IllegalArgumentException
      Compute a modified Bessel function of the second kind (K) for a real-valued order.
      Parameters:
      nu - the order of the function (must be larger than -1)
      x - the function's argument.
      Returns:
      the value of a modified Bessel function of the second kind for the specified arguments
      Throws:
      IllegalArgumentException - the argument was negative when the order was not an integer
    • K

      public static double K(int nu, double x)
      Compute a modified Bessel function of the second kind (K) for an integer-valued order.
      Parameters:
      nu - the order of the function (must be larger than -1)
      x - the function's argument.
      Returns:
      the value of a modified Bessel function of the second kind for the specified arguments
    • dKdx

      public static double dKdx(double nu, double x)
      Compute the derivative of modified Bessel function of the second kind (K) for a real-valued order.
      Parameters:
      nu - the order of the function
      x - the function's argument.
      Returns:
      the value of $\frac{d}{dx}K_\nu(x)$
    • dKdx

      public static double dKdx(int nu, double x)
      Compute the derivative of modified Bessel function of the second kind (K) for an integer-valued order.
      Parameters:
      nu - the order of the function
      x - the function's argument.
      Returns:
      the value of $\frac{d}{dx}K_\nu(x)$
    • j

      public static double j(int n, double x)
      Compute the value of a spherical Bessel function of the first kind.
      Parameters:
      n - the order of the function
      x - the argument for the function
      Returns:
      the value of jn(x)
    • djdx

      public static double djdx(int n, double x)
      Compute the derivative of a spherical Bessel function of the first kind.
      Parameters:
      n - the order of the function
      x - the argument for the function
      Returns:
      the value of $\frac{d}{dx}j_n(x)$
    • y

      public static double y(int n, double x)
      Compute the value of a spherical Bessel function of the second kind.
      Parameters:
      n - the order of the function
      x - the argument for the function
      Returns:
      the value of jn(x)
    • dydx

      public static double dydx(int n, double x)
      Compute the derivative of a spherical Bessel function of the second kind.
      Parameters:
      n - the order of the function
      x - the argument for the function
      Returns:
      the value of $\frac{d}{dx}y_n(x)$
    • P

      public static double P(int n, double x)
      Evaluate a Legendre polynomial.
      Parameters:
      n - the order of the Legendre polynomial
      x - the point at which the polynomial should be evaluated
      Returns:
      the value of the polynomial
    • dPdx

      public static double dPdx(int n, double x)
      Evaluate the derivative of a Legendre polynomial.
      Parameters:
      n - the degree of the Legendre polynomial
      x - the point at which the derivative should be evaluated
      Returns:
      the value of the derivative
    • P

      public static double P(int n, int m, double x)
      Evaluate the derivative of an associated Legendre function.
      Parameters:
      n - the degree of the Legendre function
      m - the order of the Legendre function
      x - the point at which the derivative should be evaluated
      Returns:
      the value of the derivative $\frac{d}{dx}P_n^m(x)$
    • dPdx

      public static double dPdx(int n, int m, double x)
      Compute the derivative of an associated Legendre function of degree n and order m.
      Parameters:
      n - the degree of the Legendre function
      m - the order of the Legendre function
      x - the point at which the Legendre function is evaluated
      Returns:
      the derivative at point x
    • zeta

      public static double zeta(double x)
      Compute the Riemann zeta function.
      Parameters:
      x - a real-valued argument.
      Returns:
      the value ζ(x) for values that can be expressed as double-precision numbers; negative or positive infinity for other cases as appropriate.
    • pow

      @Deprecated public static double pow(double x, int n)
      Deprecated.
      This method has been moved to the class MathOps to eliminate a module dependency.

      This method is provided to supplement the method Math.pow(double, double) by providing a method whose second argument is an integer. This is useful in some infinite series expansions of special functions. For example, for small z, the spherical Bessel function jn(z) has a first term proportional to zn in its Taylor series expansion (for larger values of |z|, the implementation in Functions does not use this Taylor series).

      The time complexity is O(log2 n). Timing measurements indicate that it is faster than java.lang.Math.pow (which handles more cases).

      Raise a number to an integer power.
      Parameters:
      x - a real number
      n - the power
      Returns:
      the value of xn
    • pow

      @Deprecated public static double pow(double x, long n)
      Deprecated.
      This method has been moved to the class MathOps to eliminate a module dependency.

      This method is provided to supplement the method Math.pow(double, double) by providing a method whose second argument is a long integer. This is useful in some infinite series expansions of special functions. For example, for small z, the spherical Bessel function jn(z) has a first term proportional to zn in its Taylor series expansion (for larger values of |z|, the implementation in Functions does not use this Taylor series).

      The time complexity is O(log2 n). Timing measurements indicate that it is faster than java.lang.Math.pow (which handles more cases).

      Raise a number to a long integer power.
      Parameters:
      x - a real number
      n - the power
      Returns:
      the value of xn
    • root

      @Deprecated public static double root(int n, double x)
      Deprecated.
      This method has been moved to the class MathOps to eliminate a module dependency.

      The second argument must be non-negative when the first argument is an even integer.

      Compute the nth root of a real number.
      Parameters:
      n - the root index (2 for the square root, 3 for the cube root, etc.)
      x - the number whose root is to be computed.
      Returns:
      the root
      Throws:
      IllegalArgumentException - an argument was out of range
    • pow

      @Deprecated public static double pow(double z, int xn, int xd)
      Deprecated.
      This method has been moved to the class MathOps to eliminate a module dependency.

      This method is provided to supplement the method Math.pow(double, double) by providing a method whose second argument is the numerator of the power and whose third argument is the denominator.

      Raise a number x to a rational power.
      Parameters:
      z - a real number
      xn - the numerator of fraction representing a rational number for the power
      xd - the denominator of a fraction representing a rational number for the power
      Returns:
      the value of xxn/xd
    • lPow

      @Deprecated public static long lPow(int x, int n) throws IllegalArgumentException, ArithmeticException
      Deprecated.
      This method has been moved to the class MathOps to eliminate a module dependency.

      This method is provided to supplement the method Math.pow(double, double) by providing a method whose second argument is an integer. This is useful in some infinite series expansions of special functions. For example, for small z, the spherical Bessel function jn(z) has a first term proportional to zn in its Taylor series expansion.

      The time complexity is O(log2 n). Timing measurements indicate that it is faster than java.lang.Math.pow (which handles more cases).

      Raise an integer to to a non-negative integer power.
      Parameters:
      x - an integer
      n - the power
      Returns:
      the value of xn
      Throws:
      IllegalArgumentException - an argument was out of bounds
      ArithmeticException - the combination of arguments would overflow the integer representation used
    • factorial

      public static double factorial(int n)
      Compute a factorial. There are a small number of values that can be represented as a double-precision number, so the implementation uses table lookup for speed, with the values computed using infinite-precision arithmetic.

      Note: while not really a special function, a factorial method is provided in this class because n! = Γ(n+1).

      Parameters:
      n - a non-negative integer whose factorial is to be computed
      Returns:
      the value of n! or Double.POSITIVE_INFINITY if the value cannot be represented as a double-precision number due to being too large
      Throws:
      IllegalArgumentException - the argument n is negative
    • longFactorial

      public static long longFactorial(int n)
      Compute a factorial, returning the results as a long integer.
      Parameters:
      n - an integer in the range [0, 20]
      Returns:
      the value of n!
      Throws:
      IllegalArgumentException - n is out of range
    • exactFactorial

      public static BigInteger exactFactorial(int n)
      Compute a factorial exactly.
      Parameters:
      n - a non-negative integer
      Returns:
      the value of n! as an arbitrary-precision integer
    • oddFactorial

      public static double oddFactorial(int n)
      Compute the product of all odd positive integers less than or equal to n. There are a small number of values that can be represented as a double-precision number, so the implementation uses table lookup for speed, with the values computed using infinite-precision arithmetic.

      Note: while not really a special function, a factorial method is provided in this class because n! = Γ(n+1).

      Parameters:
      n - a non-negative integer whose odd factorial is to be computed
      Returns:
      the value of n! or Double.POSITIVE_INFINITY if the value cannot be represented as a double-precision number due to being too large
      Throws:
      IllegalArgumentException - the argument n is negative
    • logFactorial

      public static double logFactorial(int n)
      Compute the logarithm of a factorial. A finite value will be returned for arguments whose factorials are too large to be represented as a double-precision number.
      Parameters:
      n - a non-negative integer whose factorial is to be computed
      Returns:
      the value of log n!
      Throws:
      IllegalArgumentException - the argument n is negative
    • logGamma

      public static double logGamma(double x)
      Compute the logarithm of the Gamma function
      Parameters:
      x - a non-negative number
      Returns:
      the value of log (Γ(x))
    • digamma

      public static double digamma(double x)
      Compute the digamma function. The implementation used the relation ψ(x+1) = (1/x) + ψ(x) coupled with the first terms (up to the 1/x14 term) of the asymptotic series.

      Citation: http://en.wikipedia.org/wiki/Digamma_function#Computation_and_approximation

      Parameters:
      x - the argument
      Returns:
      the value of the digamma function ψ(x)
    • digamma

      public static double digamma(int i)
      Compute the digamma function for an integral argument.

      Note: Because the digamma function with integral arguments is used in some infinite series, the implementation uses table-lookup for relatively small values of i (0 ≥ i < 8192) with the table computed using a recursion relation.

      Parameters:
      i - the argument
      Returns:
      the value of the function given its argument
    • Gamma

      public static double Gamma(double x)
      Compute the Gamma function. The function Γ(x) has poles at 0, -1, -2, -3, etc. At a poll, an infinite double-precision number is returned, with the choice of positive or negative infinity based on whether the value at x+δ is positive or negative respectively for δ>0, where δ is an arbitrarily small number.
      Parameters:
      x - a real number
      Returns:
      the value Γ(x)
    • poch

      public static double poch(double x, int n)
      Compute Pochhammer's symbol (x)n. This notation is defined so that
      • (x)0 = 1
      • (x)n = x(x+1)(x+2) ... (x + n-1) for n > 0
      Parameters:
      x - the argument
      n - the index
      Returns:
      the value (x)n
    • poch

      public static double poch(int x, int n)
      Compute Pochhammer's symbol (x)n when x is an integer. This notation is defined so that
      • (x)0 = 1
      • (x)n = x(x+1)(x+2) ... (x + n-1) for n > 0
      Parameters:
      x - the argument
      n - the index
      Returns:
      the value (x)n
    • RF

      public static double RF(double x, double y, double z) throws IllegalArgumentException
      Carlson symmetric form RF for elliptic integrals. RF(x,y,z) is defined as (1/2)t=0 (1/√((t+x)(t+y)(t+z))) dt. There is a Wikipedia article and a publication describing Carlson elliptic integrals.

      At most one of the arguments may be zero.

      Parameters:
      x - the first argument, which must be non-negative
      y - the second argument, which must be non-negative
      z - the third argument, which must be non-negative
      Returns:
      the value RF(x,y,z)
      Throws:
      IllegalArgumentException - an argument was out of range or the arguments are not consistent with each other
    • RC

      public static double RC(double x, double y) throws IllegalArgumentException
      Carlson symmetric form RC for elliptic integrals. RC(x, y) = RF(x, y, y). There is a Wikipedia article and a publication describing Carlson elliptic integrals.
      Parameters:
      x - the first argument, which must be nonnegative
      y - the second argument, which must be positive
      Returns:
      the value RC(x,y)
      Throws:
      IllegalArgumentException
    • RD

      public static double RD(double x, double y, double z) throws IllegalArgumentException
      Carlson symmetric form RD for elliptic integrals. RD(x, y, z) = RJ(x, y, z, z). There is a Wikipedia article and a publication describing Carlson elliptic integrals.

      At most one of the first two arguments may be zero.

      Parameters:
      x - the first argument, which must be nonnegative
      y - the second argument, which must be nonnegative
      z - the third argument, which must be positive
      Returns:
      the value RD(x,y,z)
      Throws:
      IllegalArgumentException
    • RJ

      public static double RJ(double x, double y, double z, double p) throws IllegalArgumentException
      Carlson symmetric form RJ for elliptic integrals. RJ(x,y,z,p) is defined as (3/2)t=0 (1/((t+p)√((t+x)(t+y)(t+z)))) dt. There is a Wikipedia article and a publication describing Carlson elliptic integrals.

      At most one of the first three arguments may be zero.

      Parameters:
      x - the first argument, which must be nonnegative
      y - the second argument, which must be nonnegative
      z - the third argument, which must be nonnegative
      p - the fourth argument, which must be nonzero
      Returns:
      the value RP(x,y,z,p)
      Throws:
      IllegalArgumentException
    • eK

      public static double eK(double k) throws IllegalArgumentException
      Compute the complete elliptic integral of the first kind. The complete elliptic integral of the first kind is defined as $$F(k) = \int_{\theta=0}^{\frac\pi2} \frac1{1-k^2\sin^2\theta} d\theta\ .$$

      The notation used is the same as that used for the Legendre form. For elliptic integrals in this form, the angle φ is called the amplitude, the parameter k is called the modulus, and the parameter n is called the characteristic. A subset of these may be used for a particular integral. One should keep in mind that a number of notations are in common use. The methods RF(double, double, double), RD(double, double, double), RC(double, double), and RJ(double, double, double, double) use Carlson's form.

      Parameters:
      k - the modulus argument, restricted to (-1, 1)
      Returns:
      the complete elliptic integral of the first kind for the given parameter
      Throws:
      IllegalArgumentException - k is out of range
    • eF

      public static double eF(double phi, double k) throws IllegalArgumentException
      Compute the incomplete elliptic integral of the first kind. The incomplete elliptic integral of the first kind is defined as $$F(\phi,k) = \int_{\theta=0}^{\phi} \frac{d\theta}{\sqrt{1-k^2 \sin^2 \theta}} \ .$$

      The notation used is the same as that used for the Legendre form. For elliptic integrals in this form, the angle φ is called the amplitude, the parameter k is called the modulus, and the parameter n is called the characteristic. A subset of these may be used for a particular integral. One should keep in mind that a number of notations are in common use. The methods RF(double, double, double), RD(double, double, double), RC(double, double), and RJ(double, double, double, double) use Carlson's form.

      Parameters:
      phi - the amplitude
      k - the modulus, restricted to (-1, 1)
      Returns:
      the incomplete elliptic integral of the first kind for the given parameters
      Throws:
      IllegalArgumentException - k is out of range
    • eE

      public static double eE(double k)
      Compute a complete elliptic integral of the second kind. The integral is defined by $$ E(k) = \int_{\theta=0}^{\frac{\pi}2}\sqrt{1-k^2\sin^2 \theta} d\theta\ .$$

      The notation used is the same as that used for the Legendre form. For elliptic integrals in this form, the angle φ is called the amplitude, the parameter k is called the modulus, and the parameter n is called the characteristic. A subset of these may be used for a particular integral. One should keep in mind that a number of notations are in common use. The methods RF(double, double, double), RD(double, double, double), RC(double, double), and RJ(double, double, double, double) use Carlson's form.

      Parameters:
      k - the modulus, restricted to (-1, 1)
      Returns:
      the incomplete elliptic integral of the second kind for the given parameters
    • eE

      public static double eE(double phi, double k) throws IllegalArgumentException
      Compute an incomplete elliptic integral of the second kind. The integral is defined by $$ E(\phi,k) = \int_{\theta=0}^{\phi}\sqrt{1-k^2\sin^2 \theta} d\theta\ .$$

      The notation used is the same as that used for the Legendre form. For elliptic integrals in this form, the angle φ is called the amplitude, the parameter k is called the modulus, and the parameter n is called the characteristic. A subset of these may be used for a particular integral. One should keep in mind that a number of notations are in common use. The methods RF(double, double, double), RD(double, double, double), RC(double, double), and RJ(double, double, double, double) use Carlson's form.

      Parameters:
      phi - the amplitude
      k - the modulus, restricted to (-1, 1)
      Returns:
      the incomplete elliptic integral of the second kind for the given parameters
      Throws:
      IllegalArgumentException
    • ePI

      public static double ePI(double n, double k)
      Compute the complete elliptic integral of the third kind. The integral is defined by $$ \Pi(n,k) = \int_{\theta=0}^{\frac{\pi}{2}} \frac{d\theta}{(1-n\sin^2\theta)\sqrt{1-k^2\sin^2\theta}}\ .$$

      The notation used is the same as that used for the Legendre form. For elliptic integrals in this form, the angle φ is called the amplitude, the parameter k is called the modulus, and the parameter n is called the characteristic. A subset of these may be used for a particular integral. One should keep in mind that a number of notations are in common use. The methods RF(double, double, double), RD(double, double, double), RC(double, double), and RJ(double, double, double, double) use Carlson's form.

      Parameters:
      n - the characteristic (n sin2θ must not equal 1 for θ ∈ [0, φ]).
      k - the modulus, restricted to (-1, 1)
      Returns:
      the complete elliptic integral of the third kind for the given parameters
    • ePI

      public static double ePI(double n, double phi, double k)
      Compute an incomplete elliptic integral of the third kind. The integral is defined by $$ \Pi(n,\phi,k) = \int_{\theta=0}^{\phi} \frac{d\theta}{(1-n\sin^2\theta)\sqrt{1-k^2\sin^2\theta}}\ .$$

      The notation used is the same as that used for the Legendre form. For elliptic integrals in this form, the angle φ is called the amplitude, the parameter k is called the modulus, and the parameter n is called the characteristic. A subset of these may be used for a particular integral. One should keep in mind that a number of notations are in common use. The methods RF(double, double, double), RD(double, double, double), RC(double, double), and RJ(double, double, double, double) use Carlson's form.

      Parameters:
      n - the characteristic (n sin2θ must not equal 1 for θ ∈ [0, φ]).
      phi - the amplitude
      k - the modulus, restricted to (-1, 1)
      Returns:
      the incomplete elliptic integral of the third kind for the given parameters
    • hgF

      public static double hgF(double a, double b, double c, double z)
      Compute the hypergeometric function F(a, b; c; z) = 2F1(a, b; c; z). The argument c must not be an integer less than or equal to 0. If z = 1, then c-a-b must not be an integer less than or equal to 0. If
      Parameters:
      a - the first parameter
      b - the second parameter
      c - the third parameter
      z - the argument
      Returns:
      the value 2F1(a, b; c; z)
    • hgF

      public static double hgF(int an, int ad, int bn, int bd, double c, double z)
      Compute the hypergeometric function F(a, b; c; z) = 2F1(a, b; c; z) when a and b are rational numbers.
      Parameters:
      an - the numerator for the first parameter (a)
      ad - the denominator for the first parameter (a)
      bn - the numerator for the second parameter (b)
      bd - the denominator for th second parameter (b)
      c - the third parameter
      z - the argument
      Returns:
      the value 2F1(an/ad, bn/bd; c; z)
    • hgF

      public static double hgF(int an, int ad, double b, double c, double z)
      Compute the hypergeometric function F(a, b; c; z) = 2F1(a, b; c; z) when a is a rational number.
      Parameters:
      an - the numerator for the first parameter (a)
      ad - the denominator for the first parameter (a)
      b - the second parameter
      c - the third parameter
      z - the argument
      Returns:
      the value 2F1(an/ad, b; c; z)
    • dhgFdx

      public static double dhgFdx(double a, double b, double c, double z) throws IllegalArgumentException
      Compute the derivative of the hypergeometric function F(a, b; c; z) = 2F1(a, b; c; z) with respect to z.
      Parameters:
      a - the first parameter
      b - the second parameter
      c - the third parameter
      z - the argument
      Returns:
      the derivative of 2F1(a, b; c; z) with respect to z
      Throws:
      IllegalArgumentException
    • d2hgFdx2

      public static double d2hgFdx2(double a, double b, double c, double z) throws IllegalArgumentException
      Compute the second derivative of the hypergeometric function F(a, b; c; z) = 2F1(a, b; c; z) with respect to z.
      Parameters:
      a - the first parameter
      b - the second parameter
      c - the third parameter
      z - the argument
      Returns:
      the second derivative of 2F1(a, b; c; z) with respect to z
      Throws:
      IllegalArgumentException
    • dhgFdx

      public static double dhgFdx(int an, int ad, double b, double c, double z) throws IllegalArgumentException
      Compute the derivative of the hypergeometric function F(a, b; c; z) = 2F1(a, b; c; z) with respect to z when a is a rational number.
      Parameters:
      an - the numerator for the first parameter (a)
      ad - the denominator for the first parameter (a)
      b - the second parameter
      c - the third parameter
      z - the argument
      Returns:
      the derivative of 2F1(an/ad, b; c; z) with respect to z
      Throws:
      IllegalArgumentException
    • d2hgFdx2

      public static double d2hgFdx2(int an, int ad, double b, double c, double z)
      Compute the second derivative of the hypergeometric function F(a, b; c; z) = 2F1(a, b; c; z) with respect to z when a is a rational number.
      Parameters:
      an - the numerator for the first parameter (a)
      ad - the denominator for the first parameter (a)
      b - the second parameter
      c - the third parameter
      z - the argument
      Returns:
      the second derivative of 2F1(an/ad, b; c; z) with respect to z
    • dhgFdx

      public static double dhgFdx(int an, int ad, int bn, int bd, double c, double z) throws IllegalArgumentException
      Compute the derivative of the hypergeometric function F(a, b; c; z) = 2F1(a, b; c; z) with respect to z when a and b are rational numbers.
      Parameters:
      an - the numerator for the first parameter (a)
      ad - the denominator for the first parameter (a)
      bn - the numerator for the second parameter (b)
      bd - the denominator for th second parameter (b)
      c - the third parameter
      z - the argument
      Returns:
      the derivative of 2F1(an/ad, bn/bd; c; z) with respect to z
      Throws:
      IllegalArgumentException
    • d2hgFdx2

      public static double d2hgFdx2(int an, int ad, int bn, int bd, double c, double z)
      Compute the second derivative of the hypergeometric function F(a, b; c; z) = 2F1(a, b; c; z) with respect to z when a and b are rational numbers.
      Parameters:
      an - the numerator for the first parameter (a)
      ad - the denominator for the first parameter (a)
      bn - the numerator for the second parameter (b)
      bd - the denominator for th second parameter (b)
      c - the third parameter
      z - the argument
      Returns:
      the second derivative of 2F1(an/ad, bn/bd; c; z) with respect to z
    • M

      public static double M(double a, double b, double z)
      Compute the confluent hypergeometric function M(a, b, z). $$M(a,b,z) = \sum_{i=0}^\infty \frac{(a)_iz^i}{(b)_ii!}$$ where (a)i is a Pochhammer symbol.
      Parameters:
      a - the first argument
      b - the second argument
      z - the third argument
      Returns:
      the value M(a, b, z)
      Throws:
      IllegalArgumentException - the function is not defined for the choice of arguments
    • M

      public static double M(long a, double b, double z)
      Compute the confluent hypergeometric function M(a, b, z) when a is a long integer. $$M(a,b,z) = \sum_{i=0}^\infty \frac{(a)_iz^i}{(b)_ii!}$$ where (a)i is a Pochhammer symbol.
      Parameters:
      a - the first argument
      b - the second argument
      z - the third argument
      Returns:
      the value M(a, b, z)
      Throws:
      IllegalArgumentException - the function is not defined for the choice of arguments
    • M

      public static double M(long a, long b, double z)
      Compute the confluent hypergeometric function M(a, b, z) when a and b are long integers. $$M(a,b,z) = \sum_{i=0}^\infty \frac{(a)_iz^i}{(b)_ii!}$$ where (a)i is a Pochhammer symbol.
      Parameters:
      a - the first argument
      b - the second argument
      z - the third argument
      Returns:
      the value M(a, b, z)
      Throws:
      IllegalArgumentException - the function is not defined for the choice of arguments
    • dMdx

      public static double dMdx(double a, double b, double x) throws IllegalArgumentException
      Compute the derivative with respect to the third argument of the confluent hypergeometric function.
      Parameters:
      a - the first argument
      b - the second argument
      x - the third argument
      Returns:
      the value of the derivative
      Throws:
      IllegalArgumentException
    • d2Mdx2

      public static double d2Mdx2(double a, double b, double x) throws IllegalArgumentException
      Compute the second derivative with respect to the third argument of the confluent hypergeometric function.
      Parameters:
      a - the first argument
      b - the second argument
      x - the third argument
      Returns:
      the value of the derivative
      Throws:
      IllegalArgumentException
    • dMdx

      public static double dMdx(long a, double b, double x) throws IllegalArgumentException
      Compute the derivative with respect to the third argument of the confluent hypergeometric function when the first argument is an integer.
      Parameters:
      a - the first argument
      b - the second argument
      x - the third argument
      Returns:
      the value of the derivative
      Throws:
      IllegalArgumentException
    • d2Mdx2

      public static double d2Mdx2(long a, double b, double x) throws IllegalArgumentException
      Compute the second derivative with respect to the third argument of the confluent hypergeometric function when the first argument is an integer..
      Parameters:
      a - the first argument
      b - the second argument
      x - the third argument
      Returns:
      the value of the derivative
      Throws:
      IllegalArgumentException
    • dMdx

      public static double dMdx(long a, long b, double x) throws IllegalArgumentException
      Compute the derivative with respect to the third argument of the confluent hypergeometric function when the first two arguments are integers.
      Parameters:
      a - the first argument
      b - the second argument
      x - the third argument
      Returns:
      the value of the derivative
      Throws:
      IllegalArgumentException
    • d2Mdx2

      public static double d2Mdx2(long a, long b, double x) throws IllegalArgumentException
      Compute the second derivative with respect to the third argument of the confluent hypergeometric function when the first two arguments are integers..
      Parameters:
      a - the first argument
      b - the second argument
      x - the third argument
      Returns:
      the value of the derivative
      Throws:
      IllegalArgumentException
    • erf

      public static double erf(double x)
      Compute the error function. The error function is defined as $\mathrm{erf}(x) = \frac{2}{\sqrt{\pi}}\int_{t=0}^{x} e^{-t^2} dt$.

      The implementation uses Equation 7.1.5 (Abramowitz and Stegun) and and when x ≥ 3.5, uses 1-erfc(x).

      Parameters:
      x - the argument to the error function
      Returns:
      the value erf(x)
    • erf

      public static double erf(double arg, int scale)
      Compute the error function using fixed-point arithmetic
      Parameters:
      arg - the argument
      scale - the number of digits past the decimal point.
      Returns:
      the value erf(arg)
    • erfc

      public static double erfc(double arg, int scale)
      Compute the error function complement using fixed-point arithmetic
      Parameters:
      arg - the argument
      scale - the number of digits past the decimal point.
      Returns:
      the value erfc(arg)
    • erfc

      public static double erfc(double x)
      Complementary error function. This function is defined as erfc(x) = 1.0 - erf(x) if the argument is larger than or equal to 3.5, the asymptotic expansion given by Equation 7.1.23 (Abramowitz and Stegun) is used.
      Parameters:
      x - the argument
      Returns:
      the value erfc(x)
    • Beta

      public static double Beta(double x, double y)
      Compute the Beta function.
      Parameters:
      x - the first argument
      y - the second argument
      Returns:
      either the value Β(x,y) or negative or positive infinity when Β(x,y) is infinite or when either Β(x,y) or an intermediate value when computing it is too large to be represented as a double-precision number.
    • Beta

      public static double Beta(double x, double a, double b)
      Compute the incomplete beta function Βx(a,b). The incomplete beta function is defined as $B_x(a,b) = \int_{t=0}^x t^{a-1}(1-t)^{b-1} dt$.
      Parameters:
      x - the limit to the integral
      a - the first argument
      b - the second argument
      Returns:
      the value Βx(a,b)
    • dBetadx

      public static double dBetadx(double x, double a, double b)
      Compute the derivative with respect to x of the incomplete beta function Βx(a,b). The incomplete beta function is defined as $B_x(a,b) = \int_{t=0}^x t^{a-1}(1-t)^{b-1} dt$.
      Parameters:
      x - the limit to the integral
      a - the first argument
      b - the second argument
      Returns:
      the derivative with respect to x of Βx(a,b)
    • d2Betadx2

      public static double d2Betadx2(double x, double a, double b)
      Compute the second derivative with respect to x of the incomplete beta function Βx(a,b). The incomplete beta function is defined as
      Parameters:
      x - the limit to the integral
      a - the first argument
      b - the second argument
      Returns:
      the second derivative with respect to x of Βx(a,b)
    • BetaI

      public static double BetaI(double x, double a, double b)
      Compute the regularized incomplete beta function Ix(a,b). This incomplete beta function is defined as Ix(a,b) = Βx(a,b) / Β(a,b).

      Note: I is prefaced with "Beta" in the method name to avoid confusion, as Java does not use subscripts that are really function arguments.

      Parameters:
      x - the limit to the integral
      a - the first argument
      b - the second argument
      Returns:
      the value of Ix(a,b)
    • dBetaIdx

      public static double dBetaIdx(double x, double a, double b)
      Compute the derivative with respect to x of the regularized incomplete beta function Ix(a,b). This incomplete beta function is defined as Ix(a,b) = Βx(a,b) / Β(a,b).

      Note: I is prefaced with "Beta" in the method name to avoid confusion, as Java does not use subscripts that are really function arguments.

      Parameters:
      x - the limit to the integral
      a - the first argument
      b - the second argument
      Returns:
      the derivative with respect to x of Ix(a,b)
    • d2BetaIdx2

      public static double d2BetaIdx2(double x, double a, double b)
      Compute the second derivative with respect to x of the regularized incomplete beta function Ix(a,b). This incomplete beta function is defined as Ix(a,b) = Βx(a,b) / Β(a,b).

      Note: I is prefaced with "Beta" in the method name to avoid confusion, as Java does not use subscripts that are really function arguments.

      Parameters:
      x - the limit to the integral
      a - the first argument
      b - the second argument
      Returns:
      the second derivative with respect to x of Ix(a,b)
    • acosh

      public static double acosh(double x)
      Compute the inverse hyperbolic cosine.
      Parameters:
      x - a real number larger than or equal to 1.0
      Returns:
      cosh-1(x)
    • asinh

      public static double asinh(double x)
      Compute the inverse hyperbolic sin.
      Parameters:
      x - a real number
      Returns:
      sinh-1(x)
    • atanh

      public static double atanh(double x)
      Compute the inverse hyperbolic tangent.
      Parameters:
      x - a real number in the range [-1.0, 1.0]
      Returns:
      tanh-1(x)
    • Ai

      public static double Ai(double x)
      Compute the Airy function of the first kind. The Airy functions Ai and Bi are solutions to the differential equation y'' - xy = 0.
      Parameters:
      x - the argument
      Returns:
      the value of Ai(x)
    • dAidx

      public static double dAidx(double x)
      Compute the first derivative of the Airy function of the first kind. The Airy functions Ai and Bi are solutions to the differential equation y'' - xy = 0.
      Parameters:
      x - the argument
      Returns:
      the value of $\frac{d}{dx}\mathrm{Ai}(x)$
    • Bi

      public static double Bi(double x)
      Compute the Airy function of the second kind. The Airy functions Ai and Bi are solutions to the differential equation y'' - xy = 0.
      Parameters:
      x - the argument
      Returns:
      the value of Bi(x)
    • dBidx

      public static double dBidx(double x)
      Compute the first derivative of the Airy function of the second kind. The Airy functions Ai and Bi are solutions to the differential equation y'' - xy = 0.
      Parameters:
      x - the argument
      Returns:
      the value of $\frac{d}{dx}\mathrm{Bi}(x)$
    • Yamp

      public static double Yamp(int ell, int m, double theta)
      Compute the amplitude of of spherical harmonics. Java cannot represent spherical harmonics because they are complex-valued functions. For a spherical harmonic Ylm(θφ), one can define an amplitude given by Ylm(θφ)e-imφ. The absolute value of the amplitude of Ylm(θφ) is equal the magnitude of Ylm(θφ) but may differ in sign depending on the value of Plm(θ). This method returns the amplitude of a spherical harmonic - a normalization of the function Plm(θ). The normalization factor is sqrt((2l+1)(l-m)!/(4π(l+m)!)).

      Citation: J.D. Jackson, "Classical Electrodynamics," page 65, John Wiley & Sons, 1962 (fifth printing).

      Parameters:
      ell - the degree of the spherical harmonic
      m - the order of the spherical harmonic
      theta - the angle of a point along a unit sphere with respect to the z axis in radians
      Returns:
      the amplitude (as defined above) of the spherical harmonic Ylm(θφ)
    • L

      public static double L(int n, double x)
      Compute the value of a Laguerre polynomial.
      Parameters:
      n - the degree of the polynomial
      x - the argument
      Returns:
      the value of Ln(x)
    • dLdx

      public static double dLdx(int n, double x)
      Compute the value of the derivative of a Laguerre polynomial.
      Parameters:
      n - the degree of the polynomial
      x - the argument
      Returns:
      the derivative $\frac{d}{dx}L_n(x)$
    • L

      public static double L(int n, double alpha, double x)
      Compute the value of an associated Laguerre polynomial.
      Parameters:
      n - the degree of the polynomial
      alpha - the order of the associated Laguerre polynomial
      x - the argument
      Returns:
      the value of Ln(α)(x)
    • dLdx

      public static double dLdx(int n, double alpha, double x)
      Compute the value of the derivative of an associated Laguerre polynomial.
      Parameters:
      n - the degree of the polynomial
      alpha - the order of the associated Laguerre polynomial
      x - the argument
      Returns:
      the derivative $\frac{d}{dx}L_n^\alpha(x)$