Union, intersection, complement, difference, and symmetric difference
Arithmetic combines numbers; set operations combine sets. Join two sets, find what they share, or carve out what one has and the other lacks.
Choose a pair of sets, then switch between union (A ∪ B) and intersection (A ∩ B). Watch which elements light up in each case.
Select an operation and see which regions of the Venn diagram are highlighted.
A ∪ B =
{ 1, 2, 3, 4, 5, 6 }
All elements that are in A or B (or both).
Just as arithmetic gives us ways to combine numbers, set operations give us ways to combine sets. Union brings sets together, intersection finds what they share, and complement identifies what lies outside.
Key insight: Union collects everything from both sets (logical OR), while intersection keeps only what they share (logical AND). These two operations are duals of each other under De Morgan's laws.
Click elements in and out of A and B, then switch between complement (Aᶜ), difference, and symmetric difference (A Δ B) to see what each one keeps.
Choose an operation and see the highlighted region on the Venn diagram. Modify sets A and B below.
A = {1, 2, 3, 4, 5}
B = {3, 4, 5, 6, 7}
Aᶜ =
{ 6, 7, 8, 9, 10 }
All elements in U but not in A.
Key insight: The complement of A contains everything in the universal set that is not in A. The symmetric difference A Δ B contains elements in exactly one of the two sets -- it is the "exclusive or" of set theory.
Pick a preset pair or type your own sets, choose an operation, and turn on step-by-step mode to watch the result build one element at a time.
Choose two sets, pick an operation, and see the result. Toggle step-by-step mode for explanations.
A ∪ B =
{ 1, 2, 3, 4 }
|A ∪ B| = 4
| Element | In A | In B | In Result |
|---|---|---|---|
| 1 | Y | N | Y |
| 2 | Y | Y | Y |
| 3 | Y | Y | Y |
| 4 | N | Y | Y |
These operations obey elegant algebraic laws -- commutativity, associativity, distributivity, and De Morgan's laws -- that mirror (and generalize) the rules of Boolean logic.
Key insight: De Morgan's laws state that (A ∪ B)ᶜ = Aᶜ ∩ Bᶜ and (A ∩ B)ᶜ = Aᶜ ∪ Bᶜ. These laws connect union, intersection, and complement in a beautiful symmetry.
Spot a mistake or have an idea?