Type up to four sets and get every union, intersection, difference, symmetric difference and complement at once, with a Venn diagram that counts the elements in each region. Enter your own expression, such as (A ∪ B)′ ∩ C, to shade it on the diagram.
Last updated:
Number of sets
Separate elements with commas, spaces or new lines; ranges like 1-20 work too
Used for complements. Leave empty to use the union of all sets.
Operators: ∪ | + u (union), ∩ & (intersection), − - \ (difference), △ ^ (symmetric difference), ′ ' (complement). ∩ binds tighter than the others; use parentheses.
Enter your values to see the result.
Advertisement
Advertisement
How to use the Set Calculator
Choose 2, 3 or 4 sets with the buttons at the top.
Type the elements of each set, separated by commas, spaces or new lines. Duplicates are removed automatically and ranges like 1-20 are expanded.
Add a universal set U if you need complements relative to a larger set; otherwise U is the union of your sets.
Optionally type an expression such as A ∩ B, A - B or (A u B)' & C. The result appears at the top and is shaded on the Venn diagram.
Read the tables for every operation, the Venn regions and subset checks, and download any of them as CSV.
Set operations at a glance
A set is an unordered collection of distinct elements, so {3, 1, 2, 2} is the same set as {1, 2, 3}. This calculator treats every element as text, which means numbers, words, letters and codes all work. Numbers are sorted numerically and everything else alphabetically.
Operation
Symbol
Type it as
Contains
A = {1,2,3}, B = {2,3,4}
Union
A ∪ B
A ∪ B, A | B, A + B, A u B
elements in A or B (or both)
{1, 2, 3, 4}
Intersection
A ∩ B
A ∩ B, A & B, A * B
elements in both A and B
{2, 3}
Difference
A − B
A - B, A \ B
elements in A but not in B
{1}
Symmetric difference
A △ B
A △ B, A ^ B, A xor B
elements in exactly one set
{1, 4}
Complement
A′, Aᶜ
A', A^c, ~A
elements of U not in A
with U = {1,…,5}: {4, 5}
Universal / empty set
U, ∅
U, ∅, {}
everything / nothing
—
Useful identities
De Morgan's laws: (A ∪ B)′ = A′ ∩ B′ and (A ∩ B)′ = A′ ∪ B′. Try both sides in the expression box: the results match.
Difference as intersection: A − B = A ∩ B′.
Distributive laws: A ∩ (B ∪ C) = (A ∩ B) ∪ (A ∩ C) and A ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C).
Subsets: A ⊆ B exactly when A ∩ B = A, which is the same as A − B = ∅.
Reading the Venn diagram
Two sets split the universal set into 4 regions, three sets into 8 and four sets into 16 (the 4-set diagram uses ellipses, because four circles cannot show every combination). Each number on the diagram is the count of elements that belong to exactly that combination of sets; hover a number to see the elements. The Venn diagram regions table lists the same counts with a ✓ for each set the region belongs to. When you enter an expression, the regions that make up its result are shaded.
Frequently asked 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 sets. For A = {1, 2, 3} and B = {2, 3, 4}, the union is {1, 2, 3, 4} and the intersection is {2, 3}.
What is A − B (set difference)?
A − B, also written A \ B, is the set of elements in A that are not in B. Order matters: with A = {1, 2, 3} and B = {2, 3, 4}, A − B = {1} but B − A = {4}.
What is the symmetric difference?
The symmetric difference A △ B contains the elements that are in exactly one of the two sets. It equals (A − B) ∪ (B − A), or (A ∪ B) − (A ∩ B). For the sets above it is {1, 4}.
How is the complement calculated?
The complement A′ (also written Aᶜ) is everything in the universal set U that is not in A, so |A′| = |U| − |A|. The result depends on U, which is why you can enter your own universal set. If you leave U empty, the calculator uses the union of all your sets.
What order are operations done in an expression?
Parentheses come first, then complements (′), then intersections (∩). Union, difference and symmetric difference have equal priority and are done from left to right. Textbooks do not all agree on precedence, so adding parentheses, for example (A − B) ∪ C, is the safest way to say what you mean.
How do I count the elements of a union?
Use the inclusion–exclusion principle: |A ∪ B| = |A| + |B| − |A ∩ B|. For three sets, |A ∪ B ∪ C| = |A| + |B| + |C| − |A ∩ B| − |A ∩ C| − |B ∩ C| + |A ∩ B ∩ C|. The calculator shows these sums with your numbers so you can check homework.
How many subsets does a set have?
A set with n elements has 2ⁿ subsets, including the empty set and the set itself, and 2ⁿ − 1 proper subsets. A 4-element set has 16 subsets. The calculator lists them all for sets of up to 6 elements (64 subsets).
Are all the tools on FreeToolCabin tested for quality and accuracy?
Yes! Every tool on our site undergoes automated Q/A testing in real browser environments to ensure high precision, correct output, and zero errors. If you happen to spot a bug or have a suggestion, please contact us at [email protected] and our team will review it right away.