# Combinatorics

## Counting Rules and Techniques

Combinatorics is a branch of mathematics concerning the study of finite or countable discrete structures.### Learning Objectives

Describe the different rules and properties for combinatorics### Key Takeaways

#### Key Points

- The rule of sum (addition rule), rule of product (multiplication rule), and inclusion-exclusion principle are often used for enumerative purposes.
- Bijective proofs are utilized to demonstrate that two sets have the same number of elements.
- Double counting is a technique used to demonstrate that two expressions are equal. The pigeonhole principle often ascertains the existence of something or is used to determine the minimum or maximum number of something in a discrete context.
- Generating functions and recurrence relations are powerful tools that can be used to manipulate sequences, and can describe if not resolve many combinatorial situations.
- Double counting is a technique used to demonstrate that two expressions are equal.

#### Key Terms

**polynomial**: An expression consisting of a sum of a finite number of terms: each term being the product of a constant coefficient and one or more variables raised to a non-negative integer power.**combinatorics**: A branch of mathematics that studies (usually finite) collections of objects that satisfy specified criteria.

### Combinatorial Rules and Techniques

Several useful combinatorial rules or combinatorial principles are commonly recognized and used. Each of these principles is used for a specific purpose. The rule of sum (addition rule), rule of product (multiplication rule), and inclusion-exclusion principle are often used for enumerative purposes. Bijective proofs are utilized to demonstrate that two sets have the same number of elements. Double counting is a method of showing that two expressions are equal. The pigeonhole principle often ascertains the existence of something or is used to determine the minimum or maximum number of something in a discrete context. Generating functions and recurrence relations are powerful tools that can be used to manipulate sequences, and can describe if not resolve many combinatorial situations. Each of these techniques is described in greater detail below.### Rule of Sum

The rule of sum is an intuitive principle stating that if there are [latex]a[/latex] possible ways to do something, and [latex]b[/latex] possible ways to do another thing, and the two things can't both be done, then there are [latex]a + b[/latex] total possible ways to do one of the things. More formally, the sum of the sizes of two disjoint sets is equal to the size of the union of these sets.### Rule of Product

The rule of product is another intuitive principle stating that if there are [latex]a[/latex] ways to do something and [latex]b[/latex] ways to do another thing, then there are [latex]a \cdot b[/latex] ways to do both things.### Inclusion-Exclusion Principle

The inclusion-exclusion principle is a counting technique that is used to obtain the number of elements in a union of multiple sets. This counting method ensures that elements that are present in more than one set in the union are not counted more than once. It considers the size of each set and the size of the intersections of the sets. The smallest example is when there are two sets: the number of elements in the union of [latex]A[/latex] and [latex]B[/latex] is equal to the sum of the number of elements in [latex]A[/latex] and [latex]B[/latex], minus the number of elements in their intersection. See the diagram below for an example with three sets.### Bijective Proof

A bijective proof is a proof technique that finds a bijective function [latex]f: A \rightarrow B[/latex] between two finite sets [latex]A[/latex] and [latex]B[/latex], which proves that they have the same number of elements, [latex]|A| = |B|[/latex]. A bijective function is one in which there is a one-to-one correspondence between the elements of two sets. In other words, each element in set [latex]B[/latex] is paired with exactly one element in set [latex]A[/latex]. This technique is useful if we wish to know the size of [latex]A[/latex], but can find no direct way of counting its elements. If [latex]B[/latex] is more easily countable, establishing a bijection from [latex]A[/latex] to [latex]B[/latex] solves the problem.### Double Counting

Double counting is a combinatorial proof technique for showing that two expressions are equal. This is done by demonstrating that the two expressions are two different ways of counting the size of one set. In this technique, a finite set [latex]X[/latex] is described from two perspectives, leading to two distinct expressions for the size of the set. Since both expressions equal the size of the same set, they equal each other.### Pigeonhole Principle

The pigeonhole principle states that if [latex]a[/latex] items are each put into one of [latex]b[/latex] boxes, where [latex]a>b[/latex], then at least one of the boxes contains more than one item. This principle allows one to demonstrate the existence of some element in a set with some specific properties. For example, consider a set of three gloves. In such a set, there must be either two left gloves or two right gloves (or three of left or right). This is an application of the pigeonhole principle that yields information about the properties of the gloves in the set.### Generating Function

