Namespaces

Types in MathNet.Numerics

Type SpecialFunctions

Namespace MathNet.Numerics

This partial implementation of the SpecialFunctions class contains all methods related to the modified bessel function.

Static Functions

Public Static Functions

double BesselI0(double x)

Returns the modified Bessel function of first kind, order 0 of the argument. The function is defined as . The range is partitioned into the two intervals [0, 8] and (8, infinity). Chebyshev polynomial expansions are employed in each interval.
Parameters
double x

The value to compute the bessel function of.

double BesselI0MStruveL0(double x)

Returns the difference between the Bessel I0 and Struve L0 functions.
Parameters
double x

The value to compute the function of.

double BesselI1(double x)

Returns the modified Bessel function of first kind, order 1 of the argument. The function is defined as . The range is partitioned into the two intervals [0, 8] and (8, infinity). Chebyshev polynomial expansions are employed in each interval.
Parameters
double x

The value to compute the bessel function of.

double BesselI1MStruveL1(double x)

Returns the difference between the Bessel I1 and Struve L1 functions.
Parameters
double x

The value to compute the function of.

double BesselK0(double x)

Returns the modified Bessel function of the second kind of order 0 of the argument. The range is partitioned into the two intervals [0, 8] and (8, infinity). Chebyshev polynomial expansions are employed in each interval.
Parameters
double x

The value to compute the bessel function of.

double BesselK0e(double x)

Returns the exponentially scaled modified Bessel function of the second kind of order 0 of the argument.
Parameters
double x

The value to compute the bessel function of.

double BesselK1(double x)

Returns the modified Bessel function of the second kind of order 1 of the argument. The range is partitioned into the two intervals [0, 2] and (2, infinity). Chebyshev polynomial expansions are employed in each interval.
Parameters
double x

The value to compute the bessel function of.

double BesselK1e(double x)

Returns the exponentially scaled modified Bessel function of the second kind of order 1 of the argument..
Parameters
double x

The value to compute the bessel function of.

double Beta(double z, double w)

Computes the Euler Beta function.
Parameters
double z

The first Beta parameter, a positive real number.

double w

The second Beta parameter, a positive real number.

Return
double

The Euler Beta function evaluated at z,w.

double BetaIncomplete(double a, double b, double x)

Returns the lower incomplete (unregularized) beta function B(a,b,x) = int(t^(a-1)*(1-t)^(b-1),t=0..x) for real a > 0, b > 0, 1 >= x >= 0.
Parameters
double a

The first Beta parameter, a positive real number.

double b

The second Beta parameter, a positive real number.

double x

The upper limit of the integral.

Return
double

The lower incomplete (unregularized) beta function.

double BetaLn(double z, double w)

Computes the logarithm of the Euler Beta function.
Parameters
double z

The first Beta parameter, a positive real number.

double w

The second Beta parameter, a positive real number.

Return
double

The logarithm of the Euler Beta function evaluated at z,w.

double BetaRegularized(double a, double b, double x)

Returns the regularized lower incomplete beta function I_x(a,b) = 1/Beta(a,b) * int(t^(a-1)*(1-t)^(b-1),t=0..x) for real a > 0, b > 0, 1 >= x >= 0.
Parameters
double a

The first Beta parameter, a positive real number.

double b

The second Beta parameter, a positive real number.

double x

The upper limit of the integral.

Return
double

The regularized lower incomplete beta function.

double Binomial(int n, int k)

Computes the binomial coefficient: n choose k.
Parameters
int n

A nonnegative value n.

int k

A nonnegative value h.

Return
double

The binomial coefficient: n choose k.

double BinomialLn(int n, int k)

Computes the natural logarithm of the binomial coefficient: ln(n choose k).
Parameters
int n

A nonnegative value n.

int k

A nonnegative value h.

Return
double

The logarithmic binomial coefficient: ln(n choose k).

double DiGamma(double x)

Computes the Digamma function which is mathematically defined as the derivative of the logarithm of the gamma function. This implementation is based on Jose Bernardo Algorithm AS 103: Psi ( Digamma ) Function, Applied Statistics, Volume 25, Number 3, 1976, pages 315-317. Using the modifications as in Tom Minka's lightspeed toolbox.
Parameters
double x

The argument of the digamma function.

