Visual Tools
Calculators
Tables
Mathematical Keyboard
Converters
Other Tools


Operations on Sets






Combining and Manipulating Sets


Set operations combine sets to form new sets. These operations — union, intersection, complement, difference, and symmetric difference — provide the tools for manipulating collections and form the basis for the algebraic rules that govern set theory. Visualizing these operations through Venn diagrams makes their behavior immediately clear.



Union


The union of two sets AA and BB is the set of elements that belong to AA or BB or both:

AB={x:xA or xB}A \cup B = \{x : x \in A \text{ or } x \in B\}


The word "or" here is inclusive — elements belonging to both sets are included. If A={1,2,3}A = \{1, 2, 3\} and B={3,4,5}B = \{3, 4, 5\}, then:

AB={1,2,3,4,5}A \cup B = \{1, 2, 3, 4, 5\}


The element 33 appears in both sets but is listed only once in the union.

Union is commutative and associative:

AB=BAA \cup B = B \cup A


(AB)C=A(BC)(A \cup B) \cup C = A \cup (B \cup C)


For multiple sets, the union extends naturally:

i=1nAi=A1A2An\bigcup_{i=1}^{n} A_i = A_1 \cup A_2 \cup \cdots \cup A_n


This contains every element that appears in at least one of the sets A1,A2,,AnA_1, A_2, \ldots, A_n.

Intersection


The intersection of two sets AA and BB is the set of elements that belong to both AA and BB:

AB={x:xA and xB}A \cap B = \{x : x \in A \text{ and } x \in B\}


If A={1,2,3}A = \{1, 2, 3\} and B={3,4,5}B = \{3, 4, 5\}, then:

AB={3}A \cap B = \{3\}


When two sets have no elements in common, their intersection is the empty set, and the sets are called disjoint:

AB=A \cap B = \emptyset


Intersection is commutative and associative:

AB=BAA \cap B = B \cap A


(AB)C=A(BC)(A \cap B) \cap C = A \cap (B \cap C)


For multiple sets:

i=1nAi=A1A2An\bigcap_{i=1}^{n} A_i = A_1 \cap A_2 \cap \cdots \cap A_n


This contains only elements that appear in every one of the sets A1,A2,,AnA_1, A_2, \ldots, A_n.

Complement


The complement of a set AA consists of all elements not in AA. This operation requires a universal set UU that contains all elements under consideration:

Ac={xU:xA}A^c = \{x \in U : x \notin A\}


Alternative notations include AA' and A\overline{A}.

If the universal set is U={1,2,3,4,5}U = \{1, 2, 3, 4, 5\} and A={1,2}A = \{1, 2\}, then:

Ac={3,4,5}A^c = \{3, 4, 5\}


The complement depends entirely on the choice of universal set. The same set AA has different complements relative to different universal sets.

Taking the complement twice returns the original set:

(Ac)c=A(A^c)^c = A


Two additional facts hold for any set AA:

AAc=UA \cup A^c = U


AAc=A \cap A^c = \emptyset


Every element either belongs to AA or to its complement, but not to both.

Set Difference


The set difference ABA \setminus B (also written ABA - B) contains all elements that belong to AA but not to BB:

AB={x:xA and xB}A \setminus B = \{x : x \in A \text{ and } x \notin B\}


If A={1,2,3,4}A = \{1, 2, 3, 4\} and B={3,4,5}B = \{3, 4, 5\}, then:

AB={1,2}A \setminus B = \{1, 2\}


BA={5}B \setminus A = \{5\}


Unlike union and intersection, set difference is not commutative — the order of AA and BB matters.

Set difference relates to complement: when BUB \subseteq U, the complement BcB^c equals UBU \setminus B. More generally:

AB=ABcA \setminus B = A \cap B^c


This expresses difference as an intersection with a complement.

Symmetric Difference


The symmetric difference of AA and BB contains elements that belong to exactly one of the two sets:

AB=(AB)(BA)A \triangle B = (A \setminus B) \cup (B \setminus A)


An equivalent definition uses union and intersection:

AB=(AB)(AB)A \triangle B = (A \cup B) \setminus (A \cap B)


If A={1,2,3}A = \{1, 2, 3\} and B={3,4,5}B = \{3, 4, 5\}, then:

AB={1,2,4,5}A \triangle B = \{1, 2, 4, 5\}


The element 33 belongs to both sets, so it is excluded from the symmetric difference.

Symmetric difference is commutative and associative:

AB=BAA \triangle B = B \triangle A


(AB)C=A(BC)(A \triangle B) \triangle C = A \triangle (B \triangle C)


The symmetric difference with the empty set leaves a set unchanged: A=AA \triangle \emptyset = A. The symmetric difference of a set with itself is empty: AA=A \triangle A = \emptyset.