Generating functions can be thought of as polynomials with infinitely many terms whose coefficients correspond to the terms of a sequence. The (ordinary) generating function of a sequence [latex]a_n[/latex] is given by: [latex]\displaystyle f(x) = \sum_{n=0}^{\infty} a_{n}x^{n}[/latex] whose coefficients give the sequence [latex]\left \{ a_{0}, a_{1}, a_{2},... \right \}[/latex].### Recurrence Relation

A recurrence relation defines each term of a sequence in terms of the preceding terms. In other words, once one or more initial terms are given, each of the following terms of the sequence is a function of the preceding terms. The Fibonacci sequence is one example of a recurrence relation. Each term of the Fibonacci sequence is given by [latex]F_{n} = F_{n-1} + F_{n-2}[/latex], with initial values [latex]F_{0}=0[/latex] and [latex]F_{1}=1[/latex]. Thus, the sequence of Fibonacci numbers begins: [latex]\displaystyle 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89,...[/latex]## Permutations

A permutation of a set of objects is an arrangement of those objects in a particular order; the number of permutations can be counted.### Learning Objectives

Calculate the number of arrangements of ordered objects using permutations### Key Takeaways

#### Key Points

- Informally, a permutation of a set of objects is an arrangement of those objects into a particular order. For example, there are six permutations of the set [latex]{1,2,3}[/latex], namely [latex](1,2,3)[/latex], [latex](1,3,2)[/latex],[latex](2,1,3)[/latex], [latex](2,3,1)[/latex], [latex](3,1,2)[/latex], and [latex](3,2,1)[/latex].
- The number of permutations of [latex]n[/latex] distinct objects is [latex]n \cdot (n − 1) \cdot (n − 2) \cdots 2 \cdot 1[/latex]. This is called [latex]n[/latex] factorial, and written [latex]n![/latex].
- When deciding permutations of a subset from a larger set, it is often useful to divide one factorial by another to determine the number of permutations possible. For example, the first six cards from a deck of cards would have [latex]\frac {52!}{46! }[/latex] permutations possible, or about 14.7 billion.

#### Key Terms

**factorial**: The result of multiplying a given number of consecutive integers from [latex]1[/latex] to the given number. In equations, it is symbolized by an exclamation mark ([latex]![/latex]). For example, [latex]5! = 1 \cdot 2 \cdot 3 \cdot 4 \cdot 5 = 120[/latex].**permutation**: An ordering of a finite set of distinct elements.

### Permutations

A permutation of a set of objects is an arrangement of those objects into a particular order. For example, there are six permutations of the set [latex]{1,2,3}[/latex]: [latex](1,2,3)[/latex], [latex](1,3,2)[/latex], [latex](2,1,3)[/latex], [latex](2,3,1)[/latex], [latex](3,1,2)[/latex], and [latex](3,2,1)[/latex]. One might define an anagram of a word as a permutation of its letters.**The 6 permutations of 3 balls:**If one has three different colored balls, there are six distinct ways to order them, as shown. These six distinct orderings are as follows: red-green-blue, red-blue-green, green-red-blue, green-blue-red, blue-red-green, and blue-green-red.

### Example

In the game of Solitaire, seven cards are dealt out at the beginning: one face-up, and the other six face-down. A complete card deck has [latex]52[/latex] cards. Assuming that the only card that is seen is the [latex]7[/latex] of spades, how many possible "hands" (the other six cards) can be underneath? What makes this a permutation problem is that the order matters: if an ace is hiding somewhere in those six cards, it makes a difference whether the ace is on the first position, the second, etc. Permutation problems can always be addressed as an example of the multiplication rule, with one small twist.**One stack of cards in a game of solitaire:**To find out how many possible combinations of cards there are below the seven of spades, we use the concept of permutations to calculate the possible arrangements of cards.

### General Considerations

In mathematics, the notion of permutation is used with several slightly different meanings, all related to the act of permuting (rearranging) objects or values. Informally, a permutation of a set of objects is an arrangement of those objects into a particular order. The study of permutations generally belongs to the field of combinatorics. Permutations occur, in more or less prominent ways, in almost every domain of mathematics. They often arise when different orderings on certain finite sets are considered, possibly only because one wants to ignore such orderings and needs to know how many configurations are thus identified. For similar reasons, permutations arise in the study of sorting algorithms in computer science.## Permutations of Distinguishable Objects

The number of permutations of distinct elements can be calculated when not all elements from a given set are used.### Learning Objectives

