Special Functions

Mathematica includes all the common special functions of mathematical physics found in standard handbooks. Each of the various classes of functions is discussed in turn.

One point you should realize is that in the technical literature there are often several conflicting definitions of any particular special function. When you use a special function in Mathematica, therefore, you should be sure to look at the definition given here to confirm that it is exactly what you want.

Mathematica gives exact results for some values of special functions.
In[1]:=
Click for copyable input
Out[1]=
No exact result is known here.
In[2]:=
Click for copyable input
Out[2]=
A numerical result, to arbitrary precision, can nevertheless be found.
In[3]:=
Click for copyable input
Out[3]=
You can give complex arguments to special functions.
In[4]:=
Click for copyable input
Out[4]=
Special functions automatically get applied to each element in a list.
In[5]:=
Click for copyable input
Out[5]=
Mathematica knows analytic properties of special functions, such as derivatives.
In[6]:=
Click for copyable input
Out[6]=
You can use FindRoot to find roots of special functions.
In[7]:=
Click for copyable input
Out[7]=

Special functions in Mathematica can usually be evaluated for arbitrary complex values of their arguments. Often, however, the defining relations given in this tutorial apply only for some special choices of arguments. In these cases, the full function corresponds to a suitable extension or analytic continuation of these defining relations. Thus, for example, integral representations of functions are valid only when the integral exists, but the functions themselves can usually be defined elsewhere by analytic continuation.

As a simple example of how the domain of a function can be extended, consider the function represented by the sum . This sum converges only when . Nevertheless, it is easy to show analytically that for any , the complete function is equal to . Using this form, you can easily find a value of the function for any , at least so long as .

Gamma and Related Functions

Beta[a,b]Euler beta function
Beta[z,a,b]incomplete beta function
BetaRegularized[z,a,b]regularized incomplete beta function
Gamma[z]Euler gamma function
Gamma[a,z]incomplete gamma function
Gamma[a,z0,z1]generalized incomplete gamma function
GammaRegularized[a,z]regularized incomplete gamma function
InverseBetaRegularized[s,a,b]inverse beta function
InverseGammaRegularized[a,s]inverse gamma function
Pochhammer[a,n]Pochhammer symbol
PolyGamma[z]digamma function
PolyGamma[n,z]^(th) derivative of the digamma function
LogGamma[z]Euler log-gamma function
LogBarnesG[z]logarithm of Barnes G-function
BarnesG[z]Barnes G-function
Hyperfactorial[n]hyperfactorial function

Gamma and related functions.

The Euler gamma function Gamma[z] is defined by the integral . For positive integer , . can be viewed as a generalization of the factorial function, valid for complex arguments .

There are some computations, particularly in number theory, where the logarithm of the gamma function often appears. For positive real arguments, you can evaluate this simply as Log[Gamma[z]]. For complex arguments, however, this form yields spurious discontinuities. Mathematica therefore includes the separate function LogGamma[z], which yields the logarithm of the gamma function with a single branch cut along the negative real axis.

The Euler beta function Beta[a, b] is .

The Pochhammer symbol or rising factorial Pochhammer[a, n] is . It often appears in series expansions for hypergeometric functions. Note that the Pochhammer symbol has a definite value even when the gamma functions that appear in its definition are infinite.

The incomplete gamma function Gamma[a, z] is defined by the integral . Mathematica includes a generalized incomplete gamma function Gamma[a, z0, z1] defined as .

The alternative incomplete gamma function can therefore be obtained in Mathematica as Gamma[a, 0, z].

The incomplete beta function Beta[z, a, b] is given by . Notice that in the incomplete beta function, the parameter is an upper limit of integration, and appears as the first argument of the function. In the incomplete gamma function, on the other hand, is a lower limit of integration, and appears as the second argument of the function.

In certain cases, it is convenient not to compute the incomplete beta and gamma functions on their own, but instead to compute regularized forms in which these functions are divided by complete beta and gamma functions. Mathematica includes the regularized incomplete beta function BetaRegularized[z, a, b] defined for most arguments by , but taking into account singular cases. Mathematica also includes the regularized incomplete gamma function GammaRegularized[a, z] defined by , with singular cases taken into account.

