In
combinatorial mathematics
Mathematics is a field of study that discovers and organizes methods, Mathematical theory, theories and theorems that are developed and Mathematical proof, proved for the needs of empirical sciences and mathematics itself. There are many ar ...
, a derangement is a
permutation
In mathematics, a permutation of a set can mean one of two different things:
* an arrangement of its members in a sequence or linear order, or
* the act or process of changing the linear order of an ordered set.
An example of the first mean ...
of the elements of a
set in which no element appears in its original position. In other words, a derangement is a permutation that has no
fixed points.
The number of derangements of a set of size is known as the subfactorial of or the derangement number or de Montmort number (after
Pierre Remond de Montmort). Notations for subfactorials in common use include , , , or .
[
For , the subfactorial equals the nearest integer to , where denotes the ]factorial
In mathematics, the factorial of a non-negative denoted is the Product (mathematics), product of all positive integers less than or equal The factorial also equals the product of n with the next smaller factorial:
\begin
n! &= n \times ...
of and is Euler's number.[
The problem of counting derangements was first considered by Pierre Raymond de Montmort in his '' Essay d'analyse sur les jeux de hazard'' in 1708; he solved it in 1713, as did Nicholas Bernoulli at about the same time.
]
Example
Suppose that a professor gave a test to 4 students – A, B, C, and D – and wants to let them grade each other's tests. Of course, no student should grade their own test. How many ways could the professor hand the tests back to the students for grading, such that no student receives their own test back? Out of 24 possible permutations (4!) for handing back the tests,
:
there are only 9 derangements (shown in blue italics above). In every other permutation of this 4-member set, at least one student gets their own test back (shown in bold red).
Another version of the problem arises when we ask for the number of ways ''n'' letters, each addressed to a different person, can be placed in ''n'' pre-addressed envelopes so that no letter appears in the correctly addressed envelope.
Counting derangements
Counting derangements of a set amounts to the ''hat-check problem'', in which one considers the number of ways in which ''n'' hats (call them ''h''1 through ''hn'') can be returned to ''n'' people (''P''1 through ''Pn'') such that no hat makes it back to its owner.
Each person may receive any of the ''n'' − 1 hats that is not their own. Call the hat which the person ''P''1 receives ''hi'' and consider ''hi''s owner: ''Pi'' receives either ''P''1's hat, ''h''1, or some other. Accordingly, the problem splits into two possible cases:
# ''Pi'' receives a hat other than ''h''1. This case is equivalent to solving the problem with ''n'' − 1 people and ''n'' − 1 hats because for each of the ''n'' − 1 people besides ''P''1 there is exactly one hat from among the remaining ''n'' − 1 hats that they may not receive (for any ''Pj'' besides ''Pi'', the unreceivable hat is ''hj'', while for ''Pi'' it is ''h''1). Another way to see this is to rename ''h''1 to ''h''''i'', where the derangement is more explicit: for any ''j'' from 2 to ''n'', ''P''''j'' cannot receive ''h''''j''.
# ''Pi'' receives ''h''1. In this case the problem reduces to ''n'' − 2 people and ''n'' − 2 hats, because ''P''1 received ''hi''s hat and ''P''''i'' received ''h''1's hat, effectively putting both out of further consideration.
For each of the ''n'' − 1 hats that ''P''1 may receive, the number of ways that ''P''2, ..., ''Pn'' may all receive hats is the sum of the counts for the two cases.
This gives us the solution to the hat-check problem: Stated algebraically, the number !''n'' of derangements of an ''n''-element set is
for ,
where and
The number of derangements of small lengths is given in the table below.
There are various other expressions for , equivalent to the formula given above. These include
for
and
: for
where