Set Calculator - Union Intersection Difference Sets

Set Calculator

Union, Intersection, Difference & More

Share this calculator

Help others solve their calculations

Found this calculator helpful? Share it with your friends, students, or colleagues who might need it!

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

📅 Published:
Set calculator showing union, intersection, difference, complement, and Cartesian product operations with step-by-step set theory results.

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

  1. Enter Set A — type elements separated by commas (e.g. 1, 2, 3, 4 or a, b, c). Duplicates are removed automatically.
  2. Enter Set B (if needed) — the second set for binary operations like union and intersection.
  3. Choose an operation — tap one of the eight operation buttons.
  4. 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:

OperationFormulaCardinality
UnionA \u222A B|A| + |B| \u2212 |A \u2229 B|
IntersectionA \u2229 B\u2264 min(|A|, |B|)
DifferenceA \u2212 B|A| \u2212 |A \u2229 B|
Symmetric DiffA \u25B3 B|A| + |B| \u2212 2|A \u2229 B|
ComplementA\u2032|U| \u2212 |A|
Cartesian ProductA \u00D7 B|A| \u00D7 |B|
Power SetP(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’s Set provide 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:

SymbolNameMeaning
\u222AUnionAll elements in either set
\u2229IntersectionElements in both sets
\u2212 or \DifferenceElements in one set but not the other
\u25B3Symmetric DifferenceIn either but not both
\u2032 or cComplementNot in the set (relative to U)
\u2208Element ofx is a member of A
\u2286SubsetEvery element of A is in B
\u2282Proper subsetSubset and not equal
\u2205Empty setA set with no elements
\u00D7Cartesian ProductAll 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

Marko Šinko - Co-Founder & Lead Developer

Marko Šinko

Co-Founder & Lead Developer, AI Math Calculator

Lepoglava, Croatia
Advanced Algorithm Expert

Croatian developer with a Computer Science degree from University of Zagreb and expertise in advanced algorithms. Co-founder of award-winning projects, ensuring precise mathematical computations and reliable calculator tools.

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.

Frequently Asked Questions

Still Have Questions?

The detailed content on this page provides comprehensive explanations and examples to help you understand better.