Skip to content

Set Calculator

Enter two sets — numbers or words — and see every standard operation at once: union, intersection, both differences, symmetric difference, complements against a universal set you can set yourself, the Cartesian product and the power set, together with the size of each. A Venn diagram shows where every element sits. Free, no sign-up.

Separate elements with commas, spaces or new lines. Braces are optional: {1, 2, 3}, 1 2 3 and red, green all work. Numbers and words are both fine.

Needed for complements. If you leave it empty, U is taken to be A ∪ B.

Try an example

Results

5

|A|

4

|B|

7

|A ∪ B|

2

|A ∩ B|

A and B overlap, and neither is a subset of the other.

Inclusion–exclusion: |A ∪ B| = |A| + |B| − |A ∩ B| = 5 + 4 − 2 = 7

Set operations

OperationResultElements
Union, A ∪ B{1, 2, 3, 4, 5, 6, 7}7
Intersection, A ∩ B{4, 5}2
Difference, A − B{1, 2, 3}3
Difference, B − A{6, 7}2
Symmetric difference, A Δ B{1, 2, 3, 6, 7}5
Complement of A, A′ = U − A{6, 7}2
Complement of B, B′ = U − B{1, 2, 3}3

Venn diagram

Venn diagram of A and B with the elements of A only, both, and B only written in each regionUAB1, 2, 34, 56, 7

Cartesian product A × B

|A × B| = |A| × |B| = 5 × 4 = 20. B × A has the same size but its pairs are written the other way round.

{(1, 4), (1, 5), (1, 6), (1, 7), (2, 4), (2, 5), (2, 6), (2, 7), (3, 4), (3, 5), (3, 6), (3, 7), (4, 4), (4, 5), (4, 6), (4, 7), (5, 4), (5, 5), (5, 6), (5, 7)}

Power sets

P(A)

A set with n elements has 2ⁿ subsets, including ∅ and the set itself. |P(A)| = 2^5 = 32.

{∅, {1}, {2}, {3}, {4}, {5}, {1, 2}, {1, 3}, {1, 4}, {1, 5}, {2, 3}, {2, 4}, {2, 5}, {3, 4}, {3, 5}, {4, 5}, {1, 2, 3}, {1, 2, 4}, {1, 2, 5}, {1, 3, 4}, {1, 3, 5}, {1, 4, 5}, {2, 3, 4}, {2, 3, 5}, {2, 4, 5}, {3, 4, 5}, {1, 2, 3, 4}, {1, 2, 3, 5}, {1, 2, 4, 5}, {1, 3, 4, 5}, {2, 3, 4, 5}, {1, 2, 3, 4, 5}}

P(B)

A set with n elements has 2ⁿ subsets, including ∅ and the set itself. |P(A)| = 2^4 = 16.

{∅, {4}, {5}, {6}, {7}, {4, 5}, {4, 6}, {4, 7}, {5, 6}, {5, 7}, {6, 7}, {4, 5, 6}, {4, 5, 7}, {4, 6, 7}, {5, 6, 7}, {4, 5, 6, 7}}

How to Use the Set Calculator

  1. 1. Enter set A and set B. Separate the elements with commas, spaces or new lines. Braces are optional, so {1, 2, 3}, 1 2 3 and red, green are all accepted, and numbers and words can be mixed.
  2. 2. Add a universal set if you need complements. A complement means “everything in U that is not in the set”, so it needs U. Leave the field empty and U is taken to be A ∪ B.
  3. 3. Read the table. Each operation is shown as a set with its number of elements. Repeated entries are dropped and counted, and the order you type does not matter.
  4. 4. Use the Venn diagram. It writes the elements of A only, of both, and of B only into their regions; elements of U outside both sets sit in the corner.

The Set Operations

OperationSymbolContainsA = {1, 2, 3, 4, 5}, B = {4, 5, 6, 7}
UnionA ∪ BElements in A or B or both{1, 2, 3, 4, 5, 6, 7}
IntersectionA ∩ BElements in both A and B{4, 5}
DifferenceA − BElements of A that are not in B{1, 2, 3}
DifferenceB − AElements of B that are not in A{6, 7}
Symmetric differenceA Δ BElements in exactly one of A and B{1, 2, 3, 6, 7}
ComplementA′Elements of U that are not in Awith U = {1, …, 10}: {6, 7, 8, 9, 10}