The incomplete beta and gamma functions, and their inverses, are common in statistics. The inverse beta function InverseBetaRegularized[s, a, b] is the solution for in . The inverse gamma function InverseGammaRegularized[a, s] is similarly the solution for in .

Derivatives of the gamma function often appear in summing rational series. The digamma function PolyGamma[z] is the logarithmic derivative of the gamma function, given by . For integer arguments, the digamma function satisfies the relation , where is Euler's constant (EulerGamma in Mathematica) and are the harmonic numbers.

The polygamma functions PolyGamma[n, z] are given by . Notice that the digamma function corresponds to . The general form is the ^(th), not the ^(th), logarithmic derivative of the gamma function. The polygamma functions satisfy the relation . PolyGamma[, z] is defined for arbitrary complex by fractional calculus analytic continuation.

BarnesG[z] is a generalization of the Gamma function and is defined by its functional identity BarnesG[z+1]=Gamma[z] BarnesG[z], where the third derivative of the logarithm of BarnesG is positive for positive z. BarnesG is an entire function in the complex plane.

LogBarnesG[z] is a holomorphic function with a branch cut along the negative real-axis such that Exp[LogBarnesG[z]]=BarnesG[z].

Hyperfactorial[n] is a generalization of to the complex plane.

Many exact results for gamma and polygamma functions are built into Mathematica.
Click for copyable input
Here is a contour plot of the gamma function in the complex plane.
In[4]:=
Click for copyable input
Out[4]=

Zeta and Related Functions

DirichletL[k,j,s]Dirichlet L-function
LerchPhi[z,s,a]Lerch's transcendent
PolyLog[n,z]polylogarithm function
PolyLog[n,p,z]Nielsen generalized polylogarithm function
RamanujanTau[n]Ramanujan function
RamanujanTauL[n]Ramanujan Dirichlet L-function
RamanujanTauTheta[n]Ramanujan theta function
RamanujanTauZ[n]Ramanujan Z-function
RiemannSiegelTheta[t]Riemann-Siegel function
RiemannSiegelZ[t]Riemann-Siegel function
StieltjesGamma[n]Stieltjes constants
Zeta[s]Riemann zeta function
Zeta[s,a]generalized Riemann zeta function
HurwitzZeta[s,a]Hurwitz zeta function
HurwitzLerchPhi[z,s,a]Hurwitz-Lerch transcendent

Zeta and related functions.

The Dirichlet-L function DirichletL[k, j, s] is implemented as (for ) where is a Dirichlet character with modulus and index .

The Riemann zeta function Zeta[s] is defined by the relation (for ). Zeta functions with integer arguments arise in evaluating various sums and integrals. Mathematica gives exact results when possible for zeta functions with integer arguments.

There is an analytic continuation of for arbitrary complex . The zeta function for complex arguments is central to number theoretic studies of the distribution of primes. Of particular importance are the values on the critical line .

In studying , it is often convenient to define the two Riemann-Siegel functions RiemannSiegelZ[t] and RiemannSiegelTheta[t] according to and (for real). Note that the Riemann-Siegel functions are both real as long as is real.

The Stieltjes constants StieltjesGamma[n] are generalizations of Euler's constant that appear in the series expansion of around its pole at ; the coefficient of is . Euler's constant is .

The generalized Riemann zeta function Zeta[s, a] is implemented as , where any term with is excluded.

The Hurwitz zeta function HurwitzZeta[s, a] is implemented as .

The Ramanujan Dirichlet L-function RamanujanTauL[s] is defined by L(s)=sum_(n=1)^infty(tau(n))/(n^s) (for ), with coefficients RamanujanTau[n]. In analogy with the Riemann zeta function, it is again convenient to define the functions RamanujanTauZ[t] and RamanujanTauTheta[t].

Here is the numerical approximation for .
Click for copyable input
Here is a three-dimensional picture of the real part of a Dirichlet L-function.
Click for copyable input
Mathematica gives exact results for .
Click for copyable input
Here is a three-dimensional picture of the Riemann zeta function in the complex plane.
Click for copyable input
This is a plot of the absolute value of the Riemann zeta function on the critical line . You can see the first few zeros of the zeta function.
Click for copyable input
This is a plot of the absolute value of the Ramanujan L function on its critical line .
Click for copyable input

