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.

Core Math & Algebra

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.

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.

De Morgan’s laws
\((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

Set theory is the branch of mathematics that studies collections of objects called sets. It provides the language and foundations for most of modern mathematics, logic and theoretical computer science.
You can build two finite sets A and B, then compute union (A ∪ B), intersection (A ∩ B), differences (A \\ B, B \\ A), symmetric difference (A △ B) and the Cartesian product (A × B). The tool also shows the cardinalities |A| and |B| and whether A and B are equal or subsets of each other.
An element is a single object that may or may not belong to a set, written with the symbol ∈. A subset is itself a set whose every element is also an element of another set, written A ⊆ B. For example, 2 ∈ {1, 2, 3}, while {1, 2} ⊆ {1, 2, 3}.
No. The calculator is designed for finite sets that you explicitly enter. However, the same operations and notation extend to many infinite sets, such as the natural numbers or real intervals. The tool is meant to build solid intuition using concrete examples.
Set theory underpins probability, statistics, analysis, and algebra, and it is central in computer science, data science, database design, information retrieval and logic. Whenever you group, filter, combine or cross-match data, you are implicitly performing set operations.

Audit: Complete
Formula (LaTeX) + variables + units
This section shows the formulas used by the calculator engine, plus variable definitions and units.
Formula (extracted LaTeX)
\[','\\]
','\
Formula (extracted text)
\(\mathbb{N} = \{ n \in \mathbb{Z} : n \ge 0 \}\) “The set of integers n such that n is greater than or equal to 0.”
Formula (extracted text)
A \(\subseteq\) B means “A is a subset of B”. A = B if and only if A \(\subseteq\) B and B \(\subseteq\) A.
Formula (extracted text)
P(A) = { \(\emptyset\), {1}, {2}, {1, 2} }
Formula (extracted text)
A \(\cup\) B = { x : x \(\in\) A or x \(\in\) B }
Formula (extracted text)
A \(\cap\) B = { x : x \(\in\) A and x \(\in\) B }
Formula (extracted text)
A \ B = { x : x \(\in\) A and x \(\notin\) B }
Variables and units
  • No variables provided in audit spec.
Sources (authoritative):
Changelog
Version: 0.1.0-draft
Last code update: 2026-01-19
0.1.0-draft · 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.
Verified by Ugo Candido on 2026-01-19
Profile · LinkedIn
Formulas

(Formulas preserved from original page content, if present.)

Version 0.1.0-draft
Citations

Add authoritative sources relevant to this calculator (standards bodies, manuals, official docs).

Changelog
  • 0.1.0-draft — 2026-01-19: Initial draft (review required).