Combination

56
Combination From Wikipedia, the free encyclopedia

description

1. From Wikipedia, the free encyclopedia2. Lexicographical order

Transcript of Combination

  • CombinationFrom Wikipedia, the free encyclopedia

  • Contents

    1 Combination 11.1 Number of k-combinations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

    1.1.1 Example of counting combinations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31.1.2 Enumerating k-combinations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4

    1.2 Number of combinations with repetition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41.2.1 Example of counting multisubsets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6

    1.3 Number of k-combinations for all k . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 61.4 Probability: sampling a random combination . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71.5 See also . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71.6 Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71.7 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 81.8 External links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

    2 Derangement 92.1 Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102.2 Counting derangements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112.3 Limit of ratio of derangement to permutation as n approaches . . . . . . . . . . . . . . . . . . . 122.4 Generalizations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122.5 Computational complexity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122.6 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 122.7 External links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 13

    3 Factorial 143.1 Denition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143.2 Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153.3 Number theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163.4 Series of reciprocals . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163.5 Rate of growth and approximations for large n . . . . . . . . . . . . . . . . . . . . . . . . . . . . 173.6 Computation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183.7 Extension of factorial to non-integer values of argument . . . . . . . . . . . . . . . . . . . . . . . 19

    3.7.1 The Gamma and Pi functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 193.7.2 Applications of the Gamma function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 213.7.3 Factorial at the complex plane . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

    i

  • ii CONTENTS

    3.7.4 Approximations of factorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223.7.5 Non-extendability to negative integers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 23

    3.8 Factorial-like products and functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233.8.1 Double factorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233.8.2 Multifactorials . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 233.8.3 Primorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243.8.4 Quadruple factorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243.8.5 Superfactorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 243.8.6 Hyperfactorial . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25

    3.9 See also . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263.10 Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 263.11 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 273.12 External links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 27

    4 Partial permutation 284.1 Representation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284.2 Combinatorial enumeration . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284.3 Restricted partial permutations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 294.4 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29

    5 Permutation 305.1 History . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305.2 Denition and one-line notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315.3 Other uses of the term permutation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32

    5.3.1 k-permutations of n . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325.3.2 Permutations with repetition . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325.3.3 Permutations of multisets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 325.3.4 Circular permutations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33

    5.4 Permutations in group theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335.4.1 Cycle notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 335.4.2 Abstract groups vs. permutations vs. group actions . . . . . . . . . . . . . . . . . . . . . 345.4.3 Product and inverse . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 345.4.4 Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 35

    5.5 Permutations of totally ordered sets . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 365.5.1 Ascents, descents, runs and excedances . . . . . . . . . . . . . . . . . . . . . . . . . . . 365.5.2 Canonical cycle notation (aka standard form) . . . . . . . . . . . . . . . . . . . . . . . . 375.5.3 Foatas transition lemma (or the fundamental bijection) . . . . . . . . . . . . . . . . . . . 375.5.4 Inversions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 37

    5.6 Permutations in computing . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385.6.1 Numbering permutations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 385.6.2 Algorithms to generate permutations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 395.6.3 Software implementations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 41

  • CONTENTS iii

    5.6.4 Applications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415.7 See also . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415.8 Notes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 425.9 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445.10 External links . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 445.11 Text and image sources, contributors, and licenses . . . . . . . . . . . . . . . . . . . . . . . . . . 50

    5.11.1 Text . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 505.11.2 Images . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 515.11.3 Content license . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 52

  • Chapter 1

    Combination

    This article is about the mathematics of selecting part of a collection. For other uses, see Combination (disambigua-tion).COMBIN redirects here. For other uses, see Combin (disambiguation).nCr redirects here. For other uses, see NCR (disambiguation).

    In mathematics, a combination is a way of selecting items from a collection, such that (unlike permutations) theorder of selection does not matter. In smaller cases it is possible to count the number of combinations. For examplegiven three fruits, say an apple, an orange and a pear, there are three combinations of two that can be drawn fromthis set: an apple and a pear; an apple and an orange; or a pear and an orange. More formally, a k-combination ofa set S is a subset of k distinct elements of S. If the set has n elements, the number of k-combinations is equal to thebinomial coecient

    n

    k

    =

    n(n 1) : : : (n k + 1)k(k 1) : : : 1 ;

    which can be written using factorials as n!k!(nk)! whenever k n , and which is zero when k > n . The set of allk-combinations of a set S is sometimes denoted by

    Sk

    .

    Combinations refer to the combination of n things taken k at a time without repetition. To refer to combinations inwhich repetition is allowed, the terms k-selection,[1] k-multiset,[2] or k-combination with repetition are often used.[3]If, in the above example, it was possible to have two of any one kind of fruit there would be 3 more 2-selections: onewith two apples, one with two oranges, and one with two pears.Although the set of three fruits was small enough to write a complete list of combinations, with large sets this becomesimpractical. For example, a poker hand can be described as a 5-combination (k = 5) of cards from a 52 card deck(n = 52). The 5 cards of the hand are all distinct, and the order of cards in the hand does not matter. There are2,598,960 such combinations, and the chance of drawing any one hand at random is 1 / 2,598,960.

    1.1 Number of k-combinationsMain article: Binomial coecient

    The number of k-combinations from a given set S of n elements is often denoted in elementary combinatorics textsby C(n; k) , or by a variation such as Cnk , nCk , nCk , Cn;k or even Ckn (the latter form was standard in French,Russian, Chinese[4] and Polish texts). The same number however occurs in many other mathematical contexts, whereit is denoted by

    nk

    (often read as n choose k); notably it occurs as a coecient in the binomial formula, hence its

    name binomial coecient. One can denenk

    for all natural numbers k at once by the relation

    (1 +X)n =P

    k0nk

    Xk;

    1

  • 2 CHAPTER 1. COMBINATION

    3-element subsets of a 5-element set

    from which it is clear thatn0

    =nn

    = 1 and

    nk

    = 0 for k > n. To see that these coecients count k-combinations

    from S, one can rst consider a collection of n distinct variables Xs labeled by the elements s of S, and expand theproduct over all elements of S:

    Qs2S(1 +Xs);

    it has 2n distinct terms corresponding to all the subsets of S, each subset giving the product of the correspondingvariables Xs. Now setting all of the Xs equal to the unlabeled variable X, so that the product becomes (1 + X)n, theterm for each k-combination from S becomes Xk, so that the coecient of that power in the result equals the numberof such k-combinations.Binomial coecients can be computed explicitly in various ways. To get all of them for the expansions up to (1 +X)n, one can use (in addition to the basic cases already given) the recursion relation

    n

    k

    =

    n 1k 1

    +

    n 1k

    ; for 0 < k < n;

    which follows from (1 + X)n = (1 + X)n 1(1 + X); this leads to the construction of Pascals triangle.For determining an individual binomial coecient, it is more practical to use the formula

  • 1.1. NUMBER OF K-COMBINATIONS 3

    n

    k

    =

    n(n 1)(n 2) (n k + 1)k!

    :

    The numerator gives the number of k-permutations of n, i.e., of sequences of k distinct elements of S, while thedenominator gives the number of such k-permutations that give the same k-combination when the order is ignored.When k exceeds n/2, the above formula contains factors common to the numerator and the denominator, and cancelingthem out gives the relation

    n

    k

    =

    n

    n k; for 0 k n:

    This expresses a symmetry that is evident from the binomial formula, and can also be understood in terms of k-combinations by taking the complement of such a combination, which is an (n k)-combination.Finally there is a formula which exhibits this symmetry directly, and has the merit of being easy to remember:

    n

    k

    =

    n!

    k!(n k)! ;

    where n! denotes the factorial of n. It is obtained from the previous formula by multiplying denominator and numer-ator by (n k)!, so it is certainly inferior as a method of computation to that formula.The last formula can be understood directly, by considering the n! permutations of all the elements of S. Each suchpermutation gives a k-combination by selecting its rst k elements. There aremany duplicate selections: any combinedpermutation of the rst k elements among each other, and of the nal (n k) elements among each other producesthe same combination; this explains the division in the formula.From the above formulas follow relations between adjacent numbers in Pascals triangle in all three directions:

    n

    k

    =

    n

    k 1n k + 1

    k; for k > 0

    n

    k

    =

    n 1k

    n

    n k ; for k < nn

    k

    =

    n 1k 1

    n

    k; for n; k > 0

    Together with the basic casesn0

    = 1 =

    nn

    , these allow successive computation of respectively all numbers

    of combinations from the same set (a row in Pascals triangle), of k-combinations of sets of growing sizes, and ofcombinations with a complement of xed size n k.

    1.1.1 Example of counting combinationsAs a concrete example, one can compute the number of ve-card hands possible from a standard fty-two card deckas:[5]

    52

    5

    =

    52 51 50 49 485 4 3 2 1 =

    311;875;200

    120= 2;598;960:

    Alternatively one may use the formula in terms of factorials and cancel the factors in the numerator against parts ofthe factors in the denominator, after which only multiplication of the remaining factors is required:Another alternative computation, equivalent to the rst, is based on writing

    n

    k

    =

    (n 0)1

    (n 1)2

    (n 2)3

    (n (k 1))k

    ;

  • 4 CHAPTER 1. COMBINATION

    which gives

    52

    5

    =

    52

    1 51

    2 50

    3 49

    4 48

    5= 2;598;960:

    When evaluated in the following order, 52 1 51 2 50 3 49 4 48 5, this can be computed using onlyinteger arithmetic. The reason is that when each division occurs, the intermediate result that is produced is itself abinomial coecient, so no remainders ever occur.Using the symmetric formula in terms of factorials without performing simplications gives a rather extensive cal-culation:

    52

    5

    =

    n!

    k!(n k)! =52!

    5!(52 5)! =52!

    5!47!

    = 80;658;175;170;943;878;571;660;636;856;403;766;975;289;505;440;883;277;824;000;000;000;000120258;623;241;511;168;180;642;964;355;153;611;979;969;197;632;389;120;000;000;000= 2;598;960:

    1.1.2 Enumerating k-combinations

    One can enumerate all k-combinations of a given set S of n elements in some xed order, which establishes a bijectionfrom an interval of

    nk

    integers with the set of those k-combinations. Assuming S is itself ordered, for instance S =

    {1,2, ...,n}, there are two natural possibilities for ordering its k-combinations: by comparing their smallest elementsrst (as in the illustrations above) or by comparing their largest elements rst. The latter option has the advantagethat adding a new largest element to S will not change the initial part of the enumeration, but just add the new k-combinations of the larger set after the previous ones. Repeating this process, the enumeration can be extendedindenitely with k-combinations of ever larger sets. If moreover the intervals of the integers are taken to start at0, then the k-combination at a given place i in the enumeration can be computed easily from i, and the bijection soobtained is known as the combinatorial number system. It is also known as rank"/"ranking and unranking incomputational mathematics.[6][7]

    There are many ways to enumerate k combinations. One way is to visit all the binary numbers less than 2n . Chosethose numbers having k nonzero bits. The positions of these 1 bits in such a number is a specic k-combination ofthe set {1,...,n}.[8]

    1.2 Number of combinations with repetitionSee also: Multiset coecientA k-combination with repetitions, or k-multicombination, or multisubset of size k from a set S is given by asequence of k not necessarily distinct elements of S, where order is not taken into account: two sequences of whichone can be obtained from the other by permuting the terms dene the same multiset. In other words, the number ofways to sample k elements from a set of n elements allowing for duplicates (i.e., with replacement) but disregardingdierent orderings (e.g. {2,1,2} = {1,2,2}). Associate an index to each element of S and think of the elements ofS as types of objects, then we can let xi denote the number of elements of type i in a multisubset. The number ofmultisubsets of size k is then the number of nonnegative integer solutions of the Diophantine equation:[9]

    x1 + x2 + : : :+ xn = k:

    If S has n elements, the number of such k-multisubsets is denoted by,

    n

    k

    ;

  • 1.2. NUMBER OF COMBINATIONS WITH REPETITION 5

    Bijection between 3-subsets of a 7-set (left)and 3-multisets with elements from a 5-set (right)So this illustrates that

    73

    =

    53

    .

    a notation that is analogous to the binomial coecient which counts k-subsets. This expression, n multichoose k,[10]is also given by a binomial coecient:

    n

    k

    =

    n+ k 1

    k

    :

    This relationship can be easily seen using a representation known as stars and bars. A solution of the above Dio-phantine equation can be represented by x1 stars, a separator (a bar), then x2 more stars, another separator, andso on. The total number of stars in this representation is k and the number of bars is n - 1 (since no separator isneeded at the very end). Thus, a string of k + n - 1 symbols (stars and bars) corresponds to a solution if there are kstars in the string. Any solution can be represented by choosing k out of k + n - 1 positions to place stars and llingthe remaining positions with bars. For example, the solution x1 = 3; x2 = 2; x3 = 0; x4 = 5 of the equationx1 + x2 + x3 + x4 = 10 can be represented by

  • 6 CHAPTER 1. COMBINATION

    FFFjFFjjFFFFF .[11]

    The number of such strings is the number of ways to place 10 stars in 13 positions,1310

    =133

    = 286; which is the

    number of 10-multisubsets of a set with 4 elements.As with binomial coecients, there are several relationships between these multichoose expressions. For example,for n 1; k 0 ,

    n

    k

    =

    k + 1

    n 1:

    This identity follows from interchanging the stars and bars in the above representation.[12]

    1.2.1 Example of counting multisubsets

    For example, if you have four types of donuts (n = 4) on a menu to choose from and you want three donuts (k = 3),the number of ways to choose the donuts with repetition can be calculated as

    4

    3

    =

    4 + 3 1

    3

    =

    6

    3

    =

    6 5 43 2 1 = 20:

    This result can be veried by listing all the 3-multisubsets of the set S = {1,2,3,4}. This is displayed in the followingtable.[13] The second column shows the nonnegative integer solutions [x1; x2; x3; x4] of the equation x1+x2+x3+x4 = 3 and the last column gives the stars and bars representation of the solutions.[14]

    1.3 Number of k-combinations for all kSee also: Binomial coecient Sum of coecients row

    The number of k-combinations for all k is the number of subsets of a set of n elements. There are several ways tosee that this number is 2n. In terms of combinations,P0kn nk = 2n , which is the sum of the nth row (countingfrom 0) of the binomial coecients in Pascals triangle. These combinations (subsets) are enumerated by the 1 digitsof the set of base 2 numbers counting from 0 to 2n - 1, where each digit position is an item from the set of n.Given 3 cards numbered 1 to 3, there are 8 distinct combinations (subsets), including the empty set:

    jffg; f1g; f2g; f3g; f1; 2g; f1; 3g; f2; 3g; f1; 2; 3ggj = 23 = 8

    Representing these subsets (in the same order) as base 2 numbers:

    0 - 0001 - 0012 - 0104 - 1003 - 0115 - 1016 - 1107 - 111

  • 1.4. PROBABILITY: SAMPLING A RANDOM COMBINATION 7

    1.4 Probability: sampling a random combinationThere are various algorithms to pick out a random combination from a given set or list. Rejection sampling is ex-tremely slow for large sample sizes. One way to select a k-combination eciently from a population of size n isto iterate across each element of the population, and at each step pick that element with a dynamically changingprobability of k# samples chosenn# samples visited . (see reservoir sampling).

    1.5 See also Binomial coecient

    Combinatorial number system

    Combinatorics

    Kneser graph

    List of permutation topics

    Multiset

    Pascals triangle

    Permutation

    Probability

    Subset

    1.6 Notes[1] Ryser 1963, p. 7 also referred to as an unordered selection.

    [2] Mazur 2010, p. 10

    [3] When the term combination is used to refer to either situation (as in (Brualdi 2010)) care must be taken to clarify whethersets or multisets are being discussed.

    [4] High School Textbook for full-time student (Required) Mathematics Book II B (in Chinese) (2nd ed.). China: PeoplesEducation Press. June 2006. pp. 107116. ISBN 978-7-107-19616-4.

    [5] Mazur 2010, p. 21

    [6] http://www.site.uottawa.ca/~{}lucia/courses/5165-09/GenCombObj.pdf

    [7] http://www.sagemath.org/doc/reference/sage/combinat/subset.html

    [8] http://rosettacode.org/wiki/Combinations

    [9] Brualdi 2010, p. 52

    [10] Benjamin & Quinn 2003, p. 70

    [11] Benjamin & Quinn 2003, pp. 71 72

    [12] Benjamin & Quinn 2003, p. 72 (identity 145)

    [13] Benjamin & Quinn 2003, p. 71

    [14] Mazur 2010, p. 10 where the stars and bars are written as binary numbers, with stars = 0 and bars = 1.

  • 8 CHAPTER 1. COMBINATION

    1.7 References Benjamin, Arthur T.; Quinn, Jennifer J. (2003), Proofs that Really Count: The Art of Combinatorial Proof, TheDolciani Mathematical Expositions 27, The Mathematical Association of America, ISBN 978-0-88385-333-7

    Brualdi, Richard A. (2010), Introductory Combinatorics (5th ed.), Pearson Prentice Hall, ISBN 978-0-13-602040-0

    Erwin Kreyszig, Advanced Engineering Mathematics, John Wiley & Sons, INC, 1999. Mazur, David R. (2010), Combinatorics: A Guided Tour, Mathematical Association of America, ISBN 978-0-88385-762-5

    Ryser, Herbert John (1963), Combinatorial Mathematics, The Carus Mathematical Monographs 14, Mathe-matical Association of America

    1.8 External links Topcoder tutorial on combinatorics C code to generate all combinations of n elements chosen as k Many Common types of permutation and combination math problems, with detailed solutions The Unknown Formula For combinations when choices can be repeated and order does NOT matter Combinations with repetitions (by: Akshatha AG and Smitha B) The dice roll with a given sum problem An application of the combinations with repetition to rolling multipledice

  • Chapter 2

    Derangement

    For the psychological condition, see psychosis.In combinatorial mathematics, a derangement is a permutation of the elements of a set, such that no element appears

    0 5 10 15 20 25 n

    y

    1

    10 3

    10 6

    10 9

    1012

    1015

    1018

    1021

    1024

    1027

    1030 y = 10n

    y = n!y = !n

    Number of possible permutations and derangements of n elements. n! (n factorial) is the number of n-permutations; !n (n subfac-torial) is the number of derangements n-permutations where all of the n elements change their initial places.

    9

  • 10 CHAPTER 2. DERANGEMENT

    in its original position.The number of derangements of a set of size n, usually written Dn, dn, or !n, is called the derangement numberor de Montmort number. (These numbers are generalized to rencontres numbers.) The subfactorial function (notto be confused with the factorial n!) maps n to !n.[1] No standard notation for subfactorials is agreed upon; n issometimes used instead of !n.[2]

    The problem of counting derangements was rst considered by Pierre Raymond de Montmort[3] in 1708; he solvedit in 1713, as did Nicholas Bernoulli at about the same time.

    2.1 Example

    The 9 derangements (from 24 permutations) are hightlighted

    Suppose that a professor has had 4 of his students student A, student B, student C, and student D take a test andwants to let his students grade each others tests. Of course, no student should grade his or her own test. How manyways could the professor hand the tests back to the students for grading, such that no student received his or her owntest back? Out of 24 possible permutations (4!) for handing back the tests, there are only 9 derangements:

    BADC, BCDA, BDAC,

    CADB, CDAB, CDBA,

    DABC, DCAB, DCBA.

    In every other permutation of this 4-member set, at least one student gets his or her own test back.Another version of the problem arises when we ask for the number of ways n letters, each addressed to a dierentperson, can be placed in n pre-addressed envelopes so that no letter appears in the correctly addressed envelope.

  • 2.2. COUNTING DERANGEMENTS 11

    2.2 Counting derangementsSuppose that there are n persons numbered 1, 2, ..., n. Let there be n hats also numbered 1, 2, ..., n. We have to ndthe number of ways in which no one gets the hat having same number as his/her number. Let us assume that the rstperson takes hat i. There are n 1 ways for the rst person to make such a choice. There are now two possibilities,depending on whether or not person i takes hat 1 in return:

    1. Person i does not take the hat 1. This case is equivalent to solving the problem with n 1 persons and n 1hats: each of the remaining n 1 people has precisely 1 forbidden choice from among the remaining n 1hats (i's forbidden choice is hat 1).

    2. Person i takes the hat 1. Now the problem reduces to n 2 persons and n 2 hats.

    From this, the following relation is derived:

    !n = (n 1)(!(n 1)+!(n 2)):

    where !n, known as the subfactorial, represents the number of derangements, with the starting values !0 = 1 and !1 =0.Notice that this same recurrence formula also works for factorials with dierent starting values. That is 0! = 1, 1! =1 and

    n! = (n 1)((n 1)! + (n 2)!)

    which is helpful in proving the limit relationship with e below.Also, the following formulae are known:[4]

    !n = n!nXi=0

    (1)ii!

    ;

    !n =

    n!

    e

    =

    n!

    e+

    1

    2

    ; n 1

    where [x] is the nearest integer function and bxc is the oor function.

    !n =(e+ e1)n!

    ben!c; n 2;!n = n!

    nXi=1

    n

    i

    !(n i);

    The following recurrence relationship also holds:[5]

    !n = n[!(n 1)] + (1)n

    Starting with n = 0, the numbers of derangements of n are:

    1, 0, 1, 2, 9, 44, 265, 1854, 14833, 133496, 1334961, 14684570, 176214841, 2290792932, ... (se-quence A000166 in OEIS).

    These numbers are also called subfactorial or rencontres numbers.Perhaps a more well-known method of counting derangements uses the inclusion-exclusion principle.

  • 12 CHAPTER 2. DERANGEMENT

    2.3 Limit of ratio of derangement to permutation as n approaches Using this recurrence, it can be shown that, in the limit,

    limn!1

    !n

    n!=

    1

    e 0:3679 : : : :

    This is the limit of the probability pn = dn/n! that a randomly selected permutation is a derangement. The probabilityconverges to this limit extremely quickly as n increases, which is why dn is the nearest integer to n!/e. The abovesemi-log graph shows that the derangement graph lags the permutation graph by an almost constant value.More information about this calculation and the above limit may be found in the article on the statistics of randompermutations.

    2.4 GeneralizationsThe problme des rencontres asks how many permutations of a size-n set have exactly k xed points.Derangements are an example of the wider eld of constrained permutations. For example, the mnage problem asksif n opposite-sex couples are seated man-woman-man-woman-... around a table, how many ways can they be seatedso that nobody is seated next to his or her partner?More formally, given sets A and S, and some sets U and V of surjections A S, we often wish to know the numberof pairs of functions (f, g) such that f is in U and g is in V, and for all a in A, f(a) g(a); in other words, where foreach f and g, there exists a derangement of S such that f(a) = (g(a)).Another generalization is the following problem:

    How many anagrams with no xed letters of a given word are there?

    For instance, for a word made of only two dierent letters, say n letters A and m letters B, the answer is, of course, 1or 0 according whether n = m or not, for the only way to form an anagram without xed letters is to exchange all theA with B, which is possible if and only if n = m. In the general case, for a word with n1 letters X1, n2 letters X2, ...,nr letters Xr it turns out (after a proper use of the inclusion-exclusion formula) that the answer has the form:

    Z 10

    Pn1(x)Pn2(x) Pnr (x)ex dx;

    for a certain sequence of polynomials Pn, where Pn has degree n. But the above answer for the case r = 2 gives anorthogonality relation, whence the Pn's are the Laguerre polynomials (up to a sign that is easily decided).[6]

    2.5 Computational complexityIt is NP-complete to determine whether a given permutation group (described by a given set of permutations thatgenerate it) contains any derangements.[7]

    2.6 References[1] The name subfactorial originates with William Allen Whitworth; see Cajori, Florian (2011), A History of Mathematical

    Notations: Two Volumes in One, Cosimo, Inc., p. 77, ISBN 9781616405717.

    [2] Ronald L. Graham, Donald E. Knuth, Oren Patashnik, Concrete Mathematics (1994), AddisonWesley, ReadingMA. ISBN0-201-55802-5

    [3] de Montmort, P. R. (1708). Essay d'analyse sur les jeux de hazard. Paris: Jacque Quillau. Seconde Edition, Revue &augmente de plusieurs Lettres. Paris: Jacque Quillau. 1713.

  • 2.7. EXTERNAL LINKS 13

    [4] Hassani, M. Derangements and Applications. J. Integer Seq. 6, No. 03.1.2, 18, 2003

    [5] See the notes for (sequence A000166 in OEIS).

    [6] Even, S.; J. Gillis (1976). Derangements and Laguerre polynomials. Mathematical Proceedings of the Cambridge Philo-sophical Society 79 (01): 135143. doi:10.1017/S0305004100052154. Retrieved 27 December 2011.

    [7] Lubiw, Anna (1981), Some NP-complete problems similar to graph isomorphism, SIAM Journal on Computing 10 (1):1121, doi:10.1137/0210002, MR 605600. Babai, Lszl (1995), Automorphism groups, isomorphism, reconstruction,Handbook of combinatorics, Vol. 1, 2 (PDF), Amsterdam: Elsevier, pp. 14471540, MR 1373683, A surprising result ofAnna Lubiw asserts that the following problem is NP-complete: Does a given permutation group have a xed-point-freeelement?.

    2.7 External links Baez, John (2003). Lets get deranged!" (PDF). Bogart, Kenneth P. and Doyle, Peter G. (1985). Non-sexist solution of the mnage problem. Dickau, Robert M. Derangement diagrams. Figures UsingMathematica. Hassani, Mehdi. Derangements and Applications. Journal of Integer Sequences (JIS), Volume 6, Issue 1,Article 03.1.2, 2003.

    Weisstein, Eric W. Derangement. MathWorldA Wolfram Web Resource.

  • Chapter 3

    Factorial

    In mathematics, the factorial of a non-negative integer n, denoted by n!, is the product of all positive integers lessthan or equal to n. For example,

    5! = 5 4 3 2 1 = 120:

    The value of 0! is 1, according to the convention for an empty product.[1]

    The factorial operation is encountered inmany areas ofmathematics, notably in combinatorics, algebra, andmathematicalanalysis. Its most basic occurrence is the fact that there are n! ways to arrange n distinct objects into a sequence (i.e.,permutations of the set of objects). This fact was known at least as early as the 12th century, to Indian scholars.[2]Fabian Stedman in 1677 described factorials as applied to change ringing.[3] After describing a recursive approach,Stedman gives a statement of a factorial (using the language of the original):

    Now the nature of these methods is such, that the changes on one number comprehends [includes]the changes on all lesser numbers, ... insomuch that a compleat Peal of changes on one number seemethto be formed by uniting of the compleat Peals on all lesser numbers into one entire body;[4]

    The notation n! was introduced by Christian Kramp in 1808.[5]

    The denition of the factorial function can also be extended to non-integer arguments, while retaining its most im-portant properties; this involves more advanced mathematics, notably techniques from mathematical analysis.

    3.1 DenitionThe factorial function is formally dened by the product

    n! =nY

    k=1

    k

    or by the recurrence relation

    n! =

    (1 ifn = 0;(n 1)! n ifn > 0

    The factorial function can also be dened by using the power rule as

    n! = Dnxn [6]

    14

  • 3.2. APPLICATIONS 15

    All of the above denitions incorporate the instance

    0! = 1;

    in the rst case by the convention that the product of no numbers at all is 1. This is convenient because:

    There is exactly one permutation of zero objects (with nothing to permute, everything is left in place). The recurrence relation (n + 1)! = n! (n + 1), valid for n > 0, extends to n = 0. It allows for the expression of many formulae, such as the exponential function, as a power series:

    ex =1Xn=0

    xn

    n!:

    It makes many identities in combinatorics valid for all applicable sizes. The number of ways to choose 0elements from the empty set is

    00

    = 0!0!0! = 1 . More generally, the number of ways to choose (all) n elements

    among a set of n isnn

    = n!n!0! = 1 .

    The factorial function can also be dened for non-integer values using more advanced mathematics, detailed in thesection below. This more generalized denition is used by advanced calculators and mathematical software such asMaple or Mathematica.

    3.2 ApplicationsAlthough the factorial function has its roots in combinatorics, formulas involving factorials occur in many areas ofmathematics.

    There are n! dierent ways of arranging n distinct objects into a sequence, the permutations of those objects. Often factorials appear in the denominator of a formula to account for the fact that ordering is to be ignored.A classical example is counting k-combinations (subsets of k elements) from a set with n elements. One canobtain such a combination by choosing a k-permutation: successively selecting and removing an element of theset, k times, for a total of

    nk = n(n 1)(n 2) (n k + 1)possibilities. This however produces the k-combinations in a particular order that one wishes to ignore;since each k-combination is obtained in k! dierent ways, the correct number of k-combinations is

    nk

    k!=

    n(n 1)(n 2) (n k + 1)k(k 1)(k 2) 1 :

    This number is known as the binomial coecientnk

    , because it is also the coecient of Xk in (1 +

    X)n.

    Factorials occur in algebra for various reasons, such as via the already mentioned coecients of the binomialformula, or through averaging over permutations for symmetrization of certain operations.

    Factorials also turn up in calculus; for example they occur in the denominators of the terms of Taylors formula,where they are used as compensation terms due to the n-th derivative of xn being equivalent to n!.

    Factorials are also used extensively in probability theory.

  • 16 CHAPTER 3. FACTORIAL

    Factorials can be useful to facilitate expression manipulation. For instance the number of k-permutations of ncan be written as

    nk =n!

    (n k)! ;

    while this is inecient as a means to compute that number, it may serve to prove a symmetry propertyof binomial coecients:n

    k

    =

    nk

    k!=

    n!

    (n k)!k! =nnk

    (n k)! =

    n

    n k:

    3.3 Number theoryFactorials have many applications in number theory. In particular, n! is necessarily divisible by all prime numbersup to and including n. As a consequence, n > 5 is a composite number if and only if

    (n 1)! 0 (mod n):A stronger result is Wilsons theorem, which states that

    (p 1)! 1 (mod p)if and only if p is prime.Legendres formula gives the multiplicity of the prime p occurring in the prime factorization of n! as

    1Xi=1

    n

    pi

    or, equivalently,

    n sp(n)p 1

    where sp(n) denotes the sum of the standard base-p digits of n.The only factorial that is also a prime number is 2, but there are many primes of the form n! 1, called factorialprimes.All factorials greater than 1! are even, as they are all multiples of 2. Also, all factorials from 5! upwards are multiplesof 10 (and hence have a trailing zero as their nal digit), because they are multiples of 5 and 2.

    3.4 Series of reciprocalsThe reciprocals of factorials produce a convergent series: (see e)

    1Xn=0

    1

    n!=

    1

    1+

    1

    1+

    1

    2+

    1

    6+

    1

    24+

    1

    120+ : : : = e :

    Although the sum of this series is an irrational number, it is possible to multiply the factorials by positive integers toproduce a convergent series with a rational sum:

  • 3.5. RATE OF GROWTH AND APPROXIMATIONS FOR LARGE N 17

    1Xn=0

    1

    (n+ 2)n!=

    1

    2+

    1

    3+

    1

    8+

    1

    30+

    1

    144: : : = 1 :

    The convergence of this series to 1 can be seen from the fact that its partial sums are less than one by an inversefactorial. Therefore, the factorials do not form an irrationality sequence.[7]

    3.5 Rate of growth and approximations for large n

    0

    20000

    40000

    60000

    80000

    100000

    120000

    140000

    160000

    180000

    0 5000 10000 15000 20000

    ln(x!)

    Plot of the natural logarithm of the factorial

    As n grows, the factorial n! increases faster than all polynomials and exponential functions (but slower than doubleexponential functions) in n.Most approximations for n! are based on approximating its natural logarithm

    logn! =nX

    x=1

    logx:

    The graph of the function f(n) = log n! is shown in the gure on the right. It looks approximately linear for allreasonable values of n, but this intuition is false. We get one of the simplest approximations for log n! by boundingthe sum with an integral from above and below as follows:

    Z n1

    logx dx nX

    x=1

    logx Z n0

    log(x+ 1) dx

  • 18 CHAPTER 3. FACTORIAL

    which gives us the estimate

    n logne

    + 1 logn! (n+ 1) log

    n+ 1

    e

    + 1:

    Hence log n! is (n log n) (see Big O notation). This result plays a key role in the analysis of the computationalcomplexity of sorting algorithms (see comparison sort). From the bounds on log n! deduced above we get that

    ene

    n n! e

    n+ 1

    e

    n+1:

    It is sometimes practical to use weaker but simpler estimates. Using the above formula it is easily shown that for alln we have (n/3)n < n! , and for all n 6 we have n! < (n/2)n .For large n we get a better estimate for the number n! using Stirlings approximation:

    n! p2n

    ne

    n:

    In fact, it can be proved that for all n we have

    n! >p2n

    ne

    n:

    Another approximation for log n! is given by Srinivasa Ramanujan (Ramanujan 1988)

    logn! n logn n+ log(n(1 + 4n(1 + 2n)))6

    +log()

    2

    = n logn n+ log(1 + 1/(2n) + 1/(8n2))

    6+

    log(2n)2

    +log()

    2:

    Thus it is even smaller than the next correction term 112n of Stirlings formula.

    3.6 ComputationIf eciency is not a concern, computing factorials is trivial from an algorithmic point of view: successivelymultiplyinga variable initialized to 1 by the integers 2 up to n (if any) will compute n!, provided the result ts in the variable. Infunctional languages, the recursive denition is often implemented directly to illustrate recursive functions.The main practical diculty in computing factorials is the size of the result. To assure that the exact result will tfor all legal values of even the smallest commonly used integral type (8-bit signed integers) would require more than700 bits, so no reasonable specication of a factorial function using xed-size types can avoid questions of overow.The values 12! and 20! are the largest factorials that can be stored in, respectively, the 32-bit and 64-bit integerscommonly used in personal computers. Floating-point representation of an approximated result allows going a bitfurther, but this also remains quite limited by possible overow. Most calculators use scientic notation with 2-digit decimal exponents, and the largest factorial that ts is then 69!, because 69! < 10100 < 70!. Calculators thatuse 3-digit exponents can compute larger factorials, up to, for example, 253! 5.210499 on HP calculators and449! 3.910997 on the TI-86. The calculator seen in Mac OS X handles up to 92!, Apples Numbers, MicrosoftExcel and Google Calculator, as well as the freeware Fox Calculator, can handle factorials up to 170!, which is thelargest factorial whose oating-point approximation can be represented as a 64-bit IEEE 754 oating-point value.The scientic calculator in Windows 7 and Windows 8 is able to calculate factorials up to 3248!.Most software applications will compute small factorials by direct multiplication or table lookup. Larger factorialvalues can be approximated using Stirlings formula. WolframAlpha can calculate exact results for the ceiling functionand oor function applied to the binary, natural and common logarithm of n! for values of n up to 249999, and upto 20,000,000! for the integers.

  • 3.7. EXTENSION OF FACTORIAL TO NON-INTEGER VALUES OF ARGUMENT 19

    If the exact values of large factorials are needed, they can be computed using arbitrary-precision arithmetic. Insteadof doing the sequential multiplications ((1 2) 3) 4 : : : , a program can partition the sequence into two parts,whose products are roughly the same size, and multiply them using a divide-and-conquer method. This is often moreecient.[8]

    The asymptotically best eciency is obtained by computing n! from its prime factorization. As documented byPeter Borwein, prime factorization allows n! to be computed in time O(n(log n log log n)2), provided that a fastmultiplication algorithm is used (for example, the SchnhageStrassen algorithm).[9] Peter Luschny presents sourcecode and benchmarks for several ecient factorial algorithms, with or without the use of a prime sieve.[10]

    3.7 Extension of factorial to non-integer values of argument

    3.7.1 The Gamma and Pi functionsMain article: Gamma functionBesides nonnegative integers, the factorial function can also be dened for non-integer values, but this requires more

    - 4 - 2 2 4

    - 20

    - 10

    10

    20

    30

    The factorial function, generalized to all real numbers except negative integers. For example, 0! = 1! = 1, (0.5)! = , (0.5)! =/2.

    advanced tools from mathematical analysis. One function that lls in the values of the factorial (but with a shiftof 1 in the argument) is called the Gamma function, denoted (z), dened for all complex numbers z except thenon-positive integers, and given when the real part of z is positive by

    (z) =

    Z 10

    tz1et dt:

    Its relation to the factorials is that for any natural number n

    n! = (n+ 1):

    Eulers original formula for the Gamma function was

  • 20 CHAPTER 3. FACTORIAL

    (z) = limn!1

    nzn!nY

    k=0

    (z + k)

    :

    An alternative notation, originally introduced by Gauss, is sometimes used. The Pi function, denoted (z) for realnumbers z no less than 0, is dened by

    (z) =

    Z 10

    tzet dt :

    In terms of the Gamma function it is

    (z) = (z + 1) :

    It truly extends the factorial in that

    (n) = n! for n 2 N :

    In addition to this, the Pi function satises the same recurrence as factorials do, but at every complex value z whereit is dened

    (z) = z(z 1) :

    In fact, this is no longer a recurrence relation but a functional equation. Expressed in terms of the Gamma functionthis functional equation takes the form

    (n+ 1) = n(n) :

    Since the factorial is extended by the Pi function, for every complex value z where it is dened, we can write:

    z! = (z)

    The values of these functions at half-integer values is therefore determined by a single one of them; one has

    1

    2

    =

    12

    ! =

    12

    =p;

    from which it follows that for n N,

    1

    2+ n

    =

    12+ n

    ! =

    12+ n

    =p

    nYk=1

    2k 12

    =(2n)!

    4nn!

    p =

    (2n 1)!22n1(n 1)!

    p:

    For example,

    (4:5) = 3:5! = (3:5) =1

    2 32 52 72

    p =

    8!

    444!

    p =

    7!

    273!

    p =

    105

    16

    p 11:63:

    It also follows that for n N,

  • 3.7. EXTENSION OF FACTORIAL TO NON-INTEGER VALUES OF ARGUMENT 21

    1

    2 n

    =

    12 n

    ! =

    12 n

    =p

    nYk=1

    2

    1 2k =(4)nn!(2n)!

    p:

    For example,

    (2:5) = (3:5)! = (3:5) = 21 2

    3 2

    5p =

    (4)33!6!

    p = 8

    15

    p 0:9453:

    The Pi function is certainly not the only way to extend factorials to a function dened at almost all complex values,and not even the only one that is analytic wherever it is dened. Nonetheless it is usually considered the most naturalway to extend the values of the factorials to a complex function. For instance, the BohrMollerup theorem states thatthe Gamma function is the only function that takes the value 1 at 1, satises the functional equation (n + 1) = n(n),is meromorphic on the complex numbers, and is log-convex on the positive real axis. A similar statement holds forthe Pi function as well, using the (n) = n(n 1) functional equation.However, there exist complex functions that are probably simpler in the sense of analytic function theory and whichinterpolate the factorial values. For example, Hadamards 'Gamma'-function (Hadamard 1894) which, unlike theGamma function, is an entire function.[11]

    Euler also developed a convergent product approximation for the non-integer factorials, which can be seen to beequivalent to the formula for the Gamma function above:

    n! = (n) =1Yk=1

    k + 1

    k

    nk

    n+ k

    =

    2

    1

    n1

    n+ 1

    3

    2

    n2

    n+ 2

    4

    3

    n3

    n+ 3

    :

    However, this formula does not provide a practical means of computing the Pi or Gamma function, as its rate ofconvergence is slow.

    3.7.2 Applications of the Gamma functionThe volume of an n-dimensional hypersphere of radius R is

    Vn =n/2

    ((n/2) + 1)Rn:

    3.7.3 Factorial at the complex planeRepresentation through the Gamma-function allows evaluation of factorial of complex argument. Equilines of am-plitude and phase of factorial are shown in gure. Let f = exp(i') = (x + iy)! = (x + iy + 1) . Severallevels of constant modulus (amplitude) = const and constant phase ' = const are shown. The grid covers range 3 x 3 , 2 y 2 with unit step. The scratched line shows the level ' = .Thin lines show intermediate levels of constant modulus and constant phase. At poles x+ iy 2 (negative integers) ,phase and amplitude are not dened. Equilines are dense in vicinity of singularities along negative integer values ofthe argument.For jzj < 1 , the Taylor expansions can be used:

    z! =1Xn=0

    gnzn:

    The rst coecients of this expansion arewhere is the Euler constant and is the Riemann zeta function. Computer algebra systems such as Sage can generatemany terms of this expansion.

  • 22 CHAPTER 3. FACTORIAL

    Amplitude and phase of factorial of complex argument

    3.7.4 Approximations of factorialFor the large values of the argument, factorial can be approximated through the integral of the digamma function,using the continued fraction representation. This approach is due to T. J. Stieltjes (1894). Writing z! = exp(P(z))where P(z) is

    P (z) = p(z) + log(2)/2 z +z +

    1

    2

    log(z);

    Stieltjes gave a continued fraction for p(z)

    p(z) =a0

    z +a1

    z +a2

    z +a3

    z +. . .

    The rst few coecients a are[12]

    There is a misconception that log(z!) = P (z) or log((z+1)) = P (z) for any complex z 0. Indeed, the relationthrough the logarithm is valid only for specic range of values of z in vicinity of the real axis, while j=((z+1))j < .The larger is the real part of the argument, the smaller should be the imaginary part. However, the inverse relation, z!= exp(P(z)), is valid for the whole complex plane apart from zero. The convergence is poor in vicinity of the negativepart of the real axis. (It is dicult to have good convergence of any approximation in vicinity of the singularities).While j=(z)j > 2 or 2 , the 6 coecients above are sucient for the evaluation of the factorial with the

  • 3.8. FACTORIAL-LIKE PRODUCTS AND FUNCTIONS 23

    complex precision. For higher precision more coecients can be computed by a rational QD-scheme (H.Rutishauser's QD algorithm).[13]

    3.7.5 Non-extendability to negative integersThe relation n! = n (n 1)! allows one to compute the factorial for an integer given the factorial for a smallerinteger. The relation can be inverted so that one can compute the factorial for an integer given the factorial for alarger integer:

    (n 1)! = n!n:

    Note, however, that this recursion does not permit us to compute the factorial of a negative integer; use of the formulato compute (1)! would require a division by zero, and thus blocks us from computing a factorial value for everynegative integer. (Similarly, the Gamma function is not dened for non-positive integers, though it is dened for allother complex numbers.)

    3.8 Factorial-like products and functionsThere are several other integer sequences similar to the factorial that are used in mathematics:

    3.8.1 Double factorialMain article: Double factorial

    The product of all the odd integers up to some odd positive integer n is called the double factorial of n, and denotedby n!!.[14] That is,

    (2k 1)!! =kY

    i=1

    (2i 1) = (2k)!2kk!

    =2kPk2k

    =(2k)

    k

    2k:

    For example, 9!! = 1 3 5 7 9 = 945.The sequence of double factorials for n = 1, 3, 5, 7, ... starts as

    1, 3, 15, 105, 945, 10395, 135135, .... (sequence A001147 in OEIS)

    Double factorial notation may be used to simplify the expression of certain trigonometric integrals,[15] to provide anexpression for the values of the Gamma function at half-integer arguments and the volume of hyperspheres,[16] andto solve many counting problems in combinatorics including counting binary trees with labeled leaves and perfectmatchings in complete graphs.[14][17]

    3.8.2 MultifactorialsA common related notation is to use multiple exclamation points to denote amultifactorial, the product of integersin steps of two ( n!! ), three ( n!!! ), or more. The double factorial is the most commonly used variant, but one cansimilarly dene the triple factorial ( n!!! ) and so on. One can dene the k-th factorial, denoted by n!(k) , recursivelyfor positive integers as

    n!(k) =

    (n if0 < n kn((n k)!(k)) ifn > k

  • 24 CHAPTER 3. FACTORIAL

    though see the alternative denition below. In addition, similarly to 0! = 1!/1 = 1, one can dene:

    n!(k) = 1 if k < n 0Some mathematicians have suggested an alternative notation of n!2 for the double factorial and similarly n!k for othermultifactorials, but this has not come into general use.In the same way that n! is not dened for negative integers, and n!! is not dened for negative even integers, n!(k) isnot dened for negative integers divisible by k .

    Alternative extension of the multifactorial

    Alternatively, the multifactorial z!(k) can be extended to most real and complex numbers z by noting that when z isone more than a positive multiple of k then

    z!(k) = z(z k) (k + 1) = k(z1)/k zk

    z kk

    k + 1

    k

    = k(z1)/k

    zk + 1

    1k + 1

    :This last expression is dened much more broadly than the original; with this denition, z!(k) is dened for all complexnumbers except the negative real numbers evenly divisible by k. This denition is consistent with the earlier denitiononly for those integers z satisfying z 1 mod k.In addition to extending z!(k) to most complex numbers z, this denition has the feature of working for all positivereal values of k. Furthermore, when k = 1, this denition is mathematically equivalent to the (z) function, describedabove. Also, when k = 2, this denition ismathematically equivalent to the alternative extension of the double factorial.

    3.8.3 PrimorialThe primorial (sequence A002110 in OEIS) is similar to the factorial, but with the product taken only over the primenumbers.

    3.8.4 Quadruple factorialThe quadruple factorial is not the multifactorial n!(4); it is a much larger number given by (2n)!/n!, starting as

    1, 2, 12, 120, 1680, 30240, 665280, ... (sequence A001813 in OEIS).

    It is also equal to

    2n(2n)!

    n!2n= 2n

    (2 4 2n)(1 3 (2n 1))2 4 2n

    = (1 2) (3 2) ((2n 1) 2) = (4n 2)!(4):

    3.8.5 SuperfactorialMain article: Large numbersN$" redirects here. For the currency, see Namibian dollar.

    Neil Sloane and Simon Ploue dened a superfactorial in The Encyclopedia of Integer Sequences (Academic Press,1995) to be the product of the rst n factorials. So the superfactorial of 4 is

    sf(4) = 1! 2! 3! 4! = 288:

  • 3.8. FACTORIAL-LIKE PRODUCTS AND FUNCTIONS 25

    In general

    sf(n) =nY

    k=1

    k! =nY

    k=1

    knk+1 = 1n 2n1 3n2 (n 1)2 n1:

    Equivalently, the superfactorial is given by the formula

    sf(n) =Y

    0i

  • 26 CHAPTER 3. FACTORIAL

    H(n) =

    nYk=1

    kk = 11 22 33 (n 1)n1 nn:

    For n = 1, 2, 3, 4, ... the values H(n) are 1, 4, 108, 27648,... (sequence A002109 in OEIS).The asymptotic growth rate is

    H(n) An(6n2+6n+1)/12en2/4

    whereA = 1.2824... is the GlaisherKinkelin constant.[18] H(14) = 1.8474...1099 is already almost equal to a googol,and H(15) = 8.0896...10116 is almost of the same magnitude as the Shannon number, the theoretical number ofpossible chess games. Compared to the Pickover denition of the superfactorial, the hyperfactorial grows relativelyslowly.The hyperfactorial function can be generalized to complex numbers in a similar way as the factorial function. Theresulting function is called the K-function.

    3.9 See also Alternating factorial Digamma function Exponential factorial Factorial number system Factorial prime Factorion List of factorial and binomial topics Pochhammer symbol, which gives the falling or rising factorial Subfactorial Trailing zeros of factorial Triangular number, the additive analogue of factorial

    3.10 Notes[1] Ronald L. Graham, Donald E. Knuth, Oren Patashnik (1988) Concrete Mathematics, Addison-Wesley, Reading MA. ISBN

    0-201-14236-8, p. 111

    [2] N. L. Biggs, The roots of combinatorics, Historia Math. 6 (1979) 109136

    [3] Stedman, Fabian (1677), Campanalogia, London, pp. 69 The publisher is given as W.S. who may have been WilliamSmith, possibly acting as agent for the Society of College Youths, to which society the Dedicatory is addressed.

    [4] Stedman 1677, p. 8.

    [5] Higgins, Peter (2008), Number Story: From Counting to Cryptography, New York: Copernicus, p. 12, ISBN 978-1-84800-000-1 says Krempe though.

    [6] http://ocw.mit.edu/courses/mathematics/18-01-single-variable-calculus-fall-2006/lecture-notes/lec4.pdf

    [7] Guy, Richard K. (2004), E24 Irrationality sequences, Unsolved problems in number theory (3rd ed.), Springer-Verlag, p.346, ISBN 0-387-20860-7, Zbl 1058.11001.

  • 3.11. REFERENCES 27

    [8] GNU MP software manual, Factorial Algorithm (retrieved 22 January 2013).

    [9] Peter Borwein. On the Complexity of Calculating Factorials. Journal of Algorithms 6, 376380 (1985)

    [10] Peter Luschny, Fast-Factorial-Functions: The Homepage of Factorial Algorithms.

    [11] Peter Luschny, Hadamard versus Euler - Who found the better Gamma function?.

    [12] Digital Library of Mathematical Functions, http://dlmf.nist.gov/5.10

    [13] Peter Luschny, On Stieltjes Continued Fraction for the Gamma Function..

    [14] Callan, David (2009), A combinatorial survey of identities for the double factorial, arXiv:0906.1317.

    [15] Meserve, B. E. (1948), Classroom Notes: Double Factorials, The American Mathematical Monthly 55 (7): 425426,doi:10.2307/2306136, MR 1527019

    [16] Mezey, Paul G. (2009), Some dimension problems in molecular databases, Journal of Mathematical Chemistry 45 (1):16, doi:10.1007/s10910-008-9365-8.

    [17] Dale, M. R. T.; Moon, J. W. (1993), The permuted analogues of three Catalan sets, Journal of Statistical Planning andInference 34 (1): 7587, doi:10.1016/0378-3758(93)90035-5, MR 1209991.

    [18] Weisstein, Eric W., GlaisherKinkelin Constant, MathWorld.

    3.11 References Hadamard, M. J. (1894), Sur LExpression Du Produit 123 (n1) Par Une Fonction Entire (PDF) (inFrench), OEuvres de Jacques Hadamard, Centre National de la Recherche Scientiques, Paris, 1968

    Ramanujan, Srinivasa (1988), The lost notebook and other unpublished papers, Springer Berlin, p. 339, ISBN3-540-18726-X

    3.12 External links Hazewinkel, Michiel, ed. (2001), Factorial, Encyclopedia of Mathematics, Springer, ISBN 978-1-55608-010-4

    Weisstein, Eric W., Factorial, MathWorld. Factorial at PlanetMath.org.

  • Chapter 4

    Partial permutation

    In combinatorial mathematics, a partial permutation, or sequence without repetition, on a nite set S is a bijectionbetween two specied subsets of S. That is, it is dened by two subsets U and V of equal size, and a one-to-onemapping from U to V. Equivalently, it is a partial function on S that can be extended to a permutation.[1][2]

    4.1 RepresentationIt is common to consider the case when the set S is simply the set {1, 2, ..., n} of the rst n integers. In this case,a partial permutation may be represented by a string of n symbols, some of which are distinct numbers in the rangefrom 1 to n and the remaining ones of which are a special hole symbol . In this formulation, the domain U of thepartial permutation consists of the positions in the string that do not contain a hole, and each such position is mappedto the number in that position. For instance, the string 1 2 would represent the partial permutation that maps 1to itself and maps 3 to 2.[3] The seven partial permutations on two items are

    , 1, 2, 1, 2, 12, 21.

    4.2 Combinatorial enumerationThe number of partial permutations on n items, for n = 0, 1, 2, ..., is given by the integer sequence

    1, 2, 7, 34, 209, 1546, 13327, 130922, 1441729, 17572114, 234662231, ... (sequence A002720 inOEIS)

    where the nth item in the sequence is given by the summation formula

    nXi=0

    i!

    n

    i

    2in which the ith term counts the number of partial permutations with support of size i, that is, the number of partialpermutations with i non-hole entries. Alternatively, it can be computed by a recurrence relation

    P (n) = 2nP (n 1) (n 1)2P (n 2):This is determined as follows:

    1. P (n 1) partial permutations where the nal elements of each set are omitted:2. P (n 1) partial permutations where the nal elements of each set map to each other.

    28

  • 4.3. RESTRICTED PARTIAL PERMUTATIONS 29

    3. (n 1)P (n 1) partial permutations where the nal element of the rst set is included, but does not map tothe nal element of the second set

    4. (n 1)P (n 1) partial permutations where the nal element of the second set is included, but does not mapto the nal element of the rst set

    5. (n 1)2P (n 2) , the partial permutations included in both counts 3 and 4, those permutations where thenal elements of both sets are included, but do not map to each other.

    4.3 Restricted partial permutationsSome authors restrict partial permutations so that either the domain[4] or the range[3] of the bijection is forced toconsist of the rst k items in the set of n items being permuted, for some k. In the former case, a partial permutationof length k from an n-set is just a sequence of k terms from the n-set without repetition. (In elementary combinatorics,these objects are sometimes confusingly called "k-permutations of the n-set.)

    4.4 References[1] Straubing, Howard (1983), A combinatorial proof of the Cayley-Hamilton theorem, Discrete Mathematics 43 (2-3): 273

    279, doi:10.1016/0012-365X(83)90164-4, MR 685635.

    [2] Ku, C. Y.; Leader, I. (2006), An Erds-Ko-Rado theorem for partial permutations, Discrete Mathematics 306 (1): 7486,doi:10.1016/j.disc.2005.11.007, MR 2202076.

    [3] Claesson, Anders; Jelnek, Vt; Jelnkov, Eva; Kitaev, Sergey (2011), Pattern avoidance in partial permutations, Elec-tronic Journal of Combinatorics 18 (1): Paper 25, 41, MR 2770130.

    [4] Burstein, Alexander; Lankham, Isaiah (2010), Restricted patience sorting and barred pattern avoidance, Permutation pat-terns, LondonMath. Soc. LectureNote Ser. 376, Cambridge: CambridgeUniv. Press, pp. 233257, doi:10.1017/CBO9780511902499.013,MR 2732833.

  • Chapter 5

    Permutation

    For other uses, see Permutation (disambiguation).nPr redirects here. For other uses, see NPR (disambiguation).In mathematics, the notion of permutation relates to the act of arranging all the members of a set into some

    sequence or order, or if the set is already ordered, rearranging (reordering) its elements, a process called permuting.These dier from combinations, which are selections of some members of a set where order is disregarded. Forexample, written as tuples, there are six permutations of the set {1,2,3}, namely: (1,2,3), (1,3,2), (2,1,3), (2,3,1),(3,1,2), and (3,2,1). These are all the possible orderings of this three element set. As another example, an anagramof a word, all of whose letters are dierent, is a permutation of its letters. In this example, the letters are alreadyordered in the original word and the anagram is a reordering of the letters. The study of permutations of nite sets isa topic in the eld of combinatorics.Permutations occur, in more or less prominent ways, in almost every area of mathematics. They often arise whendierent orderings on certain nite sets are considered, possibly only because one wants to ignore such orderings andneeds to know how many congurations are thus identied. For similar reasons permutations arise in the study ofsorting algorithms in computer science.The number of permutations of n distinct objects is n factorial usually written as n!, which means the product of allpositive integers less than or equal to n.In algebra and particularly in group theory, a permutation of a set S is dened as a bijection from S to itself. Thatis, it is a function from S to S for which every element occurs exactly once as an image value. This is related to therearrangement of the elements of S in which each element s is replaced by the corresponding f(s). The collectionof such permutations form a group called the symmetric group of S. The key to this groups structure is the fact thatthe composition of two permutations (performing two given rearrangements in succession) results in another rear-rangement. Permutations may act on structured objects by rearranging their components, or by certain replacements(substitutions) of symbols.In elementary combinatorics, the k-permutations, or partial permutations, are the ordered arrangements of k distinctelements selected from a set. When k is equal to the size of the set, these are the permutations of the set.

    5.1 HistoryThe rule to determine the number of permutations of n objects was known in Indian culture at least as early as around1150: the Lilavati by the Indian mathematician Bhaskara II contains a passage that translates to

    The product of multiplication of the arithmetical series beginning and increasing by unity and con-tinued to the number of places, will be the variations of number with specic gures.[1]

    Fabian Stedman in 1677 described factorials when explaining the number of permutations of bells in change ringing.Starting from two bells: rst, two must be admitted to be varied in two ways which he illustrates by showing 1 2and 2 1.[2] He then explains that with three bells there are three times two gures to be produced out of three whichagain is illustrated. His explanation involves cast away 3, and 1.2 will remain; cast away 2, and 1.3 will remain; castaway 1, and 2.3 will remain.[3] He then moves on to four bells and repeats the casting away argument showing that

    30

  • 5.2. DEFINITION AND ONE-LINE NOTATION 31

    there will be four dierent sets of three. Eectively this is an recursive process. He continues with ve bells usingthe casting away method and tabulates the resulting 120 combinations.[4] At this point he gives up and remarks:

    Now the nature of these methods is such, that the changes on one number comprehends the changeson all lesser numbers, ... insomuch that a compleat Peal of changes on one number seemeth to be formedby uniting of the compleat Peals on all lesser numbers into one entire body;[5]

    Stedman widens the consideration of permutations; he goes on to consider the number of permutations of the lettersof the alphabet and horses from a stable of 20.[6]

    A rst case in which seemingly unrelated mathematical questions were studied with the help of permutations occurredaround 1770, when Joseph Louis Lagrange, in the study of polynomial equations, observed that properties of thepermutations of the roots of an equation are related to the possibilities to solve it. This line of work ultimately resulted,through the work of variste Galois, in Galois theory, which gives a complete description of what is possible andimpossible with respect to solving polynomial equations (in one unknown) by radicals. In modern mathematics thereare many similar situations in which understanding a problem requires studying certain permutations related to it.

    5.2 Denition and one-line notationThere are two equivalent common ways of regarding permutations, sometimes called the active and passiveforms, or in older terminology substitutions and permutations.[7] Which form is preferable depends on the typeof questions being asked in a given discipline.The active way to regard permutations of a set S (nite or innite) is to dene them as the bijections from S toitself. Thus, the permutations are thought of as functions which can be composed with each other, forming groupsof permutations. From this viewpoint, the elements of S have no internal structure and are just labels for the objectsbeing moved: one may refer to permutations of any set of n elements as permutations on n letters.In Cauchy's two-line notation,[8] one lists the elements of S in the rst row, and for each one its image below it in thesecond row. For instance, a particular permutation of the set S = {1,2,3,4,5} can be written as:

    =

    1 2 3 4 52 5 4 3 1

    ;

    this means that satises (1)=2, (2)=5, (3)=4, (4)=3, and (5)=1. The elements of S may appear in any orderin the rst row. This permutation could also be written as:

    =

    3 2 5 1 44 5 1 2 3

    :

    The passive way to regard a permutation of the set S is an ordered arrangement (or listing, or linearly orderedarrangement, or sequence without repetition) of the elements of S. This is related to the active form as follows. Ifthere is a natural order for the elements of S,[9] say x1; x2; : : : ; xn , then one uses this for the rst row of thetwo-line notation:

    =

    x1 x2 x3 xn

    (x1) (x2) (x3) (xn):

    Under this assumption, onemay omit the rst row andwrite the permutation in one-line notation as(x1) (x2) (x3) (xn), that is, an ordered arrangement of S.[10][11] Care must be taken to distinguish one-line notation from the cycle no-tation described later. In mathematics literature, a common usage is to omit parentheses for one-line notation, whileusing them for cycle notation. The one-line notation is also called the word representation of a permutation.[12] Theexample above would then be 2 5 4 3 1 since the natural order 1 2 3 4 5 would be assumed for the rst row. (It istypical to use commas to separate these entries only if some have two or more digits.) This form is more compact,and is common in elementary combinatorics and computer science. It is especially useful in applications where theelements of S or the permutations are to be compared as larger or smaller.There are n! permutations of a nite set S having n elements.

  • 32 CHAPTER 5. PERMUTATION

    5.3 Other uses of the term permutationThe concept of a permutation as an ordered arrangement admits several generalizations that are not permutations buthave been called permutations in the literature.

    5.3.1 k-permutations of nA weaker meaning of the term permutation, sometimes used in elementary combinatorics texts, designates thoseordered arrangements in which no element occurs more than once, but without the requirement of using all theelements from a given set. These are not permutations except in special cases, but are natural generalizations of theordered arrangement concept. Indeed, this use often involves considering arrangements of a xed length k of elementstaken from a given set of size n, in other words, these k-permutations of n are the dierent ordered arrangementsof a k-element subset of an n-set (sometimes called variations in the older literature.[13]) These objects are alsoknown as partial permutations or as sequences without repetition, terms that avoid confusion with the other,more common, meaning of permutation. The number of such k -permutations of n is denoted variously by suchsymbols as Pnk , nPk , nPk , Pn;k , or P (n; k) , and its value is given by the product[14]

    P (n; k) = n (n 1) (n 2) (n k + 1)| {z }k factors

    which is 0 when k > n, and otherwise is equal to

    n!

    (n k)! :

    The product is well dened without the assumption that n is a non-negative integer and is of importance outsidecombinatorics as well; it is known as the Pochhammer symbol (n)k or as the k -th falling factorial power nk of n .This usage of the term permutation is closely related to the term "combination". A k-element combination of ann-set S is a k element subset of S, the elements of which are not ordered. By taking all the k element subsets of S andordering each of them in all possible ways we obtain all the k-permutations of S. The number of k-combinations ofan n-set, C(n,k), is therefore related to the number of k-permutations of n by:

    C(n; k) =P (n; k)

    P (k; k)=

    n!

    (n k)!k! :

    These numbers are also known as binomial coecients and denotednk

    .

    5.3.2 Permutations with repetitionOrdered arrangements of the elements of a set S of length n where repetition is allowed are called n-tuples, but havesometimes been referred to as permutations with repetition although they are not permutations in general. Theyare also called words over the alphabet S in some contexts. If the set S has k elements, the number of n-tuples over Sis:

    kn:

    There is no restriction on how often an element can appear in an n-tuple, but if restrictions are placed on how oftenan element can appear, this formula is no longer valid.

    5.3.3 Permutations of multisetsIf M is a nite multiset, then a multiset permutation is an ordered arrangement of elements of M in which eachelement appears exactly as often as is its multiplicity in M. An anagram of a word having some repeated letters is

  • 5.4. PERMUTATIONS IN GROUP THEORY 33

    an example of a multiset permutation.[15] If the multiplicities of the elements of M (taken in some order) are m1 ,m2 , ..., ml and their sum (i.e., the size of M) is n, then the number of multiset permutations of M is given by themultinomial coecient,[16]

    n

    m1;m2; : : : ;ml

    =

    n!

    m1!m2! ml! :

    For example, the number of distinct anagrams of the word MISSISSIPPI is:[17]

    11!

    1!4!4!2!

    A k-permutation of a multisetM is a sequence of length k of elements ofM in which each element appears at mostits multiplicity in M times (an elements repetition number).

    5.3.4 Circular permutationsPermutations, when considered as arrangements, are sometimes referred to as linearly ordered arrangements. Inthese arrangements there is a rst element, a second element, and so on. If, however, the objects are arranged in acircular manner this distinguished ordering no longer exists, that is, there is no rst element in the arrangement,any element can be considered as the start of the arrangement. The arrangements of objects in a circular manner arecalled circular permutations.[18][19] These can be formally dened as equivalence classes of ordinary permutationsof the objects, for the equivalence relation generated by moving the nal element of the linear arrangement to itsfront.Two circular permutations are equivalent if one can be rotated into the other (that is, cycled without changing therelative positions of the elements). The following two circular permutations on four letters are considered to be thesame.1 4 4 3 2 1 2 3The circular arrangements are to be read counterclockwise, so the following two are not equivalent since no rotationcan bring one to the other.1 1 4 3 3 4 2 2The number of circular permutations of a set S with n elements is (n - 1)!.

    5.4 Permutations in group theoryMain article: Symmetric group

    The set of all permutations of any given set S forms a group, with the composition of maps as the product operationand the identity function as the neutral element of the group. This is the symmetric group of S, denoted by Sym(S).Up to isomorphism, this symmetric group only depends on the cardinality of the set (called the degree of the group),so the nature of elements of S is irrelevant for the structure of the group. Symmetric groups have been studied mostlyin the case of nite sets, so, conned to this case, one can assume without loss of generality that S = {1,2,...,n} forsome natural number n. This is then the symmetric group of degree n, usually written as Sn.Any subgroup of a symmetric group is called a permutation group. By Cayleys theorem any group is isomorphicto some permutation group, and every nite group to a subgroup of some nite symmetric group.

    5.4.1 Cycle notationThis alternative notation describes the eect of repeatedly applying the permutation, thought of as a function froma set onto itself. It expresses the permutation as a product of cycles corresponding to the orbits of the permutation;since distinct orbits are disjoint, this is referred to as decomposition into disjoint cycles.[20]

  • 34 CHAPTER 5. PERMUTATION

    Starting from some element x of S, one writes the sequence (x (x) ((x)) ...) of successive images under , until theimage returns to x, at which point one closes the parenthesis rather than repeat x. The set of values written down formsthe orbit (under ) of x, and the parenthesized expression gives the corresponding cycle of . One then continues bychoosing a new element y of S outside the previous orbit and writing down the cycle starting at y; and so on until allelements of S are written in cycles. Since for every new cycle the starting point can be chosen in dierent ways, thereare in general many dierent cycle notations for the same permutation; for the example above one has:

    1 2 3 4 52 5 4 3 1

    =1 2 5

    3 4

    =3 4

    1 2 5

    =3 4

    5 1 2

    :

    A cycle (x) of length 1 occurs when (x) = x, and is commonly omitted from the cycle notation, provided the set S isclear: for any element x S not appearing in a cycle, one implicitly assumes (x) = x.[21] The identity permutation,which consists only of 1-cycles, can be denoted by a single 1-cycle (x), by the number 1, or by id.[22][23]

    A cycle (x1 x2 ... xk) of length k is called a k-cycle. Written by itself, it denotes a permutation in its own right,which maps xi to xi for i < k, and xk to x1, while implicitly mapping all other elements of S to themselves (omitted1-cycles). Therefore the individual cycles in the cycle notation can be interpreted as factors in a composition product.Since the orbits are disjoint, the corresponding cycles commute under composition, and so can be written in any order.The cycle decomposition is essentially unique: apart from the reordering the cycles in the product, there are no otherways to write as a product of cycles. Each individual cycle can be written in dierent ways, as in the example abovewhere (5 1 2) and (1 2 5) and (2 5 1) all denote the same cycle, though note that (5 2 1) denotes a dierent cycle.An element in a 1-cycle (x), corresponding to (x) = x, is called a xed point of the permutation . A permutationwith no xed points is called a derangement. Cycles of length two are called transpositions; such permutations merelyexchange the place of two elements, implicitly leaving the others xed. Since the orbits of a permutation partitionthe set S, for a nite set of size n, the lengths of the cycles of a permutation form a partition of n called the cycletype of . There is a 1 in the cycle type for every xed point of , a 2 for every transposition, and so on. Thecycle type of = (1 2 5)(3 4)(6 8)(7), is (3,2,2,1) which is sometimes written in a more compact form as (11,22,31).The number of n-permutations with k disjoint cycles is the signless Stirling number of the rst kind, denoted byc(n; k) .[24]

    5.4.2 Abstract groups vs. permutations vs. group actions

    Permutation groups have more structure than abstract groups, and dierent realizations of a group as a permuta-tion group need not be equivalent as permutations. For instance S3 is naturally a permutation group, in which anytransposition has cycle type (2,1); but the proof of Cayleys theorem realizes S3 as a subgroup of S6 (namely thepermutations of the 6 elements of S3 itself), in which permutation group transpositions have cycle type (2,2,2).Finding the minimal-order symmetric group containing a subgroup isomorphic to a given group (sometimes calledminimal faithful degree representation) is a rather dicult problem.[25][26] So in spite of Cayleys theorem, the studyof permutation groups diers from the study of abstract groups, being a branch of representation theory.Much of the power of permutations can be regained in an abstract setting by considering group actions instead.[27]A group action actually permutes the elements of a set according to the recipe provided by the abstract group. Forexample, S3 acts faithfully and transitively (by permuting) a set with exactly three elements.

    5.4.3 Product and inverse

    The product of two permutations is dened as their composition as functions, in other words is the function thatmaps any element x of the set to ((x)). Note that the rightmost permutation is applied to the argument rst, [28]because of the way function application is written. Some authors prefer the leftmost factor acting rst, [29] [30] [31] butto that end permutations must be written to the right of their argument, for instance as an exponent, where actingon x is written x; then the product is dened by x = (x). However this gives a dierent rule for multiplyingpermutations; this article uses the denition where the rightmost permutation is applied rst.Since the composition of two bijections always gives another bijection, the product of two permutations is again apermutation. In two-line notation, the product of two permutations is obtained by rearranging the columns of thesecond (leftmost) permutation so that its rst row is identical with the second row of the rst (rightmost) permutation.

  • 5.4. PERMUTATIONS IN GROUP THEORY 35

    The product can then be written as the rst row of the rst permutation over the second row of the modied secondpermutation. For example, given the permutations,

    P =

    1 2 3 4 52 4 1 3 5

    and Q =

    1 2 3 4 55 4 3 2 1

    ;

    the product QP is:

    QP =

    1 2 3 4 55 4 3 2 1

    1 2 3 4 52 4 1 3 5

    =

    2 4 1 3 54 2 5 3 1

    1 2 3 4 52 4 1 3 5

    =

    1 2 3 4 54 2 5 3 1

    :

    In cyclic notation this same product would be given by:

    Q P = (15)(24) (1243) = (1435):

    Since function composition is associative, so is the product operation on permutations: () = (). Therefore,products of more than two permutations are usually written without adding parentheses to express grouping; they arealso usually written without a dot or other sign to indicate multiplication.The identity permutation, which maps every element of the set to itself, is the neutral element for this product. Intwo-line notation, the identity is

    1 2 3 n1 2 3 n

    :

    Since bijections have inverses, so do permutations, and the inverse 1 of is again a permutation. Explicitly,whenever (x)=y one also has 1(y)=x. In two-line notation the inverse can be obtained by interchanging the twolines (and sorting the columns if one wishes the rst line to be in a given order). For instance

    1 2 3 4 52 5 4 3 1

    1=

    2 5 4 3 11 2 3 4 5

    =

    1 2 3 4 55 1 4 3 2

    :

    In cycle notation one can reverse the order of the elements in each cycle to obtain a cycle notation for its inverse.Thus,

    [(125)(34)]1 = (521)(43) = (152)(34):

    Having an associative product, a neutral element, and inverses for all its elements, makes the set of all permutationsof S into a group, called the symmetric group of S.

    5.4.4 Properties

    Every permutation of a nite set can be expressed as the product of transpositions.[32] Moreover, although many suchexpressions for a given permutation may exist, there can never be among them both expressions with an even numberand expressions with an odd number of transpositions. All permutations are then classied as even or odd, accordingto the parity of the transpositions in any such expression.Multiplying permutations written in cycle notation follows no easily described pattern, and the cycles of the productcan be entirely dierent from those of the permutations being composed. However the cycle structure is preserved inthe special case of conjugating a permutation by another permutation , which means forming the product 1.Here the cycle notation of the result can be obtained by taking the cycle notation for and applying to all the entriesin it.[33]

  • 36 CHAPTER 5. PERMUTATION

    Matrix representation

    One can represent a permutation of {1, 2, ..., n} as an nn matrix. There are two natural ways to do so, but only onefor which multiplications of matrices corresponds to multiplication of permutations in the same order: this is the onethat associates to the matrix M whose entry Mi,j is 1 if i = (j), and 0 otherwise. The resulting matrix has exactlyone entry 1 in each column and in each row, and is called a permutation matrix.Here (le) is a list of these matrices for permutations of 4 elements. The Cayley table on the right shows these matricesfor permutations of 3 elements.

    Permutation of components of a sequence

    As with any group, one can consider actions of a symmetric group on a set, and there are many ways in whichsuch an action can be dened. For the symmetric group of {1, 2, ..., n} there is one particularly natural action,namely the action by permutation on the set Xn of sequences of n symbols taken from some set X. As with thematrix representation, there are two natural ways in which the result of permuting a sequence (x1,x2,...,xn) by can be dened, but only one is compatible with the multiplication of permutations (so as to give a left action of thesymmetric group on Xn); with the multiplication rule used in this article this is the one given by

    (x1; : : : ; xn) = (x1(1); : : : ; x1(n)):

    This means that each component xi ends up at position (i) in the sequence permuted by .

    5.5 Permutations of totally ordered setsIn some applications, the elements of the set being permuted will be compared with each other. This requires thatthe set S has a total order so that any two elements can be compared. The set {1, 2, ..., n} is totally ordered by theusual "" relation and so it is the most frequently used set in these applications, but in general, any totally ordered setwill do. In these applications, the ordered arrangement view of a permutation is needed to talk about the positions ina permutation.Here are a number of properties that are directly related to the total ordering of S.

    5.5.1 Ascents, descents, runs and excedances

    An ascent of a permutation of n is any position i < n where the following value is bigger than the current one. Thatis, if = 12...n, then i is an ascent if i < i.For example, the permutation 3452167 has ascents (at positions) 1,2,5,6.Similarly, a descent is a position i < n with i > i, so every i with 1 i < n either is an ascent or is a descent of .An ascending run of a permutation is a nonempty increasing contiguous subsequence of the permutation that cannotbe extended at either end; it corresponds to a maximal sequence of successive ascents (the latter may be empty:between two successive descents there is still an ascending run of length 1). By contrast an increasing subsequence ofa permutation is not necessarily contiguous: it is an increasing sequence of elements obtained from the permutationby omitting the values at some positions. For example, the permutation 2453167 has the ascending runs 245, 3, and167, while it has an increasing subsequence 2367.If a permutation has k 1 descents, then it must be the union of k ascending runs.[34]

    The number of permutations of n with k ascents is (by denition) the Eulerian number

    nk

    ; this is also the number

    of permutations of n with k descents. Some authors however dene the Eulerian number

    nk

    as the number of

    permutations with k ascending runs, which corresponds to k1 descents.[35]An excedance of a permutation 12...n in an index j such that j > j. If the inequality is not strict, i.e. j j,then j is called a weak excedance. The number of n-permutations with k excedances coincides with the number ofn-permutations with k descents.[36]

  • 5.5. PERMUTATIONS OF TOTALLY ORDERED SETS 37

    5.5.2 Canonical cycle notation (aka standard form)In some combinatorial contexts it useful to x a certain order or the elements in the cycles and of the (disjoint) cyclesthemselves. Mikls Bna calls the following ordering choices the canonical cycle notation:

    in each cycle the largest element is listed rst the cycles are sorted in increasing order of their rst element

    For example, (312)(54)(8)(976) is a permutation in canonical cycle notation.[37] Note that the canonical cycle notationdoes not omit one-cycles.Richard P. Stanley calls the same choice of representation the standard representation of a permutation.[38] andMartin Aigner uses the term standard form for the same notion.[12] Sergey Kitaev also uses the standard formterminology, but reverses both ch