8
$\begingroup$

I have a permutation a in a product of disjoint cycles form as follows

$a = {{(1,9,3,7)(2,11,6)(4,8,5,10)}}$

I want to represent it in a matrix form A such that

$A = \begin{pmatrix}1&2&3&4&5&6&7&8&9&10&11\\9&11&7&8&10&2&1&5&3&4&6 \end{pmatrix}$

I believe a can be defined in Mathematica as

a = Cycles[{{1, 9, 3, 7}, {2, 11, 6}, {4, 8, 5, 10}}]

How do I convert a to A?

$\endgroup$
0

2 Answers 2

11
$\begingroup$
mat = {Sort @ #, #} & @ PermutationList[a];
MatrixForm @ mat // TeXForm

$ \left( \begin{array}{ccccccccccc} 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9 & 10 & 11 \\ 9 & 11 & 7 & 8 & 10 & 2 & 1 & 5 & 3 & 4 & 6 \\ \end{array} \right)$

$\endgroup$
6
$\begingroup$

One idea is to overload MatrixForm so that it does this for you automatically:

Unprotect[MatrixForm];
MatrixForm /: MakeBoxes[MatrixForm[cyc_Cycles], StandardForm] := With[
    {list=PermutationList[cyc]},
    ToBoxes[MatrixForm[{Range@Length@list, list}], StandardForm]
]
Protect[MatrixForm];

Then:

Cycles[{{1, 9, 3, 7}, {2, 11, 6}, {4, 8, 5, 10}}] //MatrixForm

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.