The difference A − B is also written A \ B. The symmetric difference can be built from the others: A Δ B = (A − B) ∪ (B − A), or equivalently (A ∪ B) − (A ∩ B).

Counting With Sets

The number of elements of a set A is its cardinality, written |A|. When two sets overlap, adding |A| and |B| counts the shared elements twice, so the inclusion–exclusion rule subtracts them once: |A ∪ B| = |A| + |B| − |A ∩ B|. Here that is 5 + 4 − 2 = 7. The calculator prints this check for your sets.

QuantityFormulaFor the example
Union|A| + |B| − |A ∩ B|5 + 4 − 2 = 7
Cartesian product A × B|A| × |B|5 × 4 = 20 ordered pairs
Power set P(A)2^|A|2⁵ = 32 subsets
Complement|U| − |A|10 − 5 = 5

Cartesian Product and Power Set

The Cartesian product A × B is the set of all ordered pairs (a, b) with a in A and b in B. For {1, 2} × {x, y} it is {(1, x), (1, y), (2, x), (2, y)}. Order matters inside a pair, so (1, x) is not (x, 1), and B × A is a different set of the same size.

The power set P(A) is the set of all subsets of A, including the empty set ∅ and A itself. The subsets of {a, b, c} are ∅, {a}, {b}, {c}, {a, b}, {a, c}, {b, c} and {a, b, c} — eight, which is 2³. Each element is either in a subset or out of it, which is why the count doubles with every new element. The calculator lists the subsets for up to seven elements and gives the exact count for any size.

What Counts as an Element

  • Order and repeats do not matter. {1, 2, 3} and {3, 3, 2, 1} are the same set. Repeated entries are ignored and the calculator says how many it dropped.
  • Numbers are compared by value. 3, +3 and 3.0 are one element, and numbers are listed in increasing order before words.
  • Words are case-sensitive. a and A are two different elements.
  • A set can contain sets. Nested braces such as {{1, 2}, {3}} are kept whole, so you can paste a power set back in as a new set.
  • The empty set is written ∅ or {}. It has no elements, and it is a subset of every set.

Frequently Asked Questions

What is the difference between union and intersection?
The union A ∪ B contains everything that is in A, in B, or in both. The intersection A ∩ B contains only what is in both. For {1, 2, 3} and {3, 4} the union is {1, 2, 3, 4} and the intersection is {3}.
What is the symmetric difference of two sets?
A Δ B holds the elements that are in exactly one of the two sets — in A or B but not in both. It is the union with the intersection removed. For {1, 2, 3} and {3, 4} it is {1, 2, 4}.
Why does a complement need a universal set?
The complement A′ means everything that is not in A, and “everything” only has a meaning within a chosen universe U. The complement of {1, 2} is {3, 4, 5} if U = {1, …, 5}, but {3, …, 100} if U = {1, …, 100}. Without U the calculator uses A ∪ B.
How many subsets does a set have?
A set with n elements has 2ⁿ subsets, counting the empty set and the set itself. A 3-element set has 8, a 10-element set has 1,024, and a 20-element set has 1,048,576.
What is a Cartesian product?
The Cartesian product A × B is the set of all ordered pairs with the first entry from A and the second from B. It has |A| × |B| pairs, and unlike union or intersection it depends on the order: A × B and B × A are different sets.
What does |A| mean?
|A| is the cardinality of A: the number of distinct elements it has. For A = {a, b, c} it is 3. The empty set has cardinality 0.
How is a proper subset different from a subset?
A is a subset of B (A ⊆ B) if every element of A is in B, which includes the case A = B. A is a proper subset (A ⊂ B) if it is a subset and B has at least one extra element. The calculator tells you which relationship holds.

Related Tools

More in Math Calculators

See all Math Calculators