Skip to main content

Questions tagged [permutation]

For questions about the functionality related to permutations in Mathematica.

Filter by
Sorted by
Tagged with
5 votes
1 answer
148 views

Find permutation that satisfies conditions

Suppose you what to find a permutation of integers {1, 2, ..., 13} that satisfy some rules. Rules can be found in variable rules....
azerbajdzan's user avatar
  • 18.7k
2 votes
1 answer
86 views

Pattern Matching and Permutations

I am working with some math students on some problems involving permutations. My Mathematica knowledge is limited and I'm hoping to get some help. Two sample problems: a)how many ways can the ...
Tom De Vries's user avatar
  • 3,780
1 vote
2 answers
117 views

How to determine if two colorings of a graph are the same?

A coloring of a graph $G$ with vertex set $V$ is the partitioning of $V$ into so-called color classes so that no two vertices of the same class are adjacent. A $k$-coloring contains exactly $k$ color ...
licheng's user avatar
  • 2,039
3 votes
4 answers
172 views

Replacing the heads of an expression in left to right order

I would like to replace the occurrences of the head f in an expression. The expression only contains two possible heads: f and g. These heads are applied to exactly two arguments. Example: ...
ExpressionCoder's user avatar
2 votes
1 answer
81 views

Problem with permutations

For a given binary array like {0, 1, 1, 0,..}, I need to find the shortest permutation, sorting it in standard order ...
lesobrod's user avatar
  • 1,699
0 votes
1 answer
58 views

Permute subsystems of a matrix?

Suppose I have a matrix $M$ acts on the space $\mathbb C^4\otimes \mathbb C^2\otimes \mathbb C^4\otimes \mathbb C^3$. Is there a method to permute the 2nd subsystem of $M$ and the 4th subsystem of $M$?...
narip's user avatar
  • 381
7 votes
9 answers
611 views

Rearrange triple sublists

Given a set of triple lists (all contain element 9!) tripel = {{5, 10, 9}, {4, 9, 3}, {3, 9, 8}, {4, 5, 9}, {9, 10, 8}} I would ...
Ulrich Neumann's user avatar
9 votes
9 answers
919 views

Shuffling two lists into each other

Given a subset s of Range[n] and two lists a and b, with ...
მამუკა ჯიბლაძე's user avatar
1 vote
1 answer
82 views

Value of a function over permutations of two lists

I want to do the sum (in Ising lattice gauge theory) ...
QFTheorist's user avatar
3 votes
2 answers
176 views

Select a subset in the bit-strings with even 1s overlapped - thank you

