Beginner

Set Operations Calculator

Enter two sets of numbers (comma-separated) to instantly compute all standard set operations: union A ∪ B, intersection A ∩ B, difference A \ B and symmetric difference A △ B. The number line shows which elements belong to each set.
Comma-separated numbers (integers or decimals)
Comma-separated numbers (integers or decimals)
Union |A ∪ B|
7

Total distinct elements across both sets

|A| (cardinality of A)
5
|B| (cardinality of B)
5
|A ∩ B| (intersection)
3
|A △ B| (symmetric diff.)
4
A ∪ B
{1, 2, 3, 4, 5, 6, 7}
A ∩ B
{3, 4, 5}
A \ B
{1, 2}
A △ B
{1, 2, 6, 7}
0123456781234567Number line: blue = A only, pink = B only, purple = A ∩ B
Step by step
  1. 1

    Cardinality of A

    |A| = 5
  2. 2

    Cardinality of B

    |B| = 5
  3. 3

    Intersection size

    |A ∩ B| = 3
  4. 4

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

    5 + 5 − 3 = 7
    Inclusion–exclusion principle: sum the sizes and subtract the overlap once.
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?

Enter two sets as comma-separated numbers. A ∪ B (union) collects all distinct elements; A ∩ B (intersection) keeps only shared elements; A \ B (difference) removes B-members from A; A △ B (symmetric difference) keeps elements in exactly one set. Cardinality is the count of elements in each result.

Formula
A ∪ B = all elements in either set • A ∩ B = elements in both • A \ B = A without B • A △ B = (A \ B) ∪ (B \ A)
How this is calculated

A set is an unordered collection of distinct elements. This calculator treats each comma-separated number as a unique element (duplicates are merged). It then applies the four fundamental binary set operations: union (all elements from either set), intersection (only elements present in both), difference A \ B (A minus any element also in B), and symmetric difference (elements in exactly one set but not both).

Cardinality — written |A| — is simply the count of distinct elements in a set. The inclusion-exclusion principle states |A ∪ B| = |A| + |B| − |A ∩ B|, which you can verify with the numbers shown above.

This calculator accepts any real numbers, not just integers. Floating-point comparisons use exact equality, so values like 0.1 and 0.10 are treated identically (both parse to the same IEEE 754 double), but 0.1 and 0.10000001 are considered different elements.

Frequently asked questions

The empty set ∅ contains no elements and has cardinality 0. It appears when two sets share no elements (empty intersection) or when A \ B removes every element of A because B contains all of them.

The symmetric difference A △ B contains elements that are in A or B but not in both — equivalently, (A ∪ B) \ (A ∩ B). It is sometimes written as A ⊕ B.

Yes. Any real numbers parseable as JavaScript numbers work: integers, decimals and negatives (e.g. -3, 2.5, 0.01). Separate them with commas, spaces or semicolons.

Also known as

set builder notation calculator
union intersection sets calculator
set difference symmetric difference
venn diagram set calculator
cardinality of sets
a union b intersection b math
set theory calculator

APA

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

Chicago

TG we-Calculate Editorial Team. "Set Operations Calculator." TG we-Calculate. 2026. https://we-calculate.com/calculator/set-builder-calculator.

IEEE

TG we-Calculate Editorial Team, "Set Operations Calculator," TG we-Calculate, 2026. [Online]. Available: https://we-calculate.com/calculator/set-builder-calculator

BibTeX

@misc{wecalculate_set_builder_calculator, title = {Set Operations Calculator}, author = {{TG we-Calculate Editorial Team}}, howpublished = {\url{https://we-calculate.com/calculator/set-builder-calculator}}, year = {2026}, note = {TG we-Calculate} }

Did this calculator help you?