Questions tagged [sets]

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

129 questions
Filter by
Sorted by
Tagged with
420 views

Unsorted Intersection

a = {0, 3, 1, 2, 3}; b = {5, 1, 2, 3, 4, 7}; c = {3, 1, 8, 5}; ...
• 82.3k
1 vote
162 views

How can I express these two sets and find their intersection by Mathematica?

My code: M = Interval[{-1, 2}] N = Reduce[ForAll[{y, x}, x \[Element] M, y == 0.5*x^2 - 1], Reals] Intersection[M, N] Gives an error message : Set::wrsym: Symbol ...
• 45
1 vote
90 views

Most efficient way of defining the following sets for every step $n$

For each $n\in\mathbb{N}$, how do we compute sets $A_n$ and $B_n$ below: Let $A_1=[0,2/3)$. Let $B_1=(2/3,1]$. If $A_n$ is a union of intervals, then for each interval cut out the middle $1/2^{n+1}$ ...
• 81
79 views

Removing a set of original assumptions from the result of Reduce

I am having trouble using set operations when applying them to lists which cme from the Reduce function. As an example, here is a list of assumptions and an expression for which I would like to know ...
• 297
106 views

Generating the union of possible subsets

I want to calculate the union of possible subsets within each set of the family of sets. I use the following code: ...
262 views

How to plot this set of complex numbers?

I want to plot this set of complex numbers in Mathematica: $$D := \left\{\frac{1}{z}: z \in \mathbb{C}, \text{Im}(z) \ge 1, \text{Re}(z) \le \text{Im}(z), |z-1-i| \le 1\right\}$$
• 43
49 views

NextSetPartition

I'm looking for a function similar to the one in the question below, but for the more general problem of set partitions without restricting the set size. NextKSizePartition, or how to partition a set ...
• 159
1 vote
80 views

Can't use iterative variable as part specification [closed]

I've got the following mathematica code: ...
113 views

How to to divide this list into the sets with four elements? [closed]

I have a list ...
• 4,013
1 vote
107 views

How to make a list be skipped if it is an empty set when it is being iterated over

Could you give me some advice? There is a box[a,b] in which the number and number of lists are randomly generated. For example as follows. ...
• 446
1 vote
128 views

• 105
265 views

How can I remove and keep the elements of this set?

I have a list list = {{1, 3, 7, 1, 2, 1, 4, 7}, {6, 2, 7, 9, 4, 3, 6, 7}, {2, 8, 8, 2, 3, 2, 4, 6}, {5, 7, 7, 5, 2, 1, 2, 4}, {8, 10, 10, 8, 2, 1, 2, 4}} Consider ...
• 1,622
142 views

How to create a GroupBy function that is better aligned with relational algebra?

I want a GroupBy function that behaves more in alignment with relational algebra principles. I can get what I want if I do it in 2 steps: Preparation: ...
• 930
212 views

Displaying Hasse diagram (directed edges in graph pointing upwards)

I use the following code to display a Hasse diagram of a graph. ...
• 1,698
235 views

How to do integer interval arithmetic?

