Solutions
Try solving the exercise yourself first before checking the solution!
Set Theory: Exercises
Sets
- True, \mathcal{A} = \mathcal{B} since order does not matter for sets and both contain the same elements.
- False, \mathcal{A} \neq \mathcal{B} since \mathcal{A} contains duplicate values it is not a set.
- \lvert \mathcal{C} \rvert = 5
- False, \text{forecasting} \notin \mathcal{T}_{\text{DATS} \ 6103}. This machine learning task is covered in DATS 6313: Time Series Analysis and Modeling.
- False, \text{flower} \notin \{ \text{airplane}, \text{automobile}, \text{bird}, \text{cat}, \text{deer}, \text{dog}, \text{frog}, \text{horse}, \text{ship}, \text{truck} \}
Set-builder Notation
- \{\ldots,-11,-6,-1,4,9,\ldots\}
- \{ -\sqrt{3}, \sqrt{3}\}
- \{ -3, -2\}
- \{ -4,-3,-2,-1,0,1,2,3,4\}
- \{ \ldots,-2,1,0,1,2\ldots\} = \mathbb{Z}
- \{ x^n: n \in \mathbb{N}\}
- \{ 3x : n \in \mathbb{Z}\}
- \{ n^2 : n \in \mathbb{Z}\}
- \{ x \in \mathbb{N} : 3 \leq x \leq 8 \}
- \{ 2^{n} : n \in \mathbb{Z} \}
Subsets
- \{\emptyset, \{\emptyset\}\}
- \{\emptyset, \{1\}, \{2\}, \{3\}, \{1,2\}, \{2,3\}, \{1,3\}, \{1,2,3\}\}
- \{\emptyset, \{\text{Python}\}, \{\text{R}\}, \{\text{SQL}\}, \{\text{Python},\text{R}\}, \{\text{R},\text{SQL}\}, \{\text{Python},\text{SQL}\}, \{\text{Python},\text{R},\text{SQL}\}\}
- \{\emptyset, \{1\}, \{\{2,3\}\}, \{1, \{2,3\}\} \}
- \{\emptyset, \{\mathbb{N}\}, \{\mathbb{Z}\}, \{\mathbb{N}, \mathbb{Z}\} \}
Set Operations
- \mathcal{A} \cup \mathcal{B} = \{ 1, 2, 3, 4 \}
- \mathcal{A} \cap \mathcal{C} = \{ 1 \}
- \mathcal{B} - \mathcal{C} = \{ 2, 3 \}
- \mathcal{A} \cup (\mathcal{B} \cap \mathcal{C}) = \{ 1, 2, 3, 4 \}
- (\mathcal{A} - \mathcal{B}) \cap \mathcal{C} = \{ 1 \}
Cartesian Product
- Given the dataset \mathcal{D}:
\mathcal{D} = \{ (x_i, y_i) \}_{i=1}^{n}
We can rewrite the dataset in set-builder notation:
\mathcal{D} = \{ (x_i, y_i) : x_i \in \mathcal{X},\; y_i \in \mathcal{Y},\; i = 1,\ldots,n \}
To demonstrate that it is a subset of the set of all possible combinations of feature and target ordered pairs:
\begin{align*} \mathcal{D} \subseteq \{ (x, y) : x \in \mathcal{X},\; y \in \mathcal{Y} \} &= \mathcal{X} \times \mathcal{Y}. \end{align*}
- \mathcal{A} \times \mathcal{A} = \{(d,d), (d,a), (a,d), (a,a)\}
- \mathcal{A} \times \emptyset = \emptyset
- \mathcal{A} \times \mathcal{B} = \{(d,t), (d,a), (a,t), (a,a)\}
- \mathcal{B} \times \mathcal{C} = \{(t,s), (t,c), (t,i), (a,s), (a,c), (a,i)\}
- \mathcal{A} \times \mathcal{B} \times \mathcal{C} = \{ (d,t,s), (d,t,c), (d,t,i), (d,a,s), (d,a,c), (d,a,i), (a,t,s), (a,t,c), (a,t,i), (a,a,s), (a,a,c), (a,a,i)\}
Functions
- No, functions must assign exactly one output to each input. Notice that the real number 4 occurs as the first coordinate of more than one element of f, for example (4,-2) and (4,2).
- Yes, the function contains ordered pairs with exactly one output for each input.
- Domain: \mathbb{Z}, Codomain: \mathbb{N}, Range: \mathbb{N}
- Domain: \mathbb{N}, Codomain: \mathbb{R}, Range: \{x^2: x \in \mathbb{N}\} = \{1,4,9,16,\ldots\}
- No, the two functions are not equal as sets \mathbb{N} \neq \{1,4,9,16,\ldots\}
- f could be injective or surjective (bijective).
- h could be injective but not surjective.
- g could be surjective but not injective.
- f, g and h could be neither injective nor subjective.
- g \circ f=\{(1,1),(2,1),(3,3)\}
- f \circ g =\{(1,1),(2,2),(3,2)\}
- f^{-1}(x,y)=\left( \sqrt[3]{y},\; \frac{x}{\,y^{2/3}+1\,} \right)