# Permutation

*See permutation (music) for the application of this concept to music.*

In mathematics, especially in abstract algebra and related areas, a **permutation** is a bijection from a finite set *X* onto itself.

In combinatorics, the term **permutation** has a traditional meaning, which is used to include ordered lists without repetition, but not exhaustive (so of less than maximum length).

The concept of a permutation expresses the idea that distinguishable objects may be arranged in various different orders. For instance, with the numbers one to six, each possible order makes a list of the numbers, without repetitions. One such permutation is: "3, 4, 6, 1, 2, 5".

There are a number of ways in which the permutation concept may be defined more formally. A permutation is an ordered sequence containing each symbol from a set once and only once; neither "1, 2, 2, 3, 4, 5, 6" nor "1, 2, 4, 5, 6" are permutations. One can therefore point to the essential difference between a *permutation* and a set: the elements of a permutation are arranged in a specified order.

## Contents

## Arrangements and substitutions

An *arrangement* is a placement of a set's elements into definite positions (i.e. first, second, etc.), such as {1, 2, 3, 4, 5, 6} arranged as (2, 1, 6, 5, 4, 3). A *substitution* is a set of replacements of one element for another, but with no elements eliminated in the result; for instance, if you took {1, 2, 3, 4, 5, 6} and substituted 1 with 3, 3 with 4, and 4 with 1, no elements would be eliminated and you'd have one substitution.

Both arrangements and substitutions are commonly called permutations. In mathematics, however, the phrase *permutation of a set* always refers to a substitution.

## Counting permutations

In this section only, the traditional definition is used: a permutation is an ordered list without repetitions, perhaps missing some elements. It is easy to count the number of permutations of size *r* when chosen from a set of size *n* (obviously with *r*≤*n*).

For example, if we have a total of 10 elements, the integers {1, 2, ..., 10}, a permutation of three elements from this set is (5, 3, 4). In this case, *n* = 10 and *r* = 3. So how many ways can this completely be done?

- We can pretend to select the first member of all permutations out of
*n*choices because there are*n*distinct elements from the generating set. - Next, since we have used one of the
*n*elements already, the second member of the permutation has (*n*− 1) elements to choose from the remaining set. - The third member can be filled in (
*n*− 2) ways since 2 have been used already. - This pattern continues until there are
*r*members on the permutation. This means that the last member can be filled in (*n*−*r*+ 1) ways.

Summarizing, we find that a total of

*n*(*n*− 1)(*n*− 2) ... (*n*−*r*+ 1)

different permutations of *r* objects, taken from a pool of *n* objects, exist. If we denote this number
by P(*n*, *r*) and use the factorial notation, we can write

- .

In the above example, we have *n* = 10 and *r* = 3, so to find out how many unique sets, such as the one previously, we can find, we need to calculate P(10,3) = 720.

Other, older notations include ^{n}P_{r}, P_{n,r}, or _{n}P_{r}.

A common modern notation is (*n*)_{r} which is called a *falling factorial*. However, the same notation is used for the *rising factorial* (also called *Pochhammer symbol*)

*n*(*n*+ 1)(*n*+ 2)...(*n*+*r*− 1).

In the latter case, the number of permutations is (*n* + *r* − 1)_{r}.

## Abstract algebra

As explained in a previous section, in abstract algebra and other mathematical fields, the term *permutation (of a set)* is now reserved for a bijective map (bijection) from a finite set onto itself. The earlier example, of making permutations out of numbers 1 to 10, would be translated as a map from the set {1, …, 10} to itself.

## Notation

The cycle notation (1 5 2) (3 4) means that 1 is mapped to 5, 5 to 2, 2 to 1, 3 to 4, and 4 to 3. Note that if objects 1,2,3,4,5 are rearranged into the order 2,5,4,3,1, two permutations are involved: (1 5 2) (3 4) mapping the original to the final position of each object, and (1 2 5) (3 4) mapping the old to the new object at any position. The two permutations are each other's inverse.

Notation (1 5 2) implies that 3 and 4 are not changed. For the identity various notations are used, e.g. "id", "e", "()", "ι" (iota).

## More details

There are two main notations for such permutations. In relation notation, one can just arrange the "natural" ordering of the elements being permuted on a row, and the new ordering on another row:

