enumerative combinatorics
Derangements
You should know: permutations, inclusion exclusion principle
Overview
A derangement is a permutation of a set in which no element appears in its original position — a 'complete shuffle' with no fixed points. The number of derangements of n objects is denoted !n (the subfactorial), and it is a classic application of the inclusion-exclusion principle. Derangements answer questions like the 'hat-check problem': if n people check their hats and the hats are returned at random, in how many ways can every person get someone else's hat.
Intuition
Derangements come directly from applying inclusion-exclusion to the 'bad' events A_i = 'element i is in its original position.' The total number of permutations with at least one fixed point is found by inclusion-exclusion on these n events, and subtracting that from n! (all permutations) leaves exactly the derangements. Because each term in the inclusion-exclusion sum contributes a 1/k! factor, the formula !n = n!∑(-1)^k/k! emerges — and as n grows, this ratio converges to 1/e, so roughly 37% of random permutations are complete derangements no matter how large n is.
Formal Definition
The number of derangements of an n-element set is given by inclusion-exclusion over the events 'element i is fixed':
Worked Examples
List all 3! = 6 permutations and mark which have no fixed points.
Confirm with the formula.
Answer: !3 = 2 derangements: (2,3,1) and (3,1,2).
Practice Problems
Using the recurrence !n = (n-1)(!(n-1)+!(n-2)) with !1=0 and !2=1, find !3.
Using the recurrence, find !5 given !3=2 and !4=9.
5 friends check their coats. In how many ways can the coats be returned so that no one gets their own coat back?
Quiz
Summary
- A derangement is a permutation with no fixed points; !n counts derangements of n objects.
- !n is derived via inclusion-exclusion on the events 'element i is fixed', giving !n = n!∑_{k=0}^n (-1)^k/k!.
- Small values: !1=0, !2=1, !3=2, !4=9, !5=44, and !n/n! → 1/e as n → ∞.
References
- WebsiteWikipedia — Derangement
Mathematics