Set Theory Calculator
Explore set theory with an interactive calculator for union, intersection, difference and Cartesian products. Learn notation, laws, examples and applications in math and computer science.
Full original guide (expanded)
Set Theory Calculator
Build sets, compute unions, intersections, differences and Cartesian products – and see the results in clean mathematical notation.
Interactive set theory calculator
Use this tool to experiment with finite sets. Enter the elements of sets A and B, then compute standard operations: union (A ∪ B), intersection (A ∩ B), difference (A \\ B, B \\ A), symmetric difference and Cartesian product (A × B).
Separate elements with commas, spaces or new lines. Elements are treated as text (so a and A are different).
The calculator automatically removes duplicates within each set.
|A| = 0, |B| = 0
A ⊆ B? , B ⊆ A? , A = B?
Basic operations
- Union A ∪ B
- –
- Intersection A ∩ B
- –
- Difference A \\ B
- –
- Difference B \\ A
- –
- Symmetric difference A △ B
- –
Cartesian product A × B
Computed only if |A| · |B| ≤ 50, to keep the output readable.
What is set theory?
Set theory is the branch of mathematics that studies sets – collections of objects considered as a single entity. It provides the language and foundations for most of modern mathematics, logic and theoretical computer science.
With this page you can both compute concrete examples using the calculator above and revise the core concepts every student of discrete mathematics, computer science or engineering should know.
Basic concepts and notation
Sets and elements
A set is usually denoted by a capital letter (A, B, X, …), and its elements by lowercase letters (a, b, x, …).
The statement “a is an element of A” is written
a \(\in\) A
while “b is not an element of A” is written b \(\notin\) A.
Roster notation and set-builder notation
A finite set can be listed explicitly:
A = {1, 2, 3, 4}
For infinite or structured sets, we often use set-builder notation:
\(\mathbb{N} = \{ n \in \mathbb{Z} : n \ge 0 \}\)“The set of integers n such that n is greater than or equal to 0.”
Common sets
- \(\mathbb{N}\): natural numbers (0, 1, 2, 3, …)
- \(\mathbb{Z}\): all integers (..., −2, −1, 0, 1, 2, ...)
- \(\mathbb{Q}\): rational numbers
- \(\mathbb{R}\): real numbers
- \(\emptyset\): the empty set, containing no elements
Subsets, equality and power sets
Subsets and equality
A set A is a subset of B if every element of A is also an element of B. We write:
A \(\subseteq\) B means “A is a subset of B”.A = B if and only if A \(\subseteq\) B and B \(\subseteq\) A.
In the calculator above, after you click Compute set operations, you will see whether A ⊆ B, B ⊆ A and whether A = B for your particular examples.
Power set
The power set of A, denoted P(A), is the set of all subsets of A (including the empty set and A itself). If A has n distinct elements, then:
|P(A)| = 2^n
For example, if A = {1, 2}, then:
P(A) = { \(\emptyset\), {1}, {2}, {1, 2} }
Standard set operations
Union and intersection
The union of A and B, written A ∪ B, collects everything that is in A, or in B, or in both:
A \(\cup\) B = { x : x \(\in\) A or x \(\in\) B }
The intersection of A and B, written A ∩ B, contains only the elements common to both:
A \(\cap\) B = { x : x \(\in\) A and x \(\in\) B }
Set difference and symmetric difference
The difference A \\ B (sometimes written A − B) keeps the elements in A that are not in B:
A \ B = { x : x \(\in\) A and x \(\notin\) B }
The symmetric difference A △ B contains elements that are in exactly one of the two sets:
A \(\triangle\) B = (A \ B) \(\cup\) (B \ A)
Cartesian product
The Cartesian product of A and B is the set of ordered pairs:
A \(\times\) B = { (a, b) : a \(\in\) A, b \(\in\) B }
If |A| = m and |B| = n, then A × B has m · n elements. The calculator displays the full Cartesian product for small examples and warns you when the product becomes too large.
Algebra of sets and De Morgan’s laws
When working inside a universal set U, each subset A ⊆ U has a complement Aᶜ consisting of all elements in U that are not in A. Set operations satisfy rules that mirror logical connectives.
\((A \cup B)^{c} = A^{c} \cap B^{c}\)
\((A \cap B)^{c} = A^{c} \cup B^{c}\)
These identities are crucial in probability, logic, and circuit design. They also explain why Venn diagrams are so powerful: unions, intersections, and complements correspond to combining shaded regions.
Applications of set theory
- Discrete mathematics and logic: formalising statements, predicates and proofs.
- Computer science: describing data structures, databases, query languages and type systems.
- Probability and statistics: events are sets of outcomes; operations on events are set operations.
- Analysis and topology: open sets, closed sets and σ-algebras generalise the notion of “intervals” and “regions”.
Practicing with concrete finite sets, like in the calculator above, is a good way to build intuition before moving on to more abstract topics such as infinite cardinals and axiomatic set theory.
Set theory calculator – FAQ
Formula (LaTeX) + variables + units
','\
\(\mathbb{N} = \{ n \in \mathbb{Z} : n \ge 0 \}\) “The set of integers n such that n is greater than or equal to 0.”
A \(\subseteq\) B means “A is a subset of B”. A = B if and only if A \(\subseteq\) B and B \(\subseteq\) A.
P(A) = { \(\emptyset\), {1}, {2}, {1, 2} }
A \(\cup\) B = { x : x \(\in\) A or x \(\in\) B }
A \(\cap\) B = { x : x \(\in\) A and x \(\in\) B }
A \ B = { x : x \(\in\) A and x \(\notin\) B }
- No variables provided in audit spec.
- NIST — Weights and measures — nist.gov · Accessed 2026-01-19
https://www.nist.gov/pml/weights-and-measures - FTC — Consumer advice — consumer.ftc.gov · Accessed 2026-01-19
https://consumer.ftc.gov/
Last code update: 2026-01-19
- Initial audit spec draft generated from HTML extraction (review required).
- Verify formulas match the calculator engine and convert any text-only formulas to LaTeX.
- Confirm sources are authoritative and relevant to the calculator methodology.