Return
double

The value of the DiGamma function at x.

double DiGammaInv(double p)

Computes the inverse Digamma function: this is the inverse of the logarithm of the gamma function. This function will only return solutions that are positive.

This implementation is based on the bisection method.

Parameters
double p

The argument of the inverse digamma function.

Return
double

The positive solution to the inverse DiGamma function at p.

double Erf(double x)

Calculates the error function.
Parameters
double x

The value to evaluate.

Return
double

the error function evaluated at given value.

double Erfc(double x)

Calculates the complementary error function.
Parameters
double x

The value to evaluate.

Return
double

the complementary error function evaluated at given value.

double ErfcInv(double z)

Calculates the complementary inverse error function evaluated at z.
We have tested this implementation against the arbitrary precision mpmath library and found cases where we can only guarantee 9 significant figures correct.
Parameters
double z

value to evaluate.

Return
double

The complementary inverse error function evaluated at given value.

double ErfInv(double z)

Calculates the inverse error function evaluated at z.
Parameters
double z

value to evaluate.

Return
double

The inverse error function evaluated at given value.

double ExponentialIntegral(double x, int n)

Computes the generalized Exponential Integral function (En).

This implementation of the computation of the Exponential Integral function follows the derivation in "Handbook of Mathematical Functions, Applied Mathematics Series, Volume 55", Abramowitz, M., and Stegun, I.A. 1964, reprinted 1968 by Dover Publications, New York), Chapters 6, 7, and 26. AND "Advanced mathematical methods for scientists and engineers", Bender, Carl M.; Steven A. Orszag (1978). page 253

for x > 1 uses continued fraction approach that is often used to compute incomplete gamma. for 0 < x <= 1 uses Taylor series expansion

Our unit tests suggest that the accuracy of the Exponential Integral function is correct up to 13 floating point digits.

Parameters
double x

The argument of the Exponential Integral function.

int n

Integer power of the denominator term. Generalization index.

Return
double

The value of the Exponential Integral function.

double ExponentialMinusOne(double power)

Numerically stable exponential minus one, i.e. x -> exp(x)-1
Parameters
double power

A number specifying a power.

Return
double

Returns exp(power)-1.

BigInteger Factorial(BigInteger x)

Computes the factorial of an integer.

double Factorial(int x)

Computes the factorial function x -> x! of an integer number > 0. The function can represent all number up to 22! exactly, all numbers up to 170! using a double representation. All larger values will overflow.
If you need to multiply or divide various such factorials, consider using the logarithmic version FactorialLn instead so you can add instead of multiply and subtract instead of divide, and then exponentiate the result using Exp. This will also circumvent the problem that factorials become very large even for small parameters.
Return
double

A value value! for value > 0

double FactorialLn(int x)

Computes the logarithmic factorial function x -> ln(x!) of an integer number > 0.
Return
double

A value value! for value > 0

double Gamma(double z)

Computes the Gamma function.

This implementation of the computation of the gamma and logarithm of the gamma function follows the derivation in "An Analysis Of The Lanczos Gamma Approximation", Glendon Ralph Pugh, 2004. We use the implementation listed on p. 116 which should achieve an accuracy of 16 floating point digits. Although 16 digit accuracy should be sufficient for double values, improving accuracy is possible (see p. 126 in Pugh).

Our unit tests suggest that the accuracy of the Gamma function is correct up to 13 floating point digits.

Parameters
double z

The argument of the gamma function.

Return
double

The logarithm of the gamma function.

double GammaLn(double z)

Computes the logarithm of the Gamma function.

This implementation of the computation of the gamma and logarithm of the gamma function follows the derivation in "An Analysis Of The Lanczos Gamma Approximation", Glendon Ralph Pugh, 2004. We use the implementation listed on p. 116 which achieves an accuracy of 16 floating point digits. Although 16 digit accuracy should be sufficient for double values, improving accuracy is possible (see p. 126 in Pugh).

Our unit tests suggest that the accuracy of the Gamma function is correct up to 14 floating point digits.

Parameters
double z

The argument of the gamma function.

Return
double

The logarithm of the gamma function.

double GammaLowerIncomplete(double a, double x)

Returns the lower incomplete gamma function gamma(a,x) = int(exp(-t)t^(a-1),t=0..x) for real a > 0, x > 0.
Parameters
double a

