Set Theory Calculator screenshot

Set Theory Calculator

Compute the union, intersection, differences and symmetric difference of two finite sets, with the inclusion–exclusion identity printed as a check.

Privacy First
0 Runs
Updated 2026-11-22
Runs in your browser
No sign-up, no upload
Element-by-element, not by formula

Set Theory Calculator

Compute the union, intersection, differences and symmetric difference of two finite sets, with the inclusion–exclusion identity printed as a check.

How this page computes

Both lists are split on commas, spaces and semicolons, de-duplicated in first-appearance order, then sorted for printing. Membership is a lookup in the other set's collection.

Each operation is built from those memberships rather than from a shortcut. The power-set size is 2^n in BigInt, and the subset tests check containment in both directions.

The calculation runs entirely in this browser tab; nothing is uploaded.

The page performs the four set operations on two finite sets you type. With A = {1, 2, 3} and B = {3, 4} it prints a union of four elements, an intersection of one, and the two one-sided differences, each sorted and counted.

Membership is decided element by element rather than by a formula, so the printed union can be compared with |A| + |B| − |A ∩ B| on the same page. Elements are compared as text: 01 and 1 are different, and so are Red and red.

How to use Set Theory Calculator

Type the first set in the main box and the second in the Second set field, separated by commas or spaces, then press Run. Repeats are removed before anything is computed, because a set has no duplicates.

The output gives both sets, the four operations, the power-set size of the first set, the two subset tests and whether the sets are disjoint. The final check line adds the two sizes, subtracts the intersection, and compares with the union.

Why the printed union is the check

The union is built by collecting every element of both lists into one collection with repeats removed. The intersection is built by keeping the elements of the first list that also appear in the second. Neither uses the inclusion–exclusion identity, which is what makes the identity worth printing as a check.

Lists are sorted numerically when every element is a number and lexicographically otherwise, so two sets can be compared line by line. A power-set size is 2 to the power of the element count, computed exactly in BigInt even when it is far past what a double holds.

What to Expect

Best for

  • The four set operations on a typed collection
  • Checking the inclusion–exclusion identity on a real example
  • Seeing whether one set is a subset of another

Not ideal for

  • Symbolic set algebra, which needs an expression language rather than a list
  • Infinite or described sets such as all primes
  • Case-insensitive comparison, which this page does not apply

What this tool keeps

  • Every element exactly as typed, including its case and leading zeros

What may need cleanup

  • Nothing: the four results are final

Common errors

  • An empty field is refused, because the empty set is written {}, not left blank
  • Duplicate elements are removed, not counted twice

Example use cases

  • Union and intersection of {1,2,3} and {3,4}
  • Check the inclusion–exclusion identity
  • See that {1,2} is a subset of {1,2,3}

Sample input

A = 1, 2, 3 and B = 3, 4

Sample output

union {1,2,3,4}, intersection {3}, A minus B {1,2}

Who this is for

  • Students meeting set notation
  • Readers checking a Venn diagram

Frequently asked questions

Are duplicates counted?

No. A set has no multiplicity, so the lists are de-duplicated before any operation and the printed size is the number of distinct elements. A multiset question is a different page.

Is comparison case-sensitive?

Yes. Red and red are two different elements, because the page treats each element as the text you typed. Write both in the same case if you mean one element.

What does the power-set size mean?

The number of subsets of the first set, which is 2 to the power of its size. For three elements that is 8, including the empty set and the whole set.

Developer program

Build custom tools for your store

Join the SDK program to create useful ecommerce utilities for your store.