Special functions

The library includes routines for calculating the values of Airy functions, Bessel functions, Clausen functions, Coulomb wave functions, Coupling coefficients, the Dawson function, Debye functions, Dilogarithms, Elliptic integrals, Jacobi elliptic functions, Error functions, Exponential integrals, Fermi-Dirac functions, Gamma functions, Gegenbauer functions, Hypergeometric functions, Laguerre functions, Legendre functions and Spherical Harmonics, the Psi (Digamma) Function, Synchrotron functions, Transport functions, Trigonometric functions and Zeta functions.

Functions

airyAi(x)
airyBi(x)

The Airy functions Ai(x) and Bi(x) are defined by the integral representations,

Ai(x) = {1 \over \pi} \int_0^\infty \cos({1 \over 3} t^3 + xt) dt

Bi(x) = {1 \over \pi} \int_0^\infty \left( e^{-{1 \over 3} t^3} + \sin(1/3 \, t^3 + xt) \right) dt

For further information see Abramowitz & Stegun, Section 10.4.

airyAizero(n)
airyBizero(n)

Return the n-th zero of the respectives functions.

_images/examples-airy-functions-plot.png

Airy functions Ai and Bi.

besselJ(n, x)

These routines compute the regular cylindrical Bessel function of n-th order, J0(x)

_images/sf-besselJ-functions.png

Bessel functions J0(red), J1(green), J2(blue)

besselJzero(n, s)
Return the s-th zero of the Bessel Jn function.
besselY(n, x)

These routines compute the irregular cylindrical Bessel function of n-th order, Y0(x)

_images/sf-bessel-Y.png

Bessel functions Y0(red), Y1(green), Y2(blue)

besselI(n, x)
Regular modified cylindrical Bessel function.
besselK(n, x)
Irregular modified cylindrical Bessel function.
clausen(x)

The Clausen function is defined by the following integral,

Cl_2(x) = - \int_0^x dt \log(2 \sin(t/2))

It is related to the dilogarithm by Cl_2(\theta) = \Im Li_2(\exp(i\theta)).

dawson(x)

The Dawson integral is defined by

\exp(-x^2) \int_0^x dt \exp(t^2)

A table of Dawson’s integral can be found in Abramowitz & Stegun, Table 7.5.

laguerre(n, a, x)

The generalized Laguerre polynomials are defined in terms of confluent hypergeometric functions as

L^a_n(x) = {(a+1)_n \over n!} {}_1 F_1(-n,a+1,x)

and are sometimes referred to as the associated Laguerre polynomials. They are related to the plain Laguerre polynomials L_n(x) by

L^0_n(x) = L_n(x)

and

L^k_n(x) = (-1)^k {d^k \over dx^k} L_{n+k}(x)

For more information see Abramowitz & Stegun, Chapter 22.

legendreP(n, x)
_images/examples-legendre-polynomials.png

Legendre polynomials

legendreQ(n, x)
debye(n, x)

The Debye functions Dn(x) are defined by the following integral,

D_n(x) = {n \over x^n} \int_0^x dt {t^n \over e^t - 1}

For further information see Abramowitz & Stegun, Section 27.1.

fermi_dirac(n, x)

The complete Fermi-Dirac integral Fn(x) is given by,

F_n(x) = {1 \over \Gamma(n+1)} \int_0^\infty dt {t^n \over e^{t-x} + 1}

Note that the Fermi-Dirac integral is sometimes defined without the normalisation factor in other texts.

dilog(x)

These routines compute the dilogarithm for a real argument. In Lewin’s notation this is Li2(x), the real part of the dilogarithm of a real x. It is defined by the integral representation

Li_2(x) = - \Re \int_0^x ds {\log(1-s) \over s}

Note that Im(Li2(x)) = 0 for x <= 1, and -π log(x) for x > 1.

Note that Abramowitz & Stegun refer to the Spence integral S(x)= Li2(1-x) as the dilogarithm rather than Li2(x).

