A permutation can be described in matrix notation by a 2 by n matrix with the numbers 1, ..., n in the first row and the images of 1, 2, ..., n (in that order) in the second row. Since there are n! possibilities to fill the second row, the following theorem holds.

Theorem

Sn has exactly n! elements.



The first row of the 2 by n matrix describing a permutation g Sn, is always 1, 2, ..., n and hence yields no essential information. We will often omit the first row; the permutation is then given in list notation. For example, [[1, 2, 3], [3, 1, 2]] becomes [3, 1, 2] in list notation.
However, the matrix notation is useful for calculating products and inverses.

Product
To calculate gh for two permutations g, h Sn, we first look up, for each i X, the value h(i), then we look for this value in the first row of the g matrix; below this entry you find gh(i).


Inverse permutation
If g is written as the 2 by n matrix M, then the inverse of g is described by the matrix obtained from M by interchanging the two rows and sorting the columns in such a way that the first row is again 1, 2, ..., n.

Definition

The order of a permutation g is the smallest positive integer m such that gm = e.