Set Operations Calculator

Combine two or three sets with union, intersection, difference, symmetric difference and complement, and see the result shaded on a Venn diagram.

Elements separated by commas (or spaces). Braces are optional.
Needed for complements. Must contain every element of A, B and C.
Number of elements
3|A ∩ B|
|A|, |B|
6, 5
Relationship
A and B overlap; neither contains the other
Subsets of A (power set)
642^|A| = 2^6
Pairs in A × B
30size of the Cartesian product
A ∩ B{4, 5, 6}3 elements

Show the work

  1. A = {1, 2, 3, 4, 5, 6} has 6 elements; B = {4, 5, 6, 7, 8} has 5
  2. A ∩ B = {4, 5, 6}
  3. Inclusion–exclusion check: |A ∪ B| = |A| + |B| − |A ∩ B| = 6 + 5 − 3 = 8
UAB1, 2, 37, 84, 5, 69, 10
All operations
OperationResultSize
A ∪ B{1, 2, 3, 4, 5, 6, 7, 8}8
A ∩ B{4, 5, 6}3
A − B{1, 2, 3}3
B − A{7, 8}2
A △ B{1, 2, 3, 7, 8}5
A′{7, 8, 9, 10}4
B′{1, 2, 3, 9, 10}5
Cartesian product A × B (ordered pairs)
ab = 4b = 5b = 6b = 7b = 8
1(1, 4)(1, 5)(1, 6)(1, 7)(1, 8)
2(2, 4)(2, 5)(2, 6)(2, 7)(2, 8)
3(3, 4)(3, 5)(3, 6)(3, 7)(3, 8)
4(4, 4)(4, 5)(4, 6)(4, 7)(4, 8)
5(5, 4)(5, 5)(5, 6)(5, 7)(5, 8)
6(6, 4)(6, 5)(6, 6)(6, 7)(6, 8)

Sets are collections of distinct objects, and set operations combine them the way AND, OR and NOT combine statements. This calculator takes two or three sets of numbers or words, performs every standard operation (union, intersection, both differences, symmetric difference and complements), checks the counts with the inclusion–exclusion principle, and shades the requested result on a Venn diagram that shows where each element belongs. It also reports subset relationships, the size of the power set and the Cartesian product.

How to use the set calculator

  1. Enter set A and set B, separating elements with commas (spaces work when there are no commas). Curly braces are optional.
  2. Optionally enter set C for three-set operations and a universal set U for complements. U must contain every element of the other sets.
  3. Choose the operation to highlight. The tape shows its result; the table below lists all operations at once.
  4. Read the Venn diagram: each element is printed in the region it belongs to, and the highlighted operation is shaded.

Set operations and notation

A ∪ B = {x : x ∈ A or x ∈ B}  ·  A ∩ B = {x : x ∈ A and x ∈ B}
A − B = {x : x ∈ A and x ∉ B}  ·  A △ B = (A − B) ∪ (B − A)  ·  A′ = U − A

Counts follow the inclusion–exclusion principle:

|A ∪ B| = |A| + |B| − |A ∩ B|
|A ∪ B ∪ C| = |A| + |B| + |C| − |A ∩ B| − |A ∩ C| − |B ∩ C| + |A ∩ B ∩ C|

Worked example

Let U = {1, 2, …, 10}, A = {1, 2, 3, 4, 5, 6} and B = {4, 5, 6, 7, 8}.

Operation Result Size
A ∪ B {1, 2, 3, 4, 5, 6, 7, 8} 8
A ∩ B {4, 5, 6} 3
A − B {1, 2, 3} 3
B − A {7, 8} 2
A △ B {1, 2, 3, 7, 8} 5
A′ {7, 8, 9, 10} 4
B′ {1, 2, 3, 9, 10} 5

Inclusion–exclusion checks the union: 6 + 5 − 3 = 8. The elements 9 and 10 sit outside both circles, inside U. Neither set contains the other, so A and B “overlap.” A has 2⁶ = 64 subsets, and A × B contains 6 × 5 = 30 ordered pairs.

Adding C = {2, 5, 8, 9} produces a three-circle diagram: A ∩ B ∩ C = {5}, A ∪ B ∪ C = {1, …, 9}, and the three-set formula gives 6 + 5 + 4 − 3 − 2 − 2 + 1 = 9.

Useful identities

De Morgan’s laws

(A ∪ B)′ = A′ ∩ B′ and (A ∩ B)′ = A′ ∪ B′. In the example, (A ∪ B)′ = {9, 10}, and A′ ∩ B′ = {7, 8, 9, 10} ∩ {1, 2, 3, 9, 10} = {9, 10}. These mirror the logical laws ¬(p ∨ q) ≡ ¬p ∧ ¬q, which the truth table generator can verify.

Subsets and disjoint sets

A ⊆ B when every element of A is also in B; then A ∩ B = A and A ∪ B = B. Sets with no common elements are disjoint, and for them |A ∪ B| = |A| + |B| exactly.

From sets to probability

When outcomes are equally likely, the probability of an event is its size divided by the size of U. The rules for P(A or B) and P(A and B) in the probability calculator are inclusion–exclusion divided through by |U|. To count how many subsets of a given size a set has, use the combinations calculator: a 6-element set has C(6, 3) = 20 three-element subsets.

Frequently asked questions

What is the difference between union and intersection?

The union A ∪ B contains every element that is in A, in B, or in both. The intersection A ∩ B contains only the elements in both. For A = {1, 2, 3, 4, 5, 6} and B = {4, 5, 6, 7, 8}, the union is {1, 2, 3, 4, 5, 6, 7, 8} and the intersection is {4, 5, 6}.

What is the symmetric difference?

A △ B is the set of elements in exactly one of the two sets: (A − B) ∪ (B − A). It is the set version of exclusive or. In the example above it is {1, 2, 3, 7, 8}.

Why do I need a universal set for complements?

The complement A′ is everything that is not in A, but everything must be measured against some reference collection. Enter the universal set U, such as the digits 1 to 10, and the calculator lists the elements of U outside A. Without U, the complement is undefined.

Do repeated elements or order matter?

No. A set lists each distinct element once and has no order, so {3, 1, 3} and {1, 3} are the same set. The calculator removes duplicates and sorts the output, numerically if every element is a number.

How big is a power set?

A set with n elements has 2ⁿ subsets, counting the empty set and the set itself. A 6-element set has 64 subsets; the calculator lists them all when the set has 5 or fewer elements, grouped by size.

Last reviewed October 2026 by the CalcFluent editorial team. How we check our calculators.