Set Calculator — Union, Intersection, Difference & Set Theory Operations

A set calculator lets you perform union, intersection, and difference operations on two or more sets instantly. Whether you are a student studying set theory in a discrete mathematics course, a developer working with database queries, or a data scientist analyzing overlapping groups, this tool handles the math so you can focus on the problem. Enter your elements, pick an operation, and see the result with a full step-by-step breakdown.
Our set calculator supports eight operations: union (A \u222A B), intersection (A \u2229 B), set difference (A \u2212 B), symmetric difference (A \u25B3 B), complement (A\u2032), Cartesian product (A \u00D7 B), power set P(A), and subset check (A \u2286 B). It works with numbers and text elements alike.
How to Use the Set Calculator
- Enter Set A — type elements separated by commas (e.g.
1, 2, 3, 4ora, b, c). Duplicates are removed automatically. - Enter Set B (if needed) — the second set for binary operations like union and intersection.
- Choose an operation — tap one of the eight operation buttons.
- Click Calculate (or press Enter) — the result appears instantly with the step-by-step solution, formula, and cardinality.
Tip: click Load Example to fill in sample data for the currently selected operation. The calculator accepts both numbers and text, so you can work with sets like {apple, banana, cherry} just as easily as {1, 2, 3}.
Union of Sets (A \u222A B) — How Union Works
The union of two sets A and B, written A \u222A B, is the set of all elements that belong to A, or B, or both. Duplicates are never repeated in the result.
Worked Example
A = {1, 2, 3}, B = {3, 4, 5}
A \u222A B = {1, 2, 3, 4, 5} — combine both, remove the duplicate 3.
|A \u222A B| = 5
The union calculator is especially useful for merging datasets, combining search results, or solving probability problems where you need to count all possible outcomes from two events. The inclusion-exclusion principle states |A \u222A B| = |A| + |B| \u2212 |A \u2229 B|.
Intersection of Sets (A \u2229 B)
The intersection of sets A and B, written A \u2229 B, contains only the elements that appear in both sets. If the intersection is empty (A \u2229 B = \u2205), the sets are called disjoint.
Worked Example
A = {1, 2, 3, 4}, B = {3, 4, 5, 6}
A \u2229 B = {3, 4} — only 3 and 4 are in both sets.
Use the union and intersection calculator together to verify the inclusion-exclusion formula or to find common customers, shared features, or overlapping categories in your data. For a visual approach, our Venn Diagram Calculator draws the overlapping regions for you.
Set Difference (A \u2212 B) — Online Difference Calculator
The set difference A \u2212 B (also written A \ B) returns every element in A that is not in B. The direction matters: A \u2212 B and B \u2212 A usually give different results.
Worked Example
A = {1, 2, 3, 4, 5}, B = {3, 4}
A \u2212 B = {1, 2, 5} — remove elements that are in B.
B \u2212 A = \u2205 — every element of B is already in A.
The set difference calculator is widely used in database operations (SQL EXCEPT), file comparison, and access control — for example, finding users who signed up but never made a purchase.
Symmetric Difference, Complement & Cartesian Product
Beyond the basic operations, our set theory calculator supports three more operations:
- Symmetric Difference (A \u25B3 B) — elements in either A or B, but not both. Useful for finding what changed between two versions of a list.
- Set Complement (A\u2032) — all elements in the universal set U that are not in A. You define U yourself. This operation is essential for probability: P(A\u2032) = 1 \u2212 P(A).
- Cartesian Product (A \u00D7 B) — all ordered pairs (a, b). For A = {1, 2} and B = {x, y}, A \u00D7 B = {(1,x), (1,y), (2,x), (2,y)}. The number of pairs equals |A| \u00D7 |B|.
Power Set Calculator & Subset Checker
The power set P(A) is the collection of all subsets of A, including the empty set \u2205 and A itself. If |A| = n, then |P(A)| = 2n. Our power set calculator lists every subset so you can see the complete structure.
Worked Example
A = {a, b, c}
P(A) = {\u2205, {a}, {b}, {c}, {a,b}, {a,c}, {b,c}, {a,b,c}}
|P(A)| = 23 = 8 subsets
The subset check (A \u2286 B) tells you whether every element of A is contained in B. A proper subset (A \u2282 B) additionally requires A \u2260 B. The calculator checks both directions and reports the relationship in plain language.
Set Cardinality & Key Formulas
Set cardinality |A| is simply the number of distinct elements in A. Here are the formulas our set cardinality calculator uses:
| Operation | Formula | Cardinality |
|---|---|---|
| Union | A \u222A B | |A| + |B| \u2212 |A \u2229 B| |
| Intersection | A \u2229 B | \u2264 min(|A|, |B|) |
| Difference | A \u2212 B | |A| \u2212 |A \u2229 B| |
| Symmetric Diff | A \u25B3 B | |A| + |B| \u2212 2|A \u2229 B| |
| Complement | A\u2032 | |U| \u2212 |A| |
| Cartesian Product | A \u00D7 B | |A| \u00D7 |B| |
| Power Set | P(A) | 2|A| |
Set Operations in Computer Science & Data Analysis
Set operations are not just a textbook topic — they power real software every day:
- SQL & Databases — UNION, INTERSECT, and EXCEPT map directly to set union, intersection, and difference. Understanding set theory makes writing efficient queries second nature.
- Python & JavaScript — Python’s
set()and JavaScript’sSetprovide built-in union, intersection, and difference methods. - Data Science — feature selection, data deduplication, and A/B test group analysis all rely on set operations.
- Boolean Logic — set union corresponds to OR, intersection to AND, and complement to NOT. For deeper Boolean analysis, try our Boolean Algebra Calculator.
Set Notation — Symbols & Terminology Reference
Many users search for a set notation calculator because the symbols can be confusing at first. Here is a quick reference:
| Symbol | Name | Meaning |
|---|---|---|
| \u222A | Union | All elements in either set |
| \u2229 | Intersection | Elements in both sets |
| \u2212 or \ | Difference | Elements in one set but not the other |
| \u25B3 | Symmetric Difference | In either but not both |
| \u2032 or c | Complement | Not in the set (relative to U) |
| \u2208 | Element of | x is a member of A |
| \u2286 | Subset | Every element of A is in B |
| \u2282 | Proper subset | Subset and not equal |
| \u2205 | Empty set | A set with no elements |
| \u00D7 | Cartesian Product | All ordered pairs |
For more about logical operators and truth tables, see our Truth Table Generator. If you are working on probability problems that use set notation, our Probability Calculator applies these concepts to event analysis.
About the Author
Why Use This Set Calculator?
This set calculator is designed for speed and clarity. Unlike generic math solvers, it is purpose-built for set operations with step-by-step explanations, automatic duplicate removal, and proper mathematical notation. Whether you need a quick union and intersection calculator for homework, a set difference checker for a coding problem, or a power set calculator for combinatorics, everything runs in your browser — no sign-up, no install, completely free.



