Mathematical Functions

Naming Conventions
Mathematical functions in the Wolfram Language are given names according to definite rules. As with most Wolfram Language functions, the names are usually complete English words, fully spelled out. For a few very common functions, the Wolfram Language uses the traditional abbreviations. Thus the modulo function, for example, is Mod, not Modulo.
Mathematical functions that are usually referred to by a person's name have names in the Wolfram Language of the form PersonSymbol. Thus, for example, the Legendre polynomials are denoted LegendreP[n,x]. Although this convention does lead to longer function names, it avoids any ambiguity or confusion.
When the standard notation for a mathematical function involves both subscripts and superscripts, the subscripts are given before the superscripts in the Wolfram Language form. Thus, for example, the associated Legendre polynomials are denoted LegendreP[n,m,x].
Generic and NonGeneric Cases
This gives a result for the integral of that is valid for almost all values of :
For the special case of , however, the correct result is different:
The overall goal of symbolic computation is typically to get formulas that are valid for many possible values of the variables that appear in them. It is however often not practical to try to get formulas that are valid for absolutely every possible value of each variable.
The Wolfram Language always replaces by :
If is equal to 0, however, then the true result is not 0:
This construct treats both cases, but would be quite unwieldy to use:
If the Wolfram Language did not automatically replace by 0, then few symbolic computations would get very far. But you should realize that the practical necessity of making such replacements can cause misleading results to be obtained when exceptional values of parameters are used.
The basic operations of the Wolfram Language are nevertheless carefully set up so that whenever possible the results obtained will be valid for almost all values of each variable.
is not automatically replaced by :
If it were, then the result here would be , which is incorrect:
This makes the assumption that is a positive real variable, and does the replacement:
Numerical Functions
integer part of x
fractional part of x
integer x closest to x
greatest integer x not larger than x
least integer x not smaller than x
rational number approximation to x
rational approximation within tolerance dx
Functions relating real numbers and integers.
Extracting integer and fractional parts.
IntegerPart[x] and FractionalPart[x] can be thought of as extracting digits to the left and right of the decimal point. Round[x] is often used for forcing numbers that are close to integers to be exactly integers. Floor[x] and Ceiling[x] often arise in working out how many elements there will be in sequences of numbers with noninteger spacings.
1 for x>0, -1 for x<0
1 for x0, 0 for x<0
absolute value x of x
x clipped to be between -1 and +1
x rescaled to run from 0 to 1
the maximum of x1, x2,
the minimum of x1, x2,
Numerical functions of real variables.
the complex number x+iy
the real part Re z
the imaginary part Im z
the complex conjugate z* or
the absolute value z
the argument ϕ such that z=zeiϕ
the complex sign z/z for z0
Numerical functions of complex variables.
Piecewise Functions
give 1 if expr is True, and 0 if it is False
Turning conditions into numbers.
Boole[expr] is a basic function that turns True and False into 1 and 0. It is sometimes known as the characteristic function or indicator function.
This gives the area of a unit disk:
give the first vali for which condi is True
give val if all condi are False
Piecewise functions.
It is often convenient to have functions with different forms in different regions. You can do this using Piecewise.
This plots a piecewise function:
Piecewise functions appear in systems where there is discrete switching between different domains. They are also at the core of many computational methods, including splines and finite elements. Special cases include such functions as RealAbs, UnitStep, Clip, RealSign, Floor, and Max. The Wolfram Language handles piecewise functions in both symbolic and numerical situations.
This generates a square wave:
Here is the integral of the square wave:
Pseudorandom Numbers
The Wolfram Language has three functions for generating pseudorandom numbers that are distributed uniformly over a range of values.
0 or 1 with probability
an integer between imin and imax, inclusive
an integer between 0 and imax, inclusive
RandomReal[ ]
a real number between 0 and 1
RandomReal[{xmin, xmax}]
a real number between xmin and xmax
a real number between 0 and xmax
a complex number in the unit square
a complex number in the rectangle defined by zmin and zmax
a complex number in the rectangle defined by 0 and zmax
Pseudorandom number generation.
a list of n pseudorandom numbers from the given range
an n1×n2× array of pseudorandom numbers
Generating tables of pseudorandom numbers.
This will give 0 or 1 with equal probability:
This gives a pseudorandom complex number:
This gives a list of 10 pseudorandom integers between 0 and 9 (inclusive):
This gives a matrix of pseudorandom reals between 0 and 1:
RandomReal and RandomComplex allow you to obtain pseudorandom numbers with any precision.
option name
default value
precision to use for real or complex numbers
Changing the precision for pseudorandom numbers.
Here is a 30digit pseudorandom real number in the range 0 to 1:
Here is a list of four 20-digit pseudorandom complex numbers:
If you get arrays of pseudorandom numbers repeatedly, you should get a "typical" sequence of numbers, with no particular pattern. There are many ways to use such numbers.
One common way to use pseudorandom numbers is in making numerical tests of hypotheses. For example, if you believe that two symbolic expressions are mathematically equal, you can test this by plugging in "typical" numerical values for symbolic parameters, and then comparing the numerical results. (If you do this, you should be careful about numerical accuracy problems and about functions of complex variables that may not have unique values.)
Here is a symbolic equation:
Substituting in a random numerical value shows that the equation is not always True:
Other common uses of pseudorandom numbers include simulating probabilistic processes, and sampling large spaces of possibilities. The pseudorandom numbers that the Wolfram Language generates for a range of numbers are always uniformly distributed over the range you specify.
RandomInteger, RandomReal, and RandomComplex are unlike almost any other Wolfram Language functions in that every time you call them, you potentially get a different result. If you use them in a calculation, therefore, you may get different answers on different occasions.
The sequences that you get from RandomInteger, RandomReal, and RandomComplex are not in most senses "truly random", although they should be "random enough" for practical purposes. The sequences are in fact produced by applying a definite mathematical algorithm, starting from a particular "seed". If you give the same seed, then you get the same sequence.
When the Wolfram Language starts up, it takes the time of day (measured in small fractions of a second) as the seed for the pseudorandom number generator. Two different Wolfram Language sessions will therefore almost always give different sequences of pseudorandom numbers.
If you want to make sure that you always get the same sequence of pseudorandom numbers, you can explicitly give a seed for the pseudorandom generator, using SeedRandom.
reseed the pseudorandom generator, with the time of day
reseed with the integer s
Pseudorandom number generator seed.
This reseeds the pseudorandom generator:
Here are three pseudorandom numbers:
If you reseed the pseudorandom generator with the same seed, you get the same sequence of pseudorandom numbers:
Every single time RandomInteger, RandomReal, or RandomComplex is called, the internal state of the pseudorandom generator that it uses is changed. This means that subsequent calls to these functions made in subsidiary calculations will have an effect on the numbers returned in your main calculation. To avoid any problems associated with this, you can localize this effect of their use by doing the calculation inside of BlockRandom.
evaluates expr with the current state of the pseudorandom generators localized
Localizing the effects of using RandomInteger, RandomReal, or RandomComplex.
By localizing the calculation inside BlockRandom, the internal state of the pseudorandom generator is restored after generating the first list:
Many applications require random numbers from nonuniform distributions. The Wolfram Language has many distributions built into the system. You can give a distribution with appropriate parameters instead of a range to RandomInteger or RandomReal.
a pseudorandom number distributed by the random distribution dist
a list of n pseudorandom numbers distributed by the random distribution dist
an n1×n2× array of pseudorandom numbers distributed by the random distribution dist
Generating pseudorandom numbers with non-uniform distributions.
This generates 12 integers distributed by the Poisson distribution with mean 3:
This generates a 4×4 matrix of real numbers using the standard normal distribution:
This generates five high-precision real numbers distributed normally with mean 2 and standard deviation 4:
An additional use of pseudorandom numbers is for selecting from a list. RandomChoice selects with replacement and RandomSample samples without replacement.
RandomChoice[list, n]
choose n items at random from list
an n1×n2× array of values chosen randomly from list
RandomSample[list, n]
a sample of size n from list
Selecting at random.
Choose 10 items at random from the digits 0 through 9:
Chances are very high that at least one of the choices was repeated in the output. That is because when an element is chosen, it is immediately replaced. On the other hand, if you want to select from an actual set of elements, there should be no replacement.
Sample 10 items at random from the digits 0 through 9 without replacement. The result is a random permutation of the digits:
Sample 10 items from a set having different frequencies for each digit:
Integer and Number Theoretic Functions
k modulo n (remainder from dividing k by n)
the quotient of m and n (truncation of m/n)
a list of the quotient and the remainder
test whether m is divisible by n
test whether the ni are pairwise relatively prime
the greatest common divisor of n1, n2,
the least common multiple of n1, n2,
the Kronecker delta equal to 1 if all the ni are equal, and 0 otherwise
the digits of n in base b
the highest power of b that divides n
Some integer functions.
The remainder on dividing 17 by 3:
The integer part of 17/3:
Mod also works with real numbers:
The result from Mod always has the same sign as the second argument:
For any integers a and b, it is always true that b*Quotient[a,b]+Mod[a,b] is equal to a.
result in the range 0 to n-1
result in the range 1 to n
result in the range -n/2 to +n/2
result in the range d to d+n-1
Integer remainders with offsets.
Particularly when you are using Mod to get indices for parts of objects, you will often find it convenient to specify an offset.
This effectively extracts the 18 th part of the list, with the list treated cyclically:
The greatest common divisor function GCD[n1,n2,] gives the largest integer that divides all the ni exactly. When you enter a ratio of two integers, the Wolfram Language effectively uses GCD to cancel out common factors and give a rational number in lowest terms.
The least common multiple function LCM[n1,n2,] gives the smallest integer that contains all the factors of each of the ni.
The largest integer that divides both 24 and 15 is 3:
The Kronecker delta function KroneckerDelta[n1,n2,] is equal to 1 if all the ni are equal, and is 0 otherwise. can be thought of as a totally symmetric tensor.
This gives a totally symmetric tensor of rank 3:
a list of the prime factors of n, and their exponents
a list of the integers that divide n
the k th prime number
the number of primes less than or equal to x
give True if n is a prime, and False otherwise
the number of distinct primes in n
the number of prime factors counting multiplicities in n
the Liouville function
the von Mandgoldt function
a list of the Gaussian prime factors of the Gaussian integer n, and their exponents
give True if n is a Gaussian prime, and False otherwise
Integer factoring and related functions.
This gives the factors of 24 as , . The first element in each list is the factor; the second is its exponent:
Here are the factors of a larger integer:
You should realize that according to current mathematical thinking, integer factoring is a fundamentally difficult computational problem. As a result, you can easily type in an integer that the Wolfram Language will not be able to factor in anything short of an astronomical length of time. But as long as the integers you give are less than about 50 digits long, FactorInteger should have no trouble. And in special cases it will be able to deal with much longer integers.
Here is a rather special long integer:
The Wolfram Language can easily factor this special integer:
Although the Wolfram Language may not be able to factor a large integer, it can often still test whether or not the integer is a prime. In addition, the Wolfram Language has a fast way of finding the th prime number.
It is often much faster to test whether a number is prime than to factor it:
Here is a plot of the first 100 primes:
This is the millionth prime:
Particularly in number theory, it is often more important to know the distribution of primes than their actual values. The function PrimePi[x] gives the number of primes that are less than or equal to .
This gives the number of primes less than a billion:
PrimeNu gives the number of distinct primes in the factorization of n:
PrimeOmega gives the number of prime factors counting multiplicities in n:
Liouville's function gives where is the number of prime factors counting multiplicity:
The Mangoldt function returns the log of prime power base or zero when composite:
By default, FactorInteger allows only real integers. But with the option setting GaussianIntegers->True, it also handles Gaussian integers, which are complex numbers with integer real and imaginary parts. Just as it is possible to factor uniquely in terms of real primes, it is also possible to factor uniquely in terms of Gaussian primes. There is nevertheless some potential ambiguity in the choice of Gaussian primes. In the Wolfram Language, they are always chosen to have positive real parts, and nonnegative imaginary parts, except for a possible initial factor of or .
Over the Gaussian integers, 2 can be factored as :
Here are the factors of a Gaussian integer:
the power ab modulo n
the Dirichlet character
the Euler totient function
the Möbius function
the divisor function
the sum of form[i] for all i that divide n
the sum for only those divisors for which cond[i] gives True
the Jacobi symbol
the extended GCD of n1, n2,
the multiplicative order of k modulo n
the generalized multiplicative order with residues ri
the Carmichael function
a primitive root of n
Some functions from number theory.
The modular power function PowerMod[a,b,n] gives exactly the same results as Mod[a^b,n] for b>0. PowerMod is much more efficient, however, because it avoids generating the full form of a^b.
You can use PowerMod not only to find positive modular powers, but also to find modular inverses. For negative b, PowerMod[a,b,n] gives, if possible, an integer such that . (Whenever such an integer exists, it is guaranteed to be unique modulo n.) If no such integer exists, the Wolfram Language leaves PowerMod unevaluated.
PowerMod is equivalent to using Power, then Mod, but is much more efficient:
This gives the modular inverse of 3 modulo 7:
Multiplying the inverse by 3 modulo 7 gives 1, as expected:
This finds the smallest nonnegative integer so that is equal to 3 mod 11:
This verifies the result:
This returns all integers less than 11 which satisfy the relation:
If d does not have a square root modulo n, PowerMod[d,n] will remain unevaluated and PowerModList will return an empty list:
This checks that 3 is not a square modulo 5:
Even for a large modulus, the square root can be computed fairly quickly:
PowerMod[d,n] also works for composite :
There are distinct Dirichlet characters for a given modulus k, as labeled by the index j. Different conventions can give different orderings for the possible characters.
DirichletCharacter works for very large numbers:
The Euler totient function gives the number of integers less than that are relatively prime to . An important relation (Fermat's little theorem) is that for all relatively prime to .
The Möbius function is defined to be if is a product of distinct primes, and if contains a squared factor (other than 1). An important relation is the Möbius inversion formula, which states that if for all , then , where the sums are over all positive integers that divide .
The divisor function is the sum of the th powers of the divisors of . The function gives the total number of divisors of , and is variously denoted , and . The function , equal to the sum of the divisors of , is often denoted .
For prime , :
The result is 1, as guaranteed by Fermat's little theorem:
This gives a list of all the divisors of 24:
gives the total number of distinct divisors of 24:
The function DivisorSum[n,form] represents the sum of form[i] for all i that divide n. DivisorSum[n,form,cond] includes only those divisors for which cond[i] gives True.
This gives a list of sums for the divisors of five positive integers:
This imposes the condition that the value of each divisor i must be less than 6:
The Jacobi symbol JacobiSymbol[n,m] reduces to the Legendre symbol when is an odd prime. The Legendre symbol is equal to zero if is divisible by ; otherwise it is equal to if is a quadratic residue modulo the prime , and to if it is not. An integer relatively prime to is said to be a quadratic residue modulo if there exists an integer such that . The full Jacobi symbol is a product of the Legendre symbols for each of the prime factors such that .
The extended GCD ExtendedGCD[n1,n2,] gives a list where is the greatest common divisor of the , and the are integers such that . The extended GCD is important in finding integer solutions to linear Diophantine equations.
The first number in the list is the GCD of 105 and 196:
The second pair of numbers satisfies :
The multiplicative order function MultiplicativeOrder[k,n] gives the smallest integer such that . Then is known as the order of modulo . The notation is occasionally used.
The generalized multiplicative order function MultiplicativeOrder[k,n,{r1,r2,}] gives the smallest integer such that for some . MultiplicativeOrder[k,n,{-1,1}] is sometimes known as the suborder function of modulo , denoted . MultiplicativeOrder[k,n,{a}] is sometimes known as the discrete log of with respect to the base modulo .
The Carmichael function or least universal exponent gives the smallest integer such that for all integers relatively prime to .
generate the first n terms in the continued fraction representation of x
reconstruct a number from its continued fraction representation
find a rational approximation to x with tolerance dx
Continued fractions.
This generates the first 10 terms in the continued fraction representation for :
This reconstructs the number represented by the list of continued fraction terms:
The result is close to :
This gives directly a rational approximation to :
Continued fractions appear in many number theoretic settings. Rational numbers have terminating continued fraction representations. Quadratic irrational numbers have continued fraction representations that become repetitive.
the complete continued fraction representation for a rational or quadratic irrational number
test whether x is a quadratic irrational
the complete digit sequence for a rational number
the complete digit sequence in base b
Complete representations for numbers.
The continued fraction representation of starts with the term 8, then involves a sequence of terms that repeat forever:
This reconstructs from its continued fraction representation:
This number is a quadratic irrational:
This shows the recurring sequence of decimal digits in 3/7:
FromDigits reconstructs the original number:
Continued fraction convergents are often used to approximate irrational numbers by rational ones. Those approximations alternate from above and below, and converge exponentially in the number of terms. Furthermore, a convergent of a simple continued fraction is better than any other rational approximation with denominator less than or equal to .
give a list of rational approximations of x
give only the first n approximations
Continued fraction convergents.
This gives a list of rational approximations of 101/9801, derived from its continued fraction expansion:
This lists only the first 10 convergents:
This lists successive rational approximations to , until the numerical precision is exhausted:
With an exact irrational number, you have to explicitly ask for a certain number of terms:
a reduced lattice basis for the set of integer vectors vi
the echelon form for the set of integer vectors vi
Functions for integer lattices.
The lattice reduction function LatticeReduce[{v1,v2,}] is used in several kinds of modern algorithms. The basic idea is to think of the vectors of integers as defining a mathematical lattice. Any vector representing a point in the lattice can be written as a linear combination of the form , where the are integers. For a particular lattice, there are many possible choices of the "basis vectors" . What LatticeReduce does is to find a reduced set of basis vectors for the lattice, with certain special properties.
Three unit vectors along the three coordinate axes already form a reduced basis:
This gives the reduced basis for a lattice in fourdimensional space specified by three vectors:
Notice that in the last example, LatticeReduce replaces vectors that are nearly parallel by vectors that are more perpendicular. In the process, it finds some quite short basis vectors.
For a matrix , HermiteDecomposition gives matrices and such that is unimodular, , and is in reduced row echelon form. In contrast to RowReduce, pivots may be larger than 1 because there are no fractions in the ring of integers. Entries above a pivot are minimized by subtracting appropriate multiples of the pivot row.
In this case, the original matrix is recovered because it was in row echelon form:
This satisfies the required identities:
Here the second matrix has some pivots larger than 1, and nonzero entries over pivots:
the number of d digits in the base b representation of n
Digit count function.
Here are the digits in the base 2 representation of the number 77:
This directly computes the number of ones in the base 2 representation:
The plot of the digit count function is selfsimilar:
bitwise AND of the integers ni
bitwise OR of the integers ni
bitwise XOR of the integers ni
bitwise NOT of the integer n
number of binary bits in the integer n
set bit k to 1 in the integer n
get bit k from the integer n
set bit k to 0 in the integer n
shift the integer n to the left by k bits, padding with zeros
shift to the right, dropping the last k bits
Bitwise operations.
Bitwise operations act on integers represented as binary bits. BitAnd[n1,n2,] yields the integer whose binary bit representation has ones at positions where the binary bit representations of all of the ni have ones. BitOr[n1,n2,] yields the integer with ones at positions where any of the ni have ones. BitXor[n1,n2] yields the integer with ones at positions where n1 or n2 but not both have ones. BitXor[n1,n2,] has ones where an odd number of the ni have ones.
This finds the bitwise AND of the numbers 23 and 29 entered in base 2:
Bitwise operations are used in various combinatorial algorithms. They are also commonly used in manipulating bitfields in lowlevel computer languages. In such languages, however, integers normally have a limited number of digits, typically a multiple of 8. Bitwise operations in the Wolfram Language in effect allow integers to have an unlimited number of digits. When an integer is negative, it is taken to be represented in two's complement form, with an infinite sequence of ones on the left. This allows BitNot[n] to be equivalent simply to .
give True if n does not contain a squared factor, False otherwise
Testing for a squared factor.
SquareFreeQ[n] checks to see if n has a square prime factor. This is done by computing MoebiusMu[n] and seeing if the result is zero; if it is, then n is not squarefree, otherwise it is. Computing MoebiusMu[n] involves finding the smallest prime factor q of n. If n has a small prime factor (less than or equal to ), this is very fast. Otherwise, FactorInteger is used to find q.
This product of primes contains no squared factors:
The square number 4 divides 60:
SquareFreeQ can handle large integers:
give the smallest prime larger than n
return a random prime number between min and max
return a random prime number less than or equal to max
return n random prime numbers between min and max
return n random prime numbers less than or equal to max
Finding prime numbers.
NextPrime[n] finds the smallest prime p such that p>n. The algorithm does a direct search using PrimeQ on the odd numbers greater than n.
This gives the next prime after 10:
Even for large numbers, the next prime can be computed rather quickly:
This gives the largest prime less than 34:
For RandomPrime[{min,max}] and RandomPrime[max], a random prime p is obtained by randomly selecting from a prime lookup table if max is small and by a random search of integers in the range if max is large. If no prime exists in the specified range, the input is returned unevaluated with an error message.
Here is a random prime between 10 and 100:
determine whether n is a positive integer power of a rational prime
Testing for involving prime powers.
The algorithm for PrimePowerQ involves first computing the least prime factor p of n and then attempting division by p until either 1 is obtained, in which case n is a prime power, or until division is no longer possible, in which case n is not a prime power.
Here is a number that is a power of a single prime:
Over the GaussianIntegers this is a prime power:
give the smallest non-negative integer r with Mod[r,list2]==list1
Solving simultaneous congruences.
The Chinese remainder theorem states that a certain class of simultaneous congruences always has a solution. ChineseRemainder[list1,list2] finds the smallest nonnegative integer r such that Mod[r,list2] is list1. The solution is unique modulo the least common multiple of the elements of list2.
This means that , , and :
This confirms the result:
Longer lists are still quite fast:
give a primitive root of n, where n is a prime power or twice a prime power
Computing primitive roots.
PrimitiveRoot[n] returns a generator for the group of numbers relatively prime to n under multiplication . This has a generator if and only if n is 2, 4, a power of an odd prime, or twice a power of an odd prime. If n is a prime or prime power, the least positive primitive root will be returned.
Here is a primitive root of 5:
This confirms that it does generate the group:
Here is a primitive root of a prime power:
Here is a primitive root of twice a prime power:
If the argument is composite and not a prime power or twice a prime power, the function does not evaluate:
give the number of representations of an integer n as a sum of d squares
give the distinct representations of the integer n as a sum of k non-negative p th integer powers
Representing an integer as a sum of squares or other powers.
Here are the representations of 101 as a sum of 3 squares:
Combinatorial Functions
double factorial
binomial coefficient
multinomial coefficient
Catalan number
Barnes G-function
number of derangements of objects
Fibonacci number
Fibonacci polynomial
Lucas number
Lucas polynomial
harmonic number
harmonic number of order
Bernoulli number
Bernoulli polynomial
Nörlund polynomial
generalized Bernoulli polynomial
Euler number
Euler polynomial
Stirling number of the first kind
Stirling number of the second kind
Bell number
Bell polynomial
the number of unrestricted partitions of the integer
partitions of an integer
the number of partitions of into distinct parts
the signature of a permutation
Combinatorial functions.
The factorial function gives the number of ways of ordering objects. For noninteger , the numerical value of is obtained from the gamma function, discussed in "Special Functions".
The binomial coefficient Binomial[n,m] can be written as . It gives the number of ways of choosing objects from a collection of objects, without regard to order. The Catalan numbers, which appear in various tree enumeration problems, are given in terms of binomial coefficients as .
The subfactorial Subfactorial[n] gives the number of permutations of objects that leave no object fixed. Such a permutation is called a derangement. The subfactorial is given by .
The multinomial coefficient Multinomial[n1,n2,], denoted , gives the number of ways of partitioning distinct objects into sets of sizes (with ).
The Wolfram Language gives the exact integer result for the factorial of an integer:
For nonintegers, the Wolfram Language evaluates factorials using the gamma function:
The Wolfram Language can give symbolic results for some binomial coefficients:
This gives the number of ways of partitioning objects into sets containing 6 and 5 objects:
The result is the same as :
The Fibonacci numbers Fibonacci[n] satisfy the recurrence relation with . They appear in a wide range of discrete mathematical problems. For large , approaches the golden ratio. The Lucas numbers LucasL[n] satisfy the same recurrence relation as the Fibonacci numbers do, but with initial conditions and .
The Fibonacci polynomials Fibonacci[n,x] appear as the coefficients of in the expansion of .
The harmonic numbers HarmonicNumber[n] are given by ; the harmonic numbers of order HarmonicNumber[n,r] are given by . Harmonic numbers appear in many combinatorial estimation problems, often playing the role of discrete analogs of logarithms.
The Bernoulli polynomials BernoulliB[n,x] satisfy the generating function relation . The Bernoulli numbers BernoulliB[n] are given by . The appear as the coefficients of the terms in the EulerMaclaurin summation formula for approximating integrals. The Bernoulli numbers are related to the Genocchi numbers by .
Numerical values for Bernoulli numbers are needed in many numerical algorithms. You can always get these numerical values by first finding exact rational results using BernoulliB[n], and then applying N.
The Euler polynomials EulerE[n,x] have generating function , and the Euler numbers EulerE[n] are given by .
The Nörlund polynomials NorlundB[n,a] satisfy the generating function relation . The Nörlund polynomials give the Bernoulli numbers when . For other positive integer values of , the Nörlund polynomials give higher-order Bernoulli numbers. The generalized Bernoulli polynomials NorlundB[n,a,x] satisfy the generating function relation .
This gives the second Bernoulli polynomial :
You can also get Bernoulli polynomials by explicitly computing the power series for the generating function:
BernoulliB[n] gives exact rationalnumber results for Bernoulli numbers:
Stirling numbers show up in many combinatorial enumeration problems. For Stirling numbers of the first kind StirlingS1[n,m], gives the number of permutations of elements which contain exactly cycles. These Stirling numbers satisfy the generating function relation . Note that some definitions of the differ by a factor from what is used in the Wolfram Language.
Stirling numbers of the second kind StirlingS2[n,m], sometimes denoted , give the number of ways of partitioning a set of elements into nonempty subsets. They satisfy the relation .
The Bell numbers BellB[n] give the total number of ways that a set of elements can be partitioned into nonempty subsets. The Bell polynomials BellB[n,x] satisfy the generating function relation .
The partition function PartitionsP[n] gives the number of ways of writing the integer as a sum of positive integers, without regard to order. PartitionsQ[n] gives the number of ways of writing as a sum of positive integers, with the constraint that all the integers in each sum are distinct.
IntegerPartitions[n] gives a list of the partitions of , with length PartitionsP[n].
This gives a table of Stirling numbers of the first kind:
The Stirling numbers appear as coefficients in this product:
Here are the partitions of 4:
The number of partitions is given by PartitionsP[4]:
This gives the number of partitions of 100, with and without the constraint that the terms should be distinct:
The partition function increases asymptotically like . Note that you cannot simply use Plot to generate a plot of a function like PartitionsP because the function can only be evaluated with integer arguments:
Most of the functions here allow you to count various kinds of combinatorial objects. Functions like IntegerPartitions and Permutations allow you instead to generate lists of various combinations of elements.
The signature function Signature[{i1,i2,}] gives the signature of a permutation. It is equal to for even permutations (composed of an even number of transpositions), and to for odd permutations. The signature function can be thought of as a totally antisymmetric tensor, LeviCivita symbol or epsilon symbol.
ClebschGordan coefficient
Wigner 3j symbol
Racah 6j symbol
Rotational coupling coefficients.
ClebschGordan coefficients and j symbols arise in the study of angular momenta in quantum mechanics, and in other applications of the rotation group. The ClebschGordan coefficients ClebschGordan[{j1,m1},{j2,m2},{j,m}] give the coefficients in the expansion of the quantum mechanical angular momentum state in terms of products of states .
The 3j symbols or Wigner coefficients ThreeJSymbol[{j1,m1},{j2,m2},{j3,m3}] are a more symmetrical form of ClebschGordan coefficients. In the Wolfram Language, the ClebschGordan coefficients are given in terms of 3j symbols by .
The 6j symbols SixJSymbol[{j1,j2,j3},{j4,j5,j6}] give the couplings of three quantum mechanical angular momentum states. The Racah coefficients are related by a phase to the 6j symbols.
You can give symbolic parameters in 3j symbols:
Elementary Transcendental Functions
exponential function
logarithm to base
logarithm to base 2 and 10
trigonometric functions (with arguments in radians)
inverse trigonometric functions (giving results in radians)
the argument of
hyperbolic functions
inverse hyperbolic functions
sinc function
haversine function
inverse haversine function
Gudermannian function
inverse Gudermannian function
Elementary transcendental functions.
The Wolfram Language gives exact results for logarithms whenever it can. Here is :
You can find the numerical values of mathematical functions to any precision:
This gives a complex number result:
The Wolfram Language can evaluate logarithms with complex arguments:
The arguments of trigonometric functions are always given in radians:
You can convert from degrees by explicitly multiplying by the constant Degree:
Here is a plot of the hyperbolic tangent function. It has a characteristic "sigmoidal" form:
The haversine function Haversine[z] is defined by . The inverse haversine function InverseHaversine[z] is defined by . The Gudermannian function Gudermannian[z] is defined as . The inverse Gudermannian function InverseGudermannian[z] is defined by . The Gudermannian satisfies such relations as . The sinc function Sinc[z] is the Fourier transform of a square signal.
There are a number of additional trigonometric and hyperbolic functions that are sometimes used. The versine function is sometimes encountered in the literature and simply is . The coversine function is defined as . The complex exponential is sometimes written as .
Functions That Do Not Have Unique Values
When you ask for the square root of a number , you are effectively asking for the solution to the equation . This equation, however, in general has two different solutions. Both and are, for example, solutions to the equation . When you evaluate the "function" , however, you usually want to get a single number, and so you have to choose one of these two solutions. A standard choice is that should be positive for . This is what the Wolfram Language function Sqrt[x] does.
The need to make one choice from two solutions means that Sqrt[x] cannot be a true inverse function for x^2. Taking a number, squaring it, and then taking the square root can give you a different number than you started with.
gives , not :
Squaring and taking the square root does not necessarily give you the number you started with:
When you evaluate , there are again two possible answers: and . In this case, however, it is less clear which one to choose.
There is in fact no way to choose so that it is continuous for all complex values of . There has to be a "branch cut"a line in the complex plane across which the function is discontinuous. The Wolfram Language adopts the usual convention of taking the branch cut for to be along the negative real axis.
This gives , not :
The branch cut in Sqrt along the negative real axis means that values of Sqrt[z] with just above and below the axis are very different:
Their squares are nevertheless close:
The discontinuity along the negative real axis is quite clear in this threedimensional picture of the imaginary part of the square root function:
When you find an th root using , there are, in principle, possible results. To get a single value, you have to choose a particular principal root. There is absolutely no guarantee that taking the th root of an th power will leave you with the same number.
This takes the tenth power of a complex number. The result is unique:
There are 10 possible tenth roots. The Wolfram Language chooses one of them. In this case it is not the number whose tenth power you took:
There are many mathematical functions which, like roots, essentially give solutions to equations. The logarithm function and the inverse trigonometric functions are examples. In almost all cases, there are many possible solutions to the equations. Unique "principal" values nevertheless have to be chosen for the functions. The choices cannot be made continuous over the whole complex plane. Instead, lines of discontinuity, or branch cuts, must occur. The positions of these branch cuts are often quite arbitrary. The Wolfram Language makes the most standard mathematical choices for them.
for Re , for Re ( not an integer)
trigonometric functions
hyperbolic functions
Some branchcut discontinuities in the complex plane.
ArcSin is a multiplevalued function, so there is no guarantee that it always gives the "inverse" of Sin:
Values of ArcSin[z] on opposite sides of the branch cut can be very different:
A threedimensional picture, showing the two branch cuts for the function :
Mathematical Constants
: degrees to radians conversion factor
Euler's constant
Catalan's constant
Khinchin's constant
Glaisher's constant
Mathematical constants.
Euler's constant EulerGamma is given by the limit . It appears in many integrals, and asymptotic formulas. It is sometimes known as the EulerMascheroni constant, and denoted .
Catalan's constant Catalan is given by the sum . It often appears in asymptotic estimates of combinatorial functions. It is variously denoted by , , or .
Khinchin's constant Khinchin (sometimes called Khintchine's constant) is given by . It gives the geometric mean of the terms in the continued fraction representation for a typical real number.
Glaisher's constant Glaisher (sometimes called the GlaisherKinkelin constant) satisfies , where is the Riemann zeta function. It appears in various sums and integrals, particularly those involving gamma and zeta functions.
Mathematical constants can be evaluated to arbitrary precision:
Exact computations can also be done with them:
Orthogonal Polynomials
Legendre polynomials
associated Legendre polynomials
spherical harmonics
Gegenbauer polynomials (x)
Chebyshev polynomials and of the first and second kinds
Hermite polynomials
Laguerre polynomials
generalized Laguerre polynomials
Zernike radial polynomials
Jacobi polynomials
Orthogonal polynomials.
Legendre polynomials LegendreP[n,x] arise in studies of systems with threedimensional spherical symmetry. They satisfy the differential equation , and the orthogonality relation for .
The associated Legendre polynomials LegendreP[n,m,x] are obtained from derivatives of the Legendre polynomials according to . Notice that for odd integers , the contain powers of , and are therefore not strictly polynomials. The reduce to when .
The spherical harmonics SphericalHarmonicY[l,m,θ,ϕ] are related to associated Legendre polynomials. They satisfy the orthogonality relation for or , where represents integration over the surface of the unit sphere.
This gives the algebraic form of the Legendre polynomial :
The integral gives zero by virtue of the orthogonality of the Legendre polynomials:
Integrating the square of a single Legendre polynomial gives a nonzero result:
Highdegree Legendre polynomials oscillate rapidly:
The associated Legendre "polynomials" involve fractional powers:
"Special Functions" discusses the generalization of Legendre polynomials to Legendre functions, which can have noninteger degrees:
Gegenbauer polynomials GegenbauerC[n,m,x] can be viewed as generalizations of the Legendre polynomials to systems with dimensional spherical symmetry. They are sometimes known as ultraspherical polynomials.
GegenbauerC[n,0,x] is always equal to zero. GegenbauerC[n,x] is however given by the limit . This form is sometimes denoted .
Series of Chebyshev polynomials are often used in making numerical approximations to functions. The Chebyshev polynomials of the first kind ChebyshevT[n,x] are defined by . They are normalized so that . They satisfy the orthogonality relation for . The also satisfy an orthogonality relation under summation at discrete points in corresponding to the roots of .
The Chebyshev polynomials of the second kind ChebyshevU[n,z] are defined by . With this definition, . The satisfy the orthogonality relation for .
The name "Chebyshev" is a transliteration from the Cyrillic alphabet; several other spellings, such as "Tschebyscheff", are sometimes used.
Hermite polynomials HermiteH[n,x] arise as the quantummechanical wave functions for a harmonic oscillator. They satisfy the differential equation , and the orthogonality relation for . An alternative form of Hermite polynomials sometimes used is (a different overall normalization of the is also sometimes used).
The Hermite polynomials are related to the parabolic cylinder functions or Weber functions by .
This gives the density for an excited state of a quantummechanical harmonic oscillator. The average of the wiggles is roughly the classical physics result:
Generalized Laguerre polynomials LaguerreL[n,a,x] are related to hydrogen atom wave functions in quantum mechanics. They satisfy the differential equation , and the orthogonality relation for . The Laguerre polynomials LaguerreL[n,x] correspond to the special case .
You can get formulas for generalized Laguerre polynomials with arbitrary values of :
Zernike radial polynomials ZernikeR[n,m,x] are used in studies of aberrations in optics. They satisfy the orthogonality relation for .
Jacobi polynomials JacobiP[n,a,b,x] occur in studies of the rotation group, particularly in quantum mechanics. They satisfy the orthogonality relation for . Legendre, Gegenbauer, Chebyshev and Zernike polynomials can all be viewed as special cases of Jacobi polynomials. The Jacobi polynomials are sometimes given in the alternative form .
Special Functions
The Wolfram System 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 the Wolfram System, therefore, you should be sure to look at the definition given here to confirm that it is exactly what you want.
The Wolfram System gives exact results for some values of special functions:
No exact result is known here:
A numerical result, to arbitrary precision, can nevertheless be found:
You can give complex arguments to special functions:
Special functions automatically get applied to each element in a list:
The Wolfram System knows analytic properties of special functions, such as derivatives:
You can use FindRoot to find roots of special functions:
Special functions in the Wolfram System 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

