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.
Total distinct elements across both sets
- 1
Cardinality of A
|A| = 5 - 2
Cardinality of B
|B| = 5 - 3
Intersection size
|A ∩ B| = 3 - 4
|A ∪ B| = |A| + |B| − |A ∩ B|
5 + 5 − 3 = 7Inclusion–exclusion principle: sum the sizes and subtract the overlap once.
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
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
TG we-Calculate Editorial Team. (2026). Set Operations Calculator [Online calculator]. TG we-Calculate. https://we-calculate.com/calculator/set-builder-calculator
TG we-Calculate Editorial Team. "Set Operations Calculator." TG we-Calculate. 2026. https://we-calculate.com/calculator/set-builder-calculator.
TG we-Calculate Editorial Team, "Set Operations Calculator," TG we-Calculate, 2026. [Online]. Available: https://we-calculate.com/calculator/set-builder-calculator
@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?
