Understanding the union and intersection calculator — concept and principle
This calculator finds the union, intersection, differences, symmetric difference and complements of two sets, and checks the counting rule n(A ∪ B) = n(A) + n(B) − n(A ∩ B). Use it for set theory, probability, Venn diagram homework, database queries and filtering lists.
How it is calculated
- A ∪ B: elements in A, in B or in both (logical OR).
- A ∩ B: elements in both (logical AND).
- A − B: elements of A not in B, equal to A ∩ B′.
- A △ B: elements in exactly one of the sets.
- A′: elements of the universal set U not in A (shown when U is given).
- n(A ∪ B) = n(A) + n(B) − n(A ∩ B).
Duplicates are ignored, and numbers are sorted from smallest to largest.
The principle
Set operations mirror logic: union is "or", intersection is "and", complement is "not". The counting rule subtracts the intersection because elements in both sets would otherwise be counted twice, once in A and once in B. De Morgan's laws connect the operations: (A ∪ B)′ = A′ ∩ B′ and (A ∩ B)′ = A′ ∪ B′. Two sets are disjoint when their intersection is empty.
Worked example
Default inputs: A = {1, 2, 3, 4, 5}, B = {4, 5, 6, 7}, U = {1, …, 10}.
- A ∪ B = {1, 2, 3, 4, 5, 6, 7}; A ∩ B = {4, 5}.
- A − B = {1, 2, 3}; B − A = {6, 7}; A △ B = {1, 2, 3, 6, 7}.
- Count check: 7 = 5 + 4 − 2.
- Not disjoint, since 4 and 5 are shared.
- Complements in U: A′ = {6, 7, 8, 9, 10}; (A ∪ B)′ = {8, 9, 10}; (A ∩ B)′ = {1, 2, 3, 6, 7, 8, 9, 10}.
How to read the result
The union shows everything covered by at least one set; the intersection shows the overlap. The differences show what is unique to each set, and the symmetric difference combines both. Complements answer "what is left out" relative to U, which is useful for probability: P(A′) = 1 − P(A).
Common mistakes
- Forgetting to subtract the intersection when counting the union.
- Confusing A − B with B − A.
- Computing complements without defining the universal set.
- Typing elements inconsistently, so "5" and "5.0" count as different.
Frequently asked questions
What is the difference between union and intersection?
Union collects elements in either set; intersection keeps only the elements in both.
What does it mean if A ∩ B is empty?
The sets are disjoint: they share no elements.
What are De Morgan's laws for sets?
(A ∪ B)′ = A′ ∩ B′ and (A ∩ B)′ = A′ ∪ B′.
Sources: OpenStax, Contemporary Mathematics (2023), §1.4 Set Operations with Two Sets