Calculate the number of permutations of [latex]n[/latex] objects taken [latex]k[/latex] at a time### Key Takeaways

#### Key Points

- If all objects in consideration are distinct, they can be arranged in [latex]n![/latex] permutations, where [latex]n[/latex] represents the number of objects.
- If not all the objects in a set of [latex]n[/latex] unique elements are chosen, the above formula can be modified to: [latex]\displaystyle \frac {n!}{(n-k)! }[/latex], where [latex]k[/latex] represents the number of selected elements.
- When solving for quotients of factorials, the terms of the denominator can cancel with the terms of the numerator, thus eliminating perhaps the majority of terms to be multiplied.

#### Key Terms

**factorial**: The result of multiplying a given number of consecutive integers from [latex]1[/latex] to the given number. In equations, it is symbolized by an exclamation mark ([latex]![/latex]). For example, [latex]5! = 1 \cdot 2 \cdot 3 \cdot 4 \cdot 5 = 120[/latex].**permutation**: An ordering of a finite set of distinct elements.

### Permutations of a Partial Set

If not all of the objects in a set of unique elements are chosen, the following formula is used. This formula determines the number of possible permutations of [latex]k[/latex] elements selected from the set of [latex]n[/latex] elements: [latex]\displaystyle \frac {n!}{(n-k)! }[/latex] To understand the application of this concept, consider a race in which [latex]3[/latex] different prizes are awarded to the top [latex]3[/latex] fastest competitors. If [latex]25[/latex] competitors participate in the race, in how many distinct orders could the [latex]3[/latex] prizes be awarded? To solve this problem, we want to evaluate the number of possible permutations of [latex]3[/latex]elements from the set of [latex]25[/latex] elements; in other words, [latex]k = 3[/latex] and [latex]n=25[/latex]. Plugging these values into the formula, we have: [latex]\displaystyle \frac {25!}{(25-3)! } = \frac {25!}{22!} [/latex] Remember that both [latex]25![/latex] and [latex]22![/latex] contain the terms [latex]22 \cdot 21 \cdots 2 \cdot 1[/latex]. Thus, these values cancel from the numerator and denominator, and the equation can be simplified: [latex-display][/latex-display] [latex] \displaystyle \begin{align} \frac{25!}{22!} &= \frac{25 \cdot 24 \cdot 23 \cdot 22 \cdot 21 \cdots 2 \cdot 1}{22 \cdot 21 \cdots 2 \cdot 1} \\ &= 25 \cdot 24 \cdot 23 \\ &= 13,800 \end{align}[/latex] There are [latex]13,800[/latex] possible permutations in which the [latex]3[/latex] top prizes may be awarded to the [latex]25[/latex] race competitors.### General Considerations

It is worth noting that this formula does not exclude what we might call 'duplicate' permutations. In other words, the order of the elements selected does matter. Consider [latex]3[/latex] cards drawn from a pack: an ace of spades, a [latex]10[/latex] of diamonds, and a [latex]3[/latex] of clubs. The hand is exactly the same as the following: a [latex]10[/latex] of diamonds, an ace of spaces and a [latex]3[/latex] of clubs. If you are playing a game in which the order of your cards does not matter*,*you will only want to count each permutation of cards once. The formula introduced here does not apply to such situations. [latex-display][/latex-display]

## Permutations of Nondistinguishable Objects

The expression revealing the number of permutations of distinct items can be modified if not all items in the set are distinct.### Learning Objectives

Calculate the number of permutations of a given set of objects, some being non distinguishable### Key Takeaways

#### Key Points

- Some sets include repetitions of certain elements. In these cases, the number of possible permutations of the items cannot be expressed by [latex]n![/latex], where [latex]n[/latex] represents the number of elements, because this calculation would include a multiplicity of possible states.
- To correct for the multiplicity of certain permutations, divide the factorial of the total number of elements by the product of the factorials of the number of each repeated element.
- The expression for number of permutations with repeated elements is: [latex]\frac {n!}{n_1!n_2!n_3!... }[/latex] where [latex]n[/latex] is the total number of terms in a sequence and [latex]n_1[/latex], [latex]n_2[/latex], and [latex]n_3[/latex] are the number of repetitions of different elements.

#### Key Terms

**multiplicity**: The number of values for which a given condition holds.**permutation**: An ordering of a finite set of distinct elements.

