From Wikipedia
In combinatorial mathematics, a derangement is a permutation of the elements of a set in which no element appears in its original position.
For example, if we have the set , there are
permutations
But only of them are derangements –
and
I did a practical question on this here. In that question I used a tree diagram, but there must be a way to determine the number of derangements given elements.
We know elements has
derangements, what about
elements? We know there are
permutations
ABCD | BACD | CABD | DABC |
ACBD | BADC | CADB | DACB |
ACDB | BCAD | CBAD | DBAC |
ABDC | BCDA | CBDA | DBCA |
ADBC | BDAC | CDAB | DCAB |
ADCB | BDCA | CDBA | DCBA |
I have highlighted the derangements. when there are
derangements.
Let’s try to generalise.
- In how many ways can one element be in its original position?
Choose one element from the 4 to be in its original position, and then arrange the remaining three elements.
So far, we have
Clearly we are counting some arrangements multiple times, for example ABDC has A and B in the correct position, so we need to add all of the arrangements withelements in their original position.
- In how many ways can two elements be in their original position?
So now we have,
But once again we have counted some arrangements multiple times, so we need to subtract all of the arrangements withelements in their original position.
- In how many ways can three elements be in their original position?
So now we have,
We now need to add all of the arrangements withelements in their original position.
- In how many ways can four elements be in their original position?
So now we have,
Hence,
Which we can simplify to