Model 1 Consider the permutation list of 4-bit-strings: list = Permutations[{0, 0, 1, 1}, {4}] which outputs: {{0, 0, 1, 1}, {0, 1, 0, 1}, {0, 1, 1, 0}, {1, 0, 0, ...
wonderich's user avatar
  • 923
3 votes
1 answer
261 views

Thermodynamics of the 2D Ising model

I want to study the thermodynamics of the 2D Nearest Neighbour Ising model (calculate the average energy, susceptibility, etc.). I have the Hamiltonian $$\mathcal{H} = J\sum_{\langle i j \rangle} s_i ...
QFTheorist's user avatar
4 votes
4 answers
254 views

How to confirm two sets contain the same vectors in any order?

Say if I have two sets of vectors, for example: $$v_{1}=((0,0,0),(0,1,0),(0,0,1),(1,1,1))$$ $$v_{2}=((0,1,0),(1,1,1),(0,0,0),(0,0,1))$$ I want to find a way of verifying that both $v_{1}$ and $v_{2}$ ...
am567's user avatar
  • 501
1 vote
1 answer
92 views

Elements of a group that send one element to another

If I have a permutation group, say $S_{10}$, how do I get all the permutations that send the set {1, 2, 3} to {5, 6, 7}? I know ...
JRV's user avatar
  • 21
4 votes
3 answers
181 views

How to list all subgroups of symmetry group S_6?

I learned from https://oeis.org/A005432 that $S_6$ has $1455$ subgroups, how can I list them all in mathematica? As the comment says, the direct approach cannot solve the problem.
lapcal's user avatar
  • 531
5 votes
3 answers
121 views

Implementing symmetry assumptions in FullSimplify

I want to symmetrise a long expression, M, that involves a function of 4 arguments, f[u1,u2,d1,d2], and its products (for ...
jms547's user avatar
  • 399
0 votes
0 answers
40 views

Put together all possible combinations of a set of functions, variables, and operators

Using a set of functions, variables, and operators, I'm trying to assemble all of the possible combinations starting with the shortest combination and ending with the longest combination. For example, ...
ITMathematics's user avatar
0 votes
1 answer
143 views

Summation over permutation: $\sum_{\sigma \in S_N} \mathrm{sgn}(\sigma) \prod_{i=1}^N x_{i+\sigma(i)}$

Let $N$ be a natural number, and $S_N$ be the symmetric group over $\{1, \ldots, N\}$. I want to compute $$\sum_{\sigma \in S_N} \mathrm{sgn}(\sigma) \prod_{i=1}^N x_{i+\sigma(i)}$$ for small $N$ ...
Laplacian's user avatar
  • 1,053
4 votes
2 answers
354 views

How to generate all permutation matrices for 4 qubits?

In quantum mechanics, a qubit can be understood as a 2 by 1 vector denoted by Dirac notation as $$|0\rangle \equiv \left( \begin{array}{c} 1\\ 0\\ \end{array} \right) ,|1\rangle \equiv \left( \...
narip's user avatar
  • 381
1 vote
1 answer
207 views

Arrange 1-n^2 in n×n grid satisfy products of rows equal to products columns

For which $n\in\mathbb{N}$ is it possible to arrange $\{1,…,n^2\}$ in an $n\times n$ grid so that the set of products of columns equals the set of products of rows? I can find solution for $3\times 3$ ...
expression's user avatar
  • 5,652
1 vote
2 answers
127 views

Delete the subsets containing the same $2$ integers present in other subsets

From my previous question, if I consider a list like this: $\{$$\{$$\{$$1,2,3$$\}$,$\{$$4,5,6$$\}$$\}$, $\{$$\{$$1,2,4$$\}$,$\{$$3,5,6$$\}$$\}$, $\{$$\{$$1,2,5$$\}$,$\{$$3,4,6$$\}$$\}$, $\{$$\{$$1,2,6$...
user967210's user avatar
2 votes
1 answer
91 views

Cycle symmetric Sort for arguments of a function. Put trace in canonical order

I need a new Sort for the arguments of TR that maintains cyclicity, TR[a,b,c] = TR[b,c,a] = TR[c,a,b] cyclicSort[TR[b,a,c]] TR[a,c,b] ...
Albercoc's user avatar
  • 998
7 votes
3 answers
244 views

Permutations with subsets not containing the same elements

I would like to define a function of two integer variables $ \{n, k\} $, with $ k | n $, that would print all the possible permutations of the first $ n$ positive integers, such that the subsets of $ ...
user967210's user avatar
4 votes
2 answers
169 views

Generating all possible 2x2 matrices with unique elements from 1 to 4

If I have a set A={1,2,3,4}, how do I generate all 2x2 matrices with different elements chosen from ...
Karim Ezzat Messilhy's user avatar
4 votes
2 answers
166 views

Finding coefficients that impose symmetry

To simplify the main question below,consider the following random multivariate polynomial : ...
userrandrand's user avatar
  • 5,892
1 vote
2 answers
136 views

How to get all necklaces without the full permutations' set?

There are previous posts, such as Delete duplicates from list of lists as if on a necklace, that give a way to find all necklaces from a set of lists. The methods presented there work well for a small ...
Kostas's user avatar
  • 65
3 votes
4 answers
248 views

Working with tables: add new level of nested tables

I am trying to obtain all possible combinations of elements in a (long) list factors = {A, B, C}; getCombinations[factors,n] For n = 3 factors, it should give <...
Albercoc's user avatar
  • 998
5 votes
4 answers
240 views

How to efficiently find all element combination including a certain element in the list

I have the following list : alist={{5, 6, 7}, {7, 6, 8}, {5, 7, 25}, {7, 8, 26}, {7, 26, 25}, {5, 4, 6}, {4, 12, 6}, {6, 12, 13}, {6, 13, 8}} I want to find all ...
mmmm's user avatar
  • 95
0 votes
0 answers
46 views

Arranging 4 identical items in 7 spots [closed]

There are 4 unique items, for the sake of the example call them balls. Each ball is exactly the same, and we need to see how many different ways those 4 balls can fit in those 7 slots. I am not sure ...
Jack G's user avatar
  • 1
2 votes
1 answer
134 views

Permutations with inequalities constraint

In how many ways can I arrange the first $6$ positive integers such that this inequalities chain will hold? $a < b > c < d < e > f$ One of these arrangements is $\{5, 6, 1, 2, 4, 3\}$, ...
user967210's user avatar
1 vote
1 answer
67 views

Permutations of Dataset

I have data with missing values. I need all permutations which follow the two rules: Every year must be represented in each draw; and each draw must contain a minimum of two elements for each year. ...
Rogo's user avatar
  • 930
4 votes
3 answers
340 views

Find all sets whose index is divisible by the elements

Suppose I have such a set $S=\{3,4,5,...n+2\}, n\in \mathbb{Z}_{>\, 0} $, $a_n$ is any permutation of $S$ such that $n|a_n$, I want to know how many such $a_n$. The easy but inefficient way to do ...
expression's user avatar
  • 5,652
1 vote
1 answer
92 views

KSetPartitions function with fixed points

I'm trying to develop a function that computes some numerators for scattering amplitudes and I need to generate a collection of tree diagrams that contain a set of particles (effectively numbers) <...
Marcosko's user avatar
  • 259
8 votes
1 answer
435 views

Evaluating Pfaffian

The Pfaffian of an even-dimensional anti-symmetric matrix $A$ is defined as: $$\mathrm{Pf}[A] = \frac{1}{2^{n}n!}\sum_{\pi\in S_{2n}}(-1)^{\pi} a_{i_{1}i_{2}}a_{i_{3}i_{4}}\cdots a_{i_{2n-1}i_{2n}...
felix's user avatar
  • 291
2 votes
1 answer
125 views

Accelerating sum over permutations of matrix elements

I am trying to short-cut the use of a CoefficientArrays call by manually calculating the resulting matrix of coefficients myself (this avoids using symbolic arrays ...
AnotherShruggingPhysicist's user avatar
1 vote
2 answers
203 views

Generating Lyndon words modulo mirroring operation and substituion

I have two letters A,B. I want to generate all words say up to length 22 with the following properties. There is no "canonical" list so any such list will suffice, though there are many ...
2132123's user avatar
  • 657
4 votes
1 answer
142 views

How can I remove the redundant generators in PermutationGroup?

Consider: ...
yode's user avatar
  • 26.8k
17 votes
12 answers
4k views

Fastest way to generate {{a,a},{a,b},{a,c},{b,b},{b,c},{c,c}} from {a,b,c}

What is the fastest way to generate {{a,a},{a,b},{a,c},{b,b},{b,c},{c,c}} from l={a,b,c}? I've tried ...
Thrash's user avatar
  • 405
2 votes
1 answer
133 views

How to convert a PermutationGroup to a named group

We can convert any built-in named group into PermutationGroup by this code(such as AlternatingGroup[5]): ...
yode's user avatar
  • 26.8k
1 vote
0 answers
86 views

Find Max Instance Over Permutations

I would like to find the maximum of some objective function over all possible permutations ...
user2757771's user avatar
7 votes
3 answers
432 views

Is there a function to generate “subsets” allowing duplicates?

I allow them to be chosen more than once (e.g. allow {1,1}). (A subset means every element is chosen once or less) Also I neglect the order (e.g. ...
Y.D.X.'s user avatar
  • 175
4 votes
3 answers
133 views

How to find the cycle type vector of a random permutation

Given a random permutation $\pi$ of {1,2,...,n}, I want to produce a list {a1,a2,...,an} of nonnegative integers so that ai is the number of cycles in $\pi$ of length i for each i=1,2,...,n. For ...
geoffrey's user avatar
  • 867
2 votes
1 answer
57 views

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 ...
Domenico Modica's user avatar
4 votes
3 answers
591 views

Generating signed permutation matrices

As most people (on here at least) know a permutation matrix is a square binary matrix that has exactly one entry of 1 in each row and each column and 0s elsewhere. For the $n \times n$ case there are $...
1729taxi's user avatar
  • 777
3 votes
1 answer
150 views

A code that returns the partial permutations on {1,2,...,n}

A partial permutation is a bijective partial function. A partial function is a map from a subset of {1,2,...,n} into {1,2,...,n}. I want a list of the matrix representations of all the partial ...
geoffrey's user avatar
  • 867
4 votes
1 answer
244 views

Permutations with Repetition

I am working with a function of type F[a,b,c,d,e,f] that obeys the following symmetries: ...
McSenegal's user avatar
  • 151
5 votes
3 answers
224 views

Permutation avoidance function

It is common for me to see if a permutation of 1,2,...,n, avoids some fixed permutation pattern. For example, the permutation [1,4,2,3,5] contains the pattern 1,3,2, as the elements [1,4,3] appear in ...
Per Alexandersson's user avatar
5 votes
1 answer
490 views

Generating a list of integers that sums to zero

Given a pair of integers n and k, I want to generate all lists of integers of length n, ...
user366202's user avatar
4 votes
1 answer
122 views

Binary permutation list code in Mathematica

Given some natural number $N$, I am interested in the set of all binary permutations of length $N$ (with the intention of storing in lists depending on how many $1$'s appear in each permutation). My ...
John Doe's user avatar
  • 229
7 votes
3 answers
553 views

Visualizing distribution of 3 balls in 3 cells

I want to generate the following Table which shows the distribution of 3 balls in 3 cells. But so far I have had no luck using Permutations, ...
Michael Dawson's user avatar
1 vote
0 answers
36 views

Why is PermutationProduct not yielding anything? [closed]

When I am trying to compute some products of permutations in S_48, it is somehow not working. Here is my code: ...
Nick Yin's user avatar

1
2 3 4 5 6