Euler beta function
incomplete beta function
regularized incomplete beta function
Euler gamma function
incomplete gamma function
generalized incomplete gamma function
regularized incomplete gamma function
inverse beta function
inverse gamma function
Pochhammer symbol
digamma function
th derivative of the digamma function
Euler log-gamma function
logarithm of Barnes G-function
Barnes G-function
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. The Wolfram System 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 . The Wolfram System includes a generalized incomplete gamma function Gamma[a,z0,z1] defined as .
The alternative incomplete gamma function can therefore be obtained in the Wolfram System 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. The Wolfram System includes the regularized incomplete beta function BetaRegularized[z,a,b] defined for most arguments by , but taking into account singular cases. The Wolfram System 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 the Wolfram System) 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 the Wolfram System:
Here is a contour plot of the gamma function in the complex plane:

Zeta and Related Functions

Dirichlet L-function
Lerch's transcendent
polylogarithm function
Nielsen generalized polylogarithm function
Ramanujan function
Ramanujan Dirichlet L-function
Ramanujan theta function
Ramanujan Z-function
RiemannSiegel function
RiemannSiegel function
Stieltjes constants
Riemann zeta function
generalized Riemann zeta function
Hurwitz zeta function
HurwitzLerch 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. The Wolfram System 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 RiemannSiegel functions RiemannSiegelZ[t] and RiemannSiegelTheta[t] according to and (for real). Note that the RiemannSiegel 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) (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 :
Here is a three-dimensional picture of the real part of a Dirichlet L-function:
The Wolfram System gives exact results for :
Here is a threedimensional picture of the Riemann zeta function in the complex plane:
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:
This is a plot of the absolute value of the Ramanujan L function on its critical line :
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 Ktheory.
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 FermiDirac distribution in statistical mechanics by .
The Lerch transcendent can also be used to evaluate Dirichlet Lseries that appear in number theory. The basic Lseries has the form , where the "character" is an integer function with period . Lseries 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 HurwitzLerch transcendent HurwitzLerchPhi[z,s,a] generalizes HurwitzZeta[s,a] and is defined by .
the th zero of the zeta function on the critical line
the th zero above height
Zeros of the zeta function.
ZetaZero[1] represents the first nontrivial zero of :
This gives its numerical value:
This gives the first zero with height greater than 15:

Exponential Integral and Related Functions

cosine integral function
hyperbolic cosine integral function
exponential integral En(z)
exponential integral
logarithmic integral
sine integral function
hyperbolic sine integral function
Exponential integral and related functions.
The Wolfram System 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 the Wolfram System 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

error function
generalized error function
complementary error function
imaginary error function
Fresnel integral C(z)
Fresnel integral
inverse error function
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

Airy functions and
derivatives of Airy functions and
Bessel functions and
modified Bessel functions and
Kelvin functions and
Kelvin functions and
Hankel functions and
spherical Bessel functions and
spherical Hankel functions and
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 onethirdinteger 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:
The Wolfram System generates explicit formulas for halfintegerorder Bessel functions:
The Airy function plotted here gives the quantummechanical 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:
the th zero of the Bessel function
the th zero greater than
the th zero of the Bessel function
the th zero greater than
the th zero of the Airy function
the th zero less than
the th zero of the Airy function
the th zero less than
Zeros of Bessel and Airy functions.
BesselJZero[1,5] represents the fifth zero of :
This gives its numerical value:

Legendre and Related Functions

Legendre functions of the first kind
associated Legendre functions of the first kind
Legendre functions of the second kind
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 quantummechanical scattering processes.
type 1 function containing
type 2 function containing
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

hypergeometric function
regularized hypergeometric function
Kummer confluent hypergeometric function
regularized confluent hypergeometric function
confluent hypergeometric function
Whittaker functions and
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 , PoissonCharlier 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.
hypergeometric function
regularized hypergeometric function
generalized hypergeometric function
regularized generalized hypergeometric function
Meijer G function
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

-Pochhammer symbol
-Pochhammer symbol
-analog of factorial
-analog of binomial coefficient
-analog of Euler gamma function
-digamma function
th derivative of the -digamma function
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 is defined as the product . The limit defines the -Pochhammer symbol when <1. The -Pochhammer symbol is the -analog of the Pochhammer symbol, which is recovered in the limit /(1-q)n.
The -factorial is defined as /(1-q)z and is a -analog of the factorial function, which is recovered as . The relationship between the -factorial and the -gamma functions has the same functional form as the relationship z! between the factorial and the Euler gamma function.
The -digamma function is defined as the logarithmic derivative of the -gamma function . The -polygamma function 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

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 .

Spheroidal Functions

radial spheroidal functions and
z derivatives of radial spheroidal functions
angular spheroidal functions and
z derivatives of angular spheroidal functions
spheroidal eigenvalue of degree n and order m
Spheroidal functions.
The radial spheroidal functions SpheroidalS1[n,m,γ,z] and SpheroidalS2[n,m,γ,z] and angular spheroidal functions SpheroidalPS[n,m,γ,z] and SpheroidalQS[n,m,γ,z] appear in solutions to the wave equation in spheroidal regions. Both types of functions are solutions to the equation . This equation has normalizable solutions only when is a spheroidal eigenvalue given by SpheroidalEigenvalue[n,m,γ]. The spheroidal functions also appear as eigenfunctions of finite analogs of Fourier transforms.
SpheroidalS1 and SpheroidalS2 are effectively spheroidal analogs of the spherical Bessel functions and , while SpheroidalPS and SpheroidalQS are effectively spheroidal analogs of the Legendre functions and . corresponds to a prolate spheroidal geometry, while corresponds to an oblate spheroidal geometry.
angular prolate
radial prolate
angular oblate
radial oblate
Many different normalizations for spheroidal functions are used in the literature. The Wolfram System uses the MeixnerSchäfke normalization scheme.
Angular spheroidal functions can be viewed as deformations of Legendre functions:
This plots angular spheroidal functions for various spheroidicity parameters:
Angular spheroidal functions for integers are eigenfunctions of a band-limited Fourier transform:
The Mathieu functions are a special case of spheroidal functions.
An angular spheroidal function with gives Mathieu angular functions:
Elliptic Integrals and Elliptic Functions
Even more so than for other special functions, you need to be very careful about the arguments you give to elliptic integrals and elliptic functions. There are several incompatible conventions in common use, and often these conventions are distinguished only by the specific names given to arguments or by the presence of separators other than commas between arguments.
Amplitude (used by the Wolfram Language, in radians)
Argument (used by the Wolfram Language): related to amplitude by
Delta amplitude :
Coordinate :
Characteristic (used by the Wolfram Language in elliptic integrals of the third kind)
Parameter (used by the Wolfram Language): preceded by , as in
Complementary parameter :
Modulus : preceded by comma, as in ;
Modular angle : preceded by , as in ;
Nome : preceded by comma in functions;
Invariants , (used by the Wolfram Language)
Halfperiods , : , , where
Ratio of periods :
Discriminant :
Parameters of curve , (used by the Wolfram Language)
Coordinate (used by the Wolfram Language): related by
Common argument conventions for elliptic integrals and elliptic functions.
give the amplitude ϕ corresponding to argument u and parameter m
give the nome q corresponding to parameter m
give the parameter m corresponding to nome q
give the invariants {g2,g3} corresponding to the halfperiods {ω,ω}
give the halfperiods {ω,ω} corresponding to the invariants {g2,g3}
Converting between different argument conventions.

Elliptic Integrals

complete elliptic integral of the first kind
elliptic integral of the first kind
complete elliptic integral of the second kind E(m)
elliptic integral of the second kind E(ϕm)
complete elliptic integral of the third kind
elliptic integral of the third kind
Jacobi zeta function
Elliptic integrals.
Integrals of the form , where is a rational function, and is a cubic or quartic polynomial in , are known as elliptic integrals. Any elliptic integral can be expressed in terms of the three standard kinds of LegendreJacobi elliptic integrals.
The elliptic integral of the first kind EllipticF[ϕ,m] is given for by . This elliptic integral arises in solving the equations of motion for a simple pendulum. It is sometimes known as an incomplete elliptic integral of the first kind.
Note that the arguments of the elliptic integrals are sometimes given in the opposite order from what is used in the Wolfram Language.
The complete elliptic integral of the first kind EllipticK[m] is given by . Note that is used to denote the complete elliptic integral of the first kind, while is used for its incomplete form. In many applications, the parameter is not given explicitly, and is denoted simply by . The complementary complete elliptic integral of the first kind is given by . It is often denoted . and give the "real" and "imaginary" quarterperiods of the corresponding Jacobi elliptic functions discussed in "Elliptic Functions".
The elliptic integral of the second kind EllipticE[ϕ,m] is given for by .
The complete elliptic integral of the second kind EllipticE[m] is given by . It is often denoted . The complementary form is .
The Jacobi zeta function JacobiZeta[ϕ,m] is given by .
The Heuman lambda function is given by .
The elliptic integral of the third kind EllipticPi[n,ϕ,m] is given by .
The complete elliptic integral of the third kind EllipticPi[n,m] is given by .
Here is a plot of the complete elliptic integral of the second kind :
Here is with :
The elliptic integrals have a complicated structure in the complex plane:

Elliptic Functions

amplitude function
, etc.
Jacobi elliptic functions , etc.
, etc.
inverse Jacobi elliptic functions , etc.
theta functions (, , )
derivatives of theta functions (, , )
Siegel theta function
Siegel theta function
Weierstrass elliptic function
derivative of Weierstrass elliptic function
inverse Weierstrass elliptic function
Weierstrass sigma function
Weierstrass zeta function
Elliptic and related functions.
Rational functions involving square roots of quadratic forms can be integrated in terms of inverse trigonometric functions. The trigonometric functions can thus be defined as inverses of the functions obtained from these integrals.
By analogy, elliptic functions are defined as inverses of the functions obtained from elliptic integrals.
The amplitude for Jacobi elliptic functions JacobiAmplitude[u,m] is the inverse of the elliptic integral of the first kind. If , then . In working with Jacobi elliptic functions, the argument is often dropped, so is written as .
The Jacobi elliptic functions JacobiSN[u,m] and JacobiCN[u,m] are given respectively by and , where . In addition, JacobiDN[u,m] is given by .
There are a total of twelve Jacobi elliptic functions JacobiPQ[u,m], with the letters P and Q chosen from the set S, C, D and N. Each Jacobi elliptic function JacobiPQ[u,m] satisfies the relation , where for these purposes .
There are many relations between the Jacobi elliptic functions, somewhat analogous to those between trigonometric functions. In limiting cases, in fact, the Jacobi elliptic functions reduce to trigonometric functions. So, for example, , , , , and .
The notation is often used for the integrals . These integrals can be expressed in terms of the Jacobi zeta function defined in "Elliptic Integrals".
One of the most important properties of elliptic functions is that they are doubly periodic in the complex values of their arguments. Ordinary trigonometric functions are singly periodic, in the sense that for any integer . The elliptic functions are doubly periodic, so that for any pair of integers and .
The Jacobi elliptic functions , etc. are doubly periodic in the complex plane. Their periods include and , where is the complete elliptic integral of the first kind.
The choice of "p" and "q" in the notation for Jacobi elliptic functions can be understood in terms of the values of the functions at the quarter periods and .
This shows two complete periods in each direction of the absolute value of the Jacobi elliptic function :
Also built into the Wolfram Language are the inverse Jacobi elliptic functions InverseJacobiSN[v,m], InverseJacobiCN[v,m], etc. The inverse function , for example, gives the value of for which . The inverse Jacobi elliptic functions are related to elliptic integrals.
The four theta functions are obtained from EllipticTheta[a,u,q] by taking a to be 1, 2, 3, or 4. The functions are defined by , , , . The theta functions are often written as with the parameter not explicitly given. The theta functions are sometimes written in the form , where is related to by . In addition, is sometimes replaced by , given by . All the theta functions satisfy a diffusionlike differential equation .
The Siegel theta function SiegelTheta[τ,s] with Riemann square modular matrix of dimension p and vector s generalizes the elliptic theta functions to complex dimension p. It is defined by , where n runs over all p-dimensional integer vectors. The Siegel theta function with characteristic SiegelTheta[ν,τ,s] is defined by , where the characteristic ν is a pair of p-dimensional vectors {α,β}.
The Jacobi elliptic functions can be expressed as ratios of the theta functions.
An alternative notation for theta functions is , , , , where .
The Neville theta functions can be defined in terms of the theta functions as , , , , where . The Jacobi elliptic functions can be represented as ratios of the Neville theta functions.
The Weierstrass elliptic function WeierstrassP[u,{g2,g3}] can be considered as the inverse of an elliptic integral. The Weierstrass function gives the value of for which . The function WeierstrassPPrime[u,{g2,g3}] is given by .
The Weierstrass functions are also sometimes written in terms of their fundamental halfperiods and , obtained from the invariants and using WeierstrassHalfPeriods[{u,{g2,g3}].
The function InverseWeierstrassP[p,{g2,g3}] finds one of the two values of for which . This value always lies in the parallelogram defined by the complex number halfperiods and .
InverseWeierstrassP[{p,q},{g2,g3}] finds the unique value of for which and . In order for any such value of to exist, and must be related by .
The Weierstrass zeta function WeierstrassZeta[u,{g2,g3}] and Weierstrass sigma function WeierstrassSigma[u,{g2,g3}] are related to the Weierstrass elliptic functions by and .
The Weierstrass zeta and sigma functions are not strictly elliptic functions since they are not periodic.

Elliptic Modular Functions

Dedekind eta function
Klein invariant modular function
modular lambda function
Elliptic modular functions.
The modular lambda function ModularLambda[τ] relates the ratio of halfperiods to the parameter according to .
The Klein invariant modular function KleinInvariantJ[τ] and the Dedekind eta function DedekindEta[τ] satisfy the relations .
Modular elliptic functions are defined to be invariant under certain fractional linear transformations of their arguments. Thus for example is invariant under any combination of the transformations and .

Generalized Elliptic Integrals and Functions

the arithmeticgeometric mean of and
generalized exponential associated with the elliptic curve
generalized logarithm associated with the elliptic curve
Generalized elliptic integrals and functions.
The definitions for elliptic integrals and functions given above are based on traditional usage. For modern algebraic geometry, it is convenient to use slightly more general definitions.
The function EllipticLog[{x,y},{a,b}] is defined as the value of the integral , where the sign of the square root is specified by giving the value of such that . Integrals of the form can be expressed in terms of the ordinary logarithm (and inverse trigonometric functions). You can think of EllipticLog as giving a generalization of this, where the polynomial under the square root is now of degree three.
The function EllipticExp[u,{a,b}] is the inverse of EllipticLog. It returns the list {x,y} that appears in EllipticLog. EllipticExp is an elliptic function, doubly periodic in the complex plane.
ArithmeticGeometricMean[a,b] gives the arithmeticgeometric mean (AGM) of two numbers and . This quantity is central to many numerical algorithms for computing elliptic integrals and other functions. For positive reals and the AGM is obtained by starting with , , then iterating the transformation , until to the precision required.
Mathieu and Related Functions
even Mathieu functions with characteristic value a and parameter q
odd Mathieu functions with characteristic value b and parameter q
z derivatives of Mathieu functions
characteristic value ar for even Mathieu functions with characteristic exponent r and parameter q
characteristic value br for odd Mathieu functions with characteristic exponent r and parameter q
characteristic exponent r for Mathieu functions with characteristic value a and parameter q
Mathieu and related functions.
The Mathieu functions MathieuC[a,q,z] and MathieuS[a,q,z] are solutions to the equation . This equation appears in many physical situations that involve elliptical shapes or periodic potentials. The function MathieuC is defined to be even in , while MathieuS is odd.
When the Mathieu functions are simply and . For nonzero , the Mathieu functions are only periodic in for certain values of . Such Mathieu characteristic values are given by MathieuCharacteristicA[r,q] and MathieuCharacteristicB[r,q] with an integer or rational number. These values are often denoted by and .
For integer , the even and odd Mathieu functions with characteristic values and are often denoted and , respectively. Note the reversed order of the arguments and .
According to Floquet's theorem, any Mathieu function can be written in the form , where has period and is the Mathieu characteristic exponent MathieuCharacteristicExponent[a,q]. When the characteristic exponent is an integer or rational number, the Mathieu function is therefore periodic. In general, however, when is not a real integer, and turn out to be equal.
This shows the first five characteristic values as functions of :
Working with Special Functions
automatic evaluation
exact results for specific arguments
numerical approximations to any precision
exact results for derivatives
numerical approximations to derivatives
series expansions
exact results for integrals
numerical approximations to integrals
numerical approximations to roots
Some common operations on special functions.
Most special functions have simpler forms when given certain specific arguments. The Wolfram System will automatically simplify special functions in such cases.
The Wolfram System automatically writes this in terms of standard mathematical constants:
Here again the Wolfram System reduces a special case of the Airy function to an expression involving gamma functions:
For most choices of arguments, no exact reductions of special functions are possible. But in such cases, the Wolfram System allows you to find numerical approximations to any degree of precision. The algorithms that are built into the Wolfram System cover essentially all values of parametersreal and complexfor which the special functions are defined.
There is no exact result known here:
This gives a numerical approximation to 40 digits of precision:
The result here is a huge complex number, but the Wolfram System can still find it:
Most special functions have derivatives that can be expressed in terms of elementary functions or other special functions. But even in cases where this is not so, you can still use N to find numerical approximations to derivatives.
This derivative comes out in terms of elementary functions:
This evaluates the derivative of the gamma function at the point 3:
There is no exact formula for this derivative of the zeta function:
Applying N gives a numerical approximation:
The Wolfram System incorporates a vast amount of knowledge about special functionsincluding essentially all the results that have been derived over the years. You access this knowledge whenever you do operations on special functions in the Wolfram System.
Here is a series expansion for a Fresnel function:
The Wolfram System knows how to do a vast range of integrals involving special functions:
One feature of working with special functions is that there are a large number of relations between different functions, and these relations can often be used in simplifying expressions.
try to simplify expr using a range of transformation rules
Simplifying expressions involving special functions.
This uses the reflection formula for the gamma function:
This makes use of a representation for Chebyshev polynomials:
The Airy functions are related to Bessel functions:
try to expand out special functions
Manipulating expressions involving special functions.
This expands the Gauss hypergeometric function into simpler functions:
Here is an example involving Bessel functions:
In this case the final result does not even involve PolyGamma:
This finds an expression for a derivative of the Hurwitz zeta function: