A set calculator works out the union, intersection, difference, symmetric difference and complement of sets, tests whether one set is a subset of another, lists the power set and the Cartesian product, and counts the elements in a Venn diagram. Type the elements, choose the operation and press the button. It also writes integer sets in set-builder notation. It runs in your browser.
How to use the set calculator
- Choose the operation.
- Type the elements of set A, and of set B if the operation needs one, separated by commas.
- Press Calculate.
Union, intersection and difference
The Wikipedia article on sets defines the union A ∪ B as the set of elements that belong to A or B or both, and the intersection A ∩ B as the elements that belong to both.[1] The difference A − B holds the elements of A that are not in B.[4] For A = {1, 2, 3, 4} and B = {3, 4, 5}, the union is {1, 2, 3, 4, 5}, the intersection is {3, 4}, A − B is {1, 2}, and B − A has the single element 5. The symmetric difference is the set of elements that belong to A or B but not to both, so here it is {1, 2, 5}. The calculator lists the result in order and counts its elements.
The complement
The page on complements says that the complement of a set A, often written Aᶜ or A′, is the set of elements not in A.[4] The absolute complement is taken relative to a universal set U, and is U − A. If U = {1, 2, 3, 4, 5, 6} and A = {5, 6, 1}, the complement of A is {2, 3, 4}. Enter the universal set in the last box. If an element of A is not in U, the calculator tells you, because the complement is not defined in that case.
Subsets
A set A is a subset of a set B if every element of A is also an element of B, which is written A ⊆ B.[1] The subset test tells you whether A is a subset of B, B is a subset of A, the two are equal, they share no elements, or none of these. For A = {3, 4} and B = {1, 2, 3, 4}, A is a subset of B. The empty set is a subset of every set, and every set is a subset of itself.
The power set
The power set of a set S is the set of all subsets of S, including the empty set and S itself. If S has n elements, the number of subsets is 2ⁿ.[2] The page's example is S = {x, y, z}, whose eight subsets are {}, {x}, {y}, {z}, {x, y}, {x, z}, {y, z} and {x, y, z}.[2] It also gives the count by size: C(3, 0) = 1, C(3, 1) = 3, C(3, 2) = 3 and C(3, 3) = 1.[2] The calculator lists the subsets for sets of up to 6 elements, and for larger sets, up to 10, it gives the count and the counts by size.
Counting with a Venn diagram
When two sets overlap, adding their sizes counts the overlap twice. Inclusion–exclusion fixes this: |A ∪ B| = |A| + |B| − |A ∩ B|. The Wikipedia article says that the formula expresses the fact that the sum of the sizes of the two sets may be too large, since some elements may be counted twice.[3] For three sets, the formula is |A ∪ B ∪ C| = |A| + |B| + |C| − |A ∩ B| − |A ∩ C| − |B ∩ C| + |A ∩ B ∩ C|.[3] If 30 students take French, 25 take Spanish and 10 take both, then 45 take at least one of them, 20 take only French and 15 only Spanish. The Venn mode gives all of these, for two or three sets.
Set-builder notation
Set-builder notation describes a set by a rule. The article's example is F = {n | n is an integer, and 0 ≤ n ≤ 19}, which reads: F is the set of all n such that n is an integer in the range from 0 to 19 inclusive.[1] The builder mode writes this notation for a range of integers and lists the elements. You can keep only the even numbers, the odd numbers, the primes, the perfect squares or the multiples of a number. For the integers from 1 to 20 that are prime, the set is {2, 3, 5, 7, 11, 13, 17, 19}.
The Cartesian product
The Cartesian product A × B is the set of all ordered pairs (a, b) with a from A and b from B. It has |A| × |B| elements. For A = {1, 2} and B = {a, b}, it is {(1, a), (1, b), (2, a), (2, b)}, with 4 pairs. The order matters in a pair, so A × B and B × A are different sets unless the two sets are equal.
Typing your sets
Type the elements separated by commas, semicolons or spaces, and you may wrap the set in braces. Words work as well as numbers, so {red, green} and {green, blue} give the union {red, green, blue}. The calculator removes repeats, and lists numbers in order so that the result is easy to read.
Common mistakes
- Counting repeated elements. A set has each element once.
- Mixing up A − B and B − A. They are different unless A and B are equal.
- Forgetting the empty set. It is a subset of every set and appears in the power set.
- Taking a complement without a universe. It needs a universal set U.
What next
Use this often? Add Set to your Home screen.
Frequently asked questions
What is a set calculator?
A tool that does set operations such as union, intersection, difference and complement, and lists power sets and products, from the elements that you type.
How many subsets does a set have?
A set with n elements has 2ⁿ subsets, including the empty set and the set itself. {x, y, z} has 8.
What is the union of two sets?
All the elements that belong to A or to B or to both. The union of {1, 2, 3, 4} and {3, 4, 5} is {1, 2, 3, 4, 5}.
How does the Venn diagram count work?
Inclusion–exclusion: |A ∪ B| = |A| + |B| − |A ∩ B|, with a similar longer formula for three sets.
What is set-builder notation?
A way to describe a set by a rule, such as {n | n is an integer, 0 ≤ n ≤ 19}.
Sources
Was this tool helpful?
What went wrong?
We only receive the reason you pick, never what you typed into the tool.
Thanks for your feedback.