User:Chris-martin โ public domain · Public Domain · Wikimedia Commons
When you want the probability that at least one of several events happens and the events overlap, just summing $P(A_i)$ double-counts the pairs, triple-counts the triples, and so on. PIE corrects it with alternating signs: add the singles, subtract the pairs, add the triples. We’ll use it on the classic derangement puzzle — the same engine handles “avoid all forbidden patterns” problems.
โ Intro ยท expand
Try first (productive failure)
Before the worked example: spend 60 seconds taking your best shot at this.
A guess is fine โ being briefly wrong about a problem makes the explanation
land harder when you read it. This appears once per tutorial; skip
if you already know the trick.
60s
โ Try first ยท expand
Worked example
Four people throw their hats into a pile, then each picks one hat back uniformly at random. What is the probability that no one gets their own hat โ i.e., the resulting permutation is a derangement?
โ Worked example ยท expand
Practice 1 of 3Type a fraction, decimal, or expression.
โ Practice ยท expand
Reflection
When you read a problem, what cue tells you to reach for inclusion-exclusion rather than (say) the simple complement or a recursion? In your own words, <em>why</em> do the signs alternate — what exactly is each term correcting from the term before it?