🧮
🧮 Math & statistics

Union and Intersection Calculator (A ∪ B, A ∩ B, difference & complement)

Results update as you type.

Your numbers

Understanding the union and intersection calculator — concept and principle

This calculator finds the union, intersection, differences, symmetric difference and complements of two sets, and checks the counting rule n(A ∪ B) = n(A) + n(B) − n(A ∩ B). Use it for set theory, probability, Venn diagram homework, database queries and filtering lists.

Union and intersectionA = {1…5}, B = {4…7}UAB12345678910A ∩ B{4, 5}A ∪ B{1, …, 7}7 = 5 + 4 − 2 · (A ∪ B)′ = {8, 9, 10}
4 and 5 sit in the overlap; counting A and B separately counts them twice, so subtract 2.

How it is calculated

Duplicates are ignored, and numbers are sorted from smallest to largest.

The principle

Set operations mirror logic: union is "or", intersection is "and", complement is "not". The counting rule subtracts the intersection because elements in both sets would otherwise be counted twice, once in A and once in B. De Morgan's laws connect the operations: (A ∪ B)′ = A′ ∩ B′ and (A ∩ B)′ = A′ ∪ B′. Two sets are disjoint when their intersection is empty.

Worked example

Default inputs: A = {1, 2, 3, 4, 5}, B = {4, 5, 6, 7}, U = {1, …, 10}.

  1. A ∪ B = {1, 2, 3, 4, 5, 6, 7}; A ∩ B = {4, 5}.
  2. A − B = {1, 2, 3}; B − A = {6, 7}; A △ B = {1, 2, 3, 6, 7}.
  3. Count check: 7 = 5 + 4 − 2.
  4. Not disjoint, since 4 and 5 are shared.
  5. Complements in U: A′ = {6, 7, 8, 9, 10}; (A ∪ B)′ = {8, 9, 10}; (A ∩ B)′ = {1, 2, 3, 6, 7, 8, 9, 10}.

How to read the result

The union shows everything covered by at least one set; the intersection shows the overlap. The differences show what is unique to each set, and the symmetric difference combines both. Complements answer "what is left out" relative to U, which is useful for probability: P(A′) = 1 − P(A).

Common mistakes

Keep in mind: Complements depend entirely on the universal set you choose. Changing U changes every complement.

Frequently asked questions

What is the difference between union and intersection?

Union collects elements in either set; intersection keeps only the elements in both.

What does it mean if A ∩ B is empty?

The sets are disjoint: they share no elements.

What are De Morgan's laws for sets?

(A ∪ B)′ = A′ ∩ B′ and (A ∩ B)′ = A′ ∪ B′.

Sources: OpenStax, Contemporary Mathematics (2023), §1.4 Set Operations with Two Sets

Checked 9 Nov 2026. OpenStax, Contemporary Mathematics (2023), §1.4 Set Operations with Two Sets (intersection = AND, union = inclusive OR, complement relative to the universal set, n(A ∪ B) = n(A) + n(B) − n(A ∩ B)).

🧮 All math & statistics tools →🌍 Calculators by country →