For questions pertaining to sets in the set-theoretical sense. Use "assignment" for questions about the use of the Mathematica functions Set or SetDelayed.

learn more… | top users | synonyms

7
votes
2answers
169 views

Sets and sums of different elements

Consider the set S={w,x,y,z}. If the set of all possible sums of any three different elements from S is {-1,3,5,8}, then what is the set S? How could I solve this function using Mathematica?
5
votes
2answers
174 views

Get envelope of a set of functions?

I'm new with mathematica and I'm trying to solve a problem. I have a set of functions in the same variable. Let's say the domain is [0,2]. I would like to get an ordered list of the functions ...
1
vote
1answer
64 views

Fast way to compute intersection of equivalence classes

There is a set $S=\{1, 2, \dots, m\}$ and $n$ equivalence relations on the set: $a \sim_i b $, where $a,b \in S$, $i=1, \dots, n$. Now we define $a \sim b$ iff $ a \sim_i b$ $\forall i=1, \dots, n$. ...
0
votes
1answer
43 views

Use elements of a convex sets to solve equations [closed]

i try to do sth. like this A=Solve[{x>=5, y>=3, x<13,y<13} ,{x,y}] which gives me a convex set and then ...
1
vote
1answer
68 views

Having trouble representing null sets within Mathematica

I am having trouble writing the Mathematica code to prove this answer. I was able to derive the answers but through trial and error, ideally I want to derive them through examination of correct code. ...
9
votes
1answer
172 views

Is there an easy way to do set counting in Mathematica?

I'm using counts of elements in sets, along with logic. So, for instance, I'd like to determine if Count[$a \land \neg b$] = Count [$a$] - Count[$a \land b$] ...where ...
0
votes
0answers
46 views

how to use a tree as a key to construct a table of key values

I have an interesting problem that I was able to summarize in the form of trees, sets, and key value pairs. I have the following sets of keys and values \begin{equation} \begin{aligned} k_0 &= [A]...
1
vote
0answers
36 views

Solving systems of logial and set theoretic propositions

I need to allocate a couple of dozen elements into different sets, respecting some boundary conditions, and was hoping Mathematica might somehow help. A simple example: The propositions being a) a ...
2
votes
0answers
61 views

Is there a way to make a set of all real numbers within a range? [closed]

Is there a way to create a set of all real numbers within a range? For example, the range between 1300 and 1500, including 1500 in normal distribution. Thank you very much. My problem exactly: $A$ –...
0
votes
1answer
65 views

Mining for matching elements of sets with equal divisors