The argument for the gamma function.

double x

The upper integral limit.

Return
double

The lower incomplete gamma function.

double GammaLowerRegularized(double a, double x)

Returns the lower incomplete regularized gamma function P(a,x) = 1/Gamma(a) * int(exp(-t)t^(a-1),t=0..x) for real a > 0, x > 0.
Parameters
double a

The argument for the gamma function.

double x

The upper integral limit.

Return
double

The lower incomplete gamma function.

double GammaLowerRegularizedInv(double a, double y0)

Returns the inverse P^(-1) of the regularized lower incomplete gamma function P(a,x) = 1/Gamma(a) * int(exp(-t)t^(a-1),t=0..x) for real a > 0, x > 0, such that P^(-1)(a,P(a,x)) == x.

double GammaUpperIncomplete(double a, double x)

Returns the upper incomplete gamma function Gamma(a,x) = int(exp(-t)t^(a-1),t=0..x) for real a > 0, x > 0.
Parameters
double a

The argument for the gamma function.

double x

The lower integral limit.

Return
double

The upper incomplete gamma function.

double GammaUpperRegularized(double a, double x)

Returns the upper incomplete regularized gamma function Q(a,x) = 1/Gamma(a) * int(exp(-t)t^(a-1),t=0..x) for real a > 0, x > 0.
Parameters
double a

The argument for the gamma function.

double x

The lower integral limit.

Return
double

The upper incomplete regularized gamma function.

double GeneralHarmonic(int n, double m)

Compute the generalized harmonic number of order n of m. (1 + 1/2^m + 1/3^m +... + 1/n^m)
Parameters
int n

The order parameter.

double m

The power parameter.

Return
double

General Harmonic number.

double Harmonic(int t)

Computes the t 'th Harmonic number.
Parameters
int t

The Harmonic number which needs to be computed.

Return
double

The t'th Harmonic number.

Complex Hypotenuse(Complex a, Complex b)

Numerically stable hypotenuse of a right angle triangle, i.e. (a,b) -> sqrt(a^2 + b^2)
Parameters
Complex a

The length of side a of the triangle.

Complex b

The length of side b of the triangle.

Return
Complex

Returns sqrt(a2 + b2) without underflow/overflow.

Complex32 Hypotenuse(Complex32 a, Complex32 b)

Numerically stable hypotenuse of a right angle triangle, i.e. (a,b) -> sqrt(a^2 + b^2)
Parameters
Complex32 a

The length of side a of the triangle.

Complex32 b

The length of side b of the triangle.

Return
Complex32

Returns sqrt(a2 + b2) without underflow/overflow.

double Hypotenuse(double a, double b)

Numerically stable hypotenuse of a right angle triangle, i.e. (a,b) -> sqrt(a^2 + b^2)
Parameters
double a

The length of side a of the triangle.

double b

The length of side b of the triangle.

Return
double

Returns sqrt(a2 + b2) without underflow/overflow.

float Hypotenuse(float a, float b)

Numerically stable hypotenuse of a right angle triangle, i.e. (a,b) -> sqrt(a^2 + b^2)
Parameters
float a

The length of side a of the triangle.

float b

The length of side b of the triangle.

Return
float

Returns sqrt(a2 + b2) without underflow/overflow.

double Logistic(double p)

Computes the logistic function. see: http://en.wikipedia.org/wiki/Logistic
Parameters
double p

The parameter for which to compute the logistic function.

Return
double

The logistic function of p.

double Logit(double p)

Computes the logit function, the inverse of the sigmoid logistic function. see: http://en.wikipedia.org/wiki/Logit
Parameters
double p

The parameter for which to compute the logit function. This number should be between 0 and 1.

Return
double

The logarithm of p divided by 1.0 - p.

double Multinomial(int n, Int32[] ni)

Computes the multinomial coefficient: n choose n1, n2, n3,...
Parameters
int n

A nonnegative value n.

Int32[] ni

An array of nonnegative values that sum to n.

Return
double

The multinomial coefficient.

double StruveL0(double x)

Returns the modified Struve function of order 0.
Parameters
double x

The value to compute the function of.

double StruveL1(double x)

Returns the modified Struve function of order 1.
Parameters
double x

The value to compute the function of.