Intermediate

Set Operations Calculator (Union & Intersection)

Enter two sets of elements and instantly compute their union, intersection, differences, symmetric difference and all cardinalities.
Comma, space or newline separated; duplicates removed
Comma, space or newline separated; duplicates removed

Operation

Result size
7

Number of elements in the result set

Result set
{ 1, 2, 3, 4, 5, 6, 7 }
|A|
5
|B|
4
|A ∪ B|
7
|A ∩ B|
2
|A △ B|
5

7

total

A only

42.9%

A ∩ B

28.6%

B only

28.6%

Step by step
  1. 1

    |A|

    5
  2. 2

    |B|

    4
  3. 3

    |A ∩ B| (shared elements)

    2
  4. 4

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

    5 + 4 − 2 = 7
    Inclusion–exclusion: subtract the overlap to avoid counting it twice.
Results are estimates for general information only and are not professional advice — always verify important results independently before relying on them. Read the full disclaimer.
Quick answer

How does this calculator work?

Type two sets and pick an operation. The tool removes duplicates, then returns the union, intersection, one-sided differences or symmetric difference along with every cardinality. A Venn-style donut splits the union into A-only, shared and B-only elements so you can see exactly how the two sets overlap.

Formula
A ∪ B (union), A ∩ B (intersection), A ∖ B (difference), A △ B = (A ∖ B) ∪ (B ∖ A) (symmetric difference)
How this is calculated

You type the members of Set A and Set B into two text boxes. Tokens may be separated by commas, spaces or newlines, and any repeated token is collapsed so each set contains only unique elements — exactly matching the mathematical definition of a set. Comparison is done on the literal text of each token, so "2" and "2.0" are treated as different members.

The calculator builds five derived sets. The union A ∪ B contains every element that appears in either set. The intersection A ∩ B contains the elements common to both. The difference A ∖ B keeps the elements of A that are not in B, while B ∖ A does the reverse. The symmetric difference A △ B combines the two one-sided differences — the elements that belong to exactly one of the sets. The operation selector simply chooses which of these to show as the headline result.

The cardinalities follow directly: |A|, |B|, |A ∪ B|, |A ∩ B| and |A △ B| are the element counts of the respective sets. By inclusion–exclusion they satisfy |A ∪ B| = |A| + |B| − |A ∩ B|. The donut chart partitions the union into three disjoint regions — elements only in A, elements in both, and elements only in B — which is the standard two-circle Venn breakdown. If both boxes are empty the result is undefined; an empty individual set is allowed and yields the empty set { }.

Frequently asked questions

Use commas, spaces or new lines — any mix works. For example "1, 2 3\n4" is read as four elements.

No. A set holds unique members, so repeated tokens within a box are merged into a single element before any operation runs.

A △ B is the set of elements in exactly one of the two sets: (A ∖ B) ∪ (B ∖ A). Its size equals |A ∪ B| − |A ∩ B|.

Also known as

set operations calculator
union intersection
set difference
symmetric difference
venn calculator
set theory
union and intersection

APA

TG we-Calculate Editorial Team. (2026). Set Operations Calculator (Union & Intersection) [Online calculator]. TG we-Calculate. https://we-calculate.com/calculator/set-operations-calculator

Chicago

TG we-Calculate Editorial Team. "Set Operations Calculator (Union & Intersection)." TG we-Calculate. 2026. https://we-calculate.com/calculator/set-operations-calculator.

IEEE

TG we-Calculate Editorial Team, "Set Operations Calculator (Union & Intersection)," TG we-Calculate, 2026. [Online]. Available: https://we-calculate.com/calculator/set-operations-calculator

BibTeX

@misc{wecalculate_set_operations_calculator, title = {Set Operations Calculator (Union & Intersection)}, author = {{TG we-Calculate Editorial Team}}, howpublished = {\url{https://we-calculate.com/calculator/set-operations-calculator}}, year = {2026}, note = {TG we-Calculate} }

Did this calculator help you?