The polylogarithm functions PolyLog[n, z] are given by . The polylogarithm function is sometimes known as Jonquière's function. The dilogarithm PolyLog[2, z] satisfies . Sometimes is known as Spence's integral. The Nielsen generalized polylogarithm functions or hyperlogarithms PolyLog[n, p, z] are given by . Polylogarithm functions appear in Feynman diagram integrals in elementary particle physics, as well as in algebraic K-theory.

The Lerch transcendent LerchPhi[z, s, a] is a generalization of the zeta and polylogarithm functions, given by , where any term with is excluded. Many sums of reciprocal powers can be expressed in terms of the Lerch transcendent. For example, the Catalan beta function can be obtained as .

The Lerch transcendent is related to integrals of the Fermi-Dirac distribution in statistical mechanics by .

The Lerch transcendent can also be used to evaluate Dirichlet L-series that appear in number theory. The basic L-series has the form , where the "character" is an integer function with period . L-series of this kind can be written as sums of Lerch functions with a power of .

LerchPhi[z, s, a, DoublyInfinite->True] gives the doubly infinite sum .

The Hurwitz-Lerch transcendent HurwitzLerchPhi[z, s, a] generalizes HurwitzZeta[s, a] and is defined by .

ZetaZero[k]the ^(th) zero of the zeta function on the critical line
ZetaZero[k,x0]the ^(th) zero above height

Zeros of the zeta function.

ZetaZero[1] represents the first nontrivial zero of .
Click for copyable input
This gives its numerical value.
Click for copyable input
This gives the first zero with height greater than 15.
Click for copyable input

Exponential Integral and Related Functions

CosIntegral[z]cosine integral function
CoshIntegral[z]hyperbolic cosine integral function
ExpIntegralE[n,z]exponential integral E_n(z)
ExpIntegralEi[z]exponential integral
LogIntegral[z]logarithmic integral
SinIntegral[z]sine integral function
SinhIntegral[z]hyperbolic sine integral function

Exponential integral and related functions.

Mathematica has two forms of exponential integral: ExpIntegralE and ExpIntegralEi.

The exponential integral function ExpIntegralE[n, z] is defined by .

The second exponential integral function ExpIntegralEi[z] is defined by (for ), where the principal value of the integral is taken.

The logarithmic integral function LogIntegral[z] is given by (for ), where the principal value of the integral is taken. is central to the study of the distribution of primes in number theory. The logarithmic integral function is sometimes also denoted by . In some number theoretic applications, is defined as , with no principal value taken. This differs from the definition used in Mathematica by the constant .

The sine and cosine integral functions SinIntegral[z] and CosIntegral[z] are defined by and . The hyperbolic sine and cosine integral functions SinhIntegral[z] and CoshIntegral[z] are defined by and .

Error Function and Related Functions

Erf[z]error function
Erf[z0,z1]generalized error function
Erfc[z]complementary error function
Erfi[z]imaginary error function
FresnelC[z]Fresnel integral C(z)
FresnelS[z]Fresnel integral
InverseErf[s]inverse error function
InverseErfc[s]inverse complementary error function

Error function and related functions.

The error function Erf[z] is the integral of the Gaussian distribution, given by . The complementary error function Erfc[z] is given simply by . The imaginary error function Erfi[z] is given by . The generalized error function Erf[z0, z1] is defined by the integral . The error function is central to many calculations in statistics.

The inverse error function InverseErf[s] is defined as the solution for in the equation . The inverse error function appears in computing confidence intervals in statistics as well as in some algorithms for generating Gaussian random numbers.

Closely related to the error function are the Fresnel integrals FresnelC[z] defined by and FresnelS[z] defined by . Fresnel integrals occur in diffraction theory.

Bessel and Related Functions

AiryAi[z]andAiryBi[z]Airy functions and
AiryAiPrime[z]andAiryBiPrime[z]derivatives of Airy functions and
BesselJ[n,z]andBesselY[n,z]Bessel functions and
BesselI[n,z]andBesselK[n,z]modified Bessel functions and
KelvinBer[n,z]andKelvinBei[n,z]Kelvin functions and
KelvinKer[n,z]andKelvinKei[n,z]Kelvin functions and
HankelH1[n,z]andHankelH2[n,z]Hankel functions and
SphericalBesselJ[n,z]andSphericalBesselY[n,z]
spherical Bessel functions and
SphericalHankelH1[n,z]andSphericalHankelH2[n,z]
spherical Hankel functions and
StruveH[n,z]andStruveL[n,z]Struve function and modified Struve function

