Sets and Set Theory
Set operations
Updated Oct 19, 2026
Set Union (A U B)
Contains all elements in EITHER A or B.
Example:

Intersection (A B)
Contains all the elements in BOTH A and B.

Set difference (A - B)
Contains the elements that are in A but not in B.
Symmetric difference (A (+) B)
Contains the elements that are in A or in B but not in both.
Example exercise
Given two sets A = {1, 2, 3} and B = {3, 4, 5}:
Union: { 1, 2, 3, 4, 5}
Intersection: {3}
Difference: { 1, 2}
Symmetric difference: {1, 2, 4, 5}