Inclusion–Exclusion
Applications
Master the art of counting without overcounting. Learn how to combine sets, subtract overlaps, and solve real problems using the inclusion–exclusion principle.
What is Inclusion–Exclusion?
When we count elements that belong to at least one of several sets, simply adding the set sizes together overcounts elements that appear in more than one set. The inclusion–exclusion principle is a systematic way to correct for this overcounting.
The Overcounting Problem
Why Overlaps Matter
The Two-Set Formula
The Three-Set Formula
The General Formula
For \(n\) sets, sum over all possible non-empty subsets of the collection. Subsets of odd size are added, subsets of even size are subtracted.
Inclusion–Exclusion vs. Addition Rule
| Inclusion–Exclusion | Simple Addition | |
|---|---|---|
| When to use | Sets may overlap | Sets are disjoint |
| Formula (\(n=2\)) | \(|A|+|B|-|A\cap B|\) | \(|A|+|B|\) |
| Overlap term | Must subtract | Zero (not needed) |
| Risk if misused | Undercount if you forget higher overlaps | Overcount if sets share elements |
Step-by-Step Method
Example 1: Survey Problem
In a class of 40 students: 25 study math, 20 study physics, and 10 study both. How many study at least one subject?
Example 2: Divisibility
How many integers from 1 to 100 are divisible by 2, 3, or 5?
Example 3: Complement Counting
A common technique: count what you don't want and subtract from the total. How many surjections (onto functions) from a 4-element set to a 3-element set?
Application: Euler's Totient \(\phi(n)\)
\(\phi(n)\) counts integers from 1 to \(n\) that are coprime to \(n\). Inclusion–exclusion gives us the formula directly. Find \(\phi(30)\):
Application: Derangements \(D_n\)
A derangement is a permutation where no element stays in its original position. Let \(A_i\) = permutations where element \(i\) is fixed. By inclusion–exclusion:
Common Mistakes to Avoid
Summary Table
| Sets | Formula | Terms |
|---|---|---|
| \(n = 2\) | \(|A|+|B|-|A \cap B|\) | 3 |
| \(n = 3\) | \(+\text{singles}-\text{pairs}+\text{triple}\) | 7 |
| \(n = 4\) | \(+\text{singles}-\text{pairs}+\text{triples}-\text{quad}\) | 15 |
| General \(n\) | Alternating sum over all subsets | \(2^n - 1\) |
Question 1 of 5
In a group of 100 people, 60 like coffee, 45 like tea, and 20 like both. How many like at least one of the two?
Question 2 of 5
How many integers from 1 to 60 are divisible by 2 or 3?
Question 3 of 5
For three sets where \(|A|=10\), \(|B|=12\), \(|C|=8\), \(|A \cap B|=4\), \(|A \cap C|=3\), \(|B \cap C|=2\), and \(|A \cap B \cap C|=1\), what is \(|A \cup B \cup C|\)?
Question 4 of 5
In the inclusion–exclusion formula for \(n\) sets, what sign is applied to terms involving intersections of exactly 4 sets?
Question 5 of 5
What is the number of derangements of 4 elements, \(D_4\)?