Questions tagged [permutation]
For questions about the functionality related to permutations in Mathematica.
262
questions
3
votes
1
answer
103
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 ...
3
votes
3
answers
215
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}$ ...
0
votes
1
answer
75
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 ...
4
votes
3
answers
140
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.
5
votes
3
answers
109
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 ...
0
votes
0
answers
36
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, ...
0
votes
1
answer
82
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$ ...
4
votes
2
answers
158
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( \...
1
vote
1
answer
97
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$ ...
1
vote
2
answers
123
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$...
2
votes
1
answer
77
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]
...
7
votes
3
answers
237
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 $ ...
4
votes
2
answers
134
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 ...
4
votes
2
answers
163
views
Finding coefficients that impose symmetry
To simplify the main question below,consider the following random multivariate polynomial :
...
0
votes
0
answers
50
views
Changing permutation dynamically
I am trying to make a visualization of permutation as a graph. With the first compilation of program I want to get random permutation and then be able to dynamically change permutation that I desire ...
1
vote
2
answers
127
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 ...
3
votes
4
answers
234
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
<...
5
votes
4
answers
229
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 ...
0
votes
0
answers
45
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 ...
2
votes
1
answer
115
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\}$, ...
1
vote
1
answer
64
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. ...
4
votes
3
answers
286
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 ...
1
vote
1
answer
79
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) <...
8
votes
1
answer
367
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}...
2
votes
1
answer
112
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 ...
1
vote
2
answers
198
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 ...
4
votes
1
answer
135
views
16
votes
11
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
...
2
votes
1
answer
127
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]):
...
1
vote
0
answers
81
views
Find Max Instance Over Permutations
I would like to find the maximum of some objective function over all possible permutations
...
7
votes
3
answers
389
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. ...
4
votes
3
answers
124
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 ...
2
votes
1
answer
55
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 ...
4
votes
3
answers
479
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 $...
3
votes
1
answer
137
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 ...
4
votes
1
answer
222
views
Permutations with Repetition
I am working with a function of type
F[a,b,c,d,e,f]
that obeys the following symmetries:
...
5
votes
3
answers
212
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 ...
5
votes
1
answer
487
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, ...
4
votes
1
answer
111
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 ...
7
votes
3
answers
539
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, ...
1
vote
0
answers
35
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:
...
1
vote
2
answers
163
views
How to get the length of cycles in a Cycles[] expression? [closed]
I am looking for a way to get {5,2} for a Cycles object, like: Cycles[{{1,2,3,4,5},{6,7}}]. ...
0
votes
1
answer
71
views
Finding the first few permutations of a list
Given a list, possibly with repeated elements, I am trying to get a list that consists of a specified number of distinct permutations of the list. Essentially, I want to something that works like <...
4
votes
5
answers
631
views
String permutation
I have a string "abcd". Is there any way in Mathematica such that when I apply some exchange operator $P^{ab}$ it gives me string "bacd"?
Edit:
After reading answers I felt like I ...
5
votes
3
answers
116
views
Find transformations for two non-square matrices $A$ and $B$
Given two matrices $A$ and $B$:
What transformation needs to be applied to transform matrix $A$ into matrix $B$?
...
1
vote
0
answers
64
views
How do I generate a random permutation of a (long [millions-length]) list of symbols? [closed]
I have a list of length twelve:
p = {t[1, 1], t[1, 2], t[1, 3], t[1, 4], t[2, 2], t[2, 3], t[2, 4],
t[1, 5], t[3, 3], t[3, 4], t[1, 6], t[4, 4]}
and a set of ...
3
votes
1
answer
131
views
How to get the complete list of subsets the pairwise intersections of which are empty
Given the list Range[4]. I want to get the sublists of length 2 where each element has length 2 and the pairwise intersections are empty. So I am looking for:
...
2
votes
1
answer
60
views
Unknown statistical function - groupings of permutations
Please bear with the vagueness of this question's title, as my question itself has to deal with the fact that I don't know what to call the operation I'm looking for. I have a statistical operation ...
4
votes
2
answers
153
views
Permuting elements in a nested list according to another nested list?
I have two lists (value and label). With the function Permute, I can permute the positions ...
4
votes
1
answer
166
views
Fast enumeration of all perfect matchings in complete graph
I have a code that generates the list with all possible Perfect Matchings (PM) of a fully connected graph. Each edge of the graph is mono or bi-colored with up to ...