Combinatorial Functions
n!  factorial n (n1) (n2)×...×1 
n!!  double factorial n (n2) (n4)×... 
Binomial[n,m]  binomial coefficient 
Multinomial[n_{1},n_{2},...]  multinomial coefficient (n_{1}+n_{2}+...)!/ (n_{1}!n_{2}!...) 
CatalanNumber[n]  Catalan number c_{n} 
Subfactorial[n]  number of derangements of n objects 
Fibonacci[n]  Fibonacci number F_{n} 
Fibonacci[n,x]  Fibonacci polynomial F_{n} (x) 
LucasL[n]  Lucas number L_{n} 
HarmonicNumber[n]  harmonic number H_{n} 
HarmonicNumber[n,r]  harmonic number of order r 
BernoulliB[n]  Bernoulli number B_{n} 
BernoulliB[n,x]  Bernoulli polynomial B_{n} (x) 
NorlundB[n,a]  Nörlund polynomial 
NorlundB[n,a,x]  generalized Bernoulli polynomial 
EulerE[n]  Euler number E_{n} 
EulerE[n,x]  Euler polynomial E_{n} (x) 
StirlingS1[n,m]  Stirling number of the first kind 
StirlingS2[n,m]  Stirling number of the second kind 
BellB[n]  Bell number B_{n} 
BellB[n,x]  Bell polynomial B_{n} (x) 
PartitionsP[n]  the number p (n) of unrestricted partitions of the integer n 
IntegerPartitions[n]  partitions of an integer 
PartitionsQ[n]  the number q (n) of partitions of n into distinct parts 
Signature[{i_{1},i_{2},...}]  the signature of a permutation 
Combinatorial functions.
The factorial function
n! gives the number of ways of ordering
n objects. For noninteger
n, the numerical value of
n! 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
m objects from a collection of
n 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
n objects that leave no object fixed. Such a permutation is called a derangement. The subfactorial is given by
n! (1)^{k}/k!.
The multinomial coefficient
Multinomial[n_{1}, n_{2}, ...], denoted
(N;n_{1}, n_{2}, ..., n_{m})=N!/ (n_{1}!n_{2}!... n_{m}!), gives the number of ways of partitioning
N distinct objects into
m sets of sizes
n_{i} (with
N=n_{i}).
Mathematica gives the exact integer result for the factorial of an integer.
Out[1]=  

For nonintegers, Mathematica evaluates factorials using the gamma function.
Out[2]=  

Mathematica can give symbolic results for some binomial coefficients.
Out[3]=  

This gives the number of ways of partitioning 6+5=11 objects into sets containing 6 and 5 objects.
Out[4]=  

The result is the same as .
Out[5]=  

The Fibonacci numbers
Fibonacci[n] satisfy the recurrence relation
F_{n}=F_{n1}+F_{n2} with
F_{1}=F_{2}=1. They appear in a wide range of discrete mathematical problems. For large
n,
F_{n}/F_{n1} approaches the golden ratio. The Lucas numbers
LucasL[n] satisfy the same recurrence relation as the Fibonacci numbers do, but with initial conditions
L_{1}=1 and
L_{2}=3.
The Fibonacci polynomials
Fibonacci[n, x] appear as the coefficients of
t^{n} in the expansion of
t/ (1xtt^{2})=F_{n} (x)t^{n} .
The harmonic numbers
HarmonicNumber[n] are given by
H_{n}=1/i; the harmonic numbers of order
r 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
te^{x t}/ (e^{t}1)=B_{n} (x)t^{n}/n! . The Bernoulli numbers
BernoulliB[n] are given by
B_{n}=B_{n} (0). The
B_{n} 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
G_{n}=2 (12^{n})B_{n}.
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
2e^{x t}/ (e^{t}+1)=E_{n} (x)t^{n}/n! , 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
a=1. For other positive integer values of
a, the Nörlund polynomials give higherorder Bernoulli numbers. The generalized Bernoulli polynomials
NorlundB[n, a, x] satisfy the generating function relation
.
This gives the second Bernoulli polynomial B_{2} (x).
Out[6]=  

You can also get Bernoulli polynomials by explicitly computing the power series for the generating function.
Out[7]=  

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
n elements which contain exactly
m cycles. These Stirling numbers satisfy the generating function relation
. Note that some definitions of the
differ by a factor
(1)^{nm} from what is used in
Mathematica.
Stirling numbers of the second kind
StirlingS2[n, m], sometimes denoted
, give the number of ways of partitioning a set of
n elements into
m nonempty subsets. They satisfy the relation
.
The Bell numbers
BellB[n] give the total number of ways that a set of
n 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
n as a sum of positive integers, without regard to order.
PartitionsQ[n] gives the number of ways of writing
n 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
n, with length
PartitionsP[n].
This gives a table of Stirling numbers of the first kind.
Out[9]=  

The Stirling numbers appear as coefficients in this product.
Out[10]=  

This gives the number of partitions of 100, with and without the constraint that the terms should be distinct.
Out[13]=  

The partition function p (n) 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.
Out[14]=  

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[{i_{1}, i_{2}, ...}] gives the signature of a permutation. It is equal to
+1 for even permutations (composed of an even number of transpositions), and to
1 for odd permutations. The signature function can be thought of as a totally antisymmetric tensor, LeviCivita symbol or epsilon symbol.
ClebschGordan[{j_{1},m_{1}},{j_{2},m_{2}},{j,m}]  ClebschGordan coefficient 
ThreeJSymbol[{j_{1},m_{1}},{j_{2},m_{2}},{j_{3},m_{3}}]  Wigner 3j symbol 
SixJSymbol[{j_{1},j_{2},j_{3}},{j_{4},j_{5},j_{6}}]  Racah 6j symbol 
Rotational coupling coefficients.
ClebschGordan coefficients and
nj symbols arise in the study of angular momenta in quantum mechanics, and in other applications of the rotation group. The ClebschGordan coefficients
ClebschGordan[{j_{1}, m_{1}}, {j_{2}, m_{2}}, {j, m}] give the coefficients in the expansion of the quantum mechanical angular momentum state
j, m in terms of products of states
j_{1}, m_{1} j_{2}, m_{2}.
The 3j symbols or Wigner coefficients
ThreeJSymbol[{j_{1}, m_{1}}, {j_{2}, m_{2}}, {j_{3}, m_{3}}] are a more symmetrical form of ClebschGordan coefficients. In
Mathematica, the ClebschGordan coefficients are given in terms of 3j symbols by
.
The 6j symbols
SixJSymbol[{j_{1}, j_{2}, j_{3}}, {j_{4}, j_{5}, j_{6}}] 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.
Out[15]=  
