Package rocks.palaiologos.maja
Class Maja
java.lang.Object
rocks.palaiologos.maja.Maja
A slick numerics-oriented Mathematical library for Java.
- Author:
- Palaiologos
-
Field Summary
FieldsModifier and TypeFieldDescriptionstatic 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 TypeMethodDescriptionstatic boolean[]
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
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 a complex number and a real number.static Dual
Perform real-dual addition.static Complex
Add a complex number and a real number.static Complex
Add two complex numbers together.static Dual
Perform real-dual addition.static Dual
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
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
bernoulliBound
(int n) 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
static double
besselJv
(double n, double x) Compute fractional order bessel function of n and x.static Dual
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
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
static double
besselYv
(double v, double x) Compute the fractional order bessel Y function of v and x.static Dual
static double
beta
(double x, double y) Compute the beta function of two values.static Dual
Compute the beta function of a real and dual number.static Complex
Compute the beta function of two complex numbers.static Dual
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
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
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
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
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
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
Divide a complex number and a real number.static Complex
Divide a complex number and a real number.static Complex
Divide two complex numbers.static Dual
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
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
Compare two numbers for equality.static boolean
Compare two numbers for equality.static boolean
Compare two numbers for equality.static boolean
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
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
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 mantissastatic 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
hurwitzZeta
(Complex s, Complex a) 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 numberstatic 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.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
isPerfectSquare
(long x) 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
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
lambertWm1
(Dual a) 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.6static Complex
Compute the Legendre D elliptic integral defined by DLMF §19.2.6static double
legendreE
(double phi, double k) Compute the Legendre E elliptic integral defined by DLMF §19.2.5static Complex
Compute the Legendre E elliptic integral defined by DLMF §19.2.5static double
legendreF
(double phi, double k) Compute the Legendre F elliptic integral defined by DLMF §19.2.4static Complex
Compute the Legendre F elliptic integral defined by DLMF §19.2.4static double
legendrePi
(double phi, double alpha, double k) Compute the Legendre Pi elliptic integral defined by DLMF §19.2.7static Complex
legendrePi
(Complex phi, Complex alpha, Complex k) Compute the Legendre Pi elliptic integral defined by DLMF §19.2.7static 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
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
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
Multiply a complex number and a real number.static Complex
Multiply a complex number and a real number.static Complex
Multiply two complex numbers.static Dual
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
Compare two numbers for inequality.static boolean
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
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
pochhammer
(Complex x, Complex n) 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
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
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
Compute a to the power of b, where a is a double precision number and b is a complex number.static Complex
Compute a to the power of b, where a is a complexstatic Complex
Compute a to the power of b, where a and b are both complex numbers.static Dual
static double
random()
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[]
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
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
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
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
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
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
Subtract a complex number and a real number.static Dual
static Complex
Subtract a complex number and a real number.static Complex
Subtract two complex numbers from each other.static Dual
static Dual
static double
tan
(double x) Returns the tangent of a double precision number.static Complex
Compute the tangent of a complex number.static Dual
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.
-
Field Details
-
DECA
public static final double DECASI prefix for 10^1.- See Also:
-
HECTO
public static final double HECTOSI prefix for 10^2.- See Also:
-
KILO
public static final double KILOSI prefix for 10^3.- See Also:
-
MEGA
public static final double MEGASI prefix for 10^6.- See Also:
-
GIGA
public static final double GIGASI prefix for 10^9.- See Also:
-
TERA
public static final double TERASI prefix for 10^12.- See Also:
-
PETA
public static final double PETASI prefix for 10^15.- See Also:
-
EXA
public static final double EXASI prefix for 10^18.- See Also:
-
ZETTA
public static final double ZETTASI prefix for 10^21.- See Also:
-
YOTTA
public static final double YOTTASI prefix for 10^24.- See Also:
-
DECI
public static final double DECISI prefix for 10^-1.- See Also:
-
CENTI
public static final double CENTISI prefix for 10^-2.- See Also:
-
MILLI
public static final double MILLISI prefix for 10^-3.- See Also:
-
MICRO
public static final double MICROSI prefix for 10^-6.- See Also:
-
NANO
public static final double NANOSI prefix for 10^-9.- See Also:
-
PICO
public static final double PICOSI prefix for 10^-12.- See Also:
-
FEMTO
public static final double FEMTOSI prefix for 10^-15.- See Also:
-
ATTO
public static final double ATTOSI prefix for 10^-18.- See Also:
-
ZEPTO
public static final double ZEPTOSI prefix for 10^-21.- See Also:
-
YOCTO
public static final double YOCTOSI prefix for 10^-24.- See Also:
-
LN2
public static final double LN2The value of ln(2).- See Also:
-
LN10
public static final double LN10The value of ln(10).- See Also:
-
LOG2E
public static final double LOG2EThe value of log2(e).- See Also:
-
PI
public static final double PIThe value of pi.- See Also:
-
PI_2
public static final double PI_2The value of pi/2.- See Also:
-
PI_4
public static final double PI_4The value of pi/4.- See Also:
-
TWO_PI
public static final double TWO_PIThe value of 2*PI.- See Also:
-
ONE_OVER_PI
public static final double ONE_OVER_PIThe value of 1/pi.- See Also:
-
E
public static final double EThe value of e.- See Also:
-
ONE_OVER_E
public static final double ONE_OVER_EThe value of 1/e.- See Also:
-
EPSILON
public static final double EPSILONThe epsilon value for double precision numbers. -
EULER_GAMMA
public static final double EULER_GAMMAThe Euler-Mascheroni constant.- See Also:
-
GOLDEN_RATIO
public static final double GOLDEN_RATIOThe golden ratio.- See Also:
-
APERY_CONSTANT
public static final double APERY_CONSTANTApery's constant - zeta(3).- See Also:
-
GLAISHER_CONSTANT
public static final double GLAISHER_CONSTANTGlaisher-Kinkelin constant.- See Also:
-
CATALAN_CONSTANT
public static final double CATALAN_CONSTANTCatalan's constant.- See Also:
-
GOLOMB_DICKMAN_CONSTANT
public static final double GOLOMB_DICKMAN_CONSTANTGolomb-Dickman constant.- See Also:
-
MILLS_CONSTANT
public static final double MILLS_CONSTANTMills' constant.- See Also:
-
FEIGENBAUM_CONSTANT
public static final double FEIGENBAUM_CONSTANTFeigenbaum constant.- See Also:
-
KHINCHIN_CONSTANT
public static final double KHINCHIN_CONSTANTKhinchin's constant.- See Also:
-
I
The imaginary unit.
-
-
Method Details
-
add
public static double add(double x, double y) Adds two double precision numbers together.- Parameters:
x
-y
-- Returns:
- x + y
-
add
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
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
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
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
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
Rounds both the real and imaginary parts of a complex number.- Parameters:
x
-- Returns:
- ceil(x)
-
floor
Rounds both the real and imaginary parts of a complex number.- Parameters:
x
-- Returns:
- floor(x)
-
round
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
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
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
Copy the sign of the second argument to the first argument.- Parameters:
x
-y
-- Returns:
- copySign(x, y)
-
absparts
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 startinRangeEnd
- Input range endoutRangeStart
- Output range startoutRangeEnd
- Output range endvalue
- 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 0rangeEnd
- Range end normalized to 1value
- 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
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
Compute the Pochhammer symbol (x)_n.- Parameters:
x
-n
-- Returns:
- (x)_n
-
pochhammer
Compute the Pochhammer symbol (x)_n.- Parameters:
x
-n
-- Returns:
- (x)_n
-
pochhammer
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
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
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
Domain extension of the greatest common division function onto the complex plane.- Parameters:
a
-b
-- Returns:
- gcd(a, b)
-
rem
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
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 functionx
- 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
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 integratea
- lower boundb
- upper boundN
- 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 integratea
- lower boundb
- upper boundN
- 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 integratea
- lower boundb
- upper boundN
- the degree of the quadrature, usually N=6 is sufficienteps
- 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
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 integratea
- lower boundb
- upper boundN
- 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 integratea
- lower boundb
- upper boundN
- 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 integratea
- lower boundb
- upper boundN
- the degree of the quadrature, usually N=6 is sufficienteps
- 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 fordf
- the derivative of the functionx0
- the initial guesseps
- the desired precision of the result- Returns:
- a root of the function f within the desired precision unless the iteration limit is exceeded.
-
aberth
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
-
weberE
-
lommels1
public static double lommels1(double u, double v, double z) -
legendre
public static double legendre(double n, double z) -
add
Add two complex numbers together.- Parameters:
a
-b
-- Returns:
- a + b
-
add
Perform dual addition.- Parameters:
a
-b
-- Returns:
- a + b
-
add
Perform real-dual addition.- Parameters:
a
-b
-- Returns:
- a + b
-
add
Perform real-dual addition.- Parameters:
a
-b
-- Returns:
- a + b
-
sub
-
sub
-
sub
-
mul
-
div
-
sin
-
sec
-
cos
-
csc
-
tan
-
cot
-
exp
-
log
-
pow
-
abs
-
asin
-
acos
-
atan
-
sqrt
-
sinh
-
cosh
-
tanh
-
gamma
-
digamma
-
besselI0
-
besselJ0
-
besselK0
-
besselJ1
-
besselY0
-
besselK1
-
besselJn
-
besselYn
-
besselYv
-
besselKn
-
besselJv
-
airyAi
-
airyBi
-
Chi
-
Shi
-
Ci
-
Si
-
Ei
-
erf
-
dilog
-
acot
-
acoth
-
asec
-
acsc
-
coth
-
sech
-
csch
-
asinh
-
acosh
-
atanh
-
asech
-
acsch
-
cbrt
-
beta
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
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
-
erfi
-
fresnelC
-
fresnelS
-
li
-
sinc
-
spence
-
trigamma
-
polygamma
-
polylog
-
lambertW0
-
lambertWm1
-
hurwitzZeta
-
add
Add a complex number and a real number.- Parameters:
a
-b
-- Returns:
- a + b
-
add
Add a complex number and a real number.- Parameters:
a
-b
-- Returns:
- a + b
-
sub
Subtract two complex numbers from each other.- Parameters:
a
-b
-- Returns:
- a - b
-
sub
Subtract a complex number and a real number.- Parameters:
a
-b
-- Returns:
- a - b
-
sub
Subtract a complex number and a real number.- Parameters:
a
-b
-- Returns:
- a - b
-
mul
Multiply two complex numbers.- Parameters:
a
-b
-- Returns:
- a * b
-
mul
Multiply a complex number and a real number.- Parameters:
a
-b
-- Returns:
- a * b
-
mul
Multiply a complex number and a real number.- Parameters:
a
-b
-- Returns:
- a * b
-
div
Divide two complex numbers.- Parameters:
a
-b
-- Returns:
- a / b
-
div
Divide a complex number and a real number.- Parameters:
a
-b
-- Returns:
- a / b
-
div
Divide a complex number and a real number.- Parameters:
a
-b
-- Returns:
- a / b
-
conj
Compute the complex conjugate of a complex number.- Parameters:
a
-- Returns:
- conj(a)
-
abs
Compute the absolute value of a complex number.- Parameters:
a
-- Returns:
- |a|
-
sqrt
Compute the square root of a complex number.- Parameters:
x
-- Returns:
- sqrt(x)
-
exp
Compute the value of the exponential function of a complex number.- Parameters:
x
-- Returns:
- exp(x)
-
log
Compute the natural logarithm of a complex number.- Parameters:
x
-- Returns:
- ln(x)
-
arg
Return the argument of a complex number.- Parameters:
z
-- Returns:
- Arg(z)
-
cis
Compute the value of the cis function of a number.- Parameters:
x
-- Returns:
- cos(x) + i * sin(x)
-
eq
Compare two numbers for equality.- Parameters:
a
-b
-- Returns:
- true if a == b, false otherwise
-
eq
Compare two numbers for equality.- Parameters:
a
-b
-- Returns:
- true if a == b, false otherwise
-
eq
Compare two numbers for equality.- Parameters:
a
-b
-- Returns:
- true if a == b, false otherwise
-
ne
Compare two numbers for inequality.- Parameters:
a
-b
-- Returns:
- true if a != b, false otherwise
-
ne
Compare two numbers for inequality.- Parameters:
a
-b
-- Returns:
- true if a != b, false otherwise
-
ne
Compare two numbers for inequality.- Parameters:
a
-b
-- Returns:
- true if a != b, false otherwise
-
eq
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
Find all n-th roots of a complex number.- Parameters:
x
-n
-- Returns:
- x^(1/n)
-
cbrt
Compute the principal cube root of a complex number.- Parameters:
x
-- Returns:
- cbrt(x)
-
sin
Compute the sine of a complex number.- Parameters:
x
-- Returns:
- sin(x)
-
cos
Compute the cosine of a complex number.- Parameters:
x
-- Returns:
- cos(x)
-
tan
Compute the tangent of a complex number.- Parameters:
x
-- Returns:
- tan(x)
-
cot
Compute the cotangent of a complex number.- Parameters:
x
-- Returns:
- cot(x)
-
sec
Compute the secant of a complex number.- Parameters:
x
-- Returns:
-
csc
Compute the cosecant of a complex number.- Parameters:
x
-- Returns:
-
pow
Compute a to the power of b, where a and b are both complex numbers.- Parameters:
a
-b
-- Returns:
- a^b
-
pow
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
Compute a to the power of b, where a is a complex- Parameters:
a
-b
-- Returns:
- a^b
-
sinh
Compute the hyperbolic sine of a complex number.- Parameters:
a
-- Returns:
- sinh(a)
-
cosh
Compute the hyperbolic cosine of a complex number.- Parameters:
a
-- Returns:
- cosh(a)
-
tanh
Compute the hyperbolic tangent of a complex number.- Parameters:
a
-- Returns:
- tanh(a)
-
coth
Compute the hyperbolic cotangent of a complex number.- Parameters:
a
-- Returns:
- coth(a)
-
sech
Compute the hyperbolic secant of a complex number.- Parameters:
a
-- Returns:
- sech(a)
-
csch
Compute the hyperbolic cosecant of a complex number.- Parameters:
a
-- Returns:
- csch(a)
-
asin
Compute the arcus sine of a complex number.- Parameters:
a
-- Returns:
- asin(a)
-
acos
Compute the arcus cosine of a complex number.- Parameters:
a
-- Returns:
- acos(a)
-
atan
Compute the arcus tangent of a complex number.- Parameters:
a
-- Returns:
- atan(a)
-
acot
Compute the arcus cotangent of a complex number.- Parameters:
a
-- Returns:
- acot(a)
-
acsc
Compute the arcus cosecant of a complex number.- Parameters:
a
-- Returns:
- acsc(a)
-
asec
Compute the arcus secant of a complex number.- Parameters:
a
-- Returns:
- asec(a)
-
asinh
Compute the hyperbolic arcsine of a complex number.- Parameters:
a
-- Returns:
- asinh(a)
-
acosh
Compute the hyperbolic arccosine of a complex number.- Parameters:
a
-- Returns:
- acosh(a)
-
atanh
Compute the hyperbolic arctangent of a complex number.- Parameters:
a
-- Returns:
- atanh(a)
-
acoth
Compute the hyperbolic arccotangent of a complex number.- Parameters:
a
-- Returns:
- acoth(a)
-
asech
Compute the hyperbolic arcsecant of a complex number.- Parameters:
a
-- Returns:
- asech(a)
-
negate
Negate a complex number.- Parameters:
x
-- Returns:
- -x
-
negate
public static double negate(double x) Negate a real number.- Parameters:
x
-- Returns:
- -x
-
acsch
Compute the hyperbolic arccosecant of a complex number.- Parameters:
a
-- Returns:
- acsch(a)
-
gamma
Compute the gamma function of a complex number.- Parameters:
a
-- Returns:
- gamma(a)
-
beta
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
Compute the value of the Airy Ai function at the specified point.- Parameters:
x
-- Returns:
- Ai(x)
-
airyAip
Compute the value of the Airy Ai function's first derivative at the specified point.- Parameters:
x
-- Returns:
- Ai'(x)
-
airyBi
Compute the value of the Airy Bi function at the specified point.- Parameters:
x
-- Returns:
- Bi(x)
-
airyBip
Compute the value of the Airy Bi function's first derivative at the specified point.- Parameters:
x
-- Returns:
- Bi'(x)
-
airy
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
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
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
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
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
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
Compute the lower incomplete (non-regularised) gamma function of a complex number.- Parameters:
s
-z
-- Returns:
- ligamma(s, z)
-
uiGamma
Compute the upper incomplete (non-regularised) gamma function of a complex number.- Parameters:
s
-z
-- Returns:
- uigamma(s, z)
-
erf
Compute the complex error function.- Parameters:
z
-- Returns:
- erf(z)
-
erfc
Compute the complex complementary error function.- Parameters:
z
-- Returns:
- erfc(z)
-
erfi
Compute the complex imaginary error function.- Parameters:
z
-- Returns:
- erfi(z) = -i erf(iz)
-
dawsonPlus
Compute the value of the complex Dawson function (D+) at z.- Parameters:
z
-- Returns:
- D+(z)
-
dawsonMinus
Compute the value of the complex Dawson function (D-) at z.- Parameters:
z
-- Returns:
- D-(z)
-
fresnelS
Compute the Fresnel S integral on the complex plane.- Parameters:
z
-- Returns:
- FresnelS(z)
-
fresnelC
Compute the Fresnel C integral on the complex plane.- Parameters:
z
-- Returns:
- FresnelC(z)
-
digamma
Compute the complex digamma function.- Parameters:
z
-- Returns:
- digamma(z)
-
trigamma
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
Compute the complex logarithmic integral of z, defined as li(z) = int(1/log t, t=0..z).- Parameters:
z
-- Returns:
- li(z)
-
Si
Compute the value of the complex sine integral Si(z) at z.- Parameters:
z
-- Returns:
- Si(z)
-
si
Compute the value of the complex sine integral si(z) at z.- Parameters:
z
-- Returns:
- si(z)
-
Ci
Compute the value of the complex cosine integral Ci(z) at z.- Parameters:
z
-- Returns:
- Ci(z)
-
Cin
Compute the value of the complex cosine integral Cin(z) at z.- Parameters:
z
-- Returns:
- Cin(z)
-
Shi
Compute the value of the complex hyperbolic sine integral Shi(z).- Parameters:
z
-- Returns:
- Shi(z)
-
Chi
Compute the value of the complex hyperbolic cosine integral Chi(z).- Parameters:
z
-- Returns:
- Chi(z)
-
ShiChi
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
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
Compute the Hurwitz zeta function of complex arguments.- Parameters:
s
-a
-- Returns:
- zeta(s, a)
-
dilog
Compute the complex dilogarithm of z.- Parameters:
z
-- Returns:
- dilog(z)
-
spence
Compute the Spence function of z.- Parameters:
z
-- Returns:
- spence(z)
-
polylog
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
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
Compute the specified branch of the complex Lambert W function of z.- Parameters:
z
-k
-- Returns:
- lambertw(z, k)
-
chop
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 rotatedf
- the derivative of fa
- the lower bound of the intervalb
- the upper bound of the interval- Returns:
- the area of the solid of revolution
-
solidVolume
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 rotatea
- the lower bound of the intervalb
- 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 integratea
- the lower bound of the intervalb
- the upper bound of the intervaln
- the quadrature degreeeps
- 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 integratea
- the lower bound of the intervalb
- the upper bound of the intervaln
- the quadrature degree- Returns:
- the integral of f from a to b
-
arcLength
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 fa
- the lower bound of the intervalb
- 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
Compute the Legendre F elliptic integral defined by DLMF §19.2.4- Parameters:
phi
-k
-- Returns:
- legendreF(phi, k)
-
legendreE
Compute the Legendre E elliptic integral defined by DLMF §19.2.5- Parameters:
phi
-k
-- Returns:
- legendreE(phi, k)
-
legendreD
Compute the Legendre D elliptic integral defined by DLMF §19.2.6- Parameters:
phi
-k
-- Returns:
- legendreD(phi, k)
-
legendrePi
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 atmpv
- the most probable valuesigma
- width of the distributionnorm
- 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
- orderx
- 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
- orderx
- 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 integratea
- lower boundb
- upper boundc
- lower boundd
- upper boundN
- 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 integratea
- lower boundb
- upper boundc
- lower boundd
- upper boundN
- 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 negativeArithmeticException
- 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
-