### Example: Consider the set of numbers:

[latex]\displaystyle (15, 17, 24, 24, 28)[/latex] There are five terms, so [latex]n=5[/latex]. However, two of the terms are the same; their value is [latex]24[/latex]. Thus, the number of possible distinct permutations in the set is: [latex-display]\displaystyle{\frac {5!}{2! }=60}[/latex-display] The same logic can apply to more complicated systems.### Example: Consider the set:

[latex]\displaystyle (0, 0, 0, 2, 4, 4, 7, 7, 7, 7, 7, 8, 8)[/latex] In total, there are [latex]13[/latex] elements. These include many repetitions: [latex]0[/latex] is seen 3 times, [latex]4[/latex]and [latex]8[/latex] each are observed twice, and there are [latex]5[/latex] instances of the number [latex]7[/latex]. Thus, the number of possible distinct permutations can be calculated by: [latex]\displaystyle \frac {13! }{2!\cdot 2!\cdot 3!\cdot 5! }= 2,162,160[/latex] This logic can be applied to problems involving anagrams of given words.### Example: Consider how many distinct ways you can order the letters of the word "waterfall."

The word waterfall consists of [latex]9[/latex] letters in total, so [latex]n=9[/latex]. The letter "a" appears twice, giving a value of [latex]2[/latex] for [latex]n_{1}[/latex]. Similarly, the letter "l" appears twice, yielding [latex]n_{2} = 2[/latex]. Thus, the number of distinct permutations for the letters in "waterfall" can be calculated as: [latex]\displaystyle \frac {9! }{2!\cdot 2!}= 90,720[/latex]## Combinations

A combination is a way of selecting several things out of a larger group, where (unlike permutations) order does not matter.### Learning Objectives

