Questions tagged [permutation]

For questions about the functionality related to permutations in Mathematica.

Questions with this tag might deal with simple functions to generate permutations and identify permutation cycles of lists, but could also involve more sophisticated functions dealing with permutation algebra and groups. Relevant functions are Permutations, Permute, Cycles, FindPermutation, PermutationList, Signature, and lots of others. Consider using the or tags as well.

Questions about the sorting of lists should use the tag .

Useful links:

270 questions
14
votes
4 answers

How to remove repeated permutations?

I want to get the Permutations on the elements of a list. Then I'm doing this: a = Drop[Permutations[Range[1, 16], 2], {1, 17}] i = 15; While[i <= (240 - 16), a = Drop[a, {i, i}]; i = (i + (16 - 1))] The first line of the code gives me all the…
Red Banana
  • 5,329
  • 2
  • 29
  • 47
4
votes
2 answers

Permutations: any implementation of the Cayley distance?

The Caley distance measures the distance between two permutations (see this question for a definition https://math.stackexchange.com/questions/1932991/catalan-number-and-cayley-distance-inequality-in-permutation-group). Mathematica has lots of nice…
Sergio Parreiras
  • 409
  • 2
  • 11
3
votes
1 answer

How do I create a logical permutation expression automatically

How can I create a permutation automatically with logical expressions ? For example (2 logical variables): Not[a] && Not[b] Not[a] && b a && Not[b] a && b
Jorgos
  • 319
  • 2
  • 7
3
votes
2 answers

Generating permutations of at most 'n' elements, and where a specific subset of elements always appears

I often run into a situation where I'd like to generate a set of permutations with at most $n$ elements (here $n = 5$): Permutations[{"t1","t2","t3","t4","t5","t6","t7","t8","t9","t10","t11","t12","t13"}, 5] I'd like to also specify that a specific…
3
votes
1 answer

Solve this equality of permutations

Is it possible to solve an equality such as: $$(123)=\sigma (32) \sigma (31)$$ in term of $\sigma$? I was thinking about Cycles but I couldn't figure out a way to use it. EDIT As a partial answer to my question, I have found that I can use…
mattiav27
  • 6,677
  • 3
  • 28
  • 64
3
votes
1 answer

How to get all combinations of length 3

My problem is to get the list of all combinations of length 3 where the first place can be 1,2; second place could be a,b; third place could be 1,2,3,4. So the output is should be like this: $\{\{1,a,1\},\{1,a,2\},\cdots,\{2,b,4\}\}$.
Marcus
  • 143
  • 6
2
votes
2 answers

The i-th element of a permutation

I am trying to run something of the form p = Permutations[Range[1,16]]; result={}; Table[If["p[[i]] satisfies some conditions",result=Append[result,p[[i]]]],{i,1,Length[[p]]}]; and I get an "out of memory error" when defining p. I am trying to find…
Heterotic
  • 306
  • 1
  • 9
2
votes
3 answers

Test if a list is a permutation of another list

This question may have a simple answer, but I can't find it anywhere in the documentation. I'm trying to find a function that tells me whether a list is a permutation of another list. So the function should behave like this: TestPermutation[{1, 2,…
Jelle
  • 281
  • 2
  • 8
2
votes
1 answer

Range permutations, treating given runs of consecutive element as they were identical

Given a positive integer $n$ and a list of disjoint intervals in the form $\{\{i_1,i_1+1,i_1+2,\ldots,i_1+n_1\},\{i_2,i_2+1,i_2+2,\ldots i_2+n_2\},\ldots\}$ all contained in $[1,n]$, I want to generate the permutations of $\{1\ldots n\}$ treating…
Domenico Modica
  • 489
  • 2
  • 9
2
votes
1 answer

Incorporating Signature with Permute for symmetric groups

Let $$f(x_1, x_2, x_3, x_4) := \frac{x_1^{-3} x_2^{-2} x_3^{-1}}{(1 - x_1^2) (1 -x_1^2 x_2^2) (1 - x_1^2 x_2^2 x_3^2) (1 - x_1^2 x_2^2 x_3^2 x_4^2)}.$$ I am trying to compute $$\sum_{w\in S_4} (-1)^{\overline{w}} w(f),$$ where $\overline{w}$ is the…
Mee Seong Im
  • 251
  • 1
  • 8
2
votes
0 answers

How do I iterate through all permutations of a list?

I need to generate all permutation of a list of integers, but doing so (the list has around 60 elements, is not practical. Is there a way to iterate through all permutations of a list, without first generating all of them? (There are several related…
orome
  • 12,819
  • 3
  • 52
  • 100
1
vote
1 answer

How to get all permutation of k-partition

If I want to get the list of k-partition, and the rule are below: here are k partitions all elements of partition are in the range of 1 to 30. the total of element from each partition equals to 30. For example, if k=5, the partition includes…
Winnie Lee
  • 41
  • 1
1
vote
1 answer

How to find all subsets which the total of elements is the same?

I want to find all subsets which the total of elements is the same. For example, Subsets[Range[30], {5}] means all 5-element subsets and the range of each element is from 0 to 30. But I want to get the subsets which are only the total of elements…
Winnie Lee
  • 41
  • 1
1
vote
0 answers

Why is PermutationProduct not yielding anything?

When I am trying to compute some products of permutations in S_48, it is somehow not working. Here is my code: PermutationProduct[{Cycles[{{40, 35, 33, 38}, {37, 34, 36, 39}, {46, 3, 19, 27}, {44, 5, 21, 29}, {41, 8, 24, 32}}], Cycles[{{43, 41, 46,…
Nick Yin
  • 11
  • 1
1
vote
2 answers

How to get the length of cycles in a Cycles[] expression?

I am looking for a way to get {5,2} for a Cycles object, like: Cycles[{{1,2,3,4,5},{6,7}}]. This could help with conjugacy classes. The function should give back the length of the cycles the permutation consists of, in the natural ordering of the…
Balint Pato
  • 125
  • 5
1
2