This problem is extrapolated from a problem that was solved on how to manipulate lists of set outputs as a union ( Equation Autogeneration ), where the concern now is how to mine for (or attain from ...
1
vote
2answers
297 views

How do I do the Minkowski sum of two sets?

I have 2 sets, $X$ and $Y$. How do I find the Minkowski sum of these sets?
10
votes
5answers
445 views

How to randomly select subsets

I have a list of around 300 elements. I want to sample subsets of length 25 such that my samples are all distinct. My first inclination was to use something like ...
3
votes
1answer
161 views

Finding pairs where the intersection of them is empty set from a nested list

It would be better to give an example first. Suppose I have a nested list of the form list = {{ 1,2,3,6}, { 3,6,10,20}, { 4,7,11}, { 10,20}}; where each element ...
5
votes
3answers
173 views

Finding largest Range in a list

In a list of positive integers, I would like to find the largest n such that Range[n] is a subset of the list. So for example ...
16
votes
7answers
723 views

Enumerating tuples from a larger space such that all pairs of values are present at least once

I am trying to write a function that will accept a list of N lists and returns a list of N-tuples that represent all pairs of values from the original N lists at least once. To illustrate with an ...
7
votes
1answer
306 views

A more perfect Union[]

I was doing a Project Euler problem with my class, and found the following weird fact: Union[] of a list of some 50 million numbers (of which only around 15000 were ...
3
votes
1answer
92 views

How can I create a set (list) provide a kind of rule/algorithm?

Example: S = {r ∈ Q : r² < 2} Let S be the set of all rational numbers whose squares are less than 2. It follows that 1 ∈ S, 4/3 ∈ S, but 3/2 doesn't ∈ S because 9/4 ≥ 2. Thank you.
0
votes
1answer
243 views

Inclusion-Exclusion Principle Implementation

I would like to know how I can write a Mathematica code for the Inclusion–exclusion principle. The formulas governing it are: $ P(\bigcup_{i=1}^n A_i)=\sum_{k=1}^n (-1)^{k-1} \sum_{\substack{I\...
0
votes
0answers
42 views

Addition of all elements of two sets with each other [duplicate]

Let $S_1=\{a_1,a_2,\ldots,a_m\}$ and $S_2=\{b_1,b_2,\ldots,b_n\}$ be two sets. I want to list all $a_i+b_j$ for each $1\leq i\leq m$ and $1\leq j\leq n$ in a set. Is there a commend in mathematica for ...
4
votes
3answers
331 views

Counting number of inversions

Is there an inbuilt method to find the number of inversions in a set of numbers? I found Inversions in Combinatorica but when I ...
10
votes
4answers
390 views

Complement of multisets

Given lists $a$ and $b$, which represent multisets, how can I compute the complement $a\setminus b$? I'd like to construct a function xunion that returns the ...
3
votes
1answer
423 views

Putting set elements into venn diagram

My problem has two parts. Before that I have two Lists/Sets. It suppose to be created them by two initial strings. In the first part, I need to show sets' elements in venn diagram. I can create venn ...
3
votes
1answer
226 views

Intersection does not take list of lists

The function Intersection takes a number of lists (sets) and finds their intersection. However, the precise input is ...
11
votes
10answers
847 views

Finding neighbors from list

Say you are given the following list: list={{3, 2, 1}, {3, 4, 2}, {2, 4, 1}, {1, 4, 3}}; Two numbers $x,y$, not necessarily distinct, are neighbors if one of the ...
4
votes
2answers
133 views

How to constrain the generation of all possible orderings?

Here is code from Simon Woods' answer for getting all possible weak (equal ranks allowed) orderings for $N=3$ objects: ...
7
votes
1answer
254 views

How to get all possible orderings (equal ranks allowed) for given set of $N$ objects?

Hope there is a solution besides the tedious generation of nested loops. (Trying to avoid reinventing the wheel.) Here is an example with $N = 3$ objects. There are $13$ needed orderings (first ...
5
votes
1answer
118 views

Amount of k-sized not-duplicated subsets of subsets of pair with disitinct sorted integers

I have a list, L, of this kind ($n\in \mathbb{N}$): L=Sort[RandomSample[Subsets[Range[n],{2}],RandomInteger[{1,Binomial[n,2]}]]] S contains any k-sized subset ...
4
votes
1answer
208 views

List all possible elements of a set

I have this two sets: $A = \{\emptyset, \{\emptyset\}, \{\{\emptyset\}, \emptyset\}\}$ $B = \{\{x, \{x, y\}\} | x \in A, y \in A\}$ Now I want to list all possible elements that are in $B$. How do ...
0
votes
4answers
46 views

How to multy-Set a group of lists?

I have a group of lists, for example: lists = RandomInteger[10, {100, 2}] {{6, 7}, {7, 4}, {3, 3}, ....} Now, I want to ...
11
votes
1answer
307 views

How to find longest monotonic sequence?

I have a list, for example list = {2, 1, 3, 5, 4, 6} How to find longest ascending sequence of this list? There are two meanings of this question: Find the ...
3
votes
7answers
417 views

Concise way to generate multiset lists

I wrote the following to generate a multiset with the same number of items over a fixed range: ConstantArray[#, 3]& /@ Range[9] // Flatten ...
1
vote
3answers
161 views

How to write equal subset

I have a unique set S={1,1,3,3,3} but from this unique set I can create many combinations like {1,3,3,3,1}, {3,3,1,3,1}, ... I ...
3
votes
0answers
73 views

Listing all combinations produced by picking one element from each of several sets [duplicate]

I have a problem like this, I am given the following sets {a,b,c}, {d,e,f}, {h,i,j}. I want to pick one element from each set, and output a list of all the ...
11
votes
6answers
464 views

Performing Computations on Sets

I would like to find a permutation of $\quad S=\{\frac{1}{10}, \frac{1}{2}, \frac{4}{7}, \frac{3}{5}, \frac{2}{3} \}\quad$ that maximizes the sum of theses elements raised to unique powers: $\;\{0,1,2,...
1
vote
1answer
131 views

Set theoretic operations on sets of real numbers

I have two pieces of code that produce a bunch of real numbers, say $A$ and $B$ respectively. (It is not relevant to the question, but $A$ consists of eigenvalues of the Hamiltonian of some physical ...
1
vote
2answers
2k views

Plot 3D set (or a domain of three-variable function)

is there any way to plot a "3D set" of points subject to certain rules? For example, my task is to find maximum of some function of three variables which have to meet some conditions. Of course I can'...
10
votes
3answers
396 views

Patternmatching sets

How to match set-patterns against sets? A set (in the mathematical sense) is a list of elements without repetition and order of elements does not matter. For example, we have a pattern set ...
15
votes
9answers
627 views

Any built-in function to generate successive sublists from a list?

Given lst = {a, b, c, d} I'd like to generate {{a}, {a, b}, {a, b, c}, {a, b, c, d}} but using built-in functions only, ...
4
votes
2answers
889 views

Exact cover solution

Is it possible to get a exact cover solution(s) and/or number of possible solutions in Mathematica?
2
votes
2answers
479 views

Combining lists with common elements efficiently [duplicate]

Possible Duplicate: Computing the equivalence classes of the symmetric transitive closure of a relation I am required to process sets consisting of 2-element subsets of integers by combining ...
10
votes
3answers
953 views

how to efficiently apply function to all pairs of a set (and collect the results)

To build a graph, I need to apply a function f[a_, b_] to all pairs of a list (3500 elements). The function itself returns a link ...
31
votes
7answers
2k views

How to select minimal subsets?

I am a newbie, so please point me in the right direction if you feel this question has been answered somewhere else before. Here goes: Suppose I have a list like this: ...
15
votes
5answers
3k views

Define a mathematical set

I have a terribly short question: Is there a way to define a pure mathematical set? I tried a bit of googling, but the word "set" has two meanings and the other one (as in setting) as by far more ...
6
votes
3answers
771 views

Subsets of a list

Consider the following demand of products for the next four months. data={1,20,3,40}; I could produce the whole demand in the first months, leading to the ...
12
votes
7answers
3k views

Combination and Permutation

How could I obtain the list of all the groups of 5 numbers taken from Range[12] such that the 2 lists have an empty intersection : ...