Class Maja

java.lang.Object
rocks.palaiologos.maja.Maja

public class Maja extends Object
A slick numerics-oriented Mathematical library for Java.
Author:
Palaiologos
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final double
    Apery's constant - zeta(3).
    static final double
    SI prefix for 10^-18.
    static final double
    Catalan's constant.
    static final double
    SI prefix for 10^-2.
    static final double
    SI prefix for 10^1.
    static final double
    SI prefix for 10^-1.
    static final double
    The value of e.
    static final double
    The epsilon value for double precision numbers.
    static final double
    The Euler-Mascheroni constant.
    static final double
    SI prefix for 10^18.
    static final double
    Feigenbaum constant.
    static final double
    SI prefix for 10^-15.
    static final double
    SI prefix for 10^9.
    static final double
    Glaisher-Kinkelin constant.
    static final double
    The golden ratio.
    static final double
    Golomb-Dickman constant.
    static final double
    SI prefix for 10^2.
    static final Complex
    The imaginary unit.
    static final double
    Khinchin's constant.
    static final double
    SI prefix for 10^3.
    static final double
    The value of ln(10).
    static final double
    The value of ln(2).
    static final double
    The value of log2(e).
    static final double
    SI prefix for 10^6.
    static final double
    SI prefix for 10^-6.
    static final double
    SI prefix for 10^-3.
    static final double
    Mills' constant.
    static final double
    SI prefix for 10^-9.
    static final double
    The value of 1/e.
    static final double
    The value of 1/pi.
    static final double
    SI prefix for 10^15.
    static final double
    The value of pi.
    static final double
    The value of pi/2.
    static final double
    The value of pi/4.
    static final double
    SI prefix for 10^-12.
    static final double
    SI prefix for 10^12.
    static final double
    The value of 2*PI.
    static final double
    SI prefix for 10^-24.
    static final double
    SI prefix for 10^24.
    static final double
    SI prefix for 10^-21.
    static final double
    SI prefix for 10^21.
  • Method Summary

    Modifier and Type
    Method
    Description
    static boolean[]
    aberth(Complex[] coefficients)
    Numerically finds all roots of a polynomial equation P(z) = 0.
    static double
    abs(double x)
    Returns the absolute value of a double precision number.
    static long
    abs(long x)
    Returns the absolute value of a number.
    static double
    Compute the absolute value of a complex number.
    static Dual
    abs(Dual a)
     
    static Complex
    Compute the absolute values of parts of a complex number.
    static double
    acos(double x)
    Returns the value of the inverse cosine of a double precision number.
    static Complex
    Compute the arcus cosine of a complex number.
    static Dual
     
    static double
    acosh(double x)
    Compute the value of the inverse hyperbolic cosine function at x.
    static Complex
    Compute the hyperbolic arccosine of a complex number.
    static Dual
     
    static double
    acot(double x)
    Compute the value of the inverse cotangent (1 / atan(x)) function at x.
    static Complex
    Compute the arcus cotangent of a complex number.
    static Dual
     
    static double
    acoth(double x)
    Compute the value of the inverse hyperbolic cotangent (1 / atanh(x)) function at x.
    static Complex
    Compute the hyperbolic arccotangent of a complex number.
    static Dual
     
    static double
    acsc(double x)
    Compute the value of the inverse cosecant (1 / asin(x)) function at x.
    static Complex
    Compute the arcus cosecant of a complex number.
    static Dual
     
    static double
    acsch(double x)
    Compute the value of the inverse hyperbolic cosecant (1 / asinh(x)) function at x.
    static Complex
    Compute the hyperbolic arccosecant of a complex number.
    static Dual
     
    static double
    add(double x, double y)
    Adds two double precision numbers together.
    static Complex
    add(double a, Complex b)
    Add a complex number and a real number.
    static Dual
    add(double a, Dual b)
    Perform real-dual addition.
    static Complex
    add(Complex a, double b)
    Add a complex number and a real number.
    static Complex
    Add two complex numbers together.
    static Dual
    add(Dual a, double b)
    Perform real-dual addition.
    static Dual
    add(Dual a, Dual b)
    Perform dual addition.
    static <T> T
    add(AdditiveGroup<T> group, T x, T y)
    Subtracts two values through an additive group.
    static <T> T
    add(AdditiveGroupoid<T> groupoid, T x, T y)
    Adds two values through an additive groupoid.
    static double
    agm(double a, double g)
    Computes the Arithmetic-Geometric mean.
    static double[]
    airy(double x)
    Compute the value of the Airy Ai, Ai', Bi and Bi' functions at the specified point.
    static Complex[]
    Compute the value of the Airy Ai, Ai', Bi and Bi' functions at the specified point.
    static double
    airyAi(double x)
    Compute the value of the Airy Ai function at the specified point.
    static Complex
    Compute the value of the Airy Ai function at the specified point.
    static Dual
     
    static double
    airyAip(double x)
    Compute the value of the Airy Ai function's first derivative at the specified point.
    static Complex
    Compute the value of the Airy Ai function's first derivative at the specified point.
    static double
    airyBi(double x)
    Compute the value of the Airy Bi function at the specified point.
    static Complex
    Compute the value of the Airy Bi function at the specified point.
    static Dual
     
    static double
    airyBip(double x)
    Compute the value of the Airy Bi function's first derivative at the specified point.
    static Complex
    Compute the value of the Airy Bi function's first derivative at the specified point.
    static double
    angerJ(double v, double z)
     
    static Complex
     
    static double
    arcLength(Function<Double,Double> df, double a, double b)
    Compute the arc length of a curve defined by the function f(x) and its derivative df(x) on the interval [a, b].
    static double
    Return the argument of a complex number.
    static double
    asec(double x)
    Compute the value of the inverse secant (1 / acos(x)) function at x.
    static Complex
    Compute the arcus secant of a complex number.
    static Dual
     
    static double
    asech(double x)
    Compute the value of the inverse hyperbolic secant (1 / acosh(x)) function at x.
    static Complex
    Compute the hyperbolic arcsecant of a complex number.
    static Dual
     
    static double
    asin(double x)
    Returns the value of the inverse sine of a double precision number.
    static Complex
    Compute the arcus sine of a complex number.
    static Dual
     
    static double
    asinh(double a)
    Compute the value of the inverse hyperbolic sine function at x.
    static Complex
    Compute the hyperbolic arcsine of a complex number.
    static Dual
     
    static double
    atan(double x)
    Returns the value of the inverse tangent of a double precision number.
    static Complex
    Compute the arcus tangent of a complex number.
    static Dual
     
    static double
    atan2(double y, double x)
    Returns the value of the inverse tangent of two double precision numbers.
    static double
    atanh(double a)
    Compute the value of the inverse hyperbolic tangent function at x.
    static Complex
    Compute the hyperbolic arctangent of a complex number.
    static Dual
     
    static int
    Returns an integer b such that |B_n| ≤ 2^b for all Bernoulli numbers B_n.
    static double
    besselI0(double x)
    Compute the bessel I0 function at x.
    static Dual
     
    static double
    besselI1(double x)
    Compute the bessel I1 function at x.
    static double
    besselJ0(double x)
    Compute the bessel J0 function at x.
    static Dual
     
    static double
    besselJ1(double x)
    Compute the bessel J1 function at x.
    static Dual
     
    static double
    besselJn(int n, double x)
    Compute the bessel Jn function at x.
    static Dual
    besselJn(int n, Dual a)
     
    static double
    besselJv(double n, double x)
    Compute fractional order bessel function of n and x.
    static Dual
    besselJv(double n, Dual a)
     
    static double
    besselK0(double x)
    Compute the bessel K0 function at x.
    static Dual
     
    static double
    besselK1(double x)
    Compute the bessel K1 function at x.
    static Dual
     
    static double
    besselKn(int n, double x)
    Compute the bessel Kn function at x.
    static Dual
    besselKn(int n, Dual a)
     
    static double
    besselY0(double x)
    Compute the bessel Y0 function at x.
    static Dual
     
    static double
    besselY1(double x)
    Compute the bessel Y1 function at x.
    static double
    besselYn(int n, double x)
    Compute the bessel Yn function at x.
    static Dual
    besselYn(int n, Dual a)
     
    static double
    besselYv(double v, double x)
    Compute the fractional order bessel Y function of v and x.
    static Dual
    besselYv(double n, Dual a)
     
    static double
    beta(double x, double y)
    Compute the beta function of two values.
    static Dual
    beta(double a, Dual c)
    Compute the beta function of a real and dual number.
    static Complex
    Compute the beta function of two complex numbers.
    static Dual
    beta(Dual a, double c)
    Compute the beta function of a dual and real number.
    static long
    binomial(int n, int k)
    Compute the binomial coefficient "n choose k".
    static double
    cbrt(double x)
    Returns the value of the cube root of a double precision number.
    static Complex
    Compute the principal cube root of a complex number.
    static Dual
     
    static double
    ceil(double x)
    Returns the value of the smallest integer greater than or equal to a double precision number.
    static Complex
    Rounds both the real and imaginary parts of a complex number.
    static double
    Chi(double x)
    Compute the value of the hyperbolic cosine integral function at x.
    static Complex
    Compute the value of the complex hyperbolic cosine integral Chi(z).
    static Dual
    Chi(Dual a)
     
    static double
    chiSquaredQuantile(double p, double df)
    Computes quantiles for chi-squared probability distribution at probability p .
    static Complex
    Trim insignificant real/imaginary parts (below machine epsilon), round up numbers where the real/imaginary part is very close to an integer.
    static double
    Ci(double x)
    Compute the value of the cosine integral function at x.
    static Complex
    Compute the value of the complex cosine integral Ci(z) at z.
    static Dual
    Ci(Dual a)
     
    static double
    Cin(double x)
    Compute the value of the cosine integral function at x.
    static Complex
    Compute the value of the complex cosine integral Cin(z) at z.
    static Complex
    cis(double x)
    Compute the value of the cis function of a number.
    static double
    clamp(double value, double min, double max)
    Clamp a value in the range [min, max].
    static long
    clamp(long value, long min, long max)
    Clamp a value in the range [min, max].
    static int
    compare(double x, double y)
    Compare two double precision numbers.
    static int
    compare(long x, long y)
    Compare two integers.
    static Complex
    Compute the complex conjugate of a complex number.
    static double
    copySign(double x, double y)
    Copy the sign of the second argument to the first argument.
    static long
    copySign(long x, long y)
    Copy the sign of the second argument to the first argument.
    static Complex
    Copy the sign of the second argument to the first argument.
    static double
    cos(double x)
    Returns the value of the smallest integer greater than or equal to a double precision number.
    static Complex
    Compute the cosine of a complex number.
    static Dual
    cos(Dual a)
     
    static double
    cosh(double x)
    Returns the hyperbolic cosine of a double precision number.
    static Complex
    Compute the hyperbolic cosine of a complex number.
    static Dual
     
    static double
    cot(double x)
    Compute the value of the cotangent (1 / tan(x)) function at x.
    static Complex
    Compute the cotangent of a complex number.
    static Dual
    cot(Dual a)
     
    static double
    coth(double x)
    Compute the value of the hyperbolic cotangent (1 / tanh(x)) function at x.
    static Complex
    Compute the hyperbolic cotangent of a complex number.
    static Dual
     
    static double
    csc(double x)
    Compute the value of the cosecant (1 / sin(x)) function at x.
    static Complex
    Compute the cosecant of a complex number.
    static Dual
    csc(Dual a)
     
    static double
    csch(double x)
    Compute the value of the hyperbolic cosecant (1 / sinh(x)) function at x.
    static Complex
    Compute the hyperbolic cosecant of a complex number.
    static Dual
     
    static double
    dawsonMinus(double x)
    Compute the value of the Dawson function (D-) at x.
    static Complex
    Compute the value of the complex Dawson function (D-) at z.
    static double
    dawsonPlus(double x)
    Compute the value of the Dawson function (D+) at x.
    static Complex
    Compute the value of the complex Dawson function (D+) at z.
    static double
    digamma(double x)
    Compute the digamma function of x.
    static Complex
    Compute the complex digamma function.
    static Dual
     
    static double
    dilog(double n)
    Compute the dilogarithm (the value of the Spence function at 1-x) of x.
    static Complex
    Compute the complex dilogarithm of z.
    static Dual
     
    static double
    div(double x, double y)
    Divides two double precision numbers.
    static Complex
    div(double a, Complex b)
    Divide a complex number and a real number.
    static Complex
    div(Complex a, double b)
    Divide a complex number and a real number.
    static Complex
    Divide two complex numbers.
    static Dual
    div(Dual a, Dual b)
     
    static Complex
    Compute the value of the exponential integral E1 at the specified point.
    static double
    Ei(double x)
    Compute the value of the exponential integral at x.
    static Complex
    Compute the exponential integral using a formula that was revealed to me in a dream:
    static Dual
    Ei(Dual a)
     
    static Complex
    Compute the value of the complementary exponential integral Ein at the specified point.
    static Complex
    Compute the value of the complex generalised exponential integral E_n(z).
    static boolean
    eq(double x, double y)
    Return true if x == y.
    static boolean
    eq(double x, double y, double tol)
    Return true if x is approximately equal to y.
    static boolean
    eq(double a, Complex b)
    Compare two numbers for equality.
    static boolean
    eq(Complex a, double b)
    Compare two numbers for equality.
    static boolean
    Compare two numbers for equality.
    static boolean
    eq(Complex a, Complex b, double tol)
    Compare two complex numbers for equality.
    static double
    erf(double x)
    Compute the value of the error function at x.
    static Complex
    Compute the complex error function.
    static Dual
    erf(Dual a)
     
    static double
    erfc(double x)
    Compute the value of the complementary error function at x.
    static Complex
    Compute the complex complementary error function.
    static Dual
     
    static double
    erfi(double x)
    Compute the value of the imaginary error function at x.
    static Complex
    Compute the complex imaginary error function.
    static Dual
     
    static double
    exp(double x)
    Returns the value of the exponential function of a double precision number.
    static Complex
    Compute the value of the exponential function of a complex number.
    static Dual
    exp(Dual a)
     
    static double
    expm1(double x)
    Returns the value of the exponential function of a double precision number minus one.
    static double
    fac2(double a)
     
    static double
    factorial(long n)
    Return the factorial of n as a double-precision.
    static float
    fastCos(float x)
    Return a cached value of cos(x) using Raven's method.
    static float
    fastSin(float x)
    Return a cached value of sin(x) using Raven's method.
    static long
    fib(int a)
    Compute the n-th Fibonacci number using Binet's formula.
    static double
    floor(double x)
    Returns the value of the largest integer less than or equal to a double precision number.
    static Complex
    Rounds both the real and imaginary parts of a complex number.
    static double
    fma(double a, double b, double c)
    Returns the value of the fused multiply-add operation.
    static Complex
    Returns the value of the complex fused multiply-add operation.
    static double
    fresnelC(double x)
    Compute the Fresnel integral C(x).
    static Complex
    Compute the Fresnel C integral on the complex plane.
    static Dual
     
    static double
    fresnelS(double x)
    Compute the Fresnel integral S(x).
    static Complex
    Compute the Fresnel S integral on the complex plane.
    static Dual
     
    frexp(double value)
    Break floating-point number down into exponent and mantissa
    static double
    gamma(double x)
    Compute the gamma function of x.
    static Complex
    Compute the gamma function of a complex number.
    static Dual
     
    static double
    gammaP(double a, double x)
    Compute the regularized Gamma P function.
    static double
    gammaQ(double a, double x)
    Compute the regularized Gamma Q function.
    static double
    gcd(double a, double b)
    Domain extension of the greatest common division function onto the real line.
    static long
    gcd(long a, long b)
    Compute the greatest common divisor of two integers.
    static Complex
    Domain extension of the greatest common division function onto the complex plane.
    static boolean
    ge(double x, double y)
    Return true if x >= y.
    static int
    getExponent(double x)
    Returns the exponent of a double precision number.
    static boolean
    gt(double x, double y)
    Return true if x > y.
    static double
    hurwitzZeta(double x, double a)
    Compute the value of the Hurwitz zeta function at x.
    static Dual
    hurwitzZeta(double s, Dual a)
     
    static Complex
    Compute the Hurwitz zeta function of complex arguments.
    static double
    hypergeo1F1(double a, double b, double x)
    Computes the Confluent hypergeometric function (1F1) of three arguments.
    static double
    hypergeo1F2(double a, double b, double c, double x)
    Computes the 1F2 case of the generalised hypergeometric function.
    static double
    hypergeo2F1(double a, double b, double c, double x)
    Computes the Gaussian hypergeometric function (2F1) of four arguments.
    static double
    hypergeo3F0(double a, double b, double c, double x)
    Computes the 3F0 case of the generalised hypergeometric function.
    static double
    hypot(double x, double y)
    Returns the length of the hypotenuse of a right triangle with sides of length x and y.
    static int
    icbrt(int x)
    Return the integer cube root of a number.
    static long
    icbrt(long x)
    Return the long integer cube root of a number.
    static short
    icbrt(short a)
    Return the short integer cube root of a number.
    static int
    ilog10(int x)
    Compute the value of the integer logarithm in base 10 of a number
    static Complex
    Integrate a dyadic function over a finite interval [a,b] x [c,d] using the Gauss-Legendre quadrature.
    static Complex
    Integrate a C -> C function using the Gauss-Legendre quadrature.
    static Complex
    integrateGaussLegendreRC(Function<Double,Complex> f, double a, double b, int N)
    Integrate a monadic function over a finite interval [a,b] using the Gauss-Legendre quadrature.
    static double
    integrateGaussLegendreReal(BiFunction<Double,Double,Double> f, double a, double b, double c, double d, int N)
    Integrate a dyadic function over a finite interval [a,b] x [c,d] using the Gauss-Legendre quadrature.
    static double
    integrateGaussLegendreReal(Function<Double,Double> f, double a, double b, int N)
    Integrate a monadic function over a finite interval [a,b] using the Gauss-Legendre quadrature.
    static Complex
    integrateSimpsonRC(Function<Double,Complex> f, double a, double b, int N)
    Integrate a monadic function over a finite interval [a,b] using the Simpson rule.
    static double
    integrateSimpsonReal(Function<Double,Double> f, double a, double b, int N)
    Integrate a monadic function over a finite interval [a,b] using the Simpson rule.
    static Complex[]
    Integrate a C -> C function using the Tanh-Sinh quadrature.
    static Complex[]
    integrateTanhSinhRC(Function<Double,Complex> f, double a, double b, int N, double eps)
    Integrate a monadic function over a finite interval [a,b] using the Tanh-Sinh quadrature, especially useful when singularities or infinite derivatives exist at one or both endpoints.
    static double[]
    integrateTanhSinhReal(Function<Double,Double> f, double a, double b, int N, double eps)
    Integrate a monadic function over a finite interval [a,b] using the Tanh-Sinh quadrature, especially useful when singularities or infinite derivatives exist at one or both endpoints.
    static int
    ipow(int x, int n)
    Compute the value of integer x^n.
    static long
    ipow(long x, long n)
    Compute the value of integer x^n.
    static short
    ipow(short x, short n)
    Compute the value of integer x^n.
    static boolean
    Determine whether a number is a perfect square.
    static boolean
    isPowerOfTwo(long value)
    Determine if a value is a power of two.
    static boolean
    isPrime(int n)
    Primality test for an integer in range [0, 2^31-1].
    static boolean
    isPrime(long n)
    Primality test for an unsigned integer in range [0, 2^64-1].
    static int
    isqrt(int x)
    Compute the integer square root of a number.
    static int
    isqrt(long x)
    Compute the integer square root of a number.
    static int
    isqrt(short x)
    Compute the integer square root of a number.
    static Complex
    lambertw(Complex z, long k)
    Compute the specified branch of the complex Lambert W function of z.
    static double
    lambertW0(double x)
    Compute Lambert W_0 (x).
    static Dual
     
    static double
    lambertWm1(double x)
    Compute Lambert W_(-1) (x).
    static Dual
     
    static double
    landau(double x)
    Compute the Landau distribution function.
    static double
    landau(double x, double mpv, double sigma, boolean norm)
    Compute the Landau function with specified most probable value and sigma value.
    static double
    lcm(double a, double b)
    Domain extension of the least common multiple function onto the real line.
    static long
    lcm(long a, long b)
    Compute the least common multiple of two integers.
    static Complex
    Domain extension of the least common multiple function onto the complex plane.
    static boolean
    le(double x, double y)
    Return true if x <= y.
    static double
    legendre(double n, double z)
     
    static double
    legendreD(double phi, double k)
    Compute the Legendre D elliptic integral defined by DLMF §19.2.6
    static Complex
    Compute the Legendre D elliptic integral defined by DLMF §19.2.6
    static double
    legendreE(double phi, double k)
    Compute the Legendre E elliptic integral defined by DLMF §19.2.5
    static Complex
    Compute the Legendre E elliptic integral defined by DLMF §19.2.5
    static double
    legendreF(double phi, double k)
    Compute the Legendre F elliptic integral defined by DLMF §19.2.4
    static Complex
    Compute the Legendre F elliptic integral defined by DLMF §19.2.4
    static double
    legendrePi(double phi, double alpha, double k)
    Compute the Legendre Pi elliptic integral defined by DLMF §19.2.7
    static Complex
    legendrePi(Complex phi, Complex alpha, Complex k)
    Compute the Legendre Pi elliptic integral defined by DLMF §19.2.7
    static double
    lerchPhi(double z, double s, double a)
    Compute the value of the Lerch transcendent function at z, s, a.
    static Complex
    Compute the Lerch transcendent of z, s, and a.
    static double
    li(double x)
    Compute the logarithmic integral of x, defined as li(x) = int(1/log t, t=0..x).
    static Complex
    Compute the complex logarithmic integral of z, defined as li(z) = int(1/log t, t=0..z).
    static Dual
    li(Dual a)
     
    static double
    liGamma(double a, double x)
    Compute the value of the lower incomplete gamma function.
    static Complex
    Compute the lower incomplete (non-regularised) gamma function of a complex number.
    static double
    linearInterpolate(double fromValue, double toValue, double progress)
    Linearly interpolate between two values.
    static double
    linearMap(double inRangeStart, double inRangeEnd, double outRangeStart, double outRangeEnd, double value)
    Linearly map a value from one range to another.
    static double
    linearNorm(double rangeStart, double rangeEnd, double value)
    Linearly normalise value from a range.
    static double
    log(double x)
    Returns the value of the natural logarithm of a double precision number.
    static Complex
    Compute the natural logarithm of a complex number.
    static Dual
    log(Dual a)
     
    static double
    log10(double x)
    Returns the value of the base 10 logarithm of a double precision number.
    static double
    log1p(double x)
    Returns the value of the natural logarithm of a double precision number plus one.
    static double
    log2(double x)
    Returns the value of the base 2 logarithm of a double precision number.
    static double[]
    logabsgamma(double x)
    Computes the logarithm of the absolute value of the gamma function of x.
    static double
    logbeta(double x, double y)
    Compute the logarihtm of the beta function of two values.
    static Complex
    Compute the logarithm of the beta function in the complex plane.
    static double
    loggamma(double x)
    Compute the logarithm of the gamma function of x.
    static Complex
    Principal branch of the logarithm of the gamma function.
    static double
    lommels1(double u, double v, double z)
     
    static boolean
    lt(double x, double y)
    Return true if x < y.
    static double
    max(double x, double y)
    Returns the larger of two numbers (maximum).
    static double
    min(double x, double y)
    Returns the smaller of two numbers (minimum).
    static double
    mod(double x, double y)
    Returns the modulus of two double precision numbers.
    static long
    mod(long x, long y)
    Returns the modulus of two numbers.
    static double
    mul(double x, double y)
    Multiplies two double precision numbers.
    static Complex
    mul(double a, Complex b)
    Multiply a complex number and a real number.
    static Complex
    mul(Complex a, double b)
    Multiply a complex number and a real number.
    static Complex
    Multiply two complex numbers.
    static Dual
    mul(Dual a, Dual b)
     
    static <T> T
    mul(MultiplicativeGroup<T> group, T x, T y)
    Divides two values through a multiplicative group.
    static <T> T
    mul(MultiplicativeGroupoid<T> groupoid, T x, T y)
    Multiplies two values through a multiplicative groupoid.
    static boolean
    ne(double x, double y)
    Return true if x != y.
    static boolean
    ne(double a, Complex b)
    Compare two numbers for inequality.
    static boolean
    ne(Complex a, double b)
    Compare two numbers for inequality.
    static boolean
    Compare two numbers for inequality.
    static double
    negate(double x)
    Negate a real number.
    static Complex
    Negate a complex number.
    static double
    newtonRaphson(Function<Double,Double> f, Function<Double,Double> df, double x0, double eps)
    Find a root of a monadic function using the Newton-Raphson method.
    static double
    nextAfter(double x, double y)
    Returns the value of the double precision number adjacent to the first argument in the direction of the second argument.
    static double
    nextDown(double x)
    Returns the value of the double precision number adjacent to the first argument in the direction of negative infinity.
    static long
    nextPowerOfTwo(long value)
    Returns the next power of two.
    static int
    nextPrime(int n)
    Find the next prime after n.
    static long
    nextPrime(long n)
    Find the next prime after (unsigned) n.
    static double
    nextUp(double x)
    Returns the value of the double precision number adjacent to the first argument in the direction of positive infinity.
    static double
    normQuantile(double p)
    Computes quantiles for standard normal distribution N(0, 1) at probability p.
    static double
    pochhammer(double x, double n)
    Compute the Pochhammer symbol (x)_n.
    static double
    pochhammer(double x, int n)
    Compute the Pochhammer symbol (x)_n.
    static Complex
    pochhammer(Complex x, double n)
    Compute the Pochhammer symbol (x)_n.
    static Complex
    pochhammer(Complex x, int n)
    Compute the Pochhammer symbol (x)_n.
    static Complex
    Compute the Pochhammer symbol (x)_n.
    static double
    polygamma(double n, double x)
    Compute the value of the n-th polygamma function at x.
    static Dual
    polygamma(double n, Dual a)
     
    static Complex
    Compute the value of the order-N polygamma function at complex z.
    static double
    polylog(int n, double x)
    Compute the polylogarithm of x.
    static Dual
    polylog(int n, Dual a)
     
    static Complex
    Compute the polylogarithm of s and z.
    static double
    pow(double x, double y)
    Returns the value of the first argument raised to the power of the second argument.
    static double
    pow(double x, int z)
    Compute the value of x^z where x is a double precision floating point number and z is an integer.
    static Complex
    pow(double a, Complex b)
    Compute a to the power of b, where a is a double precision number and b is a complex number.
    static Complex
    pow(Complex a, long b)
    Compute a to the power of b, where a is a complex
    static Complex
    Compute a to the power of b, where a and b are both complex numbers.
    static Dual
    pow(Dual a, int b)
     
    static double
    Returns a random double precision number in range [0, 1).
    static double
    random(double max)
    Returns a random double precision number in range [0, max).
    static double
    random(double min, double max)
    Returns a random double precision number in range [min, max).
    static long
    random(long max)
    Returns a random long integer in range [0, max).
    static long
    random(long min, long max)
    Returns a random long integer in range [min, max).
    static long
    Return a random sign (-1 or 1).
    static double
    rem(double x, double y)
    Returns the remainder that results from dividing two double precision numbers.
    static Complex
    Domain extension of the remainder function onto the complex plane.
    static double
    root(double x, int deg)
    Compute the n-th root of a complex number.
    static Complex[]
    root(Complex x, int n)
    Find all n-th roots of a complex number.
    static long
    round(double x)
    Rounds a double precision number to the nearest integer.
    static Complex
    Rounds both the real and imaginary parts of a complex number.
    static double
    scalb(double x, int n)
    Returns the correctly rounded value of x*2^n.
    static double
    sec(double x)
    Compute the value of the secant (1 / cos(x)) function at x.
    static Complex
    Compute the secant of a complex number.
    static Dual
    sec(Dual a)
     
    static double
    sech(double x)
    Compute the value of the hyperbolic secant (1 / cosh(x)) function at x.
    static Complex
    Compute the hyperbolic secant of a complex number.
    static Dual
     
    static double
    Shi(double x)
    Compute the value of the hyperbolic sine integral function at x.
    static Complex
    Compute the value of the complex hyperbolic sine integral Shi(z).
    static Dual
    Shi(Dual a)
     
    static double[]
    ShiChi(double x)
    Compute both the hyperbolic sine and cosine integral at x.
    static Complex[]
    Compute the value of the complex hyperbolic sine integral Shi(z) and complex hyperbolic cosine integral Chi(z).
    static double
    si(double x)
    Compute the value of the sine integral function at x.
    static Complex
    Compute the value of the complex sine integral si(z) at z.
    static double
    Si(double x)
    Compute the value of the sine integral function at x.
    static Complex
    Compute the value of the complex sine integral Si(z) at z.
    static Dual
    Si(Dual a)
     
    static double
    signum(double x)
    Returns the sign of a double precision number.
    static long
    signum(long x)
    Returns the sign of a number.
    static Complex
    Returns the sign of a complex number.
    static double
    sin(double x)
    Returns the value of the sine of a double precision number.
    static Complex
    Compute the sine of a complex number.
    static Dual
    sin(Dual a)
     
    static double
    sinc(double x)
    Returns the sinc function of a double precision number, defined as sin(x) / x, except for x = 0, where sinc(x) = 1.
    static Complex
    Returns the sinc function of a complex number, defined as sin(x) / x, except for x = 0, where sinc(x) = 1.
    static Dual
     
    static double
    sinh(double x)
    Returns the hyperbolic sine of a double precision number.
    static Complex
    Compute the hyperbolic sine of a complex number.
    static Dual
     
    static double
    solidArea(Function<Double,Double> f, Function<Double,Double> df, double a, double b)
    Compute the surface area of a solid of revolution created by rotating the function f(x) about the x-axis.
    static double
    solidVolume(Function<Double,Double> f, double a, double b)
    Compute the volume of a solid of revolution created by rotating the function f(x) about the x-axis.
    static double
    spence(double n)
    Compute the Spence function of x.
    static Complex
    Compute the Spence function of z.
    static Dual
     
    static double
    sqrt(double x)
    Returns the square root of a double precision number.
    static Complex
    Compute the square root of a complex number.
    static Dual
     
    static double
    squash(double x)
    Compute the value of the logistic sigmoid "squash" function at x.
    static double
    stretch(double x)
    Compute the value of the inverse of the logistic sigmoid "squash" function at x.
    static double
    struve(double v, double x)
    Computes the value of the Struve function of order v at x.
    static double
    struveL0(double x)
    Computes the value of the modified Struve function of 0th order.
    static double
    struveL1(double x)
    Computes the value of the modified Struve function of 1st order.
    static double
    sub(double x, double y)
    Subtracts two double precision numbers.
    static Complex
    sub(double a, Complex b)
    Subtract a complex number and a real number.
    static Dual
    sub(double a, Dual b)
     
    static Complex
    sub(Complex a, double b)
    Subtract a complex number and a real number.
    static Complex
    Subtract two complex numbers from each other.
    static Dual
    sub(Dual a, double b)
     
    static Dual
    sub(Dual a, Dual b)
     
    static double
    tan(double x)
    Returns the tangent of a double precision number.
    static Complex
    Compute the tangent of a complex number.
    static Dual
    tan(Dual a)
     
    static double
    tanh(double x)
    Returns the hyperbolic tangent of a double precision number.
    static Complex
    Compute the hyperbolic tangent of a complex number.
    static Dual
     
    static double
    toDegrees(double x)
    Converts the value to degrees from radians.
    static double
    toRadians(double x)
    Converts the value to radians from degrees.
    static double
    trigamma(double x)
    Compute the trigamma function of x.
    static Complex
    Compute the complex trigamma function.
    static Dual
     
    static double
    uiGamma(double a, double x)
    Compute the value of the upper incomplete gamma function.
    static Complex
    Compute the upper incomplete (non-regularised) gamma function of a complex number.
    static double
    ulp(double x)
    Returns the value of the unit in last place (ULP) of a double precision number.
    static double
    weberE(double v, double z)
     
    static Complex
     
    static double
    zeta(double x)
    Compute the value of the Riemann zeta function at x.
    static Complex
    Compute the value of the complex Riemann zeta function at z.

    Methods inherited from class java.lang.Object

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

  • Method Details

    • add

      public static double add(double x, double y)
      Adds two double precision numbers together.
      Parameters:
      x -
      y -
      Returns:
      x + y
    • add

      public static <T> T add(AdditiveGroupoid<T> groupoid, T x, T y)
      Adds two values through an additive groupoid.
    • sub

      public static double sub(double x, double y)
      Subtracts two double precision numbers.
      Parameters:
      x -
      y -
      Returns:
      x - y
    • add

      public static <T> T add(AdditiveGroup<T> group, T x, T y)
      Subtracts two values through an additive group.
    • mul

      public static double mul(double x, double y)
      Multiplies two double precision numbers.
      Parameters:
      x -
      y -
      Returns:
      x * y
    • mul

      public static <T> T mul(MultiplicativeGroupoid<T> groupoid, T x, T y)
      Multiplies two values through a multiplicative groupoid.
    • div

      public static double div(double x, double y)
      Divides two double precision numbers.
      Parameters:
      x -
      y -
      Returns:
      x / y
    • mul

      public static <T> T mul(MultiplicativeGroup<T> group, T x, T y)
      Divides two values through a multiplicative group.
    • mod

      public static double mod(double x, double y)
      Returns the modulus of two double precision numbers.
      Parameters:
      x -
      y -
      Returns:
      x mod y
    • mod

      public static long mod(long x, long y)
      Returns the modulus of two numbers.
      Parameters:
      x -
      y -
      Returns:
      x mod y
    • rem

      public static double rem(double x, double y)
      Returns the remainder that results from dividing two double precision numbers.
      Parameters:
      x -
      y -
      Returns:
      x % y
    • abs

      public static double abs(double x)
      Returns the absolute value of a double precision number.
      Parameters:
      x -
      Returns:
      |x|
      See Also:
    • abs

      public static long abs(long x)
      Returns the absolute value of a number.
      Parameters:
      x -
      Returns:
      |x|
    • acos

      public static double acos(double x)
      Returns the value of the inverse cosine of a double precision number.
      Parameters:
      x -
      Returns:
      cos^-1(x)
      See Also:
    • asin

      public static double asin(double x)
      Returns the value of the inverse sine of a double precision number.
      Parameters:
      x -
      Returns:
      sin^-1(x)
      See Also:
    • atan

      public static double atan(double x)
      Returns the value of the inverse tangent of a double precision number.
      Parameters:
      x -
      Returns:
      tan^-1(x)
      See Also:
    • atan2

      public static double atan2(double y, double x)
      Returns the value of the inverse tangent of two double precision numbers.
      Parameters:
      y -
      x -
      Returns:
      atan2(y, x)
      See Also:
    • cbrt

      public static double cbrt(double x)
      Returns the value of the cube root of a double precision number.
      Parameters:
      x -
      Returns:
      x^(1/3)
      See Also:
    • ceil

      public static double ceil(double x)
      Returns the value of the smallest integer greater than or equal to a double precision number.
      Parameters:
      x -
      Returns:
      ceil(x)
      See Also:
    • cos

      public static double cos(double x)
      Returns the value of the smallest integer greater than or equal to a double precision number.
      Parameters:
      x -
      Returns:
      ceil(x)
      See Also:
    • cosh

      public static double cosh(double x)
      Returns the hyperbolic cosine of a double precision number.
      Parameters:
      x -
      Returns:
      cosh(x)
      See Also:
    • exp

      public static double exp(double x)
      Returns the value of the exponential function of a double precision number.
      Parameters:
      x -
      Returns:
      e^x
      See Also:
    • expm1

      public static double expm1(double x)
      Returns the value of the exponential function of a double precision number minus one.
      Parameters:
      x -
      Returns:
      e^x - 1
      See Also:
    • floor

      public static double floor(double x)
      Returns the value of the largest integer less than or equal to a double precision number.
      Parameters:
      x -
      Returns:
      floor(x)
      See Also:
    • hypot

      public static double hypot(double x, double y)
      Returns the length of the hypotenuse of a right triangle with sides of length x and y.
      Parameters:
      x -
      y -
      Returns:
      sqrt(x ^ 2 + y ^ 2)
      See Also:
    • log

      public static double log(double x)
      Returns the value of the natural logarithm of a double precision number.
      Parameters:
      x -
      Returns:
      ln(x)
      See Also:
    • log10

      public static double log10(double x)
      Returns the value of the base 10 logarithm of a double precision number.
      Parameters:
      x -
      Returns:
      log10(x)
      See Also:
    • log1p

      public static double log1p(double x)
      Returns the value of the natural logarithm of a double precision number plus one.
      Parameters:
      x -
      Returns:
      ln(x + 1)
      See Also:
    • log2

      public static double log2(double x)
      Returns the value of the base 2 logarithm of a double precision number.
      Parameters:
      x -
      Returns:
      log2(x)
    • max

      public static double max(double x, double y)
      Returns the larger of two numbers (maximum).
      Parameters:
      x -
      y -
      Returns:
      max(x, y)
      See Also:
    • min

      public static double min(double x, double y)
      Returns the smaller of two numbers (minimum).
      Parameters:
      x -
      y -
      Returns:
      min(x, y)
      See Also:
    • pow

      public static double pow(double x, double y)
      Returns the value of the first argument raised to the power of the second argument.
      Parameters:
      x -
      y -
      Returns:
      x^y
      See Also:
    • signum

      public static double signum(double x)
      Returns the sign of a double precision number.
      Parameters:
      x -
      Returns:
      -1 if x < 0, 0 if x == 0, 1 if x > 0
      See Also:
    • signum

      public static long signum(long x)
      Returns the sign of a number.
      Parameters:
      x -
      Returns:
      -1 if x < 0, 1 if x > 0
    • signum

      public static Complex signum(Complex x)
      Returns the sign of a complex number.
      Parameters:
      x -
      Returns:
      A complex number where the real and imaginary parts correspond to the sign of the real and imaginary parts of x.
    • sin

      public static double sin(double x)
      Returns the value of the sine of a double precision number.
      Parameters:
      x -
      Returns:
      sin(x)
      See Also:
    • ceil

      public static Complex ceil(Complex x)
      Rounds both the real and imaginary parts of a complex number.
      Parameters:
      x -
      Returns:
      ceil(x)
    • floor

      public static Complex floor(Complex x)
      Rounds both the real and imaginary parts of a complex number.
      Parameters:
      x -
      Returns:
      floor(x)
    • round

      public static Complex round(Complex x)
      Rounds both the real and imaginary parts of a complex number.
      Parameters:
      x -
      Returns:
      round(x)
    • sinc

      public static double sinc(double x)
      Returns the sinc function of a double precision number, defined as sin(x) / x, except for x = 0, where sinc(x) = 1.
      Parameters:
      x -
      Returns:
      sinc(x)
    • sinc

      public static Complex sinc(Complex x)
      Returns the sinc function of a complex number, defined as sin(x) / x, except for x = 0, where sinc(x) = 1.
      Parameters:
      x -
      Returns:
      sinc(x)
    • sinh

      public static double sinh(double x)
      Returns the hyperbolic sine of a double precision number.
      Parameters:
      x -
      Returns:
      sinh(x)
      See Also:
    • sqrt

      public static double sqrt(double x)
      Returns the square root of a double precision number.
      Parameters:
      x -
      Returns:
      x^(1/2)
      See Also:
    • tan

      public static double tan(double x)
      Returns the tangent of a double precision number.
      Parameters:
      x -
      Returns:
      tan(x)
      See Also:
    • tanh

      public static double tanh(double x)
      Returns the hyperbolic tangent of a double precision number.
      Parameters:
      x -
      Returns:
      tanh(x)
      See Also:
    • toDegrees

      public static double toDegrees(double x)
      Converts the value to degrees from radians.
      Parameters:
      x -
      Returns:
      x * 180 / PI
      See Also:
    • toRadians

      public static double toRadians(double x)
      Converts the value to radians from degrees.
      Parameters:
      x -
      Returns:
      x * PI / 180
      See Also:
    • ulp

      public static double ulp(double x)
      Returns the value of the unit in last place (ULP) of a double precision number.
      Parameters:
      x -
      Returns:
      ULP(x)
      See Also:
    • fma

      public static double fma(double a, double b, double c)
      Returns the value of the fused multiply-add operation.
      Parameters:
      a -
      b -
      c -
      Returns:
      a * b + c
    • fma

      public static Complex fma(Complex x, Complex y, Complex z)
      Returns the value of the complex fused multiply-add operation.
      Parameters:
      x -
      y -
      z -
      Returns:
      x * y + z
    • nextAfter

      public static double nextAfter(double x, double y)
      Returns the value of the double precision number adjacent to the first argument in the direction of the second argument.
      Parameters:
      x -
      y -
      Returns:
      nextAfter(x, y)
      See Also:
    • nextUp

      public static double nextUp(double x)
      Returns the value of the double precision number adjacent to the first argument in the direction of positive infinity.
      Parameters:
      x -
      Returns:
      nextUp(x)
      See Also:
    • nextDown

      public static double nextDown(double x)
      Returns the value of the double precision number adjacent to the first argument in the direction of negative infinity.
      Parameters:
      x -
      Returns:
      nextDown(x)
      See Also:
    • scalb

      public static double scalb(double x, int n)
      Returns the correctly rounded value of x*2^n.
      Parameters:
      x -
      n -
      Returns:
      scalb(x, n)
      See Also:
    • copySign

      public static double copySign(double x, double y)
      Copy the sign of the second argument to the first argument.
      Parameters:
      x -
      y -
      Returns:
      copySign(x, y)
      See Also:
    • copySign

      public static long copySign(long x, long y)
      Copy the sign of the second argument to the first argument.
      Parameters:
      x -
      y -
      Returns:
      copySign(x, y)
    • copySign

      public static Complex copySign(Complex x, Complex y)
      Copy the sign of the second argument to the first argument.
      Parameters:
      x -
      y -
      Returns:
      copySign(x, y)
    • absparts

      public static Complex absparts(Complex x)
      Compute the absolute values of parts of a complex number.
      Parameters:
      x -
      Returns:
      |re(x)| + i|im(x)|
    • getExponent

      public static int getExponent(double x)
      Returns the exponent of a double precision number.
      Parameters:
      x -
      Returns:
      exponent(x)
      See Also:
    • round

      public static long round(double x)
      Rounds a double precision number to the nearest integer.
      Parameters:
      x -
      Returns:
      round(x)
      See Also:
    • random

      public static double random()
      Returns a random double precision number in range [0, 1).
      Returns:
      random()
    • random

      public static double random(double min, double max)
      Returns a random double precision number in range [min, max).
      Parameters:
      min -
      max -
      Returns:
      random() * (max - min) + min
    • random

      public static long random(long min, long max)
      Returns a random long integer in range [min, max).
      Parameters:
      min -
      max -
      Returns:
      random() * (max - min) + min
    • random

      public static double random(double max)
      Returns a random double precision number in range [0, max).
      Parameters:
      max -
      Returns:
      random() * max
    • random

      public static long random(long max)
      Returns a random long integer in range [0, max).
      Parameters:
      max -
      Returns:
      random() * max
    • lt

      public static boolean lt(double x, double y)
      Return true if x < y.
      Parameters:
      x -
      y -
      Returns:
      x < y
    • le

      public static boolean le(double x, double y)
      Return true if x <= y.
      Parameters:
      x -
      y -
      Returns:
      x <= y
    • gt

      public static boolean gt(double x, double y)
      Return true if x > y.
      Parameters:
      x -
      y -
      Returns:
      x > y
    • ge

      public static boolean ge(double x, double y)
      Return true if x >= y.
      Parameters:
      x -
      y -
      Returns:
      x >= y
    • eq

      public static boolean eq(double x, double y)
      Return true if x == y.
      Parameters:
      x -
      y -
      Returns:
      x == y
    • ne

      public static boolean ne(double x, double y)
      Return true if x != y.
      Parameters:
      x -
      y -
      Returns:
      x != y
    • compare

      public static int compare(double x, double y)
      Compare two double precision numbers.
      Parameters:
      x -
      y -
      Returns:
      1 if x > y, 0 if x == y, -1 if x < y
    • compare

      public static int compare(long x, long y)
      Compare two integers.
      Parameters:
      x -
      y -
      Returns:
      1 if x > y, 0 if x == y, -1 if x < y
    • eq

      public static boolean eq(double x, double y, double tol)
      Return true if x is approximately equal to y.
      Parameters:
      x -
      y -
      tol -
      Returns:
      abs(x - y) <= tol
    • isPerfectSquare

      public static boolean isPerfectSquare(long x)
      Determine whether a number is a perfect square.
      Parameters:
      x -
      Returns:
      true if x is a perfect square, false otherwise
    • linearMap

      public static double linearMap(double inRangeStart, double inRangeEnd, double outRangeStart, double outRangeEnd, double value)
      Linearly map a value from one range to another. Input range must not be empty.
      Parameters:
      inRangeStart - Input range start
      inRangeEnd - Input range end
      outRangeStart - Output range start
      outRangeEnd - Output range end
      value - Value to map
      Returns:
      Mapped value. Values outside the input range are not clamped to output range
    • linearNorm

      public static double linearNorm(double rangeStart, double rangeEnd, double value)
      Linearly normalise value from a range. Range must not be empty.
      Parameters:
      rangeStart - Range start normalized to 0
      rangeEnd - Range end normalized to 1
      value - Value to normalize
      Returns:
      Normalized value. Values outside the range are not clamped to 0 and 1
    • linearInterpolate

      public static double linearInterpolate(double fromValue, double toValue, double progress)
      Linearly interpolate between two values.
      Parameters:
      fromValue -
      toValue -
      progress -
      Returns:
      fromValue + (toValue - fromValue) * progress
    • clamp

      public static double clamp(double value, double min, double max)
      Clamp a value in the range [min, max].
      Parameters:
      value -
      min -
      max -
      Returns:
      min if value < min, max if value > max, value otherwise
    • clamp

      public static long clamp(long value, long min, long max)
      Clamp a value in the range [min, max].
      Parameters:
      value -
      min -
      max -
      Returns:
      min if value < min, max if value > max, value otherwise
    • isPowerOfTwo

      public static boolean isPowerOfTwo(long value)
      Determine if a value is a power of two.
      Parameters:
      value -
      Returns:
      true if value is a power of two, false otherwise
    • nextPowerOfTwo

      public static long nextPowerOfTwo(long value)
      Returns the next power of two. If the number is already a power of two, this function acts as an identity function.
      Parameters:
      value -
      Returns:
      the next power of two
    • randomSign

      public static long randomSign()
      Return a random sign (-1 or 1).
      Returns:
      -1 or 1
    • fastSin

      public static float fastSin(float x)
      Return a cached value of sin(x) using Raven's method. The cache is 65KB large.
      Parameters:
      x - angle in radians, between -2*pi and 2*pi inclusive.
      Returns:
      sin(x)
    • fastCos

      public static float fastCos(float x)
      Return a cached value of cos(x) using Raven's method. The cache is 65KB large.
      Parameters:
      x - angle in radians, between -2*pi and 2*pi inclusive.
      Returns:
      cos(x)
    • icbrt

      public static int icbrt(int x)
      Return the integer cube root of a number. If x < 0, -cbrt(-x) is returned.
      Parameters:
      x -
      Returns:
      floor(cbrt ( x))
    • icbrt

      public static long icbrt(long x)
      Return the long integer cube root of a number. If x < 0, -cbrt(-x) is returned.
      Parameters:
      x -
      Returns:
      floor(cbrt ( x))
    • icbrt

      public static short icbrt(short a)
      Return the short integer cube root of a number. If a < 0, -cbrt(-a) is returned.
      Parameters:
      a -
      Returns:
      floor(cbrt ( a))
    • isqrt

      public static int isqrt(int x)
      Compute the integer square root of a number. If x < 0, -isqrt(-x) is returned.
      Parameters:
      x -
      Returns:
      floor(sqrt ( x))
    • isqrt

      public static int isqrt(long x)
      Compute the integer square root of a number. If x < 0, -isqrt(-x) is returned.
      Parameters:
      x -
      Returns:
      floor(sqrt ( x))
    • isqrt

      public static int isqrt(short x)
      Compute the integer square root of a number. If x < 0, -isqrt(-x) is returned.
      Parameters:
      x -
      Returns:
      floor(sqrt ( x))
    • ilog10

      public static int ilog10(int x)
      Compute the value of the integer logarithm in base 10 of a number
      Parameters:
      x -
      Returns:
      floor(log10 ( x))
    • ipow

      public static int ipow(int x, int n)
      Compute the value of integer x^n.
      Parameters:
      x -
      n -
      Returns:
      x^n.
    • ipow

      public static long ipow(long x, long n)
      Compute the value of integer x^n.
      Parameters:
      x -
      n -
      Returns:
      x^n.
    • ipow

      public static short ipow(short x, short n)
      Compute the value of integer x^n.
      Parameters:
      x -
      n -
      Returns:
      x^n.
    • frexp

      public static Pair<Integer,Double> frexp(double value)
      Break floating-point number down into exponent and mantissa
      Parameters:
      value -
      Returns:
      A pair of the exponent and the mantissa.
    • pow

      public static double pow(double x, int z)
      Compute the value of x^z where x is a double precision floating point number and z is an integer.
      Parameters:
      x -
      z -
      Returns:
      x^z.
      Throws:
      ArithmeticException - in case of overflow.
    • airyAi

      public static double airyAi(double x)
      Compute the value of the Airy Ai function at the specified point.
      Parameters:
      x -
      Returns:
      Ai(x)
    • airyAip

      public static double airyAip(double x)
      Compute the value of the Airy Ai function's first derivative at the specified point.
      Parameters:
      x -
      Returns:
      Ai'(x)
    • airyBi

      public static double airyBi(double x)
      Compute the value of the Airy Bi function at the specified point.
      Parameters:
      x -
      Returns:
      Bi(x)
    • airyBip

      public static double airyBip(double x)
      Compute the value of the Airy Bi function's first derivative at the specified point.
      Parameters:
      x -
      Returns:
      Bi'(x)
    • airy

      public static double[] airy(double x)
      Compute the value of the Airy Ai, Ai', Bi and Bi' functions at the specified point.
      Parameters:
      x -
      Returns:
      a double array of length 4 containing Ai, Ai', Bi and Bi' in that order.
    • gamma

      public static double gamma(double x)
      Compute the gamma function of x.
      Parameters:
      x -
      Returns:
      gamma(x)
    • loggamma

      public static double loggamma(double x)
      Compute the logarithm of the gamma function of x.
      Parameters:
      x -
      Returns:
      log(gamma ( x))
    • digamma

      public static double digamma(double x)
      Compute the digamma function of x.
      Parameters:
      x -
      Returns:
      digamma(x)
    • trigamma

      public static double trigamma(double x)
      Compute the trigamma function of x.
      Parameters:
      x -
      Returns:
      trigamma(x)
    • uiGamma

      public static double uiGamma(double a, double x)
      Compute the value of the upper incomplete gamma function.
      Parameters:
      a -
      x -
      Returns:
      gamma_u(a, x)
    • liGamma

      public static double liGamma(double a, double x)
      Compute the value of the lower incomplete gamma function.
      Parameters:
      a -
      x -
      Returns:
      gamma_l(a, x)
    • pochhammer

      public static double pochhammer(double x, double n)
      Compute the Pochhammer symbol (x)_n.
      Parameters:
      x -
      n -
      Returns:
      (x)_n
    • pochhammer

      public static double pochhammer(double x, int n)
      Compute the Pochhammer symbol (x)_n.
      Parameters:
      x -
      n -
      Returns:
      (x)_n
    • pochhammer

      public static Complex pochhammer(Complex x, int n)
      Compute the Pochhammer symbol (x)_n.
      Parameters:
      x -
      n -
      Returns:
      (x)_n
    • pochhammer

      public static Complex pochhammer(Complex x, double n)
      Compute the Pochhammer symbol (x)_n.
      Parameters:
      x -
      n -
      Returns:
      (x)_n
    • pochhammer

      public static Complex pochhammer(Complex x, Complex n)
      Compute the Pochhammer symbol (x)_n.
      Parameters:
      x -
      n -
      Returns:
      (x)_n
    • Ei

      public static double Ei(double x)
      Compute the value of the exponential integral at x.
      Parameters:
      x -
      Returns:
      Ei(x)
    • zeta

      public static double zeta(double x)
      Compute the value of the Riemann zeta function at x.
      Parameters:
      x -
      Returns:
      zeta(x)
    • zeta

      public static Complex zeta(Complex z)
      Compute the value of the complex Riemann zeta function at z.
      Parameters:
      z -
      Returns:
      zeta(z)
    • hurwitzZeta

      public static double hurwitzZeta(double x, double a)
      Compute the value of the Hurwitz zeta function at x.
      Parameters:
      x -
      a -
      Returns:
      zeta(x, a)
    • polygamma

      public static double polygamma(double n, double x)
      Compute the value of the n-th polygamma function at x.
      Parameters:
      n -
      x -
      Returns:
      polygamma(n, x)
    • polygamma

      public static Complex polygamma(Complex n, Complex z)
      Compute the value of the order-N polygamma function at complex z.
      Parameters:
      n -
      z -
      Returns:
      polygamma(n, z)
    • beta

      public static double beta(double x, double y)
      Compute the beta function of two values.
      Parameters:
      x -
      y -
      Returns:
      beta(x, y)
    • logbeta

      public static double logbeta(double x, double y)
      Compute the logarihtm of the beta function of two values. Uses the identity that log(beta(x, y)) = log(gamma(x)) + log(gamma(y)) - log(gamma(x + y)).
      Parameters:
      x -
      y -
      Returns:
      log(beta ( x, y))
    • factorial

      public static double factorial(long n)
      Return the factorial of n as a double-precision. n must be positive. Faster than using the gamma function.
      Parameters:
      n -
      Returns:
      n!
      Throws:
      ArithmeticException - if n is negative
    • dilog

      public static double dilog(double n)
      Compute the dilogarithm (the value of the Spence function at 1-x) of x.
      Parameters:
      n -
      Returns:
      dilog(x)
    • spence

      public static double spence(double n)
      Compute the Spence function of x.
      Parameters:
      n -
      Returns:
      Spence(x)
    • polylog

      public static double polylog(int n, double x)
      Compute the polylogarithm of x.
      Parameters:
      n -
      x -
      Returns:
      Li_n(x)
    • sec

      public static double sec(double x)
      Compute the value of the secant (1 / cos(x)) function at x.
      Parameters:
      x -
      Returns:
      sec(x)
    • csc

      public static double csc(double x)
      Compute the value of the cosecant (1 / sin(x)) function at x.
      Parameters:
      x -
      Returns:
      csc(x)
    • cot

      public static double cot(double x)
      Compute the value of the cotangent (1 / tan(x)) function at x.
      Parameters:
      x -
      Returns:
      cot(x)
    • sech

      public static double sech(double x)
      Compute the value of the hyperbolic secant (1 / cosh(x)) function at x.
      Parameters:
      x -
      Returns:
      sech(x)
    • csch

      public static double csch(double x)
      Compute the value of the hyperbolic cosecant (1 / sinh(x)) function at x.
      Parameters:
      x -
      Returns:
      csch(x)
    • coth

      public static double coth(double x)
      Compute the value of the hyperbolic cotangent (1 / tanh(x)) function at x.
      Parameters:
      x -
      Returns:
      coth(x)
    • asec

      public static double asec(double x)
      Compute the value of the inverse secant (1 / acos(x)) function at x.
      Parameters:
      x -
      Returns:
      asec(x)
    • acsc

      public static double acsc(double x)
      Compute the value of the inverse cosecant (1 / asin(x)) function at x.
      Parameters:
      x -
      Returns:
      acsc(x)
    • acot

      public static double acot(double x)
      Compute the value of the inverse cotangent (1 / atan(x)) function at x.
      Parameters:
      x -
      Returns:
      acot(x)
    • asinh

      public static double asinh(double a)
      Compute the value of the inverse hyperbolic sine function at x.
      Parameters:
      a -
      Returns:
      asinh(a)
    • acosh

      public static double acosh(double x)
      Compute the value of the inverse hyperbolic cosine function at x.
      Parameters:
      x -
      Returns:
      acosh(x)
    • atanh

      public static double atanh(double a)
      Compute the value of the inverse hyperbolic tangent function at x.
      Parameters:
      a -
      Returns:
      atanh(a)
    • asech

      public static double asech(double x)
      Compute the value of the inverse hyperbolic secant (1 / acosh(x)) function at x.
      Parameters:
      x -
      Returns:
      asech(x)
    • acsch

      public static double acsch(double x)
      Compute the value of the inverse hyperbolic cosecant (1 / asinh(x)) function at x.
      Parameters:
      x -
      Returns:
      acsch(x)
    • acoth

      public static double acoth(double x)
      Compute the value of the inverse hyperbolic cotangent (1 / atanh(x)) function at x.
      Parameters:
      x -
      Returns:
      acoth(x)
    • lambertW0

      public static double lambertW0(double x)
      Compute Lambert W_0 (x).
      Parameters:
      x -
      Returns:
      W_0(x)
    • lambertWm1

      public static double lambertWm1(double x)
      Compute Lambert W_(-1) (x).
      Parameters:
      x -
      Returns:
      W_(- 1) (x)
    • lerchPhi

      public static double lerchPhi(double z, double s, double a)
      Compute the value of the Lerch transcendent function at z, s, a.
      Parameters:
      z -
      s -
      a -
      Returns:
      Lerch(z, s, a)
      Throws:
      ArithmeticException - if the computation fails unexpectedly due to exceeding the amount of allowed iterations.
    • dawsonPlus

      public static double dawsonPlus(double x)
      Compute the value of the Dawson function (D+) at x.
      Parameters:
      x -
      Returns:
      D+(x)
    • dawsonMinus

      public static double dawsonMinus(double x)
      Compute the value of the Dawson function (D-) at x.
      Parameters:
      x -
      Returns:
      D-(x)
    • erf

      public static double erf(double x)
      Compute the value of the error function at x.
      Parameters:
      x -
      Returns:
      erf(x)
    • erfc

      public static double erfc(double x)
      Compute the value of the complementary error function at x.
      Parameters:
      x -
      Returns:
      erfc(x)
    • erfi

      public static double erfi(double x)
      Compute the value of the imaginary error function at x.
      Parameters:
      x -
      Returns:
      erfi(x)
    • stretch

      public static double stretch(double x)
      Compute the value of the inverse of the logistic sigmoid "squash" function at x.
      Parameters:
      x -
      Returns:
      stretch(x)
    • squash

      public static double squash(double x)
      Compute the value of the logistic sigmoid "squash" function at x.
      Parameters:
      x -
      Returns:
      squash(x)
    • Si

      public static double Si(double x)
      Compute the value of the sine integral function at x.
      Parameters:
      x -
      Returns:
      Si(x)
    • Ci

      public static double Ci(double x)
      Compute the value of the cosine integral function at x.
      Parameters:
      x -
      Returns:
      Ci(x)
    • Shi

      public static double Shi(double x)
      Compute the value of the hyperbolic sine integral function at x.
      Parameters:
      x -
      Returns:
    • Chi

      public static double Chi(double x)
      Compute the value of the hyperbolic cosine integral function at x.
      Parameters:
      x -
      Returns:
      Chi(x)
    • si

      public static double si(double x)
      Compute the value of the sine integral function at x.
      Parameters:
      x -
      Returns:
      si(x)
    • Cin

      public static double Cin(double x)
      Compute the value of the cosine integral function at x.
      Parameters:
      x -
      Returns:
      Cin(x)
    • ShiChi

      public static double[] ShiChi(double x)
      Compute both the hyperbolic sine and cosine integral at x. Return the results in a two-element double precision array.
      Parameters:
      x -
      Returns:
      {Shi(x), Chi(x)}
    • fresnelC

      public static double fresnelC(double x)
      Compute the Fresnel integral C(x).
      Parameters:
      x -
      Returns:
      C(x)
    • fresnelS

      public static double fresnelS(double x)
      Compute the Fresnel integral S(x).
      Parameters:
      x -
      Returns:
      S(x)
    • besselY0

      public static double besselY0(double x)
      Compute the bessel Y0 function at x.
      Parameters:
      x -
      Returns:
      Y0(x)
    • besselY1

      public static double besselY1(double x)
      Compute the bessel Y1 function at x.
      Parameters:
      x -
      Returns:
      Y1(x)
    • besselYn

      public static double besselYn(int n, double x)
      Compute the bessel Yn function at x.
      Parameters:
      n -
      x -
      Returns:
      Yn(x)
    • besselJ0

      public static double besselJ0(double x)
      Compute the bessel J0 function at x.
      Parameters:
      x -
      Returns:
      J0(x)
    • besselJ1

      public static double besselJ1(double x)
      Compute the bessel J1 function at x.
      Parameters:
      x -
      Returns:
      J1(x)
    • besselJn

      public static double besselJn(int n, double x)
      Compute the bessel Jn function at x.
      Parameters:
      n -
      x -
      Returns:
      Jn(x)
    • besselI0

      public static double besselI0(double x)
      Compute the bessel I0 function at x.
      Parameters:
      x -
      Returns:
      I0(x)
    • besselI1

      public static double besselI1(double x)
      Compute the bessel I1 function at x.
      Parameters:
      x -
      Returns:
      I1(x)
    • besselK0

      public static double besselK0(double x)
      Compute the bessel K0 function at x.
      Parameters:
      x -
      Returns:
      K0(x)
    • besselK1

      public static double besselK1(double x)
      Compute the bessel K1 function at x.
      Parameters:
      x -
      Returns:
      K1(x)
    • besselKn

      public static double besselKn(int n, double x)
      Compute the bessel Kn function at x.
      Parameters:
      n -
      x -
      Returns:
      Kn(x)
    • gcd

      public static long gcd(long a, long b)
      Compute the greatest common divisor of two integers.
      Parameters:
      a -
      b -
      Returns:
      gcd(a, b)
    • gcd

      public static double gcd(double a, double b)
      Domain extension of the greatest common division function onto the real line.
      Parameters:
      a -
      b -
      Returns:
      gcd(a, b)
    • gcd

      public static Complex gcd(Complex a, Complex b)
      Domain extension of the greatest common division function onto the complex plane.
      Parameters:
      a -
      b -
      Returns:
      gcd(a, b)
    • rem

      public static Complex rem(Complex a, Complex b)
      Domain extension of the remainder function onto the complex plane.
      Parameters:
      a -
      b -
      Returns:
      a rem b
    • lcm

      public static long lcm(long a, long b)
      Compute the least common multiple of two integers.
      Parameters:
      a -
      b -
      Returns:
      lcm(a, b)
    • lcm

      public static double lcm(double a, double b)
      Domain extension of the least common multiple function onto the real line.
      Parameters:
      a -
      b -
      Returns:
      lcm(a, b)
    • lcm

      public static Complex lcm(Complex a, Complex b)
      Domain extension of the least common multiple function onto the complex plane.
      Parameters:
      a -
      b -
      Returns:
      lcm(a, b)
    • fib

      public static long fib(int a)
      Compute the n-th Fibonacci number using Binet's formula. Due to floating point precision issues, this method is only accurate for n ≤= 75.
      Parameters:
      a -
      Returns:
      fib(a)
    • hypergeo2F1

      public static double hypergeo2F1(double a, double b, double c, double x)
      Computes the Gaussian hypergeometric function (2F1) of four arguments.
      Parameters:
      a -
      b -
      c -
      x -
      Returns:
      (2F1)(a, b, c, x)
    • hypergeo1F1

      public static double hypergeo1F1(double a, double b, double x)
      Computes the Confluent hypergeometric function (1F1) of three arguments.
      Parameters:
      a -
      b -
      x -
      Returns:
      (1F1)(a, b, x)
    • hypergeo1F2

      public static double hypergeo1F2(double a, double b, double c, double x)
      Computes the 1F2 case of the generalised hypergeometric function.
      Parameters:
      a -
      b -
      c -
      x -
      Returns:
      a double array the approximation and the estimated error of (1F2)(a, b, c x)
    • hypergeo3F0

      public static double hypergeo3F0(double a, double b, double c, double x)
      Computes the 3F0 case of the generalised hypergeometric function.
      Parameters:
      a -
      b -
      c -
      x -
      Returns:
      a double array the approximation and the estimated error of (1F2)(a, b, c x)
    • struve

      public static double struve(double v, double x)
      Computes the value of the Struve function of order v at x.
      Parameters:
      v - order of the Struve function
      x - argument of the Struve function
      Returns:
      Struve(v, x)
    • struveL0

      public static double struveL0(double x)
      Computes the value of the modified Struve function of 0th order.
      Parameters:
      x - argument of the Struve function
      Returns:
      StruveL0(x)
    • struveL1

      public static double struveL1(double x)
      Computes the value of the modified Struve function of 1st order.
      Parameters:
      x - argument of the Struve function
      Returns:
      StruveL1(x)
    • logabsgamma

      public static double[] logabsgamma(double x)
      Computes the logarithm of the absolute value of the gamma function of x.
      Parameters:
      x -
      Returns:
      { log(|Gamma(x)|), sign(Gamma(x)) }
      See Also:
    • besselJv

      public static double besselJv(double n, double x)
      Compute fractional order bessel function of n and x.
      Parameters:
      n -
      x -
      Returns:
      J_n(x)
    • besselYv

      public static double besselYv(double v, double x)
      Compute the fractional order bessel Y function of v and x.
      Parameters:
      v -
      x -
      Returns:
      Y_n(x)
    • integrateSimpsonReal

      public static double integrateSimpsonReal(Function<Double,Double> f, double a, double b, int N)
      Integrate a monadic function over a finite interval [a,b] using the Simpson rule. The number of intervals is given by N and the precision of the final result greatly depends on this parameter.
      Parameters:
      f - function to integrate
      a - lower bound
      b - upper bound
      N - number of intervals, N=10000 tends to give a good approximation in most scenarios.
      Returns:
      integral of f over [a,b]
      Throws:
      IllegalArgumentException - if N is not a positive integer
    • integrateGaussLegendreReal

      public static double integrateGaussLegendreReal(Function<Double,Double> f, double a, double b, int N)
      Integrate a monadic function over a finite interval [a,b] using the Gauss-Legendre quadrature. The number of intervals is given by N and the precision of the final result greatly depends on this parameter. The computation of an integral using the Gauss-Legendre quadrature involves caching the coefficients required to perform the integration depending on the value of the N parameter. This means that the first call to this method will be slower than subsequent calls with the same value of N. The coefficients are internally cached inside a ConcurrentHashMap.
      Parameters:
      f - function to integrate
      a - lower bound
      b - upper bound
      N - number of intervals, N=6 tends to give a good approximation in most scenarios. N must be between 1 and 30.
      Returns:
      integral of f over [a,b]
      Throws:
      IllegalArgumentException - if N is not a positive integer
    • integrateTanhSinhReal

      public static double[] integrateTanhSinhReal(Function<Double,Double> f, double a, double b, int N, double eps)
      Integrate a monadic function over a finite interval [a,b] using the Tanh-Sinh quadrature, especially useful when singularities or infinite derivatives exist at one or both endpoints. The Tanh-Sinh quadrature is not as efficient as Gaussian quadrature for smooth integrands.
      Parameters:
      f - function to integrate
      a - lower bound
      b - upper bound
      N - the degree of the quadrature, usually N=6 is sufficient
      eps - desired precision of the result (usually 1.0e-9 is sufficient)
      Returns:
      an array of double values, first of which is the integral of f over [a,b], while the second is the estimated error.
      Throws:
      IllegalArgumentException - if N is not a positive integer
    • integrateSimpsonRC

      public static Complex integrateSimpsonRC(Function<Double,Complex> f, double a, double b, int N)
      Integrate a monadic function over a finite interval [a,b] using the Simpson rule. The number of intervals is given by N and the precision of the final result greatly depends on this parameter.
      Parameters:
      f - function to integrate
      a - lower bound
      b - upper bound
      N - number of intervals, N=10000 tends to give a good approximation in most scenarios.
      Returns:
      integral of f over [a,b]
      Throws:
      IllegalArgumentException - if N is not a positive integer
    • integrateGaussLegendreRC

      public static Complex integrateGaussLegendreRC(Function<Double,Complex> f, double a, double b, int N)
      Integrate a monadic function over a finite interval [a,b] using the Gauss-Legendre quadrature. The number of intervals is given by N and the precision of the final result greatly depends on this parameter. The computation of an integral using the Gauss-Legendre quadrature involves caching the coefficients required to perform the integration depending on the value of the N parameter. This means that the first call to this method will be slower than subsequent calls with the same value of N. The coefficients are internally cached inside a ConcurrentHashMap.
      Parameters:
      f - function to integrate
      a - lower bound
      b - upper bound
      N - number of intervals, N=6 tends to give a good approximation in most scenarios. N must be between 1 and 30.
      Returns:
      integral of f over [a,b]
      Throws:
      IllegalArgumentException - if N is not a positive integer
    • integrateTanhSinhRC

      public static Complex[] integrateTanhSinhRC(Function<Double,Complex> f, double a, double b, int N, double eps)
      Integrate a monadic function over a finite interval [a,b] using the Tanh-Sinh quadrature, especially useful when singularities or infinite derivatives exist at one or both endpoints. The Tanh-Sinh quadrature is not as efficient as Gaussian quadrature for smooth integrands.
      Parameters:
      f - function to integrate
      a - lower bound
      b - upper bound
      N - the degree of the quadrature, usually N=6 is sufficient
      eps - desired precision of the result (usually 1.0e-9 is sufficient)
      Returns:
      an array of double values, first of which is the integral of f over [a,b], while the second is the estimated error.
      Throws:
      IllegalArgumentException - if N is not a positive integer
    • binomial

      public static long binomial(int n, int k)
      Compute the binomial coefficient "n choose k".
      Parameters:
      n - the number of elements, n > 0.
      k - the number of elements to choose, 0 < k <= n.
      Returns:
      n! / (k! * (n-k)!)
      Throws:
      IllegalArgumentException - if n <= 0 or k < 0 or k > n.
    • newtonRaphson

      public static double newtonRaphson(Function<Double,Double> f, Function<Double,Double> df, double x0, double eps)
      Find a root of a monadic function using the Newton-Raphson method.
      Parameters:
      f - the function to find a root for
      df - the derivative of the function
      x0 - the initial guess
      eps - the desired precision of the result
      Returns:
      a root of the function f within the desired precision unless the iteration limit is exceeded.
    • aberth

      public static boolean[] aberth(Complex[] coefficients)
      Numerically finds all roots of a polynomial equation P(z) = 0. There are (n+1) coefficients and n roots. The leading coefficient must not be zero. Errors are returned in a boolean array for each root. Success is indicated by false, i.e. no error. On return each root should be checked against its flag.
      Parameters:
      coefficients -
      Returns:
    • bernoulliBound

      public static int bernoulliBound(int n)
      Returns an integer b such that |B_n| ≤ 2^b for all Bernoulli numbers B_n.
      Parameters:
      n -
      Returns:
    • agm

      public static double agm(double a, double g)
      Computes the Arithmetic-Geometric mean.
      Parameters:
      a -
      g -
      Returns:
      the Arithmetic-Geometric mean of a and g
    • fac2

      public static double fac2(double a)
    • angerJ

      public static double angerJ(double v, double z)
    • weberE

      public static double weberE(double v, double z)
    • angerJ

      public static Complex angerJ(Complex v, Complex z)
    • weberE

      public static Complex weberE(Complex v, Complex z)
    • lommels1

      public static double lommels1(double u, double v, double z)
    • legendre

      public static double legendre(double n, double z)
    • add

      public static Complex add(Complex a, Complex b)
      Add two complex numbers together.
      Parameters:
      a -
      b -
      Returns:
      a + b
    • add

      public static Dual add(Dual a, Dual b)
      Perform dual addition.
      Parameters:
      a -
      b -
      Returns:
      a + b
    • add

      public static Dual add(Dual a, double b)
      Perform real-dual addition.
      Parameters:
      a -
      b -
      Returns:
      a + b
    • add

      public static Dual add(double a, Dual b)
      Perform real-dual addition.
      Parameters:
      a -
      b -
      Returns:
      a + b
    • sub

      public static Dual sub(Dual a, Dual b)
    • sub

      public static Dual sub(Dual a, double b)
    • sub

      public static Dual sub(double a, Dual b)
    • mul

      public static Dual mul(Dual a, Dual b)
    • div

      public static Dual div(Dual a, Dual b)
    • sin

      public static Dual sin(Dual a)
    • sec

      public static Dual sec(Dual a)
    • cos

      public static Dual cos(Dual a)
    • csc

      public static Dual csc(Dual a)
    • tan

      public static Dual tan(Dual a)
    • cot

      public static Dual cot(Dual a)
    • exp

      public static Dual exp(Dual a)
    • log

      public static Dual log(Dual a)
    • pow

      public static Dual pow(Dual a, int b)
    • abs

      public static Dual abs(Dual a)
    • asin

      public static Dual asin(Dual a)
    • acos

      public static Dual acos(Dual a)
    • atan

      public static Dual atan(Dual a)
    • sqrt

      public static Dual sqrt(Dual a)
    • sinh

      public static Dual sinh(Dual a)
    • cosh

      public static Dual cosh(Dual a)
    • tanh

      public static Dual tanh(Dual a)
    • gamma

      public static Dual gamma(Dual a)
    • digamma

      public static Dual digamma(Dual a)
    • besselI0

      public static Dual besselI0(Dual a)
    • besselJ0

      public static Dual besselJ0(Dual a)
    • besselK0

      public static Dual besselK0(Dual a)
    • besselJ1

      public static Dual besselJ1(Dual a)
    • besselY0

      public static Dual besselY0(Dual a)
    • besselK1

      public static Dual besselK1(Dual a)
    • besselJn

      public static Dual besselJn(int n, Dual a)
    • besselYn

      public static Dual besselYn(int n, Dual a)
    • besselYv

      public static Dual besselYv(double n, Dual a)
    • besselKn

      public static Dual besselKn(int n, Dual a)
    • besselJv

      public static Dual besselJv(double n, Dual a)
    • airyAi

      public static Dual airyAi(Dual a)
    • airyBi

      public static Dual airyBi(Dual a)
    • Chi

      public static Dual Chi(Dual a)
    • Shi

      public static Dual Shi(Dual a)
    • Ci

      public static Dual Ci(Dual a)
    • Si

      public static Dual Si(Dual a)
    • Ei

      public static Dual Ei(Dual a)
    • erf

      public static Dual erf(Dual a)
    • dilog

      public static Dual dilog(Dual a)
    • acot

      public static Dual acot(Dual a)
    • acoth

      public static Dual acoth(Dual a)
    • asec

      public static Dual asec(Dual a)
    • acsc

      public static Dual acsc(Dual a)
    • coth

      public static Dual coth(Dual a)
    • sech

      public static Dual sech(Dual a)
    • csch

      public static Dual csch(Dual a)
    • asinh

      public static Dual asinh(Dual a)
    • acosh

      public static Dual acosh(Dual a)
    • atanh

      public static Dual atanh(Dual a)
    • asech

      public static Dual asech(Dual a)
    • acsch

      public static Dual acsch(Dual a)
    • cbrt

      public static Dual cbrt(Dual a)
    • beta

      public static Dual beta(Dual a, double c)
      Compute the beta function of a dual and real number. The derivative is taken as d/da beta(a,c).
      Parameters:
      a -
      c -
      Returns:
    • beta

      public static Dual beta(double a, Dual c)
      Compute the beta function of a real and dual number. The derivative is taken as d/dc beta(a,c).
      Parameters:
      a -
      c -
      Returns:
    • erfc

      public static Dual erfc(Dual a)
    • erfi

      public static Dual erfi(Dual a)
    • fresnelC

      public static Dual fresnelC(Dual a)
    • fresnelS

      public static Dual fresnelS(Dual a)
    • li

      public static Dual li(Dual a)
    • sinc

      public static Dual sinc(Dual a)
    • spence

      public static Dual spence(Dual a)
    • trigamma

      public static Dual trigamma(Dual a)
    • polygamma

      public static Dual polygamma(double n, Dual a)
    • polylog

      public static Dual polylog(int n, Dual a)
    • lambertW0

      public static Dual lambertW0(Dual a)
    • lambertWm1

      public static Dual lambertWm1(Dual a)
    • hurwitzZeta

      public static Dual hurwitzZeta(double s, Dual a)
    • add

      public static Complex add(Complex a, double b)
      Add a complex number and a real number.
      Parameters:
      a -
      b -
      Returns:
      a + b
    • add

      public static Complex add(double a, Complex b)
      Add a complex number and a real number.
      Parameters:
      a -
      b -
      Returns:
      a + b
    • sub

      public static Complex sub(Complex a, Complex b)
      Subtract two complex numbers from each other.
      Parameters:
      a -
      b -
      Returns:
      a - b
    • sub

      public static Complex sub(Complex a, double b)
      Subtract a complex number and a real number.
      Parameters:
      a -
      b -
      Returns:
      a - b
    • sub

      public static Complex sub(double a, Complex b)
      Subtract a complex number and a real number.
      Parameters:
      a -
      b -
      Returns:
      a - b
    • mul

      public static Complex mul(Complex a, Complex b)
      Multiply two complex numbers.
      Parameters:
      a -
      b -
      Returns:
      a * b
    • mul

      public static Complex mul(Complex a, double b)
      Multiply a complex number and a real number.
      Parameters:
      a -
      b -
      Returns:
      a * b
    • mul

      public static Complex mul(double a, Complex b)
      Multiply a complex number and a real number.
      Parameters:
      a -
      b -
      Returns:
      a * b
    • div

      public static Complex div(Complex a, Complex b)
      Divide two complex numbers.
      Parameters:
      a -
      b -
      Returns:
      a / b
    • div

      public static Complex div(Complex a, double b)
      Divide a complex number and a real number.
      Parameters:
      a -
      b -
      Returns:
      a / b
    • div

      public static Complex div(double a, Complex b)
      Divide a complex number and a real number.
      Parameters:
      a -
      b -
      Returns:
      a / b
    • conj

      public static Complex conj(Complex a)
      Compute the complex conjugate of a complex number.
      Parameters:
      a -
      Returns:
      conj(a)
    • abs

      public static double abs(Complex a)
      Compute the absolute value of a complex number.
      Parameters:
      a -
      Returns:
      |a|
    • sqrt

      public static Complex sqrt(Complex x)
      Compute the square root of a complex number.
      Parameters:
      x -
      Returns:
      sqrt(x)
    • exp

      public static Complex exp(Complex x)
      Compute the value of the exponential function of a complex number.
      Parameters:
      x -
      Returns:
      exp(x)
    • log

      public static Complex log(Complex x)
      Compute the natural logarithm of a complex number.
      Parameters:
      x -
      Returns:
      ln(x)
    • arg

      public static double arg(Complex z)
      Return the argument of a complex number.
      Parameters:
      z -
      Returns:
      Arg(z)
    • cis

      public static Complex cis(double x)
      Compute the value of the cis function of a number.
      Parameters:
      x -
      Returns:
      cos(x) + i * sin(x)
    • eq

      public static boolean eq(Complex a, Complex b)
      Compare two numbers for equality.
      Parameters:
      a -
      b -
      Returns:
      true if a == b, false otherwise
    • eq

      public static boolean eq(double a, Complex b)
      Compare two numbers for equality.
      Parameters:
      a -
      b -
      Returns:
      true if a == b, false otherwise
    • eq

      public static boolean eq(Complex a, double b)
      Compare two numbers for equality.
      Parameters:
      a -
      b -
      Returns:
      true if a == b, false otherwise
    • ne

      public static boolean ne(Complex a, double b)
      Compare two numbers for inequality.
      Parameters:
      a -
      b -
      Returns:
      true if a != b, false otherwise
    • ne

      public static boolean ne(double a, Complex b)
      Compare two numbers for inequality.
      Parameters:
      a -
      b -
      Returns:
      true if a != b, false otherwise
    • ne

      public static boolean ne(Complex a, Complex b)
      Compare two numbers for inequality.
      Parameters:
      a -
      b -
      Returns:
      true if a != b, false otherwise
    • eq

      public static boolean eq(Complex a, Complex b, double tol)
      Compare two complex numbers for equality.
      Parameters:
      a -
      b -
      tol -
      Returns:
      true if a ~= b, false otherwise
    • root

      public static double root(double x, int deg)
      Compute the n-th root of a complex number.
      Parameters:
      x -
      deg -
      Returns:
      x^(1/deg)
    • root

      public static Complex[] root(Complex x, int n)
      Find all n-th roots of a complex number.
      Parameters:
      x -
      n -
      Returns:
      x^(1/n)
    • cbrt

      public static Complex cbrt(Complex x)
      Compute the principal cube root of a complex number.
      Parameters:
      x -
      Returns:
      cbrt(x)
    • sin

      public static Complex sin(Complex x)
      Compute the sine of a complex number.
      Parameters:
      x -
      Returns:
      sin(x)
    • cos

      public static Complex cos(Complex x)
      Compute the cosine of a complex number.
      Parameters:
      x -
      Returns:
      cos(x)
    • tan

      public static Complex tan(Complex x)
      Compute the tangent of a complex number.
      Parameters:
      x -
      Returns:
      tan(x)
    • cot

      public static Complex cot(Complex x)
      Compute the cotangent of a complex number.
      Parameters:
      x -
      Returns:
      cot(x)
    • sec

      public static Complex sec(Complex x)
      Compute the secant of a complex number.
      Parameters:
      x -
      Returns:
    • csc

      public static Complex csc(Complex x)
      Compute the cosecant of a complex number.
      Parameters:
      x -
      Returns:
    • pow

      public static Complex pow(Complex a, Complex b)
      Compute a to the power of b, where a and b are both complex numbers.
      Parameters:
      a -
      b -
      Returns:
      a^b
    • pow

      public static Complex pow(double a, Complex b)
      Compute a to the power of b, where a is a double precision number and b is a complex number.
      Parameters:
      a -
      b -
      Returns:
      a^b
    • pow

      public static Complex pow(Complex a, long b)
      Compute a to the power of b, where a is a complex
      Parameters:
      a -
      b -
      Returns:
      a^b
    • sinh

      public static Complex sinh(Complex a)
      Compute the hyperbolic sine of a complex number.
      Parameters:
      a -
      Returns:
      sinh(a)
    • cosh

      public static Complex cosh(Complex a)
      Compute the hyperbolic cosine of a complex number.
      Parameters:
      a -
      Returns:
      cosh(a)
    • tanh

      public static Complex tanh(Complex a)
      Compute the hyperbolic tangent of a complex number.
      Parameters:
      a -
      Returns:
      tanh(a)
    • coth

      public static Complex coth(Complex a)
      Compute the hyperbolic cotangent of a complex number.
      Parameters:
      a -
      Returns:
      coth(a)
    • sech

      public static Complex sech(Complex a)
      Compute the hyperbolic secant of a complex number.
      Parameters:
      a -
      Returns:
      sech(a)
    • csch

      public static Complex csch(Complex a)
      Compute the hyperbolic cosecant of a complex number.
      Parameters:
      a -
      Returns:
      csch(a)
    • asin

      public static Complex asin(Complex a)
      Compute the arcus sine of a complex number.
      Parameters:
      a -
      Returns:
      asin(a)
    • acos

      public static Complex acos(Complex a)
      Compute the arcus cosine of a complex number.
      Parameters:
      a -
      Returns:
      acos(a)
    • atan

      public static Complex atan(Complex a)
      Compute the arcus tangent of a complex number.
      Parameters:
      a -
      Returns:
      atan(a)
    • acot

      public static Complex acot(Complex a)
      Compute the arcus cotangent of a complex number.
      Parameters:
      a -
      Returns:
      acot(a)
    • acsc

      public static Complex acsc(Complex a)
      Compute the arcus cosecant of a complex number.
      Parameters:
      a -
      Returns:
      acsc(a)
    • asec

      public static Complex asec(Complex a)
      Compute the arcus secant of a complex number.
      Parameters:
      a -
      Returns:
      asec(a)
    • asinh

      public static Complex asinh(Complex a)
      Compute the hyperbolic arcsine of a complex number.
      Parameters:
      a -
      Returns:
      asinh(a)
    • acosh

      public static Complex acosh(Complex a)
      Compute the hyperbolic arccosine of a complex number.
      Parameters:
      a -
      Returns:
      acosh(a)
    • atanh

      public static Complex atanh(Complex a)
      Compute the hyperbolic arctangent of a complex number.
      Parameters:
      a -
      Returns:
      atanh(a)
    • acoth

      public static Complex acoth(Complex a)
      Compute the hyperbolic arccotangent of a complex number.
      Parameters:
      a -
      Returns:
      acoth(a)
    • asech

      public static Complex asech(Complex a)
      Compute the hyperbolic arcsecant of a complex number.
      Parameters:
      a -
      Returns:
      asech(a)
    • negate

      public static Complex negate(Complex x)
      Negate a complex number.
      Parameters:
      x -
      Returns:
      -x
    • negate

      public static double negate(double x)
      Negate a real number.
      Parameters:
      x -
      Returns:
      -x
    • acsch

      public static Complex acsch(Complex a)
      Compute the hyperbolic arccosecant of a complex number.
      Parameters:
      a -
      Returns:
      acsch(a)
    • gamma

      public static Complex gamma(Complex a)
      Compute the gamma function of a complex number.
      Parameters:
      a -
      Returns:
      gamma(a)
    • beta

      public static Complex beta(Complex a, Complex b)
      Compute the beta function of two complex numbers. Defined as beta(a, b) = gamma(a) * gamma(b) / gamma(a + b)
      Parameters:
      a -
      b -
      Returns:
      beta(a, b)
      See Also:
    • airyAi

      public static Complex airyAi(Complex x)
      Compute the value of the Airy Ai function at the specified point.
      Parameters:
      x -
      Returns:
      Ai(x)
    • airyAip

      public static Complex airyAip(Complex x)
      Compute the value of the Airy Ai function's first derivative at the specified point.
      Parameters:
      x -
      Returns:
      Ai'(x)
    • airyBi

      public static Complex airyBi(Complex x)
      Compute the value of the Airy Bi function at the specified point.
      Parameters:
      x -
      Returns:
      Bi(x)
    • airyBip

      public static Complex airyBip(Complex x)
      Compute the value of the Airy Bi function's first derivative at the specified point.
      Parameters:
      x -
      Returns:
      Bi'(x)
    • airy

      public static Complex[] airy(Complex x)
      Compute the value of the Airy Ai, Ai', Bi and Bi' functions at the specified point.
      Parameters:
      x -
      Returns:
      a double array of length 4 containing Ai, Ai', Bi and Bi' in that order.
    • e1

      public static Complex e1(Complex x)
      Compute the value of the exponential integral E1 at the specified point. For positive values of real x, E1 and Ei relate as -E1(x) = Ei(-x).
      Parameters:
      x -
      Returns:
      E1(x)
    • Ei

      public static Complex Ei(Complex x)
      Compute the exponential integral using a formula that was revealed to me in a dream:

      Ei(z) = -E1(-z) - log(-z) + 0.5 (log(z) - log(1/z))

      Parameters:
      x -
      Returns:
      Ei(x)
    • Ein

      public static Complex Ein(Complex x)
      Compute the value of the complementary exponential integral Ein at the specified point. For all complex z, Ein and Ei relate as Ein(z) = E1(z) + EulerGamma + ln z.
      Parameters:
      x -
      Returns:
      Ein(x)
      See Also:
    • loggamma

      public static Complex loggamma(Complex x)

      Principal branch of the logarithm of the gamma function. Defined to be log(gamma(x)) for x > 0. Extended to the complex plane by analytic continuation. The function has a single branch cut on the negative real axis.

      It is not generally true that log gamma(x) = log(gamma(x)), though the real parts tend to agree. The benefit of not defining loggamma as is that the latter function has a complicated branch cut structure whereas loggamma is analytic except for on the negative real axis.

      On the real line, loggamma is related to logabsgamma.

      Parameters:
      x -
      Returns:
      See Also:
    • logbeta

      public static Complex logbeta(Complex a, Complex b)
      Compute the logarithm of the beta function in the complex plane. Defined using complex loggamma as logbeta(a, b) = loggamma(a) - loggamma(b) - loggamma(a + b).
      Parameters:
      a -
      b -
      Returns:
      logbeta(a, b)
      See Also:
    • liGamma

      public static Complex liGamma(Complex s, Complex z)
      Compute the lower incomplete (non-regularised) gamma function of a complex number.
      Parameters:
      s -
      z -
      Returns:
      ligamma(s, z)
    • uiGamma

      public static Complex uiGamma(Complex s, Complex z)
      Compute the upper incomplete (non-regularised) gamma function of a complex number.
      Parameters:
      s -
      z -
      Returns:
      uigamma(s, z)
    • erf

      public static Complex erf(Complex z)
      Compute the complex error function.
      Parameters:
      z -
      Returns:
      erf(z)
    • erfc

      public static Complex erfc(Complex z)
      Compute the complex complementary error function.
      Parameters:
      z -
      Returns:
      erfc(z)
    • erfi

      public static Complex erfi(Complex z)
      Compute the complex imaginary error function.
      Parameters:
      z -
      Returns:
      erfi(z) = -i erf(iz)
    • dawsonPlus

      public static Complex dawsonPlus(Complex z)
      Compute the value of the complex Dawson function (D+) at z.
      Parameters:
      z -
      Returns:
      D+(z)
    • dawsonMinus

      public static Complex dawsonMinus(Complex z)
      Compute the value of the complex Dawson function (D-) at z.
      Parameters:
      z -
      Returns:
      D-(z)
    • fresnelS

      public static Complex fresnelS(Complex z)
      Compute the Fresnel S integral on the complex plane.
      Parameters:
      z -
      Returns:
      FresnelS(z)
    • fresnelC

      public static Complex fresnelC(Complex z)
      Compute the Fresnel C integral on the complex plane.
      Parameters:
      z -
      Returns:
      FresnelC(z)
    • digamma

      public static Complex digamma(Complex z)
      Compute the complex digamma function.
      Parameters:
      z -
      Returns:
      digamma(z)
    • trigamma

      public static Complex trigamma(Complex z)
      Compute the complex trigamma function.
      Parameters:
      z -
      Returns:
      trigamma(z)
    • li

      public static double li(double x)
      Compute the logarithmic integral of x, defined as li(x) = int(1/log t, t=0..x).
      Parameters:
      x -
      Returns:
      li(x)
    • li

      public static Complex li(Complex z)
      Compute the complex logarithmic integral of z, defined as li(z) = int(1/log t, t=0..z).
      Parameters:
      z -
      Returns:
      li(z)
    • Si

      public static Complex Si(Complex z)
      Compute the value of the complex sine integral Si(z) at z.
      Parameters:
      z -
      Returns:
      Si(z)
    • si

      public static Complex si(Complex z)
      Compute the value of the complex sine integral si(z) at z.
      Parameters:
      z -
      Returns:
      si(z)
    • Ci

      public static Complex Ci(Complex z)
      Compute the value of the complex cosine integral Ci(z) at z.
      Parameters:
      z -
      Returns:
      Ci(z)
    • Cin

      public static Complex Cin(Complex z)
      Compute the value of the complex cosine integral Cin(z) at z.
      Parameters:
      z -
      Returns:
      Cin(z)
    • Shi

      public static Complex Shi(Complex z)
      Compute the value of the complex hyperbolic sine integral Shi(z).
      Parameters:
      z -
      Returns:
      Shi(z)
    • Chi

      public static Complex Chi(Complex z)
      Compute the value of the complex hyperbolic cosine integral Chi(z).
      Parameters:
      z -
      Returns:
      Chi(z)
    • ShiChi

      public static Complex[] ShiChi(Complex z)
      Compute the value of the complex hyperbolic sine integral Shi(z) and complex hyperbolic cosine integral Chi(z).
      Parameters:
      z -
      Returns:
      { Shi(z), Chi(z) }
    • en

      public static Complex en(Complex n, Complex z)
      Compute the value of the complex generalised exponential integral E_n(z). Uses A&S 5.1.45 E_n(z) = z^(n-1) * uiGamma(1-n, z) to perform computation.
      Parameters:
      n -
      z -
      Returns:
      E_n(z)
    • hurwitzZeta

      public static Complex hurwitzZeta(Complex s, Complex a)
      Compute the Hurwitz zeta function of complex arguments.
      Parameters:
      s -
      a -
      Returns:
      zeta(s, a)
    • dilog

      public static Complex dilog(Complex z)
      Compute the complex dilogarithm of z.
      Parameters:
      z -
      Returns:
      dilog(z)
    • spence

      public static Complex spence(Complex z)
      Compute the Spence function of z.
      Parameters:
      z -
      Returns:
      spence(z)
    • polylog

      public static Complex polylog(Complex s, Complex z)
      Compute the polylogarithm of s and z.
      Parameters:
      s -
      z -
      Returns:
      polylog(s, z)
      Throws:
      ArithmeticException - if the amount of numerical algorithm iterations is exceeded
    • lerchPhi

      public static Complex lerchPhi(Complex z, Complex s, Complex a)
      Compute the Lerch transcendent of z, s, and a. A few things to note:
      • The implementation may overflow the stack for particularly large, negative values of Re(a). This is being worked on.
      • The precision of the output may vary. Worst-case scenario revealed during non-extensive randomised trials is around 0.006% relative error
      Parameters:
      z -
      s -
      a -
      Returns:
      lerch(z, s, a)
    • lambertw

      public static Complex lambertw(Complex z, long k)
      Compute the specified branch of the complex Lambert W function of z.
      Parameters:
      z -
      k -
      Returns:
      lambertw(z, k)
    • chop

      public static Complex chop(Complex z)
      Trim insignificant real/imaginary parts (below machine epsilon), round up numbers where the real/imaginary part is very close to an integer.
      Parameters:
      z -
      Returns:
      iround(z)
    • solidArea

      public static double solidArea(Function<Double,Double> f, Function<Double,Double> df, double a, double b)
      Compute the surface area of a solid of revolution created by rotating the function f(x) about the x-axis. The function f(x) must be continuous and differentiable on the interval [a, b]. The area is computed using the Gauss-Legendre quadrature as 2pi * integral of f(x) * sqrt(1 + df(x)^2) from a to b.
      Parameters:
      f - the function to rotate
      df - the derivative of f
      a - the lower bound of the interval
      b - the upper bound of the interval
      Returns:
      the area of the solid of revolution
    • solidVolume

      public static double solidVolume(Function<Double,Double> f, double a, double b)
      Compute the volume of a solid of revolution created by rotating the function f(x) about the x-axis. The function f(x) must be continuous and differentiable on the interval [a, b]. The volume is computed using the Gauss-Legendre quadrature as pi * integral of f(x)^2 from a to b (the disk method).
      Parameters:
      f - the function to rotate
      a - the lower bound of the interval
      b - the upper bound of the interval
      Returns:
      the volume of the solid of revolution
    • integrateTanhSinhComplex

      public static Complex[] integrateTanhSinhComplex(Function<Complex,Complex> f, Complex a, Complex b, int n, double eps)
      Integrate a C -> C function using the Tanh-Sinh quadrature. Performs integration through a straight line contour from a to b.
      Parameters:
      f - the function to integrate
      a - the lower bound of the interval
      b - the upper bound of the interval
      n - the quadrature degree
      eps - the desired accuracy
      Returns:
      the integral of f from a to b
    • integrateGaussLegendreComplex

      public static Complex integrateGaussLegendreComplex(Function<Complex,Complex> f, Complex a, Complex b, int n)
      Integrate a C -> C function using the Gauss-Legendre quadrature. Performs integration through a straight line contour from a to b.
      Parameters:
      f - the function to integrate
      a - the lower bound of the interval
      b - the upper bound of the interval
      n - the quadrature degree
      Returns:
      the integral of f from a to b
    • arcLength

      public static double arcLength(Function<Double,Double> df, double a, double b)
      Compute the arc length of a curve defined by the function f(x) and its derivative df(x) on the interval [a, b]. The arc length is computed using the Gauss-Legendre quadrature as the integral of sqrt(1 + df(x)^2) from a to b.
      Parameters:
      df - the derivative of f
      a - the lower bound of the interval
      b - the upper bound of the interval
      Returns:
      the arc length of the curve
    • legendreF

      public static double legendreF(double phi, double k)
      Compute the Legendre F elliptic integral defined by DLMF §19.2.4
      Parameters:
      phi -
      k -
      Returns:
      legendreF(phi, k)
    • legendreE

      public static double legendreE(double phi, double k)
      Compute the Legendre E elliptic integral defined by DLMF §19.2.5
      Parameters:
      phi -
      k -
      Returns:
      legendreE(phi, k)
    • legendreD

      public static double legendreD(double phi, double k)
      Compute the Legendre D elliptic integral defined by DLMF §19.2.6
      Parameters:
      phi -
      k -
      Returns:
      legendreD(phi, k)
    • legendrePi

      public static double legendrePi(double phi, double alpha, double k)
      Compute the Legendre Pi elliptic integral defined by DLMF §19.2.7
      Parameters:
      phi -
      alpha -
      k -
      Returns:
      legendrePi(phi, alpha, k)
    • legendreF

      public static Complex legendreF(Complex phi, Complex k)
      Compute the Legendre F elliptic integral defined by DLMF §19.2.4
      Parameters:
      phi -
      k -
      Returns:
      legendreF(phi, k)
    • legendreE

      public static Complex legendreE(Complex phi, Complex k)
      Compute the Legendre E elliptic integral defined by DLMF §19.2.5
      Parameters:
      phi -
      k -
      Returns:
      legendreE(phi, k)
    • legendreD

      public static Complex legendreD(Complex phi, Complex k)
      Compute the Legendre D elliptic integral defined by DLMF §19.2.6
      Parameters:
      phi -
      k -
      Returns:
      legendreD(phi, k)
    • legendrePi

      public static Complex legendrePi(Complex phi, Complex alpha, Complex k)
      Compute the Legendre Pi elliptic integral defined by DLMF §19.2.7
      Parameters:
      phi -
      alpha -
      k -
      Returns:
      legendrePi(phi, alpha, k)
    • landau

      public static double landau(double x, double mpv, double sigma, boolean norm)
      Compute the Landau function with specified most probable value and sigma value.
      Parameters:
      x - the value to evaluate the function at
      mpv - the most probable value
      sigma - width of the distribution
      norm - whether to normalize the result
      Returns:
      landau(x, mpv, sigma, norm)
    • landau

      public static double landau(double x)
      Compute the Landau distribution function.
      Parameters:
      x - the value to evaluate the function at
      Returns:
      landau(x)
    • gammaP

      public static double gammaP(double a, double x)
      Compute the regularized Gamma P function.
      Parameters:
      a - order
      x - argument
      Returns:
      gammaP(a, x)
      Throws:
      ArithmeticException - if arguments are outside of the domain or the iteration count is exceeded.
    • gammaQ

      public static double gammaQ(double a, double x)
      Compute the regularized Gamma Q function.
      Parameters:
      a - order
      x - argument
      Returns:
      gammaQ(a, x)
      Throws:
      ArithmeticException - if arguments are outside of the domain or the iteration count is exceeded.
    • normQuantile

      public static double normQuantile(double p)
      Computes quantiles for standard normal distribution N(0, 1) at probability p.
      Parameters:
      p - probability between 0 and 1.
      Returns:
      quantile value
      Throws:
      IllegalArgumentException - if p is not between 0 and 1
    • chiSquaredQuantile

      public static double chiSquaredQuantile(double p, double df)
      Computes quantiles for chi-squared probability distribution at probability p .
      Parameters:
      p - probability between 0 and 1.
      df - degrees of freedom
      Returns:
      quantile value
      Throws:
      IllegalArgumentException - if p is not between 0 and 1
    • integrateGaussLegendreReal

      public static double integrateGaussLegendreReal(BiFunction<Double,Double,Double> f, double a, double b, double c, double d, int N)
      Integrate a dyadic function over a finite interval [a,b] x [c,d] using the Gauss-Legendre quadrature. The number of intervals is given by N and the precision of the final result greatly depends on this parameter. The computation of an integral using the Gauss-Legendre quadrature involves caching the coefficients required to perform the integration depending on the value of the N parameter. This means that the first call to this method will be slower than subsequent calls with the same value of N. The coefficients are internally cached inside a ConcurrentHashMap.
      Parameters:
      f - function to integrate
      a - lower bound
      b - upper bound
      c - lower bound
      d - upper bound
      N - number of intervals, N=6 tends to give a good approximation in most scenarios. N must be between 1 and 30.
      Returns:
      integral of f over [a,b] x [c,d]
      Throws:
      IllegalArgumentException - if N is not a positive integer
    • integrateGaussLegendreComplex

      public static Complex integrateGaussLegendreComplex(BiFunction<Complex,Complex,Complex> f, Complex a, Complex b, Complex c, Complex d, int N)
      Integrate a dyadic function over a finite interval [a,b] x [c,d] using the Gauss-Legendre quadrature. The number of intervals is given by N and the precision of the final result greatly depends on this parameter. The computation of an integral using the Gauss-Legendre quadrature involves caching the coefficients required to perform the integration depending on the value of the N parameter. This means that the first call to this method will be slower than subsequent calls with the same value of N. The coefficients are internally cached inside a ConcurrentHashMap.
      Parameters:
      f - function to integrate
      a - lower bound
      b - upper bound
      c - lower bound
      d - upper bound
      N - number of intervals, N=6 tends to give a good approximation in most scenarios. N must be between 1 and 30.
      Returns:
      integral of f over [a,b] x [c,d]
      Throws:
      IllegalArgumentException - if N is not a positive integer
    • isPrime

      public static boolean isPrime(int n)
      Primality test for an integer in range [0, 2^31-1].
    • isPrime

      public static boolean isPrime(long n)
      Primality test for an unsigned integer in range [0, 2^64-1]. Notice that some values of n that will be interpreted as negative when signed may yield a truthy value, as the number is reinterpreted as unsigned.
    • nextPrime

      public static int nextPrime(int n)
      Find the next prime after n.
      Throws:
      IllegalArgumentException - if n is negative
      ArithmeticException - if n is too large
    • nextPrime

      public static long nextPrime(long n)
      Find the next prime after (unsigned) n.
      Throws:
      ArithmeticException - if n is too large