Skip to main content
Calcimator

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

C Only0
A ∩ B (excl. C)10
A ∩ C (excl. B)0
B ∩ C (excl. A)0
A ∩ B ∩ C0
How to Use This Calculator
  1. Enter the total population or universe size.
  2. Input the size of Set A, Set B, and their intersection.
  3. Review the exclusive regions: A only, B only, both A and B, and neither.
  4. Calculate percentages of the universe in each region for proportion analysis.
  5. Use the output to solve inclusion-exclusion problems in probability and combinatorics.

How the result changes with Set A Size

Set A SizeA OnlyB OnlyUnion Total
20102040
30202050
60502080
1009020120

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

  1. Identify Input Parameters
    4 parameters
    Set A Size = 40, Set B Size = 30, Set C Size (0 for 2-set) = 0, A ∩ B Overlap = 10 = 7 input(s) provided
  2. Calculate A Only
    30 = 30
  3. Calculate B Only
    20 = 20
  4. Calculate Union Total
    60 = 60
  5. Calculate C Only
    0 = 0
  6. Calculate A ∩ B
    10 = 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.

The questions that sit next to this one — chosen by subject, including calculators filed under a different category.

More in Math & Statistics.