Math
Set calculator
Type two or three sets and get every standard operation on them at once: union, intersection, differences, symmetric difference and complements, with each element placed in its region of a Venn diagram.
Separate elements with commas; braces are optional. Letters and words work too: {a, b, c} or {red, blue}.
| Operation | Result | Size |
|---|---|---|
| A ∪ B | {1, 2, 3, 4, 5, 6, 7} | 7 |
| A ∩ B | {4, 5} | 2 |
| A − B | {1, 2, 3} | 3 |
| B − A | {6, 7} | 2 |
| A Δ B | {1, 2, 3, 6, 7} | 5 |
| A′ (complement of A) | {6, 7, 8, 9, 10} | 5 |
| B′ | {1, 2, 3, 8, 9, 10} | 6 |
| (A ∪ B)′ | {8, 9, 10} | 3 |
| A′ ∩ B′ | {8, 9, 10} | 3 |
| Sets | Relationship |
|---|---|
| A and B | Neither is a subset of the other |
Power set of A (25 = 32 subsets):
P(A) = {∅, {1}, {2}, {3}, {4}, {5}, {1, 2}, {1, 3}, {2, 3}, {1, 4}, {2, 4}, {3, 4}, {1, 5}, {2, 5}, {3, 5}, {4, 5}, {1, 2, 3}, {1, 2, 4}, {1, 3, 4}, {2, 3, 4}, {1, 2, 5}, {1, 3, 5}, {2, 3, 5}, {1, 4, 5}, {2, 4, 5}, {3, 4, 5}, {1, 2, 3, 4}, {1, 2, 3, 5}, {1, 2, 4, 5}, {1, 3, 4, 5}, {2, 3, 4, 5}, {1, 2, 3, 4, 5}}
Cartesian product A × B (5 × 4 = 20 ordered pairs):
A × B = {(1, 4), (1, 5), (1, 6), (1, 7), (2, 4), (2, 5), (2, 6), (2, 7), (3, 4), (3, 5), (3, 6), (3, 7), (4, 4), (4, 5), (4, 6), (4, 7), (5, 4), (5, 5), (5, 6), (5, 7)}
Show the working, step by step
List each set once, without repeats, in order.
A = {1, 2, 3, 4, 5} |A| = 5 B = {4, 5, 6, 7} |B| = 4
Check each element of A against B. Those in both form the intersection.
1 ∉ B 2 ∉ B 3 ∉ B 4 ∈ B ✓ 5 ∈ B ✓ A ∩ B = {4, 5}
The union takes every element that is in A or B (or both), each once.
A ∪ B = {1, 2, 3, 4, 5, 6, 7}
Check the count with the addition rule, which subtracts the overlap counted twice.
|A ∪ B| = |A| + |B| − |A ∩ B| = 5 + 4 − 2 = 7
A − B keeps the elements of A that are not in B; the symmetric difference is everything in exactly one of the two sets.
A − B = {1, 2, 3} B − A = {6, 7} A Δ B = (A − B) ∪ (B − A) = {1, 2, 3, 6, 7}
The complement of A is everything in U that is not in A.
A′ = U − A = {6, 7, 8, 9, 10} De Morgan: (A ∪ B)′ = A′ ∩ B′ = {8, 9, 10}
Set operations and their symbols
| Operation | Symbol | Contains the elements that are… |
|---|---|---|
| Union | A ∪ B | in A or in B (or both) |
| Intersection | A ∩ B | in both A and B |
| Difference | A − B (also A \ B) | in A but not in B |
| Symmetric difference | A Δ B (also A ⊕ B) | in exactly one of A and B |
| Complement | A′ (also Aᶜ or Ā) | in the universal set U but not in A |
| Cartesian product | A × B | ordered pairs (a, b) with a ∈ A and b ∈ B |
| Power set | P(A) | every subset of A, as a set of sets |
The sizes of the results follow a few rules that are worth knowing because they catch mistakes:
|A ∪ B| = |A| + |B| − |A ∩ B| |A × B| = |A| × |B| |P(A)| = 2^|A| (A ∪ B)′ = A′ ∩ B′ (A ∩ B)′ = A′ ∪ B′ (De Morgan’s laws)
A worked example
The calculator starts with A = {1, 2, 3, 4, 5}, B = {4, 5, 6, 7} and the universal set U = {1, 2, …, 10}.
- Go through A and check each element against B. Only 4 and 5 are in both, so A ∩ B = {4, 5}.
- The union collects everything once: A ∪ B = {1, 2, 3, 4, 5, 6, 7}. Check the count: 5 + 4 − 2 = 7.
- A − B = {1, 2, 3} and B − A = {6, 7}, so A Δ B = {1, 2, 3, 6, 7}.
- Complements come from U: A′ = {6, 7, 8, 9, 10} and B′ = {1, 2, 3, 8, 9, 10}.
- De Morgan: (A ∪ B)′ = {8, 9, 10}, and A′ ∩ B′ is also {8, 9, 10}.
In the Venn diagram, 1, 2 and 3 sit in the part of A outside B, 4 and 5 in the overlap, 6 and 7 in the part of B outside A, and 8, 9 and 10 outside both circles but inside U. A has five elements, so its power set has 2⁵ = 32 subsets, and A × B has 5 × 4 = 20 ordered pairs.
Three sets
Fill in set C and the calculator adds the three-way results: A ∪ B ∪ C, A ∩ B ∩ C, the pairwise intersections, and mixed expressions such as (A ∪ B) ∩ C. The Venn diagram then has seven regions inside the circles. The size of the three-way union comes from inclusion–exclusion:
|A ∪ B ∪ C| = |A| + |B| + |C| − |A ∩ B| − |A ∩ C| − |B ∩ C| + |A ∩ B ∩ C|
If you only know the counts (a survey says 45 people like tea, 40 like coffee, 15 like both) and not the elements themselves, use the inclusion–exclusion mode of the discrete maths calculator.
Typing sets
- Braces are optional:
{1, 2, 3}and1, 2, 3are read the same. - Without commas, spaces separate elements:
a b c. - Elements can be words (
red, green) or tuples ((1, 2), (3, 4)); a comma inside brackets does not split an element. - Type
∅or{}for the empty set. - Every element of A, B and C must also be in U. If one is missing, the calculator says so rather than quietly giving a wrong complement.
Common mistakes
- Adding sizes for a union. |A| + |B| counts the overlap twice. Here 5 + 4 = 9, but the union has 7 elements.
- Taking A − B to be the same as B − A. Difference is not symmetric: {1, 2, 3} is not {6, 7}.
- Mixing up ⊂ and ∈. 4 ∈ A says 4 is an element of A; {4} ⊂ A says the set containing 4 is a subset of A. The power set is a set of subsets, so its elements are sets.
- A complement with no universal set. A′ depends on U. With U = {1, …, 7} instead of {1, …, 10}, the complement of A shrinks to {6, 7}.
Common questions
What is the difference between union and intersection?
The union A ∪ B contains every element that is in A, in B, or in both. The intersection A ∩ B contains only the elements that are in both. For A = {1, 2, 3, 4, 5} and B = {4, 5, 6, 7}, the union is {1, 2, 3, 4, 5, 6, 7} and the intersection is {4, 5}.
How do I find the complement of a set?
You need a universal set U first, because the complement A′ is everything in U that is not in A: A′ = U − A. With U = {1, …, 10} and A = {1, 2, 3, 4, 5}, A′ = {6, 7, 8, 9, 10}. Without a universal set the complement is not defined, so the calculator leaves it out when U is blank.
What is the symmetric difference A Δ B?
The elements in exactly one of the two sets: A Δ B = (A − B) ∪ (B − A), which is also (A ∪ B) − (A ∩ B). For the default sets it is {1, 2, 3, 6, 7}. It plays the role of exclusive or (XOR) for sets.
How many subsets does a set have?
A set with n elements has 2ⁿ subsets, counting the empty set and the set itself, because each element is either in a subset or not. {1, 2, 3, 4, 5} has 2⁵ = 32 subsets, and 31 of them are proper subsets. The collection of all subsets is the power set P(A).
Does the order of elements or repeating an element matter?
No. {1, 2, 3} and {3, 1, 2} are the same set, and {1, 1, 2} is just {1, 2}. The calculator sorts the elements and drops repeats, and tells you when it has dropped any. Order does matter inside the ordered pairs of a Cartesian product: (1, 4) and (4, 1) are different pairs.
Related calculators
-
Relation calculator
Properties and closures of a relation on a set.
-
Discrete math calculator
Inclusion–exclusion counts, recurrences and the pigeonhole principle.
-
Boolean algebra
The logic behind ∪, ∩ and complement: AND, OR and NOT.
-
Probability calculator
P(A ∪ B), P(A ∩ B) and complements for events.