Venn Diagram Calculator

Enter the size of set A, set B, and their overlap to find the union, the intersection, and the "only A" and "only B" regions of a two-set Venn diagram.

Quick Facts

Formula
|A ∪ B| = |A| + |B| − |A ∩ B|
Inclusion–exclusion: the overlap is subtracted so shared elements are counted once.

Your Results

Calculated
Union — |A ∪ B|
-
Elements in A or B (or both)
Only A
-
In A but not B
Only B
-
In B but not A
Intersection — |A ∩ B|
-
In both A and B

Ready

Enter set sizes and the overlap, then calculate.

How the two-set Venn diagram calculator works

A Venn diagram of two sets is drawn as two overlapping circles. Circle A holds every element of set A, circle B holds every element of set B, and the lens where they overlap holds the elements that belong to both. This calculator takes the size of set A, the size of set B, and the size of their overlap, then works out the four quantities people usually want: the union, the "only A" region, the "only B" region, and the intersection itself.

The inclusion–exclusion formula

The core identity is the two-set inclusion–exclusion principle:

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

The union (elements in A or B or both) is not simply |A| + |B|, because the elements sitting in the overlap would be counted once in |A| and again in |B|. Subtracting the intersection |A ∩ B| removes that double count. From the same three inputs the individual regions follow directly:

  • Only A (in A but not B) = |A| − |A ∩ B|
  • Only B (in B but not A) = |B| − |A ∩ B|
  • Both (the overlap) = |A ∩ B|, the value you entered

These three disjoint regions always add back up to the union: (|A| − |A ∩ B|) + |A ∩ B| + (|B| − |A ∩ B|) = |A| + |B| − |A ∩ B|.

A worked example

Suppose 30 students take Chemistry (set A) and 25 take Physics (set B), and 10 of them take both. The union is 30 + 25 − 10 = 45 students taking at least one of the two subjects. Only Chemistry is 30 − 10 = 20, only Physics is 25 − 10 = 15, and the overlap is 10. Check: 20 + 10 + 15 = 45, which matches the union.

Why the overlap can never exceed either set

Every element in the overlap belongs to both A and B, so the overlap is a subset of each circle. That means |A ∩ B| ≤ |A| and |A ∩ B| ≤ |B| at the same time — the intersection can be at most the size of the smaller set. If someone tells you 30 people like tea, 25 like coffee, and 40 like both, the numbers are inconsistent: "both" cannot outnumber either single group. The calculator rejects that case rather than returning a negative "only A" region.

Common reference points

  • Disjoint (mutually exclusive) sets: overlap = 0, so the union is simply |A| + |B| and the circles touch at most at an edge.
  • One set inside the other: if |A ∩ B| = |A|, then set A is entirely contained in B, "only A" = 0, and the union equals |B|.
  • Identical sets: if |A| = |B| = |A ∩ B|, both circles coincide and the union equals either set.

Frequently Asked Questions

What is the formula for a two-set Venn diagram?
The inclusion–exclusion principle: |A ∪ B| = |A| + |B| − |A ∩ B|. The union equals the size of A plus the size of B minus their overlap, since elements in both would otherwise be counted twice. The individual regions are: only A = |A| − |A ∩ B|, only B = |B| − |A ∩ B|, and the overlap = |A ∩ B|.
Can the intersection be larger than one of the sets?
No. The overlap |A ∩ B| can never exceed the smaller of |A| and |B|, because every shared element must belong to both sets. If your "both" value is larger than either set size, one of the three numbers is wrong, and this calculator flags it as an invalid input.
What does the union tell me?
The union |A ∪ B| is the number of distinct elements that are in A, in B, or in both — counted once each. It answers questions like "how many people are in at least one of these groups?" It is always less than or equal to |A| + |B|, with equality only when the sets do not overlap.
Does this calculator work for three sets?
This tool covers the two-set case. For three sets the inclusion–exclusion principle extends to |A ∪ B ∪ C| = |A| + |B| + |C| − |A ∩ B| − |A ∩ C| − |B ∩ C| + |A ∩ B ∩ C|, which needs the three pairwise overlaps and the triple overlap as extra inputs.