Express (0,2) as a Union of disjoint open intervals
(2) Write the following sets as an interval or union of intervals. In each case x ∈ R.
(a) A = {x|x≠5 ∧ x≠8}.
(b) B = {x|x²(x³-1) ≠ 0}.
(c) C = {x|x³- 2x ≠ 0}.
(d) D = {x|(x-2)(x + 3)(x+4) = 0 ⇒ x ≥ 2}.
(3) Simplify each of the following sets and give the final result as an interval or union of intervals
(a) ([-3,2] ∩ (0,5))ᶜ.
(b) ((-3,5.6] ∩ (-5, 2.43)) ∪ (0.3, 11).
(c) (2,4]ᶜ ∩ ((-∞,5)) ∪ [0, ∞)).
(d) (-0.3, 0.03) ∪ ((-∞, 1/30) ∩ [5,∞)).
(4) Find the supremum and infimum of each of the following sets of real numbers:
(a) All numbers of the form 2⁻ᵖ + 3⁻q + 5⁻ʳ, where p, q, and r take on all positive integer values.
calculus - Expressing intervals as a union or intersection of intervals of the form $(a,b]$ - Mathematics Stack Exchange
calculus - Union of intervals - Mathematics Stack Exchange
Videos
I don't know how is that possible, because I'm assuming that (0,1) ∪ (1,2) does not include 1.
So How it can be actually expressed?
Let's think formally about what a boundary is. If you have a set $A$, with closure $\bar{A}$ and interior $\mathring{A}$, then the boundary of $A$ is $\partial{A} = \bar{A} \setminus \mathring{A}$.
Let $A = \{1,2,3\} \cup (2,4)$.
What is the closure of this set? The easy way is to find the points whose neighborhoods always contain some points in $A$ (the closure is the set of these points, by definition). In this case, the closure is $\{1\} \cup [2,4]$.
The interior is, by definition, the set of points who have at least one neighborhood contained totally in the set. So, the interior of this set is $(2,4)$.
The boundary of the set is therefore $\bar{A} \setminus \mathring{A} = \{1,2,4\}$, just three points!
You can always display a set in $\mathbb{R}$ as a union of points (singletons) with intervals. So, the original set would be $\{1\} \cup [2,4)$ as you essentially suggested.
You get the union of a bunch of points and the open set $(2,4)$, as you note, but I would write this as $\{1\}\cup[2,4)$.
Sort them by one of the terms (start, for example), then check for overlaps with its (right-hand) neighbor as you move through the list.
class tp:
def __repr__(self):
return "(%d,%d)" % (self.start, self.end)
def __init__(self, start, end):
self.start = start
self.end = end
s = [tp(5, 10), tp(7, 8), tp(0, 5)]
s.sort(key=lambda self: self.start)
y = [s[0]]
for x in s[1:]:
if y[-1].end < x.start:
y.append(x)
elif y[-1].end == x.start:
y[-1].end = x.end
Use the sweep line algorithm. Basically, you sort all the values in a list (while keeping whether it's beginning or end of the interval along with each item). This operation is O(n log n). Then you loop in a single pass along the sorted items and compute the intervals O(n).
O(n log n) + O(n) = O(n log n)