Calculate the number of ways of selecting several things out of a larger group (where order doesn't matter) using combinations### Key Takeaways

#### Key Points

- A combination is a mathematical concept where one counts the number of ways one can select several elements out of a larger group.
- Unlike a permutation, when determining the number of combinations, order does not matter.
- Formally, a [latex]k[/latex]-combination of a set [latex]S[/latex] is a subset of [latex]k[/latex] distinct elements of [latex]S[/latex]. If the set has [latex]n[/latex] elements the number of [latex]k[/latex]-combinations is equal to the binomial coefficient: [latex]\begin{pmatrix} n\\ k \end{pmatrix} = \frac {n(n-1)...(n-k+1)}{k(k-1)...1}[/latex], which can be written using factorials as [latex]\frac {n!}{k!(n-k)! }[/latex] whenever [latex]k \le n[/latex] and which is zero when [latex]k > n[/latex].

#### Key Terms

**combination**: A way of selecting elements from a set, where order does not matter.**binomial coefficient**: A coefficient of any of the terms in the expansion of the binomial power [latex](1+x)^n[/latex].

- A school offers [latex]50[/latex] classes. Each student must choose [latex]6[/latex] of them to fill out a schedule. How many possible schedules can be made?
- A basketball team has [latex]12[/latex] players, but only [latex]5[/latex] will start. How many possible starting teams can they field?
- Your computer contains [latex]300[/latex] videos, but you can only fit [latex]10[/latex] of them on your phone. How many possible ways can you load your phone?

### General Considerations

The number of [latex]k[/latex]-combinations, or [latex]\begin{pmatrix} S \\ k \end{pmatrix}[/latex], is also known as the binomial coefficient, because it occurs as a coefficient in the binomial formula. The binomial coefficient is the coefficient of the [latex]x^k[/latex] term in the polynomial expansion of [latex](1+x)^n[/latex]. [latex][/latex]## Licenses & Attributions

### CC licensed content, Shared previously

- Curation and Revision.
**Authored by:**Boundless.com.**License:**Public Domain: No Known Copyright.

### CC licensed content, Specific attribution

- Bijection.
**Provided by:**Wikipedia**Located at:**https://en.wikipedia.org/wiki/Bijection.**License:**CC BY-SA: Attribution-ShareAlike. - Pigeonhole principle.
**Provided by:**Wikipedi**License:**CC BY-SA: Attribution-ShareAlike. - Inclusion-exclusion principle.
**Provided by:**Wikipedia**License:**CC BY-SA: Attribution-ShareAlike. - Combinatorics.
**Provided by:**Wikipedia**License:**CC BY-SA: Attribution-ShareAlike. - Double counting (proof technique).
**Provided by:**Wikipedia**License:**CC BY-SA: Attribution-ShareAlike. - Bijective proof.
**Provided by:**Wikipedia**License:**CC BY-SA: Attribution-ShareAlike. - Combinatorial principles.
**Provided by:**Wikipedia**License:**CC BY-SA: Attribution-ShareAlike. - combinatorics.
**Provided by:**Wiktionary**License:**CC BY-SA: Attribution-ShareAlike. - polynomial.
**Provided by:**Wiktionary**License:**CC BY-SA: Attribution-ShareAlike. - Kenny Felder, Advanced Algebra II: Conceptual Explanations. September 17, 2013.
**Provided by:**OpenStax CNX**Located at:**https://cnx.org/contents/[email protected]:803bcd82-f87f-416e-863d-ed4b2e64823e.**License:**CC BY: Attribution. - Permutation.
**Provided by:**Wikipedia**License:**CC BY-SA: Attribution-ShareAlike. - permutation.
**Provided by:**Wiktionary**License:**CC BY-SA: Attribution-ShareAlike. - factorial.
**Provided by:**Wiktionary**License:**CC BY-SA: Attribution-ShareAlike. - Kenny Felder, Advanced Algebra II: Conceptual Explanations. December 11, 2012.
**Provided by:**OpenStax CNX**Located at:**https://cnx.org/contents/[email protected]:803bcd82-f87f-416e-863d-ed4b2e64823e.**License:**CC BY: Attribution. - Permutations RGB.
**Provided by:**Wikipedia**License:**CC BY-SA: Attribution-ShareAlike. - Permutation.
**Provided by:**Wikipedia**License:**CC BY-SA: Attribution-ShareAlike. - permutation.
**Provided by:**Wiktionary**License:**CC BY-SA: Attribution-ShareAlike. - factorial.
**Provided by:**Wiktionary**License:**CC BY-SA: Attribution-ShareAlike. - Factorial.
**Provided by:**Wikipedia**Located at:**https://en.wikipedia.org/wiki/Factorial.**License:**CC BY-SA: Attribution-ShareAlike. - Kenny Felder, Advanced Algebra II: Conceptual Explanations. December 11, 2012.
**Provided by:**OpenStax CNX**Located at:**https://cnx.org/contents/[email protected]:803bcd82-f87f-416e-863d-ed4b2e64823e.**License:**CC BY: Attribution. - Permutations RGB.
**Provided by:**Wikipedia**License:**CC BY-SA: Attribution-ShareAlike. - Permutation.
**Provided by:**Wikipedia**License:**CC BY-SA: Attribution-ShareAlike. - multiplicity.
**Provided by:**Wiktionary**License:**CC BY-SA: Attribution-ShareAlike. - permutation.
**Provided by:**Wiktionary**License:**CC BY-SA: Attribution-ShareAlike. - Kenny Felder, Advanced Algebra II: Conceptual Explanations. December 11, 2012.
**Provided by:**OpenStax CNX**Located at:**https://cnx.org/contents/[email protected]:803bcd82-f87f-416e-863d-ed4b2e64823e.**License:**CC BY: Attribution. - Permutations RGB.
**Provided by:**Wikipedia**License:**CC BY-SA: Attribution-ShareAlike. - Permutation.
**Provided by:**Wikipedia**License:**CC BY-SA: Attribution-ShareAlike. - Kenny Felder, Advanced Algebra II: Conceptual Explanations. September 17, 2013.
**Provided by:**OpenStax CNX**Located at:**https://cnx.org/contents/[email protected]:77982c3d-7bb5-42f0-9779-c0be5aa1a589.**License:**CC BY: Attribution. - Combination.
**Provided by:**Wikipedia**Located at:**https://en.wikipedia.org/wiki/Combination.**License:**CC BY-SA: Attribution-ShareAlike. - binomial coefficient.
**Provided by:**Wiktionary**License:**CC BY-SA: Attribution-ShareAlike. - Kenny Felder, Advanced Algebra II: Conceptual Explanations. December 11, 2012.
**Provided by:**OpenStax CNX**Located at:**https://cnx.org/contents/[email protected]:803bcd82-f87f-416e-863d-ed4b2e64823e.**License:**CC BY: Attribution. - Permutations RGB.
**Provided by:**Wikipedia**License:**CC BY-SA: Attribution-ShareAlike.