Why does the expansion of $e^x$ appear to arise in the formula for derangement of $n$ things $D_{n}=n!\sum_{k=0}^n \frac{(-1)^k}{k!}$ I was recently toying with Wolfram|Alpha with the expansion of $e^x$ and I noticed a strange thing. On substituting $x=-1$ (if it is allowed), I get on the RHS the strange looking infinite expression of $$e^{-1}=\left(1-\frac{1}{1!}+\frac{1}{2!}-\frac{1}{3!}+\ldots+(-1)^n\frac{1}{n!}+\ldots\right)$$
(ignoring for the time being all terms after ${n+1}^{th}$ term), which I find very similar to the formula I learned for the number of derangements of $n$ things (if we ignore the infinite nature of the expansion of $e^x$ and just look at the first $n+1$ terms for some time) $$D_n=n!\left(1-\frac{1}{1!}+\frac{1}{2!}-\frac{1}{3!}+\ldots+(-1)^n\frac{1}{n!}\right)$$
So is this similarity just a coincidence? Or are they related in any way whatsoever? Because I am not able to relate them in any way; after all, $e$ and derangements in combinatorics seem like two very different topics to me. But their similarity is very striking... Even for a beginner like me.
 A: The following is very heuristic:
The probability that a given one of the $n$ things is not at his proper place is $1-{1\over n}$. Assuming that the $n$ things are placed properly or improperly independently of each other the probability that all things are improperly placed computes to
$$\left(1-{1\over n}\right)^n\doteq{1\over e}\ .$$
A: It's from the generating function theory and the fact that we have a nice recursion formula for derangements: $d_{n+1} = n(d_n + d_{n-1})$ for $n \ge 1$. For any counting problem like this where the answer is $d_n$ for $n$ objects, we can define a formal exponential generating function $D(x) = \sum_{n=0}^\infty d_n \frac{x^n}{n!}$ (there is also a normal generating function without the $n!$ term).
Know we can try to determine the function $D(x)$ from the recursion, and from that get the coefficients $d_n$, this is worked out very nicely in this answer, where you will see the connection.
A: There's a lot of stuff to say here. First, here is one way of interpreting the result: asymptotically, the probability that a random permutation is a derangement is $e^{-1}$. There are a lot of related claims you can write down. Here are two:


*

*For fixed $k$, asymptotically, the probability that a random permutation has exactly $k$ fixed points is $\frac{e^{-1}}{k!}$. 

*For fixed $k$, asymptoically, the probability that a random permutation has no $k$-cycles is $e^{- \frac{1}{k}}$. 


So basically there's a lot of $e$ business going on. My preferred way to think about all this is via a very large and beautiful generating function called the exponential formula, which you can read about here and here. It describes the cycle types of all permutations simultaneously, and specializing it in various ways extracts various information about cycle types. See, for example, here. 
