I understand the whole concept of Rencontres numbers but I can't understand how to prove this equation

$$D_{n,0}=\left[\frac{n!}{e}\right]$$

where $[\cdot]$ denotes the rounding function (i.e., $[x]$ is the integer nearest to $x$). This equation that I wrote comes from solving the following recursion, but I don't understand how exactly did the author calculate this recursion

$\begingroup$If the floor function is the function which sends any real number $x$ to the largest integer not greater than $x$, as is customary, the assertion is false, for even values of $n$. For example there is $1$ derangement of $\{1,2\}$ but $\lfloor2!/e\rfloor=0$.$\endgroup$
– DidNov 18 '11 at 16:16

A Derangement is a permutation, $P$, in which no element is mapped to itself; that is, $P(k)\ne k$, for $1\le k\le n$. Let $\mathcal{D}(n)$ be the number of derangements of $n$ items.

Here are a few methods of computing $\mathcal{D}(n)$.

Method 1 (build from smaller derangements):

Let us count the number of derangements of $n$ items so that $P(P(n))=n$. There are $n-1$ choices for $P(n)$, and for each of those choices, $\mathcal{D}(n-2)$ ways to arrange the other $n-2$ items. Thus, there are $(n-1)\mathcal{D}(n-2)$ derangements of $n$ items so that $P(P(n))=n$.

Let us count the number of derangements of $n$ items so that $P(P(n))\not=n$. There are $n-1$ choices for $P(n)$, and for each choice, there is a derangement of $n-1$ items identical to $P$ except that they map $P^{-1}(n)\to P(n)$. Thus, there are $(n-1)\mathcal{D}(n-1)$ derangements of $n$ items so that $P(P(n))\not=n$.

Count the number of permutations of $n$ items by counting how many fix exactly $k$ items.

There are $\binom{n}{k}$ ways to choose the $k$ items to fix, then $\mathcal{D}(n-k)$ ways to arrange the $n-k$ items that are not fixed. Since there are $n!$ permutations of $n$ items, we get
$$
n!=\sum_{k=0}^n\binom{n}{k}\mathcal{D}(n-k)\tag{2}
$$
and therefore, rearranging $(2)$ yields
$$
\mathcal{D}(n)=n!-\sum_{k=1}^n\binom{n}{k}\mathcal{D}(n-k)\tag{3}
$$
Method 3 (inclusion-exclusion):

Let $S_i$ be the set of permutations of $n$ items which fix item $i$. Then the number of permutations in $k$ of the $S_i$ would be the number of permutations that fix $k$ items. There are $\binom{n}{k}$ ways to choose the $k$ items to fix, and $(n-k)!$ ways to arrange the other $n-k$ items. Thus, the number of permutations that fix at least $1$ item would be
$$
\sum_{k=1}^n(-1)^{k-1}\binom{n}{k}(n-k)!=\sum_{k=1}^n(-1)^{k-1}\frac{n!}{k!}\tag{4}
$$
Since there are $n!$ permutations in total, the number of permutations that don't fix any items is
$$
\begin{align}
\mathcal{D}(n)
&=n!-\sum_{k=1}^n(-1)^{k-1}\frac{n!}{k!}\\
&=\sum_{k=0}^n(-1)^k\frac{n!}{k!}\tag{5}\\
&\approx \frac{n!}{e}
\end{align}
$$
In fact, the difference
$$
\begin{align}
\left|\frac{n!}{e}-\mathcal{D}(n)\right|
&=\left|\sum_{k=n+1}^\infty(-1)^k\frac{n!}{k!}\right|\\
&=\left|\frac{1}{n+1}-\frac{1}{(n+1)(n+2)}+\frac{1}{(n+1)(n+2)(n+3)}-\dots\right|\\
&<\frac{1}{n+1}\tag{6}
\end{align}
$$
This method yields directly that $\mathcal{D}(n)$ is the closest integer to $\frac{n!}{e}$ for $n>0$.

$\begingroup$+1 for the nice survey on derangements. Two comments: 1) Your Method 1 is equivalent to my answer. 2) You might be interested in this paper of mine generalizing the derangement numbers.$\endgroup$
– Mike SpiveyNov 18 '11 at 22:07

1

$\begingroup$@Mike: I didn't mean to step on any toes. However, I wanted to include $(1)$ because I was planning on using it to derive the closed form (I've just added said derivation).$\endgroup$
– robjohn♦Nov 18 '11 at 23:07

$\begingroup$@user350331: Inclusion-Exclusion says that the number of items in the union is $$\sum_{k=1}^n(-1)^{k-1}N(k)$$ where $N(k)$ is the sum of the number of items in all of the intersections of $k$ of the $S_i$. To count these, we multiply the number of intersections of $k$ of the $S_i$, $\binom{n}{k}$, by the size of each intersection of $k$ of the $S_i$, $(n-k)!$.$\endgroup$
– robjohn♦Dec 17 '16 at 9:59

Here's a different derivation. A derangement $D_n$ ($= D_{n,0}$) is a permutation of $n$ elements with no fixed points. We will prove an integral representation for $D_n$ that produces quick derivations of $D_n \approx n!/e$ and $D_n = n! \sum_{k=0}^n (-1)^k/k!.$

For any derangement $(j_1, j_2, \ldots, j_n)$, we have $j_n \neq n$. Let $j_n = k$, where $k \in \{1, 2, \ldots, n-1\}$. We now break the derangements on $n$ elements into two cases.

Case 1: $j_k = n$ (so $k$ and $n$ map to each other). By removing elements $k$ and $n$ from the permutation we have a derangement on $n-2$ elements, and so, for fixed $k$, there are $D_{n-2}$ derangements in this case.

Case 2: $j_k \neq n$. Swap the values of $j_k$ and $j_n$, so that we have a new permutation with $j_k = k$ and $j_n \neq n$. By removing element $k$ we have a derangement on $n-1$ elements, and so, for fixed $k$, there are $D_{n-1}$ derangements in this case.

Equation $(2)$ is actually a special case of a more general result that says that the number of permutations with a specified set of fixed points can be represented by $\int_0^{\infty} R_{\tilde{G}}(t) e^{-t} dt$, where $\tilde{G}$ is the complement of $G$ in the complete bipartite graph on $n$ elements, and $R_G(t)$ is the associated rook polynomial for $G$. (See, for example, P. Mark Kayll, "Integrals Don't Have Anything to Do with Discrete Math, Do They?", Mathematics Magazine84(2): 2011, 108-119.)