Set Calculator: Union, Intersection, Difference & Venn Diagram
AlgebraFreeNo sign-up
A set calculator combines sets the way you would on paper, listing each element once. For A = {1, 2, 3, 4, 5} and B = {4, 5, 6, 7}, the union A ∪ B is {1, 2, 3, 4, 5, 6, 7}, the intersection A ∩ B is {4, 5}, and the difference A − B is {1, 2, 3}. The Venn diagram shades the region for each answer.
| 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′ | {6, 7, 8, 9, 10} | 5 |
| B′ | {1, 2, 3, 8, 9, 10} | 6 |
Show steps
- Write each set once, in orderA = {1, 2, 3, 4, 5} and B = {4, 5, 6, 7}; U = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10}. Repeated elements count once, and order does not matter.
- Start with A, then add what is new in BElements of B that are not already in A: {6, 7}. So A ∪ B = {1, 2, 3, 4, 5, 6, 7}.
- Check the sizeInclusion–exclusion: |A ∪ B| = |A| + |B| − |A ∩ B| = 5 + 4 − 2 = 7.
Related: probability calculator · permutations and combinations calculator · truth table generator
How to use the set calculator
- Two sets: type the elements of A and B separated by commas, and a universal set U if you need complements (1..10 means 1 to 10). Choose what to show. You get the answer, a shaded Venn diagram, every other operation in a table, the sizes and whether A ⊆ B, B ⊆ A, A = B or the sets are disjoint.
- Three sets: enter A, B, C (and U) and any expression, such as (A ∪ B) ∩ C′. Use the symbol buttons or type u, n, – and ‘ instead. Add an equals sign to test an identity such as De Morgan’s law.
- Power set: list every subset of a set, grouped by size.
- A × B: list all ordered pairs of the Cartesian product.
Elements can be numbers, letters or short words. Duplicates are removed, numbers like 2.0 and 2 count as the same element, and an empty box means the empty set ∅.
The set operations
All examples use A = {1, 2, 3, 4, 5}, B = {4, 5, 6, 7} and U = {1, 2, …, 10}.
| Operation | Symbol | Keeps | Example |
|---|---|---|---|
| Union | A ∪ B | everything in A or B (or both) | {1, 2, 3, 4, 5, 6, 7} |
| Intersection | A ∩ B | only what is in both | {4, 5} |
| Difference | A − B | what is in A but not in B | {1, 2, 3} |
| Difference | B − A | what is in B but not in A | {6, 7} |
| Symmetric difference | A △ B | what is in exactly one of them | {1, 2, 3, 6, 7} |
| Complement | A′ | everything in U that is not in A | {6, 7, 8, 9, 10} |
A − B is also written A \ B, and the complement A′ is also written Aᶜ or Ā. A complement only makes sense once you say what the universal set is: the complement of {1, 3, 5} is {2, 4} inside U = {1, 2, 3, 4, 5}, but {2, 4, 6, 7, 8, 9, 10} inside U = {1, …, 10}.
Subsets and the power set
A ⊆ B (A is a subset of B) means every element of A is also in B. {2, 4} ⊆ {1, 2, 3, 4}, and every set is a subset of itself. A proper subset (A ⊂ B) is a subset that is not equal to B. The empty set ∅ is a subset of every set, because it has no element that could be missing.
The power set P(A) is the set of all subsets. Each element is either in a subset or not, so a set with n elements has 2ⁿ subsets and 2ⁿ − 1 proper subsets. For {a, b, c} that is 8 subsets: ∅, {a}, {b}, {c}, {a, b}, {a, c}, {b, c} and {a, b, c}. The number with exactly k elements is the binomial coefficient C(n, k), which is why the sizes 1, 3, 3, 1 match a row of Pascal’s triangle.
Cardinality and inclusion–exclusion
The cardinality |A| is the number of distinct elements. Adding |A| and |B| counts the shared elements twice, so subtract them once:
- |A ∪ B| = |A| + |B| − |A ∩ B|. With the sets above: 5 + 4 − 2 = 7.
- |A ∪ B ∪ C| = |A| + |B| + |C| − |A ∩ B| − |A ∩ C| − |B ∩ C| + |A ∩ B ∩ C|. With C = {2, 4, 6, 8}: 5 + 4 + 4 − 2 − 2 − 2 + 1 = 8.
The same formula answers survey questions. If 18 students play soccer, 12 play tennis and 5 play both, then 18 + 12 − 5 = 25 play at least one of the two sports.
Reading a Venn diagram
Two circles split the rectangle U into four regions: only A, both, only B, and neither. Three circles make eight regions. To shade an expression, work from the inside out. For (A ∪ B) ∩ C′ with the sets above, A ∪ B is {1, 2, 3, 4, 5, 6, 7} and C′ is {1, 3, 5, 7, 9, 10}, so the answer is {1, 3, 5, 7}: the parts of A and B that lie outside C. The calculator shades the regions and writes each element where it belongs.
Set identities
| Law | Identity |
|---|---|
| Commutative | A ∪ B = B ∪ A and A ∩ B = B ∩ A |
| Associative | A ∪ (B ∪ C) = (A ∪ B) ∪ C |
| Distributive | A ∪ (B ∩ C) = (A ∪ B) ∩ (A ∪ C) |
| De Morgan | (A ∪ B)′ = A′ ∩ B′ and (A ∩ B)′ = A′ ∪ B′ |
| Difference | A − B = A ∩ B′ |
Type an identity with an equals sign in the Three sets tab. The calculator compares both sides for your sets and also checks all eight Venn regions, so it can tell a true law from two sides that only happen to match. For example, A ∪ B = A ∪ C is false in general: with the sets above, the left side is {1, 2, 3, 4, 5, 6, 7} and the right side is {1, 2, 3, 4, 5, 6, 8}.
The Cartesian product
A × B is the set of all ordered pairs (a, b) with a from A and b from B. For A = {1, 2, 3} and B = {x, y} there are 3 · 2 = 6 pairs: (1, x), (1, y), (2, x), (2, y), (3, x), (3, y). Order matters, so (1, x) is not the same as (x, 1). Two dice give 6 · 6 = 36 outcomes, which is why the product is the starting point for many probability questions.
Common mistakes
| Mistake | Fix |
|---|---|
| Listing a shared element twice in a union | Write each element once: {1, 2, 3} ∪ {3, 4} = {1, 2, 3, 4}. |
| Treating A − B and B − A as the same | Difference is not symmetric; check which set you start from. |
| Taking a complement without U | State the universal set first. |
| Mixing up ∈ and ⊆ | 2 ∈ {1, 2}, but {2} ⊆ {1, 2}. |
| Thinking ∅ and {∅} are equal | ∅ has no elements; {∅} has one element, the empty set. |
| Forgetting ∅ and the set itself in a power set | Count them: there should be 2ⁿ subsets. |
Sets practice quiz: 10 questions
Test yourself with 10 multiple-choice questions. Choose an answer and press Submit to see if you are right and why. Your score appears at the end.
Each of the 4 elements is in or out: 2⁴ = 16. 15 counts only the proper subsets.
|A ∪ B| = 12 + 9 − 4 = 17. Adding 12 + 9 counts the 4 shared elements twice.
Each of the 3 first entries pairs with each of the 4 second entries: 3 · 4 = 12.
Quiz complete
Frequently asked questions
What is the union of two sets?
The union A ∪ B contains every element that is in A, in B or in both, each listed once. {1, 2, 3} ∪ {3, 4} = {1, 2, 3, 4}.
What is the intersection of two sets?
The intersection A ∩ B contains only the elements the sets share. {1, 2, 3} ∩ {3, 4} = {3}. If nothing is shared, the answer is ∅ and the sets are called disjoint.
What does subset mean?
A ⊆ B means every element of A is also in B. The calculator checks this both ways and also tells you whether the sets are equal.
What is the difference between A − B and B − A?
A − B keeps the elements of A that are not in B; B − A keeps the elements of B that are not in A. For {1, 2, 3} and {3, 4}, A − B = {1, 2} and B − A = {4}.
Why do I need a universal set for the complement?
The complement A′ is everything that is not in A, and "everything" has to be defined. The universal set U says what that is.
How many subsets does a set with n elements have?
2ⁿ, including ∅ and the set itself. A set with 4 elements has 16 subsets, 15 of them proper.
Related calculators
- Probability calculator: unions, intersections and complements of events.
- Permutations and combinations calculator: count subsets of a given size with C(n, k).
- Truth table generator: the logic behind ∪ (or), ∩ (and) and complement (not).
- GCF and LCM calculator: the greatest common factor is the largest element of the intersection of two factor sets.
More algebra calculators
Related to This Article
More math articles
- Top 10 6th Grade FSA Math Practice Questions
- 4th Grade Math Practice by Topic: Skill Worksheets and Exercises
- The Best Grade 7 Math Book for Rhode Island Students
- The Best Grade 8 ELA Practice Tests for Wyoming Students
- Texas Revolution and Annexation: Slavery, Sovereignty and Statehood
- Strict and broad construction
- TDEE Calculator
- Agents and Conflicting Messages
- Top 10 4th Grade SBAC Math Practice Questions
- Stereotypes, Prejudice, and Discrimination



What people say about "Set Calculator: Union, Intersection, Difference & Venn"?
No one replied yet.