Set Theory Calculator
Calculate union, intersection, difference, symmetric difference, and complements for two sets with similarity metrics.
About this calculator
This calculator derives every standard two-set relationship — union, intersection, the two one-way differences, symmetric difference, and both complements — from just three cardinalities: Set A Size, Set B Size, and the Overlap (A ∩ B) between them. Union (A ∪ B) is setASize + setBSize − overlapCount (line 13), so Set A Size is the single strongest driver of it at the calculator's defaults — a 10% nudge to Set A Size (50) is 5, while the same 10% nudge to Set B Size (30) is only 3, so Set A Size moves Union about 1.7 times as much simply because its default value is larger; with equal-sized sets, the two inputs would move Union equally. Increasing the Overlap, by contrast, pulls Union down, since a larger shared region means fewer elements are being counted twice.
Universal Set Size never enters the Union formula at all; it only affects Complement of A and Complement of B, and the engine silently raises it to at least setASize + setBSize − overlapCount (line 7-10) if you type a smaller value, rather than rejecting the entry. Overlap Count itself is clamped to never exceed the smaller of the two set sizes (line 6), since a shared region can't be larger than either set it belongs to. This calculator only models two sets — it has no way to represent a three-way (or higher) overlap, such as a three-circle Venn diagram, where the pairwise overlap counts alone aren't enough to determine how much of all three sets intersect at once.
Inputs
Results
Union (A ∪ B)
70
Intersection (A ∩ B)
10
How to Use This Calculator
- Enter the sizes of Set A and Set B, plus their Overlap (A ∩ B) and the Universal Set Size.
- All set operations — union, intersection, both differences, and symmetric difference — are calculated automatically from those sizes.
- Review the resulting cardinalities, including the Complement of A and Complement of B.
- Check the Set Region Sizes bar chart to visualize the overlap.
- Use the cardinality outputs to verify set relationships in database queries or combinatorics problems.
How the result changes with Set A Size
| Set A Size | Union (A ∪ B) | Intersection (A ∩ B) |
|---|---|---|
| 25 | 45 | 10 |
| 38 | 58 | 10 |
| 75 | 95 | 10 |
| 125 | 145 | 10 |
What each input means
- Set A Size
- Number of elements in set A
- Set B Size
- Number of elements in set B
- Overlap (A ∩ B)
- Number of elements shared by both A and B
- Universal Set Size
- Total elements in the universal set (must be ≥ union size)
How this is calculated
Worked example, using the default values
- Identify Input Parameters4 parametersSet A Size = 50, Set B Size = 30, Overlap (A ∩ B) = 10, Universal Set Size = 100 = 4 input(s) provided
- Calculate UnionUnion70 = 70
- Calculate IntersectionIntersection10 = 10
- Calculate DifferenceDifference40 = 40
- Calculate DifferenceDifference20 = 20
Engine last updated . Checked against 4 independently-derived tests — how we verify calculators. Built by Paul Gunder, a software engineer, not a licensed financial, medical, or legal professional.
Frequently Asked Questions
Does Set A Size or Set B Size move the Union size more?
Set A Size does, at the calculator's default values — Union is setASize + setBSize − overlapCount (line 13), a straight sum, but Set A Size defaults to 50 versus Set B Size's 30, so the same proportional nudge to Set A Size produces a larger absolute swing in Union. With equal-sized sets, the two would move it equally.
Why doesn't Universal Set Size change the Union?
Union (A ∪ B) is computed directly as setASize + setBSize − overlapCount (line 13) and never references Universal Set Size at all. Universal Set Size only feeds into Complement of A and Complement of B, which measure what's outside each set relative to the universe you declare.
What happens if I set Universal Set Size smaller than the union of A and B?
The engine won't let it shrink that far: it silently raises Universal Set Size to at least setASize + setBSize − overlapCount (lines 7-10) before using it, since a universal set can never be smaller than a union it's supposed to contain. You won't see an error, just a larger effective value.
Can I set Overlap (A ∩ B) larger than either set?
No. The engine clamps Overlap Count to Math.min(setASize, setBSize) (line 6), because the number of elements shared between two sets can never exceed the size of the smaller set — typing a larger overlap just gets capped down automatically rather than rejected.
Related Calculators
The questions that sit next to this one — chosen by subject, including calculators filed under a different category.
Venn Diagram Calculator
Calculate exclusive region values for 2-set or 3-set Venn diagrams using inclusion-exclusion principle.
Logic & Formal ReasoningTruth Table Generator
Generate a complete truth table for propositional logic formulas with 2-4 variables and common logical operations.
Discrete MathematicsInclusion-Exclusion Calculator
Apply the inclusion-exclusion principle to compute union sizes and exclusive membership for up to three sets.
Logic & Formal ReasoningBoolean Algebra Simplifier
Estimate Boolean expression simplification from sum-of-products form. Calculates term and literal reduction using grouping heuristics.
More in Math & Statistics.