How to calculate union, intersection and complement of integer intervals without actually generating all integers in the range and perform set-arithmetic (Union, <...
• 47.1k
1 vote
37 views

Is there a nice way to deal with sets in an abstract/symbolic way?

For instance, if I wanted to declare $A$ to be the set of all finite subsets of $\mathbb{Z}$, and declare $B$ to be a set comprising all finite subsets of $\mathbb{Z^{-}}$, and then declare $C$ to be ...
• 763
1 vote
101 views

Speed up random set partition code

I have managed to construct code for randomly generating a set partition of size n with k parts. Note that the total number of such objects is counted by a Stirling number of the second kind. The code ...
• 2,489
290 views

Enumeration of a certain sequence III

Let us call a collection $\mathcal{F} \subseteq \mathcal{P}(X)$ satisfying: $\emptyset, X \in \mathcal{F}$ For all $U, V \in \mathcal{F}$ it holds that $U \cap V \in \mathcal{F}$. special. We can ...
• 105
174 views

formations of union of sets

How do I get the formations generated by the union of sets? Practical example As an example of this calculation,if we denote the four sets: ...
• 982
324 views

Verifying a combination problem using subsets

The question is shown below. The handwritten answer is one of the methods of the mark scheme. This method "seemed" ok, but we are not so convinced about the Total of 140 ways. Also, there is ...
• 1,652
174 views

• 592
852 views

How to generate Venn diagram from a universe and 3 random sets?

Given a universe u with random numbers between 1 and 50 and three sets a,b,c, that have random numbers a between 3 and 30, b between 2 and 40 and c between 4 and 49 How can I represent the sets a, b ...
• 490
218 views

How can I subtract and calculate the complement of a pair of sets? [closed]

I cannot properly implement these operations. How can I do it? This is a reduced example: A={2,3,4} B={2,4,6} C={1,2,3,4} Find ...
• 417
179 views

Can Solve[...] be used for set math? If so, how? If not, how else?

I'm a recreational user who loves using the product. I'm looking for a strategy to solve the following question using Mathematica. The question is from a sample actuarial exam. I can solve this with ...
168 views

Mathematica code for q-Stirling numbers

In the paper [A new $q$-Analog of Stirling Numbers],(https://hal.archives-ouvertes.fr/hal-01372920/document)[PDF] J. Cigler defined $q$-Stirling numbers of the second kind as the following: He ...
• 143
72 views

Part of array as a blank variable [duplicate]

I have a little question. Let me define the function: f[k_]:=k So 'k' in the argument of 'f' is a blank variable. Is there a way to define a part of array as a ...
144 views

What Does CompileSetIterate Do?

The list of compilable functions (given by CompileCompilerFunctions[] // Sort) shows one of the more interesting- and core-sounding functions: ...
• 1,627
258 views

How to draw 3D sets in Mathematica given inqualities

I would like to draw a 3D set ($E$) given the following conditions: $E=\{(x, y, z)\in\mathbb R^3: x, y, z \in [0, 1], x+2y-1\leq z\}$ I have seen in the Mathematica documentation that there are ...
1 vote
72 views

How to ask Mathematica to do the given operation for a set of parameters?

I have a set of numbers like this s = {a, b, c, d, e, f, ..., g, h} and I would like to ask Mathematica to do the following operation (to sum the subtractions of ...
425 views

Most efficient way to find equivalence classes of an equivalence relation

This is a most basic thing and is probably just built-in but I am ignorant of it, so... I've got some set S={a,b,c,...} and a function ...
• 2,076
60 views

Is there an argument to MemberQ so that it will always return TRUE?

Is there an argument for the first input to MemberQ which will result in MemberQ always returning TRUE? It would basically be a constant for the set of everything, I suppose.
• 5,606
1 vote
127 views

How to determine the domain (intersection and disjoint set) of two functions define on a set? [closed]

Suppose I have two multivariate functions $f(x,y,z)$ and $g(x,y,z)$ such that $0<x<1,0<y<1,0<z<1$. $f(x,y,z)$ is defined on values satisfying $\{0<x<1,0<y<1/2, z>y\}$ ...
• 147
60 views

How do we express set theoretic extensionality in Mathematica for instance I want it to see {2,1} as equal to {1,2)

I think the title pretty much covers it
• 465
200 views

Decompose set into elements?

Given a list of tuples where one element is a set: ...
• 343
195 views

How to decompose a list of n-tuples into a union of Cartesian products

I have a list with all elements at the same level { {a, d}, {a, e}, {a, f}, {b, d}, {b, e}, {b, f}, {c, d}, {c, e}, {c, f}, {x, t}, {x, q} } How ...
68 views

Symbolic Set Difference

Suppose I have two symbolic set containing 2-points like A={(m,n)| for m,n belonging to whole numbers}. So m,n=0,1,2,... and I have another set containing 2-points ...
• 1,122
42 views

Generalizing previous question: Partition $[a,b]$ into $m$ sub-intervals and count number of sub-interval intersecting $A_1\subseteq[a,b]$?

In my previous question, How to partition $[a,b]$ into $m$ equal sub-intervals and count the number of sub-intervals that intersect with a subset of $[a,b]$?, I was given an answer to my specific ...
• 81
1 vote
140 views

How to partition $[a,b]$ into $m$ equal sub-intervals and count the number of sub-intervals that intersect with a subset of $[a,b]$?

Suppose we have a subset of $[a,b]$, where $a=0$ and $b=1$, such as $$A_1=\left\{\frac{1}{2^x}+\frac{1}{2^y}+\frac{1}{2^z}:x,y,z\in\mathbb{Z}\right\}\cap[0,1]$$ Which is a subset of $[0,1]$ If we ...
• 81
297 views

How can I solve a Set Cover problem in Mathematica

I have $n$ non-empty possibly non-disjoint sets $S_i$, each having a cost $c_i$, and the union $\Omega=\bigcup_{i=1}^{n}S_i$. How can I find a selection of $S_i$ such that the union is also $\Omega$ ...
• 25.6k
1 vote
180 views

How can one expand an arbitrary boolean combination into the $2^n$ atoms of the associated boolean algebra of size $2^{2^n}$?

The answer of user250938 to Can one usefully apply the Boolean functions of Mathematica to measurable Boolean sets? and the second comment of Monroe Eskew to the answer to https://mathoverflow.net/...
• 2,335
129 views

Can one usefully apply the Boolean functions of Mathematica to measurable Boolean sets?

This is something of an attempted succinct/pointed rephrasing of an earlier question Given measures on sets and on certain Boolean combinations of the sets, can one check their consistency and/or ...
• 2,335
114 views

every set intersection for every set in a family with another family of sets

I want to find for each list within a list of lists what intersections occur when taking set intersection for each list in another list of lists. Hopefully that makes sense. I have tried ...
• 477
742 views

Delete sublist when sub-sublists contain same element

Given lis={{{a},{b,c,d}},{{a,b},{b,c}},{{b,c},{a,b,c}},{{b},{d}},{{a,b},{c,d}}} I want to delete sublists which have one or more elements in common. So that I ...
• 2,788
1k views

How to stretch this Venn diagram?

I am trying to duplicate (approximately) the following Venn diagram in Mathematica: I have used the top of this page as a guide, which showcases the following Venn diagram triplet: ...
• 3,145
1 vote
383 views

ArgMin over intervals and discrete sets

I was playing with ArgMin but I'm not sure how to use it for constrained optimization. For example, ArgMin[x^2, x] returns <...
• 133
1 vote
151 views

Possible way to plot the solution density of diophantine equations

Well, I'm trying to investigate the density of solutions to Diophantine equations. What is a general method to describe that density? I've two functions: \varphi\left(\text{a},\text{b},\text{c}\...
• 2,021