Bessel and related functions.

The Bessel functions BesselJ[n, z] and BesselY[n, z] are linearly independent solutions to the differential equation . For integer , the are regular at , while the have a logarithmic divergence at .

Bessel functions arise in solving differential equations for systems with cylindrical symmetry.

is often called the Bessel function of the first kind, or simply the Bessel function. is referred to as the Bessel function of the second kind, the Weber function, or the Neumann function (denoted ).

The Hankel functions (or Bessel functions of the third kind) HankelH1[n, z] and HankelH2[n, z] give an alternative pair of solutions to the Bessel differential equation, related according to .

The spherical Bessel functions SphericalBesselJ[n, z] and SphericalBesselY[n, z], as well as the spherical Hankel functions SphericalHankelH1[n, z] and SphericalHankelH2[n, z], arise in studying wave phenomena with spherical symmetry. These are related to the ordinary functions by , where and can be and , and , or and . For integer , spherical Bessel functions can be expanded in terms of elementary functions by using FunctionExpand.

The modified Bessel functions BesselI[n, z] and BesselK[n, z] are solutions to the differential equation . For integer , is regular at ; always has a logarithmic divergence at . The are sometimes known as hyperbolic Bessel functions.

Particularly in electrical engineering, one often defines the Kelvin functions KelvinBer[n, z], KelvinBei[n, z], KelvinKer[n, z] and KelvinKei[n, z]. These are related to the ordinary Bessel functions by , .

The Airy functions AiryAi[z] and AiryBi[z] are the two independent solutions and to the differential equation . tends to zero for large positive , while increases unboundedly. The Airy functions are related to modified Bessel functions with one-third-integer orders. The Airy functions often appear as the solutions to boundary value problems in electromagnetic theory and quantum mechanics. In many cases the derivatives of the Airy functions AiryAiPrime[z] and AiryBiPrime[z] also appear.

The Struve function StruveH[n, z] appears in the solution of the inhomogeneous Bessel equation, which for integer has the form ; the general solution to this equation consists of a linear combination of Bessel functions with the Struve function added. The modified Struve function StruveL[n, z] is given in terms of the ordinary Struve function by . Struve functions appear particularly in electromagnetic theory.

Here is a plot of . This is a curve that an idealized chain hanging from one end can form when you wiggle it.
In[16]:=
Click for copyable input
Out[16]=
Mathematica generates explicit formulas for half-integer-order Bessel functions.
In[2]:=
Click for copyable input
Out[2]=
The Airy function plotted here gives the quantum-mechanical amplitude for a particle in a potential that increases linearly from left to right. The amplitude is exponentially damped in the classically inaccessible region on the right.
In[17]:=
Click for copyable input
Out[17]=
BesselJZero[n,k]the ^(th) zero of the Bessel function
BesselJZero[n,k,x0]the ^(th) zero greater than
BesselYZero[n,k]the ^(th) zero of the Bessel function
BesselYZero[n,k,x0]the ^(th) zero greater than
AiryAiZero[k]the ^(th) zero of the Airy function
AiryAiZero[k,x0]the ^(th) zero less than
AiryBiZero[k]the ^(th) zero of the Airy function
AiryBiZero[k,x0]the ^(th) zero less than

Zeros of Bessel and Airy functions.

BesselJZero[1, 5] represents the fifth zero of .
In[18]:=
Click for copyable input
Out[18]=
This gives its numerical value.
In[19]:=
Click for copyable input
Out[19]=

Legendre and Related Functions

LegendreP[n,z]Legendre functions of the first kind
LegendreP[n,m,z]associated Legendre functions of the first kind
LegendreQ[n,z]Legendre functions of the second kind
LegendreQ[n,m,z]associated Legendre functions of the second kind

Legendre and related functions.

The Legendre functions and associated Legendre functions satisfy the differential equation . The Legendre functions of the first kind, LegendreP[n, z] and LegendreP[n, m, z], reduce to Legendre polynomials when and are integers. The Legendre functions of the second kind LegendreQ[n, z] and LegendreQ[n, m, z] give the second linearly independent solution to the differential equation. For integer they have logarithmic singularities at . The and solve the differential equation with .

