\magnification 1900 \parindent 0pt \parskip 10pt \pageno=1 \hsize 7.2truein \hoffset -0.35truein \voffset -0.3truein \vsize 10truein \def\u{\vskip -10pt} \def\v{\vfill} \def\s{\vskip -5pt} \def\r{\vskip -4pt} \def\t{\vskip 10pt} \def\Z{\cal Z} \def\hb{\hfil \break} \def\hr{\vskip 5pt \hrule } \def\S5{\Sigma_{n=1}^5} \underbar{6.3 Derangements} Suppose each person in a group of $n$ friends brings a gift to a party. In how many ways can the $n$ gifts be distributed so that no person receives their own gift. Let the set of friends = $\{p_1, ..., p_n\}$ where $p_j = $ person $j$. \hb Let the set of gifts = $\{g_1, ..., g_n\}$ where $g_j$ = the gift brought by person $j$. Suppose $f: \{p_1, ..., p_n\} \rightarrow \{g_1, ..., g_n\}$, \hb $f(p_k) = g_j$ iff person $p_k$ receives give $g_j$, the gift brought by person $j$. \hb If no person receives their own gift. Then $f(p_j) \not= g_j$. In simpler notation, \hb $f: \{1, ..., n\} \rightarrow \{1, ..., n\} $ such that $f(j) \not = j$ Recall: \hb a permutation on $ \{1, ..., n\} $ is a bijection $f\{1, ..., n\} \rightarrow \{1, ..., n\} $ Ex: The permutation 1 2 3 4 5 corresponds to the identity function. Ex: The permutation 1 3 2 corresponds to the function $f(1) = 1$, $f(2) = 2$, $f(3) = 2$ Defn: A {\it derangement} of $\{1, ..., n\}$ is a permutation $i_1 i_2 ... i_n$ such that $i_j \not = j$. I.e, $j$ is not in the $j$th place. In function notation: $f(j) = i_j$, then if $i_1 i_2 ... i_n$ is a derangement, $f(j) \not= j$ In yet other wording, recall a permuation corresponds to the placement of $n$ non-attacking rooks on an $n \times n$ chessboard. Ex: The permutation 1 3 2 corresponds to the following rook placement: \v A derangment corresponds to non-attacking rook placement with forbidden positions along the diagonal $(j, j)$, for $j = 1, ..., n$. Ex: If rooks are placed on the following $3 \times 3$ chessboard in non-attacking position, then the rook placement corresponds to a derangement if no rook is placed in a spot marked with an $X$. \v Thus the derangements of $\{1, 2, 3\}$ are 2 3 1, 2 1 3, 3 1 2, 3 2 1. \eject Let $D_n$ = the number of derangements of $\{1, ..., n\}$. Thm 6.3.1: For $n \geq 1$, $D_n = n!( 1 - {1 \over 1!} + {1 \over 2!} - {1 \over 3!} + ... + (-1)^n{1 \over n!})$ Pf: Use the inclusion and exclusion principle: If $A_i \subset S$, \line{$\overline{\cup A_i} = |S| - \Sigma_{j = 1}^n |A_j| + \Sigma_{i, j} |A_i \cap A_j| - ... + (-1)^n |A_{1} \cap A_{2} \cap ... \cap A_{n}|.$} Choose $S$. What can we count which contains the set of derangements? Let $S =$ the set of permutations of $\{1, ..., n\}$. Then $|S| = n!$. Choose $A_j$ such that the set of derangments = $\overline{\cup A_j}$. \hb Let $A_j$ = set of permutations such that $j$ is in the $j$th spot. Note: $|A_j| = (n-1)!$ since their is only one choice for the $j$th spot (namely j), leaving $n-1$ terms to permute in the remaining $n-1$ places. $|A_i \cap A_j| = (n-2)!$ $|A_{i_1} \cap A_{i_2} \cap ... \cap A_{i_k}| = (n-k)!$. Thus $D_n = n! - \Sigma_{j = 1}^n (n-1)! + \Sigma_{i, j}(n-2)! - ... + (-1)^n (n -n)!$ $= \left(\matrix{n \cr 0}\right) n! - \left(\matrix{n \cr 1}\right) (n-1)! + \left(\matrix{n \cr 2}\right) (n-2)! - ... + \left(\matrix{n \cr n}\right) (-1)^n 0!$ $= n! - {n! \over 1!} + {n! \over 2!} + ... + (-1)^n {n! \over n!}$ $= n!(1 - {1 \over 1!} + {1 \over 2!} + ... + (-1)^n {1 \over n!})$ Recall $\left(\matrix{n \cr k}\right) =$ number of ways to choose $k$ $A_i$'s. \eject Sidenote: Finding the number of derangements is often called the hat check problem, because in the old days it was sometimes stated in the following terms: If $n$ men check their hats, what the probability that the hats are returned so that no one received their own hat. Recall: If $E \subset S$, then the probability of $E$ = $P(E) = {|E| \over |S|}$ $S$ = sample space, $E$ = events. Note: we assume each outcome is equally likely. What is the probability that a waiter delivers 4 orders to 4 customers so that no customer receives what they ordered? Answer: ${D_4 \over 4!} = 1 - 1 + {1 \over 2} - {1 \over 6} = {1 \over 3}$ The probability that a permutation of $\{1, ..., n\}$ is a derangement = ${D_n \over n!} = 1 - {1 \over 1!} + {1 \over 2!} + ... + (-1)^n {1 \over n!}$ Recall from Taylor's expansion from Calculus I, the if $f(x) = $ Recall from Calculus I (Taylor's exp), the $e^{-1} = \Sigma_{j = 0}^\infty (-1)^j {1 \over !}$. Thus $e^{-1}$ is a good approximation for the probability of a derangement for $n$ (slightly) large. Thus the probability that if floor, ceiling. We can derive a recursive formula for $D_n$ (we will look at many recursive formulas in chapter 7). Lemma A: $D_n = (n-1)(D_{n-2} + D_{n-1})$ Note the above formula is a recursive formula as we can determine $D_n$ by calculating $D_k$ for $k < n$. Note $D_1 = 0$, $D_2 = 1$ (as 2 1 is the only derangement of $\{1, 2\}$). Thus $D_3 = 2(0 + 1) = 2$, $D_4 = 3(1 + 2) = 9$, $D_5 = 4(2 + 9) = 44$, etc. Combinatorial proof of lemma A: $D_n = $ the number of derangements of $\{1, ..., n\}$, a set containing $n$ elements. $D_{n-1} = $ the number of derangements of $\{1, ..., n-1\}$, a set containing $n-1$ elements. Let's analyze $D_n$. The first position of our derangement can be anything except 1. Thus there are $n-1$ choices for the first position is $n-1$. Note $n-1$ appears in our formula. Let's see if we can use this. Let $r_2 =$ the number of derangments such that 2 is in the first position. In general, let $r_k$ = the number of derangments such that $k$ is in the $n$th position. Note that $r_1 = r_3 = ... = r_{n-1}$ (while $r_n = 0$). Then $D_n = r_1 + ... + r_{n-1} = r_{n-1} + ... + r_{n-1} = (n-1)r_{n-1}$. Thus we have (hopefully) simplified our problem to showing that $r_{n-1} = D_{n-2} + D_{n-1}$ Let $r_{n-1}'$ = the number of derangments such that $n-1$ is in the $n$th position and $n$ is in the $n-1$st position. Note $r_{n-1}' = D_{n-2}$. Note $r_n - r_{n-1}' =$ the number of derangments such that $n-1$ is in the $n$th position and $k$ is in the $n-1$st position for some $k \leq n-2$. We would like to show that $D_{n-1} =$ the number of derangments of $\{1, ..., n-1\}$ such that $n-1$ is in the $n$th position and $k$ is in the $n-1$st position for some $k \leq n-2$. Let ${\cal P}_{n}$ the set of derangement where $n-1$ is in the $n$th position and $k$ is in the $n-1$st position for some $k \leq n-2$. Let ${\cal D}_{n-1}$ = the set of derangments of $\{1, ..., n-1\}$. How can we Let's analyze a derangement where $n-1$ is in the $n$th position and $k$ is in the $n-1$st position for some $k \leq n-2$. We would like to create a bijection from ${\cal P}_{n}$ to ${\cal D}_{n-1}$ Let $i_1i_2... i_n \in {\cal P}_{n}$. Then $i_n = n-1$ and $i_{n-1} = k$ for some $k \leq n-2$. Create $j_1 j_2 ... j_{n-1}$, a derangment of $\{1, ..., n-1\}$ by let $j_l = \cases{ i_l & if $i_l \not= n$, $1 \leq l \leq n-1$ \cr n-1 & if $i_l \not= n$ } $ Ex: $25314 \rightarrow 2431$ Another (simpler) recurrance relation: Lemma B: $D_n = nD_{n-1} + (-1)^n$ for $n \geq 2$ Proof by induction on $n$. $n = 2$: $D_2 = 1$ (use definition or Thm 6.3.1) $2D_1 + (-1)^2 = 2(0) + 1 = 1$. Thus $D_n = nD_{n-1} + (-1)^n$ holds for $n = 2$. Suppose $D_{k-1} = (k-1)D_{k-2} + (-1)^{k-1}$ for $k < n$ Then $D_k = (k-1) D_{k-2} + (k-1) D_{k-1} $ Note $D_{k-1} = (k-1)D_{k-2} + (-1)^{k-1}$ implies $(k-1) D_{k-2} = D_{k-1} - (-1)^{k-1}$ Thus $D_k = D_{k-1} - (-1)^{k-1} + (k-1) D_{k-1} = k D_{k-1} + (-1) (-1)^{k-1} = k D_{k-1} + (-1)^{k} $ \underbar{6.4 Permutations with Forbidden Positions} Recall in section 6.3, we looked at permutations with forbidden positions A derangment corresponds to non-attacking rook placement with forbidden positions along the diagonal $(j, j)$, for $j = 1, ..., n$. Let $X_j \subset \{1, ..., n\}$ for $j = 1, ..., n$. Defn: $P(X_1, X_2, ..., X_n) =$ the set of permutations $i_1i_2...i_n$ of $\{1, ..., n\}$ such that $i_j \not\in X_j$. Defn: $P(X_1, X_2, ..., X_n) = |P(X_1, X_2, ..., X_n)|$ Ex: $P(X_1, X_2, ..., X_n)$ corresponds to the set of derangements of $\{1, ..., n\}$ if $X_j = \{j\}$. Thus $D_n = |P( \{1\}, \{2\}, ..., \{n\}|$ Recall, we can visualize permutations with forbidden positions via $n \times n$ chessboards. Ex: Derangements of $\{1, 2, 3\}$ Non-derangement example: $n = 4$, $X_i = \{j, j+1\}$, $j = 1, 2, 3$, $X_4 = \emptyset$. $P(X_1, X_2, ..., X_n) = P(\{1, 2\}, \{2, 3\}, \{3, 4\}, \emptyset) = \{3124, 3412, 3421, 4123\}$. $p(X_1, X_2, ..., X_n) = p(\{1, 2\}, \{2, 3\}, \{3, 4\}, \emptyset) = |\{3124, 3412, 3421, 4123\}| = 4$. We can use the inclusion-exclusion principle to calculate $p(X_1, X_2, ..., X_n)$ (although in many cases, the computation can be tediously long and beyond computer capabilities for large $n$). Similar to the proof of Thm 6.3.1, $p(X_1, X_2, ..., X_n) = |S| - \Sigma_{j = 1}^n |A_j| + \Sigma_{i, j} |A_i \cap A_j| - ... + (-1)^n |A_{1} \cap A_{2} \cap ... \cap A_{n}|$ where Let $S =$ the set of permutations of $\{1, ..., n\}$. Then $|S| = n!$. Let $A_j$ = set of permutations $i_1i_2...i_n$ such that $i_j in X_j$ (for a fixed $j$). Note there are $|X_j|$ ways to place a rook in the $j$th position. There are $(n-1)!$ ways to place the remaining $n-1$ rooks so that the permutation belongs to $A_j$. Thus $|A_j| = |X_j|(n-1)!$. Thus $\Sigma_{j = 1}^n |A_j| = \Sigma_{j = 1}^n |X_j|(n-1)!= (n-1)!\Sigma_{j = 1}^n |X_j| = r_1(n-1)!$ where $r_1 = \Sigma_{j = 1}^n |X_j|$. Note $r_1 =$ number of ways to place $1$ nonattacking rooks on an $n \times n$ chessboard so that the rook is in a forbidden position. Let's now look at $A_j \cap A_k$. $i_1i_2...i_n \in A_j \cap A_k$, then $i_j \in A_j$ and $i_k \in A_k$. Thus there are $|X_j|$ ways to place a rook in the $j$th position and $|X_k|$ ways to place a rook in the $k$th position. There are $(n-2)!$ ways to place the remaining $n-1$ rooks so that the permutation belongs to $A_j \cap A_k$. Thus $|A_j \cap A_k| = |X_j||X_k|(n-2)!$. $\Sigma_{i, j} |A_i \cap A_j| = \Sigma_{i, j} |X_j||X_k|(n-2)! = (n-2)! \Sigma_{i, j} |X_j||X_k|$. Let $r_2 = \Sigma_{i, j} |X_j||X_k|$. Note $r_2 =$ number of ways to place $2$ nonattacking rooks on an $n \times n$ chessboard so that each of the $2$ rooks is in a forbidden position. Similarly, define $r_k =$ number of ways to place $k$ nonattacking rooks on an $n \times n$ chessboard so that each of the $k$ rooks is in a forbidden position. Then $\Sigma |A_{i_1} \cap A_{i_2} \cap ... \cap A_{i_k}| = r_k(k-1)!$. Thm 6.4.1: $p(X_1, X_2, ..., X_n) = n! - r_1(n-1)! + r_2(n-2)! - ... + (-1)^nr_n$. \end