Venn Diagram Calculator

Work out union, intersection, complement and symmetric difference for two overlapping sets.
Enter set sizes and the overlap to get every region.

Set Operations Results

The basics

A set is a collection of distinct elements. Venn diagrams show how two or more sets overlap using circles, and they are named for John Venn, who introduced them in England in 1880.

This calculator handles the two-set case. You give it the size of A, the size of B, and how many elements are in both, and it splits the world into the regions those three numbers determine.

The four operations

Take A = {1, 2, 3} and B = {2, 3, 4}.

Operation Symbol Result Size
Union A ∪ B {1, 2, 3, 4} 4
Intersection A ∩ B {2, 3} 2
Difference A − B {1} 1
Symmetric difference A △ B {1, 4} 2

Union is everything in either set. Intersection is only what is in both. Difference A − B is what A has that B does not, and it is the one operation here that is not symmetric: B − A = {4}, a different set. Symmetric difference is everything in exactly one of them, which is the union with the overlap cut out.

Inclusion-exclusion

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

Add the two sizes and you have counted the overlap twice, so you subtract it once. That is the whole idea, and it generalises: for three sets you add the three sizes, subtract the three pairwise overlaps, then add the triple overlap back, because subtracting the three pairs removed it three times having added it three times.

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

The universal set and complements

The universal set U is everything under consideration. Give it and you get complements: |A′| = |U| − |A|, plus the count of elements in neither set, |U| − |A ∪ B|.

U has to be at least as large as the union, since the union is made of things inside U. Enter a smaller number and the arithmetic produces negative counts, which is why this calculator rejects it rather than printing them.

Where this gets used

SQL has the operations built in as UNION, INTERSECT and EXCEPT. Probability runs on the same identity in a different costume: P(A or B) = P(A) + P(B) − P(A and B), and forgetting that final subtraction is the single most common mistake in an introductory probability course.

The everyday use is survey analysis. “180 customers bought coffee, 95 bought pastry, 40 bought both” tells you immediately that 235 people bought something, not 275, and that 55 bought only pastry. Getting that wrong in a report is easy, and the numbers usually look plausible enough that nobody checks.


How we build and check this calculator

This calculator runs entirely in your browser, so the numbers you enter stay on your device. The math behind it is written by hand and tested against worked examples and standard references before the page goes live.

SuperGlobalCalculator is independently built and maintained. See how we build and verify our calculators.


Embed This Calculator

Copy the code below and paste it into your website or blog.
The calculator will work directly on your page.