Legendre functions arise in studies of quantum-mechanical scattering processes.

LegendreP[n,m,z] or LegendreP[n,m,1,z]
type 1 function containing
LegendreP[n,m,2,z]type 2 function containing
LegendreP[n,m,3,z]type 3 function containing

Types of Legendre functions. Analogous types exist for LegendreQ.

Legendre functions of type 1 and Legendre functions of type 2 have different symbolic forms, but the same numerical values. They have branch cuts from to and from to . Legendre functions of type 3, sometimes denoted and , have a single branch cut from to .

Toroidal functions or ring functions, which arise in studying systems with toroidal symmetry, can be expressed in terms of the Legendre functions and .

Conical functions can be expressed in terms of and .

When you use the function LegendreP[n, x] with an integer , you get a Legendre polynomial. If you take to be an arbitrary complex number, you get, in general, a Legendre function.

In the same way, you can use the functions GegenbauerC and so on with arbitrary complex indices to get Gegenbauer functions, Chebyshev functions, Hermite functions, Jacobi functions and Laguerre functions. Unlike for associated Legendre functions, however, there is no need to distinguish different types in such cases.

Hypergeometric Functions and Generalizations

Hypergeometric0F1[a,z]hypergeometric function
Hypergeometric0F1Regularized[a,z]regularized hypergeometric function
Hypergeometric1F1[a,b,z]Kummer confluent hypergeometric function
Hypergeometric1F1Regularized[a,b,z]regularized confluent hypergeometric function
HypergeometricU[a,b,z]confluent hypergeometric function
WhittakerM[k,m,z]andWhittakerW[k,m,z]
Whittaker functions and
ParabolicCylinderD[,z]parabolic cylinder function

Confluent hypergeometric functions and related functions.

Many of the special functions that have been discussed so far can be viewed as special cases of the confluent hypergeometric function Hypergeometric1F1[a, b, z].

The confluent hypergeometric function can be obtained from the series expansion . Some special results are obtained when and are both integers. If , and either or , the series yields a polynomial with a finite number of terms.

If is zero or a negative integer, then itself is infinite. But the regularized confluent hypergeometric function Hypergeometric1F1Regularized[a, b, z] given by has a finite value in all cases.

Among the functions that can be obtained from are the Bessel functions, error function, incomplete gamma function, and Hermite and Laguerre polynomials.

The function is sometimes denoted or . It is often known as the Kummer function.

The function can be written in the integral representation .

The confluent hypergeometric function is a solution to Kummer's differential equation , with the boundary conditions and .

The function HypergeometricU[a, b, z] gives a second linearly independent solution to Kummer's equation. For this function behaves like for small . It has a branch cut along the negative real axis in the complex plane.

The function has the integral representation .

, like , is sometimes known as the Kummer function. The function is sometimes denoted by .

The Whittaker functions WhittakerM[k, m, z] and WhittakerW[k, m, z] give a pair of solutions to the normalized Kummer differential equation, known as Whittaker's differential equation. The Whittaker function is related to by . The second Whittaker function obeys the same relation, with replaced by .

The parabolic cylinder functions ParabolicCylinderD[, z] are related to the Hermite functions by .

The Coulomb wave functions are also special cases of the confluent hypergeometric function. Coulomb wave functions give solutions to the radial Schrödinger equation in the Coulomb potential of a point nucleus. The regular Coulomb wave function is given by , where .

Other special cases of the confluent hypergeometric function include the Toronto functions , Poisson-Charlier polynomials , Cunningham functions , and Bateman functions .

A limiting form of the confluent hypergeometric function that often appears is Hypergeometric0F1[a, z]. This function is obtained as the limit .

The function has the series expansion and satisfies the differential equation .

Bessel functions of the first kind can be expressed in terms of the function.

Hypergeometric2F1[a,b,c,z]hypergeometric function
Hypergeometric2F1Regularized[a,b,c,z]
regularized hypergeometric function
HypergeometricPFQ[{a1,...,ap},{b1,...,bq},z]
generalized hypergeometric function
HypergeometricPFQRegularized[{a1,...,ap},{b1,...,bq},z]
regularized generalized hypergeometric function
MeijerG[{{a1,...,an},{an+1,...,ap}},{{b1,...,bm},{bm+1,...,bq}},z]
Meijer G function
AppellF1[a,b1,b2,c,x,y]Appell hypergeometric function of two variables

