Stack Exchange Network

Stack Exchange network consists of 175 Q&A communities including Stack Overflow, the largest, most trusted online community for developers to learn, share their knowledge, and build their careers.

Visit Stack Exchange

Questions tagged [combinatorics]

Questions on the use of Mathematica in combinatorics, including the Combinatorica add-on package.

0
votes
0answers
34 views

Combinatorics/Permutations [migrated]

A village has about 1 million residents. Suppose each resident has a jar with 100 coins in it.Two jars are considered to be “equivalent” if they have the same number of 10c, 20c, 50c, \$1 and \$2 ...
1
vote
0answers
46 views

Computing Definite Sums of Rational Functions

I am attempting to compute a rather complicated sum, $S_n$, that in the end satisfies the relation $(S_n + T_n) m^3 = (\frac{(n+1)^2 - 1}{n+1})m^3$. I should note that $T_n$ is also unknown. There are ...
4
votes
1answer
55 views

Question about FindKClique

Say we have a graph: g = CompleteGraph[5]; and that we want to find all the triangles in g. I tried to use ...
3
votes
1answer
55 views

Generating integer partitions with fixed first element

I'm trying to generate all integer partitions where the first entry is a fixed number i.e. all young diagrams with first row/column fixed. I'm aware of the function IntegerPartitions[n] and I could ...
0
votes
0answers
30 views

Triangulations of a convex polygon

I have a piece of code which finds all triangulations of a convex polygon. It is known that a number of such triangulations for a given $n$-gon is is given by ($n-2$)th Catalan Number, so for instance,...
4
votes
0answers
54 views

Four color theorem in Mathematica [closed]

The four color theorem is a theorem about graphs (as in graphs and networks) and it was proved with the aid of a computer. To date, there is no hand-checkable proof. The software that was used to ...
0
votes
1answer
37 views

How to generate all the combinations with repetition?

