Inclusion–Exclusion
Principle
Master the art of counting without double-counting. Learn how overlapping sets combine and why simply adding sizes gives the wrong answer.
Why Counting Gets Tricky
Imagine a class of 30 students. 18 play basketball, 15 play soccer, and 8 play both. How many play at least one sport? If you add \(18 + 15 = 33\), you get more than 30: the 8 students who play both were counted twice.
Sets and Their Sizes
Visualizing the Overlap
The Two-Set Formula
For any two finite sets \(A\) and \(B\):
We include each set's size, then exclude the intersection we double-counted: hence the name inclusion–exclusion.
Extending to Three Sets
We add back \(|A \cap B \cap C|\) because it was subtracted too many times in the pairwise step.
The General Pattern
In words: add singles, subtract pairs, add triples, subtract quadruples, and so on, alternating signs. Each term accounts for an over- or under-count from the previous level.
Union vs. Sum
| Union \(|A \cup B|\) | Simple Sum \(|A| + |B|\) | |
|---|---|---|
| Counts overlap | Once | Twice |
| Result when disjoint | \(|A| + |B|\) | \(|A| + |B|\) |
| Result with overlap | \(|A| + |B| - |A \cap B|\) | Over-counts by \(|A \cap B|\) |
| When are they equal? | Only when \(A \cap B = \emptyset\) (disjoint sets) | |
How to Apply It
Example 1: Two-Set Basics
In a group of 50 students, 30 study French and 25 study Spanish. 10 study both. How many study at least one language?
Example 2: Three-Set Problem
Of 100 people surveyed: 55 like tea, 45 like coffee, 40 like juice. Pairwise overlaps: 20 like tea and coffee, 15 like tea and juice, 10 like coffee and juice. 5 like all three. How many like at least one drink?
Everyone likes at least one drink. The alternating sum accounts perfectly for every overlap level.
Example 3: Complementary Counting
How many integers from 1 to 100 are divisible by 2, 3, or 5?
The Complement Trick
Sometimes it is easier to count what you do not want:
Real-World Applications
Common Mistakes
Quick Reference Table
| Sets | Formula | Terms |
|---|---|---|
| 2 sets | \(|A| + |B| - |A \cap B|\) | 3 |
| 3 sets | \(\sum|A_i| - \sum|A_i \cap A_j| + |A \cap B \cap C|\) | 7 |
| \(n\) sets | \(\displaystyle\sum_{k=1}^{n}(-1)^{k+1}\sum_{|S|=k}\left|\bigcap_{i\in S}A_i\right|\) | \(2^n - 1\) |
Question 1 of 5
In a class of 40 students, 22 play tennis and 18 play volleyball. 8 play both. How many play at least one sport?
Question 2 of 5
For three sets, after adding \(|A| + |B| + |C|\) and subtracting all pairwise intersections, what must you do with \(|A \cap B \cap C|\)?
Question 3 of 5
How many integers from 1 to 60 are divisible by either 3 or 5?
Question 4 of 5
If \(|A| = 15\), \(|B| = 12\), and \(|A \cup B| = 20\), what is \(|A \cap B|\)?
Question 5 of 5
For \(n\) sets, how many terms appear in the full inclusion–exclusion formula?