WOLFRAM|DEMONSTRATIONS PROJECT

Rule of Sum and the Inclusion-Exclusion Principle

​
A
B
start
2
start
1
end
18
end
18
step
2
step
2
name
set
number
A
{2,4,6,8,10,12,14,16,18}
9
B
{1,3,5,7,9,11,13,15,17}
9
A⋃B
{1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18}
18
A⋂B
{}
0
n(A⋃B) = n(A) + n(B)
-
n
(
A
⋂
B
)
18 = 9 + 9
- 0
If there are
n(A)
ways of getting a result
A
and
n(B)
ways to get a result
B
, then the number of ways of getting
A
or
B
is
n(A)+n(B)
, as long as the results
A
and
B
do not overlap.
To get the right number when there is overlap, think of the possible results
A
and
B
as sets. Then the number of ways to get an element from
A
or
B
is
n(A⋃B)=n(A)+n(B)-n(A⋂B)
. This is called the principle of inclusion-exclusion.