This means that in the first position, the second element of the set should be placed, in the second position, the fifth element in the set should be placed, and so on. Alternatively, if we have a finite set of elements (which need not be integers), we can firstly create an association between each element and an integer. More precisely, we can create a mapping ν(*s*) : *S* → **Z** where ν is bijective, and S is our pool of elements. One can then read the above notation as mapping the element ν^{−1}(1) to element ν^{−1}(2), element ν^{−1}(2) to element ν^{−1}(5), and so on.

Alternatively, we can write the permutation in terms of how the elements change when the permutation is successively applied. If we look at the above permutation as an example, if we take an element in the first position, the result of applying the permutation is then placed in the second position, the result of applying the permutation again is placed in the fifth position, and if we were to apply the permutation again we see that the element has now returned to the first permutation. We say that the behaviour of such an element is a cycle, and we can write this cycle as (1 2 5), or alternatively as (2 5 1) or (5 1 2), but not as e.g. (1 5 2). The next cycle begins with any other element not considered till now, until every element appears in a cycle.

As such, we can write the permutation as a set of cycles. The previous permutation just considered has cycle form (1 2 5)(3 4). The order *of* the cycles is not significant (but, as said before, the order of the elements *within* a cycle is, up to cyclic change).
Thus, the same permutation could be written as e.g (4 3)(2 5 1). The "canonical" form for a permutation places the lowest-numbered position in each cycle first in that cycle and then orders the cycles by increasing first element; see also cycles and fixed points.

This notation often omits fixed points, that is, elements mapped to themselves; thus (1 3)(2)(4 5) can become simply (1 3)(4 5), since a cycle of just one element has no effect.

A permutation consisting of one cycle is itself called a *cycle*. The number of entries of a cycle is called the *length*. For example, the length of (1 2 5) is three. Cycles of length two are called transpositions; the two elements merely exchange places.

### Special permutations

If we think of a permutation that "changes" the position of the first element to the first element, the second to the second, and so on, we really have not changed the positions of the elements at all. Because of its action, we describe it as the *identity permutation* because it acts as an identity function.

If we have some permutation called *P*, we can describe a permutation, written *P*^{−1}, which undoes the action of applying *P*. In essence, performing P then P^{−1} is the same as performing the identity permutation. We always have such a permutation since a permutation is a bijective map. Such a permutation is called the *inverse permutation*.

One can define the product of two permutations. If we have two permutations, *P* and *Q*, the action of performing *P* and *Q* will be the same as performing some other permutation, *R*, itself. Note that *R* could be *P* or *Q*. The product of *P* and *Q* is defined to be the permutation *R*. For more, see symmetric group and permutation group.

An even permutation is a permutation which can be expressed as the product of an even number of transpositions, and the identity permutation is an even permutation as it equals (1 2)(1 2). An odd permutation is a permutation which can be expressed as the product of an odd number of transpositions. It can be shown that every permutation is either odd or even and can't be both.

We can also represent a permutation in matrix form - the resulting matrix is known as a *permutation matrix*.

## Permutations in computing

Some of the older textbooks do look at permutations as *assignments*, as mentioned above. In computer science terms, these are assignment operations, with values

- 1, 2, ...,
*n*

assigned to variables

*x*_{1},*x*_{2}, ...,*x*_{n}.

Each value should be assigned just once.

The assignment/substitution difference is then illustrative of one way in which functional programming and imperative programming differ — pure functional programming has no assignment mechanism. The mathematics *convention* is nowadays that permutations are just functions and the operation on them is function composition; functional programmers follow this. In the assignment language a *substitution* is an instruction to switch round the values assigned, simultaneously; a well-known problem.

## Numbering permutations

Factoradic numbers can be used to assign unique numbers to permutations, such that given a factoradic n, one can quickly find the corresponding permutation.

## See also

- Cyclic permutation
- Permutations and combinations
- Even and odd permutations
- Combinations
- Josephus permutation
- Symmetric group
- Permutation group
- Cyclic order
- Weak order of permutations
- Substitution cipher
- Sorting network
- Random permutationda:Permutation

de:Permutation es:Permutación eo:Permutaĵo fr:Permutation it:Permutazione he:תמורה (מתמטיקה) lt:Kėliniai nl:Permutatie ja:順列 ko:순열 no:Permutasjon pl:Permutacja pt:Permutação ru:Перестановка sv:Permutation