Venn Diagram Calculator
Calculate exclusive region values for 2-set or 3-set Venn diagrams using inclusion-exclusion principle.
About this calculator
This calculator switches its entire formula set based on one condition: `const isTwoSet = setC === 0` (line 15). At the default Set C Size of 0, it takes the two-set branch (lines 27-34), where A Only is simply Set A minus the overlap and B Only is Set B minus the overlap — Set B never enters the formula for A Only, and Set A never enters the formula for B Only, in that branch. Only once Set C Size rises above 0 does the calculator switch to full three-set inclusion-exclusion (lines 36-53), bringing A∩C, B∩C, and A∩B∩C into every region calculation.
The A∩B Overlap you enter is itself clamped to never exceed the smaller of Set A and Set B (line 7's `Math.min(setA, setB)`), so at the defaults — Set A 40, Set B 30 — Set B's inertness to A Only holds as long as Set B stays large enough that the clamp never bites; shrink Set B below the overlap value and the clamp starts reshaping A Only indirectly, through the overlap it caps rather than through a direct term in the formula. Union Total in the two-set branch is Set A plus Set B minus their overlap (line 34), so it responds to all three inputs, with Set A moving it the most at the defaults because Set A (40) is larger than Set B (30). What this does not account for: any universe/complement region outside the sets shown, and it silently floors every rounded region output at 0 rather than reporting a negative count when overlap inputs describe an impossible configuration.
Inputs
Results
A Only
30
B Only
20
Union Total
60
How to Use This Calculator
- Enter the total population or universe size.
- Input the size of Set A, Set B, and their intersection.
- Review the exclusive regions: A only, B only, both A and B, and neither.
- Calculate percentages of the universe in each region for proportion analysis.
- Use the output to solve inclusion-exclusion problems in probability and combinatorics.
How the result changes with Set A Size
| Set A Size | A Only | B Only | Union Total |
|---|---|---|---|
| 20 | 10 | 20 | 40 |
| 30 | 20 | 20 | 50 |
| 60 | 50 | 20 | 80 |
| 100 | 90 | 20 | 120 |
What each input means
- Set A Size
- Total elements in set A
- Set B Size
- Total elements in set B
- Set C Size (0 for 2-set)
- Total elements in set C (set to 0 for a two-set diagram)
- A ∩ B Overlap
- Number of elements in both A and B
- A ∩ C Overlap
- Number of elements in both A and C (only for 3-set diagrams)
- B ∩ C Overlap
- Number of elements in both B and C (only for 3-set diagrams)
- A ∩ B ∩ C Overlap
- Number of elements in all three sets
How this is calculated
Worked example, using the default values
- Identify Input Parameters4 parametersSet A Size = 40, Set B Size = 30, Set C Size (0 for 2-set) = 0, A ∩ B Overlap = 10 = 7 input(s) provided
- Calculate A Only30 = 30
- Calculate B Only20 = 20
- Calculate Union Total60 = 60
- Calculate C Only0 = 0
- Calculate A ∩ B10 = 10
Engine last updated . Checked against 5 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
Why doesn't Set B affect the A Only region?
In the default two-set mode, A Only is computed as `setA - abOverlap` (line 28) — Set B's size never appears in that line at all. This holds as long as A ∩ B Overlap stays at or below Set B's own size, since the overlap value itself is clamped to `Math.min(setA, setB)` (line 7); if Set B ever drops below the overlap you entered, the clamp reshapes the overlap and A Only changes indirectly.
What triggers the calculator to switch from a 2-set to a 3-set Venn diagram?
A single condition: `const isTwoSet = setC === 0` (line 15). Leaving Set C Size at its default of 0 keeps every calculation in the simpler two-set branch (lines 27-34); typing any value above 0 into Set C Size switches the entire region calculation over to three-set inclusion-exclusion (lines 36-53), bringing A∩C, B∩C, and the triple overlap into play.
Does Union Total respond equally to Set A and Set B?
Not at the defaults — Set A (40) moves Union Total more than Set B (30) does, purely because it's the larger of the two numbers going into the same formula, `setA + setB - abOverlap` (line 34). Nudging the bigger input by 10% produces a bigger absolute swing even though both sets enter the formula with identical coefficients.
Can any region value come out negative if my overlap numbers don't make sense?
No — every three-set region is passed through `Math.max(0, …)` after the inclusion-exclusion arithmetic (lines 46-51), so an impossible combination of overlaps (for example, an A∩B∩C Overlap larger than what the pairwise overlaps allow) floors at 0 rather than displaying a negative count, though the underlying inputs may still not describe a geometrically valid Venn diagram.
Related Calculators
The questions that sit next to this one — chosen by subject, including calculators filed under a different category.
Set Theory Calculator
Calculate union, intersection, difference, symmetric difference, and complements for two sets with similarity metrics.
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.