Hypergeometric functions and generalizations.

The hypergeometric function Hypergeometric2F1[a, b, c, z] has series expansion . The function is a solution of the hypergeometric differential equation .

The hypergeometric function can also be written as an integral: .

The hypergeometric function is also sometimes denoted by , and is known as the Gauss series or the Kummer series.

The Legendre functions, and the functions that give generalizations of other orthogonal polynomials, can be expressed in terms of the hypergeometric function. Complete elliptic integrals can also be expressed in terms of the function.

The Riemann P function, which gives solutions to Riemann's differential equation, is also a function.

The generalized hypergeometric function or Barnes extended hypergeometric function HypergeometricPFQ[{a1, ..., ap}, {b1, ..., bq}, z] has series expansion .

The Meijer G function MeijerG[{{a1, ..., an}, {an+1, ..., ap}}, {{b1, ..., bm}, {bm+1, ..., bq}}, z] is defined by the contour integral representation , where the contour of integration is set up to lie between the poles of and the poles of . MeijerG is a very general function whose special cases cover most of the functions discussed in the past few sections.

The Appell hypergeometric function of two variables AppellF1[a, b1, b2, c, x, y] has series expansion . This function appears for example in integrating cubic polynomials to arbitrary powers.

The q-Series and Related Functions

QPochhammer[z,q]-Pochhammer symbol TemplateBox[{z, q}, QPochhammer2]
QPochhammer[z,q,n]-Pochhammer symbol TemplateBox[{z, q, n}, QPochhammer]
QFactorial[z,q]-analog of factorial
QBinomial[n,m,q]-analog of binomial coefficient
QGamma[z,q]-analog of Euler gamma function TemplateBox[{z, q}, QGamma]
QPolyGamma[z,q]-digamma function
QPolyGamma[n,z,q]^(th) derivative of the -digamma function
QHypergeometricPFQ[{a1,...,ap},{b1,...,bq},q,z]
basic hypergeometric series

-series and related functions.

The -Pochhammer symbol is a natural object in the calculus of -differences, playing the same role as the power function in infinitesimal calculus or the falling factorial in the calculus of finite differences.

The finite -Pochhammer symbol TemplateBox[{z, q, n}, QPochhammer] is defined as the product . The limit defines the -Pochhammer symbol TemplateBox[{z, q}, QPochhammer2] when TemplateBox[{q}, Abs]<1. The -Pochhammer symbol TemplateBox[{z, q, n}, QPochhammer] is the -analog of the Pochhammer TemplateBox[{a, n}, Pochhammer] symbol, which is recovered in the limit TemplateBox[{a, n}, Pochhammer]=lim_(q->1) TemplateBox[{{q, ^, a}, q, n}, QPochhammer]/(1-q)^n.

The -factorial TemplateBox[{z, q}, QFactorial] is defined as TemplateBox[{q, q, z}, QPochhammer]/(1-q)^z and is a -analog of the factorial function, which is recovered as . The relationship TemplateBox[{z, q}, QFactorial]=TemplateBox[{{z, +, 1}, q}, QGamma] between the -factorial and the -gamma functions has the same functional form as the relationship z!=TemplateBox[{{z, +, 1}}, Gamma] between the factorial and the Euler gamma function.

The -digamma function is defined as the logarithmic derivative of the -gamma function  TemplateBox[{z, q}, QPolyGamma]=1/(TemplateBox[{z, q}, QGamma])(partialTemplateBox[{z, q}, QGamma])/(partialz). The -polygamma function TemplateBox[{n, z, q}, QPolyGamma3] of order is defined as the ^(th) derivative with respect to of the -digamma function.

The basic hypergeometric series is a -analog of the generalized hypergeometric series. It was introduced by Heine as a -analog of Gauss hypergeometric series and arises in combinatorics.

The Product Log Function

ProductLog[z]product log function

The product log function.

The product log function gives the solution for in . The function can be viewed as a generalization of a logarithm. It can be used to represent solutions to a variety of transcendental equations. The tree generating function for counting distinct oriented trees is related to the product log by .

New to Mathematica? Find your learning path »
Have a question? Ask support »