1.3: Set Operations
- Page ID
- 88838
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
\( \newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\)
( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\)
\( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)
\( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\)
\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)
\( \newcommand{\Span}{\mathrm{span}}\)
\( \newcommand{\id}{\mathrm{id}}\)
\( \newcommand{\Span}{\mathrm{span}}\)
\( \newcommand{\kernel}{\mathrm{null}\,}\)
\( \newcommand{\range}{\mathrm{range}\,}\)
\( \newcommand{\RealPart}{\mathrm{Re}}\)
\( \newcommand{\ImaginaryPart}{\mathrm{Im}}\)
\( \newcommand{\Argument}{\mathrm{Arg}}\)
\( \newcommand{\norm}[1]{\| #1 \|}\)
\( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\)
\( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\AA}{\unicode[.8,0]{x212B}}\)
\( \newcommand{\vectorA}[1]{\vec{#1}} % arrow\)
\( \newcommand{\vectorAt}[1]{\vec{\text{#1}}} % arrow\)
\( \newcommand{\vectorB}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vectorC}[1]{\textbf{#1}} \)
\( \newcommand{\vectorD}[1]{\overrightarrow{#1}} \)
\( \newcommand{\vectorDt}[1]{\overrightarrow{\text{#1}}} \)
\( \newcommand{\vectE}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash{\mathbf {#1}}}} \)
\( \newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} } \)
\( \newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}} \)
\(\newcommand{\avec}{\mathbf a}\) \(\newcommand{\bvec}{\mathbf b}\) \(\newcommand{\cvec}{\mathbf c}\) \(\newcommand{\dvec}{\mathbf d}\) \(\newcommand{\dtil}{\widetilde{\mathbf d}}\) \(\newcommand{\evec}{\mathbf e}\) \(\newcommand{\fvec}{\mathbf f}\) \(\newcommand{\nvec}{\mathbf n}\) \(\newcommand{\pvec}{\mathbf p}\) \(\newcommand{\qvec}{\mathbf q}\) \(\newcommand{\svec}{\mathbf s}\) \(\newcommand{\tvec}{\mathbf t}\) \(\newcommand{\uvec}{\mathbf u}\) \(\newcommand{\vvec}{\mathbf v}\) \(\newcommand{\wvec}{\mathbf w}\) \(\newcommand{\xvec}{\mathbf x}\) \(\newcommand{\yvec}{\mathbf y}\) \(\newcommand{\zvec}{\mathbf z}\) \(\newcommand{\rvec}{\mathbf r}\) \(\newcommand{\mvec}{\mathbf m}\) \(\newcommand{\zerovec}{\mathbf 0}\) \(\newcommand{\onevec}{\mathbf 1}\) \(\newcommand{\real}{\mathbb R}\) \(\newcommand{\twovec}[2]{\left[\begin{array}{r}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\ctwovec}[2]{\left[\begin{array}{c}#1 \\ #2 \end{array}\right]}\) \(\newcommand{\threevec}[3]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\cthreevec}[3]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \end{array}\right]}\) \(\newcommand{\fourvec}[4]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\cfourvec}[4]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \end{array}\right]}\) \(\newcommand{\fivevec}[5]{\left[\begin{array}{r}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\cfivevec}[5]{\left[\begin{array}{c}#1 \\ #2 \\ #3 \\ #4 \\ #5 \\ \end{array}\right]}\) \(\newcommand{\mattwo}[4]{\left[\begin{array}{rr}#1 \amp #2 \\ #3 \amp #4 \\ \end{array}\right]}\) \(\newcommand{\laspan}[1]{\text{Span}\{#1\}}\) \(\newcommand{\bcal}{\cal B}\) \(\newcommand{\ccal}{\cal C}\) \(\newcommand{\scal}{\cal S}\) \(\newcommand{\wcal}{\cal W}\) \(\newcommand{\ecal}{\cal E}\) \(\newcommand{\coords}[2]{\left\{#1\right\}_{#2}}\) \(\newcommand{\gray}[1]{\color{gray}{#1}}\) \(\newcommand{\lgray}[1]{\color{lightgray}{#1}}\) \(\newcommand{\rank}{\operatorname{rank}}\) \(\newcommand{\row}{\text{Row}}\) \(\newcommand{\col}{\text{Col}}\) \(\renewcommand{\row}{\text{Row}}\) \(\newcommand{\nul}{\text{Nul}}\) \(\newcommand{\var}{\text{Var}}\) \(\newcommand{\corr}{\text{corr}}\) \(\newcommand{\len}[1]{\left|#1\right|}\) \(\newcommand{\bbar}{\overline{\bvec}}\) \(\newcommand{\bhat}{\widehat{\bvec}}\) \(\newcommand{\bperp}{\bvec^\perp}\) \(\newcommand{\xhat}{\widehat{\xvec}}\) \(\newcommand{\vhat}{\widehat{\vvec}}\) \(\newcommand{\uhat}{\widehat{\uvec}}\) \(\newcommand{\what}{\widehat{\wvec}}\) \(\newcommand{\Sighat}{\widehat{\Sigma}}\) \(\newcommand{\lt}{<}\) \(\newcommand{\gt}{>}\) \(\newcommand{\amp}{&}\) \(\definecolor{fillinmathshade}{gray}{0.9}\)Terminology
Just as there are arithmetic operations on numbers, there are set operations on sets.
The set \(C\) is the union of the sets \(A\) and \(B\), denoted \(A \cup B\), if and only if \(C=\{ x | x \in A \mbox{ or } x \in B \}\).
Consider \(A=\{a,l,k,s\}\) and \(B=\{a,c,l,k\}\). \(A \cup B = \{a,c,l,k,s \}\) because \(a \in A\text{,}\) \(c \in B\text{,}\) \(l \in A\text{,}\) \(k \in A\text{,}\) and \(s \in B\text{.}\) Note it does not matter if we say because \(a \in A\) or because \(a \in B\text{.}\) This is further discussed in Section 2.1
Checkpoint \(\PageIndex{3}\) Compare/Contrast.
Union can be thought of as taking the elements of the first set and adding any elements of the second set that are different. Our question is how does union differ from addition?
- ►Hint
-
Add texts here. Do not delete this text first. Try unions of \(A=\{1,2,3\}\) with the following sets \(B_1=\{4,5,7\}\text{,}\) \(B_2=\{3,4,5\}\text{,}\) and \(B_3=\{2,3\}\text{.}\)
The set \(C\) is the intersection of the sets \(A\) and \(B\), denoted \(A \cap B\), if and only if \(C=\{ x | x \in A \mbox{ and } x \in B \}\).
Watch the video in Figure 1.3.5 demonstrating reading the set intersection definition twice. The first time think about what set intersection is. The second time think about how it illustrates reading and understanding a definition.
Figure \(\PageIndex{5}\): Understanding the set intersection definition
The set \(C\) is the difference between the sets \(A\) and \(B\), denoted \(A-B\), if and only if \(C=\{ x | x \in A \mbox{ but } x \not\in B \}\).
Checkpoint \(\PageIndex{7}\) Compare/Contrast.
Just as we considered how union is like addition we can compare and contrast set difference with subtraction.
- ►Hint
-
Add texts here. Do not delete this text first. Try the set difference of \(A=\{1,2,3\}\) with the following sets \(B_3=\{2,3\}\), \(B_2=\{3,4,5\}\), and \(B_1=\{4,5,7\}\).
A programmer must consider how to implement an operation like set difference.
(a) Find \(A-B\) for \(A=\{1,3,5,7,9\}\) and \(B=\{1,3,9\}\)
(b) Set difference must remove from \(A\) every element in \(B\). Consider the following psuedo-code.
for x in A do for y in B do if y==x then remove(A,x) exit inner for loop end if end for end for
How many times will the comparison (if x==y
line) be run for these sets \(A\) and \(B\).
(c) If the psuedo-code algorithm were reversed so the outside loop were for \(B\) and the inside loop for \(A\) would it change the number of comparisons?
In many circumstance there is a universal set that is part of the context for a problem. It may or may not be explicitly stated. For example the set of all integers may be the universal set for discussion of even and odd numbers.
The set \(C\) is the complement of the set \(A\) with respect to the universal set \(U\), denoted \(\neg A\) or \(\overline{A}\), if and only if \(C=U-A\).
The set \(P\) is the power set of the set \(A\), denoted \(P(A)\) or \(2^A\), if and only if \(P\) is the set of all subsets of
\(A\).
For example if \(A=\{0,1\}\) then \(P(A)=\{ \emptyset, \{0\}, \{1\}, \{0,1\}\}.\)
Checkpoint \(\PageIndex{11}\). Developing Power Sets. Power sets are sets. This means they are unordered. However, to generate them it helps us list all subsets if we impose some convenient order. The following suggest parts of a heuristic for listing elements of power sets. We consider the power set of \(S=\{a,b,c\}\text{.}\)
(a) There are subsets of \(S\) of size 0,1,2, and 3. What is the only subset of size 0? What is the only subset of size 3?
(b) List all subsets of size 1.
(c) List all subsets of size 2.
(d) There are an equal number of subsets of size 1 and size 2 for \(S\text{.}\) Find a logical correspondence between the subsets of size 1 and size 2 (pair each subset of size 1 with a subset of size 2).
(e) In general for a set of size \(n\) how could one generate all subsets? Note the steps above only suggests two parts of an algorithm.
The set \(C\) is the Cartesian product of the sets \(A\) and \(B,\) denoted \(A \times B,\) if and only if \(C=\{(a,b) | a \in A \mbox{ and } b \in B. \}.\)
For example if \(A=\{0,1\}\) and \(B=\{a,b\}\) then \(A \times B =\) \(\{(0,a), (0,b), (1,a),\) \((1,b)\}.\)
Note for a set \(A\) and positive integer \(n \ge 1\) we use the notation \(A^n\) to mean \(n\) copies of \(A\) in a Cartesian product. For example, \(A^3 = A \times A \times A\text{.}\)
We define the size of a finite set \(A\text{,}\) denote \(|A|\) to be the number of elements it contains.
For example if \(A=\{a,b,c\}\) then \(|A|=3.\) There are ways to define the size of infinite sets, but those must wait for later classes.
Checkpoint \(\PageIndex{14}\).
WeBWork: http://aholiab.uaa.alaska.edu/webwor...VU1FTlQoKTs%3D
1.3.2 Practice
Checkpoint \(\PageIndex{16}\) Identify the following in the diagram above.
- \(\displaystyle A \cup B\)
- \(\displaystyle A \cap B\)
- \(\displaystyle A-B\)
- \(\displaystyle B-A\)
- \(\displaystyle \neg A\)
- \(\displaystyle \neg B\)
Checkpoint \(\PageIndex{17}\) Calculate the following for \(A=\{0,1,2\}\) and \(B=\{0,1\}.\)
- \(\displaystyle P(A)\)
- \(\displaystyle A \times B\)
- \(\displaystyle B \times A\)
- \(\displaystyle A-B\)
- \(\displaystyle B-A\)
Checkpoint 1\(\PageIndex{18}\) Perform the set operations indicated on the sets below. The universal set is all integers.
- \(A=\{n | n=2k \) for some integer \(k\}\)
- \(B=\{n | n=5k \) for some integer \(k\}\)
- \(C=\{n | n=6k \) for some integer \(k\}\)
- \(D=\{n | n=10k \) for some integer \(k \}\)
- \(\displaystyle A \cup B\)
- \(\displaystyle A \cap B\)
- \(\displaystyle C \cap D\)
- \(\displaystyle A-B\)
- \(\displaystyle B-A\)
- \(\displaystyle \neg A\)
- \(\displaystyle \neg B\)