cdilog(z)
Compute the dilogarithm for a complex argument.
erf(x)

The error function erf(x)

{2 \over \sqrt{\pi}} \int_0^x dt e^{-t^2}

expint(n, x)

Compute the exponential integral En(x) of order n,

E_n(x) = \Re \int_1^\infty dt {\exp(-xt) \over t^n}

expintEi(x)

Computes the exponential integral Ei(x),

Ei(x) = - PV \int_{-x}^\infty dt {\exp(-t) \over t}

where PV denotes the principal value of the integral.

expint3(x)
Computes the third-order exponential integral \textrm{Ei}_3(x) =
\int_0^xdt \exp(-t^3) for x >= 0.
Shi(x)
Compute the integral \textrm{Shi}(x) = \int_0^x dt \sinh(t)/t.
Chi(x)

Compute the integral

\textrm{Chi}(x) = \Re \left( \gamma_E +
\log(x) + \int_0^x dt \dfrac{\cosh(t)-1}{t} \right)

where γE is the Euler constant.

Si(x)
Compute the Sine integral \textrm{Si}(x) = \int_0^x dt \dfrac{\sin(t)}{t}.
Ci(x)
Compute the Cosine integral \textrm{Ci}(x) = -\int_x^\infty dt \dfrac{\cos(t)}{t} for x > 0.
atanint(x)
compute the Arctangent integral, which is defined as \textrm{AtanInt}(x) = \int_0^x dt \dfrac{\arctan(t)}{t}.
fact(n)
Compute the factorial n!. The factorial is related to the Gamma function by n! = Γ (n+1).
doublefact(n)
Compute the double factorial n!! = n(n-2)(n-4) \dots.
lnfact(n)
These routines compute the logarithm of the factorial of N, log(n!). The algorithm is faster than computing ln(Γ (n+1)).
lndoublefact(n)
Compute the logarithm of the double factorial of N, log(n!!).
choose(n, k)

Compute the combinatorial factor

\binom{n}{k} = \dfrac{n!}{k! (n-k)!}

lnchoose(n, k)
Compute the logarithm of “n choose m”. This is equivalent to the sum \log(n!) - \log(m!) - \log((n-m)!).
gamma(x)
Compute the Gamma function Γ (x), subject to x not being a negative integer or zero. The function is computed using the real Lanczos method.
lngamma(x)
Compute the logarithm of the Gamma function, \log(\Gamma(x)), subject to x not being a negative integer or zero. For x<0 the real part of \log(\Gamma(x)) is returned, which is equivalent to \log(|\Gamma(x)|). The function is computed using the real Lanczos method.
beta(a, b)
lnbeta(a, b)
zeta(n)
These routines compute the Riemann zeta function \zeta(s) for arbitrary s, s \ne 1.

Hypergeometric functions

hyperg0F1(a, b)
These routines compute the hypergeometric function 0F1(c,x).
hyperg1F1(m, n, x)
These routines compute the confluent hypergeometric function 1F1(m,n,x) = M(m,n,x). The parameters m and n can be integer or real numbers.
hypergU(m, n, x)
These routines compute the confluent hypergeometric function U(m,n,x). The parameters m and n can be integer or real numbers.
hyperg2F1(a, b, c, x)

These routines compute the Gauss hypergeometric function 2F1(a,b,c,x) = F(a,b,c,x) for |x| < 1.

If the arguments (a,b,c,x) are too close to a singularity then the function can return the error code `GSL_EMAXITER’ when the series approximation converges too slowly. This occurs in the region of x=1, c - a - b = m for integer m.

hyperg2F1conj(a, c, x)
These routines compute the Gauss hypergeometric function 2F1(a, a^*, c, x) where a is complex parameter, c and x are real parameters with |x| < 1.

Table Of Contents

Previous topic

Numerical Integration

Next topic

Function minimization

This Page