Set theory calculator — union, intersection, difference and Venn regions

List the elements of sets A and B (and optionally C and a universal set U) to get their union, intersection, differences, complements, sizes and every region of the Venn diagram.

Live demo · real result from this tool
A ∪ B{1, 2, 3, 4, 5, 6, 7}
A ∩ B
{4, 5}
A − B
{1, 2, 3}
B − A
{6, 7}
A Δ B (symmetric difference)
{1, 2, 3, 6, 7}
|A|, |B|, |A ∪ B|, |A ∩ B|
5, 4, 7, 2
|A × B| (Cartesian product)
20
|P(A)| (power set)
32
Relationship
overlapping, neither contains the other

Complements relative to U

A′
{6, 7, 8, 9, 10}
B′
{1, 2, 3, 8, 9, 10}
(A ∪ B)′ = A′ ∩ B′
{8, 9, 10}

Venn diagram regions

RegionElements
Only A{1, 2, 3}
Only B{6, 7}
A ∩ B{4, 5}
Outside all sets{8, 9, 10}

Processed on your device — nothing is uploaded.

How to use the set theory calculator

  1. Type the elements of Set A and Set B, separated by commas.
  2. For three-set problems, fill in Set C (optional).
  3. For complements, enter the Universal set U (optional, for complements). Clear it if you do not need complements.
  4. Read the results: A ∪ B, A ∩ B, A − B, B − A, A Δ B, the sizes, and the Relationship line.
  5. Use the Venn diagram regions table to fill in a diagram, region by region.

What it does and when to use it

Set operations are a standard topic in school maths, probability and discrete maths. Exam questions often ask you to shade or fill in a Venn diagram, find a complement, or check a law such as De Morgan’s. This tool does the bookkeeping, so you can concentrate on the reasoning, and it lets you test a law with your own example sets.

The same logic appears with true and false values in the truth table generator. For counting arrangements and selections from a set, use the permutation and combination calculator. The prime factorization tool lists divisors, which make good example sets.

How it works

Each set is split into elements, trimmed and de-duplicated. Then:

  • A ∪ B: every element in A or B.
  • A ∩ B: elements in both.
  • A − B: elements of A that are not in B.
  • A Δ B: (A − B) ∪ (B − A).
  • A′: U − A.
  • Subset: A ⊂ B when every element of A is in B and the sets are not equal.

Results are sorted numerically when every element is a number, and alphabetically otherwise. Empty results are shown as ∅.

Step by step for A = {1, 2, 3, 4, 5}, B = {4, 5, 6, 7}, U = {1, …, 10}:

  1. Shared elements: 4 and 5, so A ∩ B = {4, 5}.
  2. Join and remove repeats: A ∪ B = {1, 2, 3, 4, 5, 6, 7}.
  3. Check the count: |A ∪ B| = |A| + |B| − |A ∩ B| = 5 + 4 − 2 = 7.
  4. Everything in U outside the union: (A ∪ B)′ = {8, 9, 10}.
  5. De Morgan’s law says this equals A′ ∩ B′ = {6, 7, 8, 9, 10} ∩ {1, 2, 3, 8, 9, 10} = {8, 9, 10}. It does.

Worked examples

Two overlapping sets. With the sets above, the tool gives A − B = {1, 2, 3}, B − A = {6, 7} and (A ∪ B)′ = A′ ∩ B′: {8, 9, 10}.

Words, no overlap. A = {apple, pear}, B = {kiwi}: the intersection is ∅ (empty set) and the tool reports Relationship: A and B are disjoint.

Three sets. A = {1, 2, 3}, B = {2, 3, 4}, C = {3, 4, 5}: A ∩ B ∩ C: {3}. The Venn table puts 1 in “Only A”, 2 in “A ∩ B only”, 4 in “B ∩ C only” and 5 in “Only C”.

Subset. A = {2, 4}, B = {1, 2, 3, 4} gives A ⊂ B (A is a proper subset of B) and A − B = ∅.

Limits and tips

  • Spaces inside an element are kept, so “New York” is one element.
  • The tool works with finite lists only; it cannot handle rules such as “all even numbers”.
  • Your sets stay in your browser.

Frequently asked questions

How should I type a set?
Separate elements with commas, semicolons or new lines. Curly brackets around the list are optional. Repeated elements are counted once, because a set has no duplicates.
Can the elements be words?
Yes. Elements are compared as text, so apple, pear and kiwi work. This also means 1 and 1.0 count as different elements, so write numbers the same way in every set.
Why do I need a universal set?
A complement A′ means "everything not in A", which only makes sense within a stated universe U. If U is left empty, complements are skipped. If A or B contains something outside U, the tool warns you.
What is the symmetric difference?
A Δ B holds the elements in exactly one of the two sets. It equals (A − B) ∪ (B − A), or (A ∪ B) − (A ∩ B).
Does it list the power set or the Cartesian product?
It gives their sizes, |P(A)| = 2^|A| and |A × B| = |A| × |B|, but not the full lists, which grow very quickly.

Written by the ToolsRift team · Last updated

Pages are drafted with AI assistance and checked by automated tests. How we write and check pages.

Was this tool useful?

Report a problem

Start typing to search every tool.

↑ ↓ to moveEnter to openEsc to close