Sub topic 9
The Three-Set Inclusion-Exclusion Formula
Prerequisites and the working model
Assume you can read set notation, calculate intersections from a Venn diagram, and solve simple arithmetic expressions. Let A, B, and C be three sets inside the same universal set. The union contains every element in at least one set. The intersection contains elements common to the named sets.
For three sets, the inclusion-exclusion formula is:
n(A ∪ B ∪ C) = n(A) + n(B) + n(C) − n(A ∩ B) − n(B ∩ C) − n(A ∩ C) + n(A ∩ B ∩ C)
This formula counts the union without counting any element more than once.
Why the signs change
Begin by adding the sizes of all three sets. An element in exactly two sets is counted twice, so subtract the three pairwise intersections.
An element in all three sets was counted three times at the start. It was then subtracted once for each of the three pairwise intersections. Its current count is therefore zero. Add the three-way intersection once to restore it to a count of one.
The pairwise intersections in this formula include the three-way intersection. They mean “in both sets,” even if the element is also in the third set.
Worked example
Suppose:
- n(A) = 30
- n(B) = 25
- n(C) = 20
- n(A ∩ B) = 10
- n(B ∩ C) = 8
- n(A ∩ C) = 6
- n(A ∩ B ∩ C) = 4
Substitute the values:
n(A ∪ B ∪ C) = 30 + 25 + 20 − 10 − 8 − 6 + 4
n(A ∪ B ∪ C) = 55
Therefore, 55 elements belong to at least one of the three sets.
The calculation can be checked in stages:
| Part of the calculation | Value |
|---|---|
| Sum of individual sets | 75 |
| Sum of pairwise intersections | 24 |
| Add the three-way intersection | 4 |
| Union | 55 |
n_a, n_b, n_c = 30, 25, 20
n_ab, n_bc, n_ac = 10, 8, 6
n_abc = 4
union = n_a + n_b + n_c - n_ab - n_bc - n_ac + n_abc
print(union) # 55Common errors and checks
Do not subtract the three-way intersection permanently. It must be added at the end.
Do not use pairwise values that mean “exactly two.” If a question gives exactly-two counts, convert them first. For example, the exactly-A-and-B region is n(A ∩ B) − n(A ∩ B ∩ C).
The result cannot exceed the sum of the individual set sizes. It also cannot be smaller than any individual set size. If the universal set has N elements, the union cannot exceed N.
Exercise
If n(A) = 40, n(B) = 35, n(C) = 25, n(A ∩ B) = 12, n(B ∩ C) = 9, n(A ∩ C) = 7, and n(A ∩ B ∩ C) = 3, find n(A ∪ B ∪ C).
Show answer
40 + 35 + 25 − 12 − 9 − 7 + 3 = 75.