Calculate derangements using inclusion-exclusion. Find permutations with no fixed points…
- User
Calculate derangements using inclusion-exclusion. Find permutations with no fixed points using the formula with alternating factorials.
- Assistant
Explaining derangements using inclusion-exclusion
The number of derangements of n objects (permutations with no fixed points) is given by inclusion-exclusion as
Dₙ = n! - C(n,1)(n-1)! + C(n,2)(n-2)! - ... + (-1)ⁿ C(n,n)(n-n)!
which simplifies to
Dₙ = n! * ∑ₖ₌₀ⁿ (-1)ᵏ / k!.
This formula counts permutations with zero fixed points by alternately subtracting and adding permutations fixing k points. It’s also approximately equal to n!/e. If (A_i) is the set of permutations of ({1,\dots,n}) in which (i) is fixed, then (|A_i|=(n-1)!), (|A_i\cap A_j|=(n-2)!), and in general (|A_{i_1}\cap\cdots\cap A_{i_k}|=(n-k)!). Inclusion–exclusion gives [ D_n = n! - \binom{n}{1}(n-1)! + \binom{n}{2}(n-2)! - \cdots + (-1)^n\binom{n}{n}(0!),, ] the number of permutations with no fixed points. Factoring out (n!) and using (\binom{n}{k}(n-k)! = \frac{n!}{k!}) yields the alternating factorial formula [ D_n = n!\left(1 - \frac{1}{1!} + \frac{1}{2!} - \frac{1}{3!} + \cdots + (-1)^n\frac{1}{n!}\right). ]For example, (D_4 = 4!(1 - 1 + \tfrac{1}{2} - \tfrac{1}{6} + \tfrac{1}{24}) = 9), (D_5 = 44), and in general (D_n) is approximately (n!/e).
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.