Understanding Set Operations
Set theory is a fundamental branch of mathematics that deals with collections of distinct objects. Set operations allow us to combine, compare, and analyze these collections in various ways.
Common Set Operations
Union (A ∪ B)
All elements that are in A, in B, or in both.
A ∪ B = {x : x in A or x in B}
Intersection (A ∩ B)
All elements that are in both A and B.
A ∩ B = {x : x in A and x in B}
Difference (A - B)
Elements in A that are not in B.
A - B = {x : x in A and x not in B}
Symmetric Difference
Elements in either A or B but not in both.
A Δ B = (A - B) ∪ (B - A)
Inclusion-Exclusion Principle
The cardinality of the union of two sets is given by the inclusion-exclusion principle: |A ∪ B| = |A| + |B| - |A ∩ B|. This formula prevents double-counting elements that appear in both sets.
Applications of Set Operations
- Database queries (SQL UNION, INTERSECT, EXCEPT)
- Probability theory (events as sets)
- Data analysis (finding common or unique records)
- Computer science (data structures, algorithms)