Works on this device
Set Calculator
Type sets as lists of elements and get their union, intersection, differences, complements, subsets and Venn diagram regions. You can also count regions from numbers only, and write a range of numbers in interval or set-builder notation.
Enter your values
Check these values
Your values are worked out in this browser. They are not sent to a server.
Your result will show here
Fill in the values, then choose Calculate.
Your result
How it was worked out
How to use this calculator
- Choose what you want to work out, for example Two sets: union, intersection, difference.
- Type each set as a list with commas:
1, 2, 3orred, green, blue. The braces { } are optional. - Type a universal set U if you want complements, such as
1..10for the whole numbers 1 to 10. Leave it blank if you do not need it. - Choose Calculate. You can copy the sets as text or download every table as a CSV file.
How the page reads a set
- Elements are separated by commas or by new lines. Spaces at the ends of an element are removed, and spaces inside it are kept, so
New Yorkis one element. - Put an element in double quotes when it has a comma or spaces at its ends:
"Smith, J". Blank items, such as two commas in a row, are skipped. {}or∅is the empty set.- A range of whole numbers such as
1..10or-3..3is read as every whole number from the first to the last, up to 1,000 numbers. - A repeated element counts once, because a set holds each element only once. The page tells you how many repeats it removed.
- Under More options: numbers are read by value, so
2,2.0and4/2are one element; untick it to compare them as text. Upper and lower case are different (Redis notred) unless you tick Ignore upper and lower case. - A set inside a set, such as
{1, {2, 3}}, is not read as a set. Put such an element in double quotes to keep it as one text element.
The operations
- Union A ∪ B: the elements in A, in B or in both.
- Intersection A ∩ B: the elements in both A and B.
- Difference A − B (also written A \ B): the elements in A that are not in B.
- Symmetric difference A △ B: the elements in exactly one of the two sets.
- Complement A′ (also Aᶜ): the elements of the universal set U that are not in A.
- Subset A ⊆ B: every element of A is in B. A proper subset A ⊂ B is a subset that is not equal to B.
- Power set P(A): the set of all subsets of A. A set with n elements has 2^n subsets and 2^n − 1 proper subsets.
- Cartesian product A × B: all ordered pairs (a, b) with a from A and b from B. It has n(A) × n(B) pairs.
- Inclusion and exclusion: n(A ∪ B) = n(A) + n(B) − n(A ∩ B), and n(A ∪ B ∪ C) = n(A) + n(B) + n(C) − n(A ∩ B) − n(A ∩ C) − n(B ∩ C) + n(A ∩ B ∩ C).
Worked examples
A = {1, 2, 3, 4, 5}, B = {4, 5, 6, 7} and U = {1, ..., 10}. Then A ∪ B = {1, 2, 3, 4, 5, 6, 7}, A ∩ B = {4, 5}, A − B = {1, 2, 3}, B − A = {6, 7} and A′ = {6, 7, 8, 9, 10}. The check: 5 + 4 − 2 = 7 elements in the union.
In a group of 50 people, 25 like tea, 18 like coffee and 7 like both. Then 25 + 18 − 7 = 36 like at least one, 18 like only tea, 11 like only coffee and 14 like neither.
The interval −2 < x ≤ 5 is (−2, 5] in interval notation and {x ∈ ℝ | −2 < x ≤ 5} in set-builder notation. It holds the 7 whole numbers −1, 0, 1, 2, 3, 4 and 5.
The set {n² | n ∈ ℤ, −3 ≤ n ≤ 3} in roster form is {0, 1, 4, 9}: the values 9, 4 and 1 each come twice and are listed once.
Limits you should know
- A typed set can have up to 2,000 elements, each of up to 200 characters. Every subset is listed for a set of up to 10 elements, and every pair of a product up to 2,500 pairs. Larger sets still get the counts.
- The page works with finite sets that you list. It does not read a typed set expression such as (A ∪ B)′ ∩ C, and it does not prove set identities. Work out such an expression one operation at a time.
- The interval mode is for real numbers between two ends. The roster mode works out a rule with +, −, ×, ÷ and powers for each whole number n in a range, with exact fractions.
- To solve an equation or an inequality and get its solution set, use the Equation & Inequality Solver.