Inclusion-Exclusion Principle Calculator

Choose two or three sets and enter the sizes of the sets and their overlaps.

How many elements A has.

How many elements B has.

The size of the overlap of A and B.

Try

Result

You entered∣A∣=20, ∣B∣=30, ∣A∩B∣=10|A| = 20,\ |B| = 30,\ |A \cap B| = 10

40\displaystyle 40

Only in A

10\displaystyle 10

Only in B

20\displaystyle 20

In both

10\displaystyle 10
Show the work
  1. Inclusion–exclusion for two sets

    Adding ∣A∣|A| and ∣B∣|B| counts everything in both sets twice, so take away the size of the overlap once.

    ∣A∪B∣=∣A∣+∣B∣−∣A∩B∣=20+30−10=50−10=40\begin{aligned} |A \cup B| &= |A| + |B| - |A \cap B| \\ &= 20 + 30 - 10 \\ &= 50 - 10 \\ &= 40 \end{aligned}
  2. Result

    So there are 4040 elements in AA or BB or both.

Worked examples