# Tagged Questions

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

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 ...
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, ...
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?
173 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 ...
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. ...
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$. ...
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 ...
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 ...
172 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 ...
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 ...
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.
207 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 ...
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{aligned} k_0 &= [A]...
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 ...
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$ –...
464 views

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 ...
330 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 ...
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 ...
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 ...
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 ...
416 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 ...
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 ...
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: ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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 ...
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'...
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 ...
889 views

### Exact cover solution

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