Venn Diagram Calculator: Inclusion-Exclusion for Two or Three Sets

Work out how many are in each region of a two or three set Venn diagram, and how many are in none, from the set sizes and overlaps.

Calculated from standard textbook formulas, with every step shown. The formulas are fixed, so the working does not need checking: what matters is the numbers you type in. Use these calculators only if you are competent to choose the inputs (loads, material strength, dimensions, supports) and check your units and assumptions. For learning and checking your own working: design and sign-off are for a qualified engineer. Drafting Central does not store the numbers you type.

How this calculator works

Enter the size of each set, the size of each overlap (counting those also in the third set) and the number in all three. The calculator uses inclusion-exclusion to find the total in at least one set, then splits it into the seven regions of the Venn diagram.

If you also give the total number under consideration, it finds how many are in none of the sets. If the numbers cannot all be true, for example an overlap bigger than a set, it tells you which region comes out negative.

For just two sets, leave set C and the overlaps with C at 0. It suits survey and quality problems, such as how many people hold two licences, or how many parts fail one, two or three tests.

Formulas used

  • |A\cup B| = |A| + |B| - |A\cap B|
  • |A\cup B\cup C| = |A|+|B|+|C| - |A\cap B| - |A\cap C| - |B\cap C| + |A\cap B\cap C|

Worked example

With the default numbers in the calculator above:

  1. Total in at least one set (inclusion-exclusion): 55
  2. Only in A: 16
  3. Only in B: 13
  4. Only in C: 10
  5. In A and B but not C: 6
  6. In A and C but not B: 4
  7. In B and C but not A: 2
  8. In all three sets: 4
  9. In none of the sets: 5

Change the numbers in the calculator to see the full working, every step, for your own case.

A second worked example

A different case, with these numbers: Size of set C (0 if only two sets) 0; In both A and C (including those also in B) 0; In both B and C (including those also in A) 0; In all three sets 0.

  1. Total in at least one set (inclusion-exclusion): 45
  2. Only in A: 20
  3. Only in B: 15
  4. Only in C: 0
  5. In A and B but not C: 10
  6. In A and C but not B: 0
  7. In B and C but not A: 0
  8. In all three sets: 0
  9. In none of the sets: 15

Common questions

Do the overlaps include the middle region?

Yes. Enter the full size of each two-set overlap, including the items that are also in the third set. The calculator takes the middle out for the "only" regions.

What if a region comes out negative?

The numbers cannot all be right. Check the overlaps: an overlap cannot be bigger than either set it is part of.

Can it do four sets?

No. This tool covers two or three sets.

Related calculators

Got a question about this? Ask an engineering question and get a plain-language answer with references.

Further reading: Any discrete mathematics text (the principle of inclusion-exclusion).

Need a calculator we do not have?

Tell us what you would like to calculate. We read every request and build the most asked-for ones.

We store your request (and your email if you give it) to decide what to build. We do not store the numbers you type into calculators.

Embed this calculator on your own page

Copy this code into your page. The calculator runs inside the frame and links back to Drafting Central.

Need this drawn, designed or checked?

Drafting Central is a mechanical engineering and drafting business working with customers across Australia and around the world. A calculator gives you the numbers; we can turn them into drawings and designs.

Need help with a real project?

Talk to Drafting Central →

← All engineering calculators