Macaulay2 » Documentation
Packages » Permutations :: Miscellaneous
next | previous | forward | backward | up | index | toc

Miscellaneous -- a detailed overview of permutations in Macaulay2

We can compute the inverse of a permutation.

i1 : p = permutation {3,1,2,5,4};
i2 : inverse p

o2 = Permutation{2, 3, 1, 5, 4}

o2 : Permutation

The order of a permutation $p$ is its order in the symmetric group $\mathfrak{S}_n$, i.e., the smallest positive integer $k$ such that $p^k$ is the identity permutation.

i3 : p = permutation {3,1,2,5,4};
i4 : ord p

o4 = 6

Every permutation can be written as a product of transpositions. One definition for the sign of a permutation $p$ is $1$ if it can be written as a product of an even number of transpositions and is $-1$ if it can be written as an odd number of transpositions. If $\text{sign}(p) = 1$, the permutation is called even and if $\text{sign}(p) = -1 $, it is called pdd.

i5 : p = permutation {3,1,2,5,4};
i6 : sign p

o6 = -1
i7 : isEven p

o7 = false
i8 : isOdd p

o8 = true

A permutation $p$ is a derangement if $p(i) \neq i$ for all $i$. We can determine if $p$ is a derangement as well its fixed points.

i9 : p = permutation {3,1,2,5,4};
i10 : isDerangement p

o10 = true
i11 : fixedPoints p

o11 = {}

o11 : List

A permutation $p$ has an inversion $(i,j)$ if $i < j$ and $p(i) > p(j)$. We can compute all the inversions of a permutation.

i12 : p = permutation {3,1,2,5,4};
i13 : inversions p

o13 = {{1, 2}, {1, 3}, {4, 5}}

o13 : List

The source of this document is in /build/reproducible-path/macaulay2-1.25.05+ds/M2/Macaulay2/packages/Permutations/Documentation/packageDocs.m2:386:0.