I have $K$ variables. Each variable can take any value form a set with $N$ elements. We have $N^K$ possible solutions (permutations with repetition, when at each time slot we can choose among $N$ ...
1
vote
2answers
89 views

How to generate all the combinations? [duplicate]

There are $N$ optimization variables, $v_1,v_2,\cdots,v_N$. and $v_n\in{0,1,2,3,\cdots,K}$. Let $N=10$ and $K=5$. How can I generate all the possible combinations? For example, the first ...
0
votes
1answer
51 views

How make create all possible lists of twelve elements? [closed]

How can I create all possible lists of twelve elements when each element can be -1 or 1. That is, 2^12 different lists.
0
votes
1answer
29 views

Expanding integer compositions

Quick version: I would like Mathematica code that, for instance, turns {3,1,2} into {3,3,3,1,2,2}. More formally, given positive integers $c_1, \ldots, c_t$ which sum to $n$, produce the length $n$ ...
0
votes
1answer
36 views

Reverse the reccurence mirrorwise

Let be a recurrence for polynomials $R_{m,j}$ ...
0
votes
1answer
27 views

Different result with HypergeometricPFQ

I have a following sequence: Table[Sum[Sum[(1 + j + k + n)!/((1 + j + k) j! k! ), {j, 0, n}], {k, 0, n}], {n, 1, 5}] (* {16, 542, 31488, 2646024, 292224000} *) ...
5
votes
1answer
519 views

Is there a function to partition an integer set?

First I give an example. For an integer set $(0,1,2,3,4)$, there are eight kinds of subdivision or partition like this $$(0,4);\\~~(0,1)(1,4);~~(0,2)(2,4);~~(0,3)(3,4);\\ (0,1)(1,2)(2,4);~~(0,1)(1,3)(...
4
votes
3answers
771 views

Create all possible words using a set or letters

Given a list of letters, letters = { "A", "B", ..., "F" } is it possible to get Mathematica to generate all ‘words’ (in this example, 6 letter words), if only ...
1
vote
0answers
39 views

Permute using symmetric vs alternating groups

Why does this happen? Permute[{0, 0, 0}, SymmetricGroup[3]] (* {{0, 0, 0}} *) Permute[{0, 0, 0}, AlternatingGroup[3]] (* {{0, 0, 0}, {0, 0, 0}, {0, 0, 0}} *)
2
votes
1answer
156 views

Rewrite the power sum in terms of convolution

Let be an identity $$n^{2m+1}=\sum_{r=0}^{m}A_{m,r}\sum_{k=0}^{n-1}k^r(n-k)^r,$$ where $A_{m,r}$ are real coefficients, see A302971 for numerators and formula of $A_{m,r}$. Here we can notice that $\...
8
votes
0answers
105 views

StableMarriage vs. FindIndependendEdgeSet: How to use the procedure FindIndependendEdgeSet as a Gale-Shapley algorithm?

From Help, the procedure StableMarriage was an element of the Combinatorica, but it is available in the built-in ...
3
votes
1answer
41 views

Using FindInstance for Identifying Feasible Planar Solutions in a 3D Latin Hypercube

Consider a $3d$ lattice latin hypercube with $n$ steps in each dimension, so it has $n^3$ positions. Coordinates $X, Y, Z \in \{1,2,...n\}$. I want to find all of the permutations of them where they ...
1
vote
3answers
115 views

Handling cases of cross terms for multi-sums

I have expressions consisting of many multi-sums and I would like to extract cross terms out of them. Consider a simple example: $$ \sum_{m_1=1}^M \sum_{m_2=1}^M \sum_{m_3=1}^M \sum_{m_4=1}^M (x_{m_1}...
6
votes
5answers
695 views

Sum of list numbers smaller than one goal

I have five values ​​that I would like to add them so that they can be equal to or less than 3000. ...
1
vote
0answers
37 views

Binomial coefficients for negative entries [duplicate]

Mathematica evaluates the binomial coefficient $\binom{-1}{-1}$ to 1. That agrees with an application I have in mind. However many books, such as Concrete Mathematics, e.g. see here, define $\binom{...
5
votes
3answers
421 views

Find position without iterating

The code below solves for the four value of $m_i$ for a given pair of $(N_m,M_m)$. where $$ m_1+m_2+m_3+m_4 = M_m\\ |m_1|+|m_2|+|m_3|+|m_4| = N_m $$ Edit 2 New Sorting I have now realised that the ...
0
votes
1answer
40 views

How can I construct binomial terms using the Binomial function? [closed]

I want to construct a table of the terms Binomial[n, i] t^i (1-t)^(n-i) where i goes from 0 to ...
1
vote
1answer
47 views

How to find efficiently the independent vertex sets from a large adjacency matrix?

I have a binary adjacency matrix $M$ of size $72\times 72$. I would like to find all possible combinations of 18 non-adjacent nodes. There are $^{72}C_{18}$ possible (adjacent and non-adjacenct) ...
6
votes
1answer
105 views

Generate list of tuples, modulo PermutationGroup

I have a permutation group, e.g. g = PermutationGroup[{Cycles[{{1, 2}}]}] but not necessarily limited to a single generating cycle. What I want is to create a ...
0
votes
1answer
35 views

Sums of binomial expressions returns different and sometimes indeterminate expressions

A problem that I encountered multiple times when taking sums over expressions involving binomials, factorials, etc. is that Mathematica (version 11.2) returns indeterminate expressions when it should ...
0
votes
2answers
68 views

Tuples of elements from list excluding anything with repeated values

What I would like to do is the following. For a given list of elements; say (0,1,2,3,4) I would like to obtain all possible combinations of five, but not the ones with ANY repeated values. That is I ...
7
votes
2answers
329 views

How to represent a product of cycles in matrix form?

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 ...
0
votes
0answers
28 views

Enumerate all lists of $m$ non-negative integers that add to $n$ [duplicate]

Let $x_1,\dots,x_m$ be non-negative integers such that $\sum_{i=1}^m x_i=n$, where $m,n$ are given. How can I enumerate all such lists of $m$ integers that add to $n$? Note that ...
4
votes
2answers
53 views

Groupings of the Elements of a List with at Most $k$ Elements

Given a list with $n$ elements and an integer $k$ I want to get a list with all possible groupings of these n elements in sets with at most k elements. For example, given $n=\{1,2,3,4\}$ and $k=3$ I ...
3
votes
1answer
265 views

How to calculate all possible resistances made from 5 distinct resistors in series and/or parallel? [closed]

Five distinct resistors resistors={1,2,3,4,5} are given. The objective is to find a list of all possible resistances obtained by configuring all these resistors in ...
2
votes
1answer
92 views

Find All Compositions of an Integer

I can use the Combinatorica package to produce all integer compositions of the integer $n$ into $k$ parts by writing ...
3
votes
0answers
71 views

Package like combinat

I started using Mathematica and want to do some computation involving Characters of the symmetric group. In maple, I used to use the package combinat. The link is below https://www.maplesoft.com/...
1
vote
3answers
97 views

How to generate the lists of $0 \leq m \leq X$ integer values so these values add up to $X$

This must be basic, but my Mathematica (and overall programming) skill level is too low to find a handy solution: I need to generate all possible lists of $m$ integers (I call these integers $x_i$'s, ...
8
votes
3answers
268 views

Find k smallest sum n-tuples

Given a collection of sorted lists {l1, l2, ...} I need to find the smallest k index tuples taken from these lists by summed ...
2
votes
1answer
39 views

Simpifying expressions with binomial coefficients

I wrote: Simplify[Binomial[n, k] - Binomial[n - 1, k]] I expected Mathematica to simplify this according to Pascal's identity to: ...
6
votes
2answers
207 views

All adjacency matrices of size n

What would be a concise way to get all adjacency matrices of size $n$, e.g. for $n=2$, these $(2^2)^2$ matrices: ...
3
votes
1answer
63 views

Selecting special tuples from a big list, and dealing with memory limitations

OK, I'm working on some music theory stuff since that's my hobby. This is what I want to do: ...
7
votes
2answers
147 views

Testing for Symmetry and Regularity in (Graph-Theoretic) Graphs

I know my way around Mathematica pretty well, however I have not been able to find any built-in functionality for testing a (graph-theoretic) graph for being symmetric (arc transitive) – this is the ...
12
votes
4answers
391 views

How to generate all involutive permutations?

Take a finite set $S$ (i.e., a list). An involutive permutation is one that squares to the identity. How can we generate all such permutations efficiently, that is, without generating all permutations ...
5
votes
2answers
171 views

Pattern for k distinct elements of a set of n elements

I would like a pattern which takes as an argument a set with $n$ elements, and an integer $k$ which is less than $n$ and greater than 1, and which matches against any $k$ distinct elements of the set, ...
1
vote
0answers
42 views

Generating list of binomial outcomes [closed]

As an example, imagine if I have a set of 3 coins and I want to generate a list of possible coin states. I know I can brutishly execute: ...
4
votes
2answers
220 views

Scramble matrix under some condition

Assume I have a matrix. (mat = Partition[Range@9, 3]) // MatrixForm mat$=\left( \begin{array}{ccc} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & ...
0
votes
0answers
36 views

Combinatorica and MultiplicationTable in Mathematica 11

I try to use <<Combinatorica` or call IntervalSlider; Needs["Combinatorica`"] or call ...
5
votes
3answers
307 views

Implement the partition function

I am trying to write my own version of the PartitionsP function. Here is my code: ...
13
votes
1answer
1k views

How to generate all Feynman diagrams with Mathematica?

I'm using the words "Feynman diagrams" for indexing purposes, but the question is in fact purely graph-theoretic. Given a list n={n1,n2,...} of non-negative ...
0
votes
1answer
43 views

Separate list elements into groups of two in all possible ways? [duplicate]

Consider a list with an even number of elements, e.g. list = {1,2,3,4}; I would like to have a function fun that produces all ...
5
votes
2answers
148 views

Find independent tensor products using Young Tableaux

I'll present a very simplified version of what I really need to do. I have the following 2-rank tensors $h_{\mu\nu}$ , $\xi_{\rho\sigma}$, $k_{\alpha\beta}$ where $h$ and $k$ are symmetric under ...
0
votes
1answer
47 views

A problem of a sequence and its sum

{a(n)} is such a sequence, satisfying, For all a(i) ∈ {a(n)}, a(i) =1 or -1 Let S(j) = Sum[a(i) , {i ,1, j}], then for all 1<=j<=n ,S(j)>=0. For a given n , how many {a(n)} are there?
0
votes
1answer
170 views

Easy number theory problem

$p$ is an odd prime number,$S = \{x \mid 1 \leq x \leq 2p, x \in \mathbb{Z} \}$, $A$ is a subset of $S$, satisfying $\operatorname{card}(A) = p$ $\sum\limits_{x\in A} x \equiv 0 \pmod p$...