# Thread: Number of derangements of n objects

1. ## Number of derangements of n objects

Recall that a derangement of a set $S$ is a permutation $\pi$ of $S$ having no fixed points, i.e. $\pi(s)\neq s \ \ \forall s \in S$. If the number of derangements of $\{1,\dots,n\}$ is $!n$, show that

$!n = \sum_{j=0}^n{n \choose j}(-1)^{n-j} j!$.

Hint :

Spoiler:
You might first want to show that if $b_n$ is an arbitrary sequence and $a_n=\sum_{j=0}^n{n\choose j}b_j$, then $b_n$ can be retrieved by $b_n = \sum_{j=0}^n{n\choose j}(-1)^{n-j}a_j$.

2. ## Question

Is $n!$ the same as $!n$?

3. No! $n!$ is the factorial and $!n$ is the number of derangements of a set having $n$ elements.

4. Originally Posted by Bruno J.
Recall that a derangement of a set $S$ is a permutation $\pi$ of $S$ having no fixed points, i.e. $\pi(s)\neq s \ \ \forall s \in S$. If the number of derangements of $\{1,\dots,n\}$ is $!n$, show that

$!n = \sum_{j=0}^n{n \choose j}(-1)^j j!$.

Hint :

Spoiler:
You might first want to show that if $b_n$ is an arbitrary sequence and $a_n=\sum_{j=0}^n{n\choose j}b_j$, then $b_n$ can be retrieved by $b_n = \sum_{j=0}^n{n\choose j}(-1)^ja_j$.

A well-worded argument with the inclusion-exclusion principle shows that $!n=n!\sum_{j=0}^{n}\frac{(-1)^j}{j!}$. But $\sum_{j=0}^{n}{n\choose j}(-1)^j j!$. Applying the symmetry of the sum finishes the argument. I suppose you want me to show that inclusion-exclusion argument?

5. Haha... well yeah, that would certainly complete your proof!

6. Originally Posted by Bruno J.
Recall that a derangement of a set $S$ is a permutation $\pi$ of $S$ having no fixed points, i.e. $\pi(s)\neq s \ \ \forall s \in S$. If the number of derangements of $\{1,\dots,n\}$ is $!n$, show that

[CENTER] $!n = \sum_{j=0}^n{n \choose j}(-1)^j j!$.
Bruno J
You need to adjust this form. For odd n it gives a negative of the correct answer.
$n=3$ gives $1-3\cdot 1!+ 3\cdot 2! -3!=-2$

7. Originally Posted by Bruno J.
Haha... well yeah, that would certainly complete your proof!
I'll post one up later, if anyone else doesn't. Also, you can solve this with recurrence relations.

8. Originally Posted by Plato
Bruno J
You need to adjust this form. For odd n it gives a negative of the correct answer.
$n=3$ gives $1-3\cdot 1!+ 3\cdot 2! -3!=-2$
Quite right! I made a mistake. I have corrected it. Thank you Plato!

9. Spoiler:
For $j=1,2,\dots,n,$ let

$A_j=\{\sigma \in S_n|\, \sigma(j)=j\}.$

Then

$!n = n!-\left|\bigcup_{j=1}^nA_j\right|$.

By the inclusion-exclusion principle

$\left|\bigcup_{j=1}^nA_j\right|=\sum_{j=1}^{n}|A_i |-\sum_{1\le j

Consider the intersection

$A_{j_1} \cap A_{j_2} \cap \cdots \cap A_{j_r}=\{\sigma \in S_n|\, \sigma(j_1)=j_1, \sigma(j_2)=j_2, \dots ,\sigma(j_r)=j_r\}$, for $1 \le r \le n.$

There are $\binom{n}{r}$ of these r-intersections, each of them having $(n-r)!$ permutations. Thus, we have

$\sum_{1 \le j_{1} < j_{2} < \cdots < j_{r} \le n}|A_{j_1} \cap A_{j_2} \cap \cdots \cap A_{j_r}|=\binom{n}{r}(n-r)!$,

so

$!n = \binom{n}{0}n! -\left[\binom{n}{1}(n-1)!-\cdots +(-1)^{n-1}\binom{n}{n}(n-n)!\right]$

$=\binom{n}{n}(-1)^{n-n}n!+\binom{n}{n-1}(-1)^{n-(n-1)}(n-1)!+\cdots+\binom{n}{0}(-1)^n0!$

$=\sum_{j=0}^{n}\binom{n}{j}(-1)^{n-j}j!$.

10. Good job, Black! You are an impressive new member. Are you a university student?

I will post another nice solution later today.

11. Here is another proof.

First, I prove the statement in the hint that I gave. Consider the exponential generating function

$g_B(z)=\sum_{j=0}^\infty b_j \frac{z^j}{j!}$

of the sequence $B=\{b_j\}$. By the basic properties of exponential generating functions, the product of the exponential generating functions of two sequences is the exponential generating function of their binomial convolution. So we have

$g_A(z) = \sum_{j=0}^\infty a_j \frac{z^j}{j!} = e^zg_B(z)$

and so $g_B(z)=e^{-z}g_A(z)$. Extracting the coefficient of $\frac{z^n}{n!}$ on both sides we obtain $b_n = \sum_{j=0}^n {n \choose j}(-1)^{n-j}a_j$ as required.

Now let us partition the set $S_n$ of permutations of $\{1,\dots,n\}$ as follows; let $T_j \subset S_n$ denote those permutations which have precisely $j$ fixed points, for $j=0, \dots, n$. Clearly there are ${n \choose j}$ ways of picking the elements which are to be fixed, and the remaining $n-j$ elements have to be deranged. So $|T_j| = {n \choose j}!(n-j)$. Since the $T_j$ are clearly distinct we have

$|S_n|=n!=\sum_{j=0}^n|T_j| = \sum_{j=0}^n{n \choose j}!(n-j) = \sum_{j=0}^n{n \choose j}!j$

because ${n \choose j} = {n \choose n-j}$. Now just apply the binomial involution just proved!