Sub topic 3
Union, Intersection, Difference and Complement
Assume you already know basic set notation, whole-number arithmetic, and how to read a word problem. In this chapter, a set is a collection of distinct objects. We use capital letters such as \(A\) and \(B\) to name sets. The symbol \(n(A)\) means the number of elements in set \(A\).
Let
\[ U=\{1,2,3,4,5,6\},\quad A=\{1,2,3,4\},\quad B=\{3,4,5\}. \]
Here, \(U\) is the universal set, meaning the complete collection being considered.
Union: \(A\cup B\)
The union of two sets contains every element that belongs to \(A\), to \(B\), or to both.
\[ A\cup B=\{1,2,3,4,5\}. \]
Do not count an element twice. Although 3 and 4 occur in both sets, each appears once in the union.
In word problems, union often means:
- at least one of the conditions;
- either \(A\) or \(B\), including both;
- \(A\) or \(B\) or both.
The word “or” usually indicates a union.
Intersection: \(A\cap B\)
The intersection contains only the elements common to both sets.
\[ A\cap B=\{3,4\}. \]
In word problems, intersection often means:
- both \(A\) and \(B\);
- common members;
- people satisfying both conditions.
The word “and” usually indicates an intersection.
Difference: \(A-B\)
The difference \(A-B\) contains elements that belong to \(A\) but do not belong to \(B\).
\[ A-B=\{1,2\}. \]
The order matters:
\[ B-A=\{5\}. \]
Therefore, \(A-B\) and \(B-A\) are generally different sets. In a Venn diagram, \(A-B\) is the part inside \(A\) but outside \(B\). It is also called “\(A\) only.”
Complement: \(A^c\)
The complement of \(A\) contains every element in the universal set that is not in \(A\).
\[ A^c=U-A=\{5,6\}. \]
A complement cannot be understood without knowing the universal set. If the universal set changed, the complement could change too.
For example, if \(U=\{1,2,3,4,5,6,7,8\}\), then the complement of the same \(A\) would be \(\{5,6,7,8\}\).
Seeing the operations together
The diagram names the regions, but a Venn diagram shows their exact positions:
| Expression | Meaning | Value |
|---|---|---|
| \(A\cup B\) | In A or B or both | \(\{1,2,3,4,5\}\) |
| \(A\cap B\) | In both A and B | \(\{3,4\}\) |
| \(A-B\) | In A but not B | \(\{1,2\}\) |
| \(A^c\) | In U but not A | \(\{5,6\}\) |
Python set operators match these definitions:
A = {1, 2, 3, 4}
B = {3, 4, 5}
U = {1, 2, 3, 4, 5, 6}
print(A | B) # union
print(A & B) # intersection
print(A - B) # difference
print(U - A) # complement of A in UThe outputs are {1, 2, 3, 4, 5}, {3, 4}, {1, 2}, and {5, 6}. Python may display elements in a different order because sets are unordered.
Exercise
Let U = {1, 2, 3, 4, 5, 6, 7}, A = {1, 2, 3, 4}, and B = {3, 4, 5}. Find A ∪ B, A ∩ B, A - B, and Bᶜ.
Show answer
A ∪ B = {1, 2, 3, 4, 5}; A ∩ B = {3, 4}; A - B = {1, 2}; Bᶜ = {1, 2, 6, 7}.