The Sum Rule and Basic Permutations
Learn when to add vs multiply in counting, understand permutations and factorial notation.
Introduction
In Lesson 1, we learned to multiply choices for sequential stages. But what if we have multiple disjoint scenarios? That's where the Rule of Sum comes in. We'll also introduce permutations - ordered arrangements of objects.
Learning Objectives:
- Master the Rule of Sum (Addition Principle)
- Understand when to add vs multiply in counting problems
- Define and calculate permutations
- Compute factorials and apply them to arrangement problems
The Rule of Sum
If a task can be done in one of several mutually exclusive ways:
- Way 1: possibilities
- Way 2: possibilities
- ...
- Way : possibilities
Then the total number of ways is:
Key requirement: The ways must be disjoint (mutually exclusive) - no outcome can be counted in multiple ways.
Example 1: Travel Options
You can travel from City A to City B by:
- Bus: 5 different bus routes
- Train: 3 different train routes
- Flight: 2 different flights
How many total ways to travel from A to B?
Solution: The methods are mutually exclusive (you choose one):
You add because you're choosing one option from disjoint sets.
Add vs Multiply:
- Add when choosing one option from disjoint scenarios
- Multiply when making sequential choices at independent stages
Combining Rules
Most problems require both rules. The key is identifying the structure:
Example 2: Menu Selection
A restaurant offers:
- Appetizers: Soup (1 type) or Salad (3 types)
- Entrees: Pasta (4 types) or Steak (2 types)
How many different two-course meals (appetizer + entree)?
Solution:
- Appetizer choices: (Rule of Sum - disjoint)
- Entree choices: (Rule of Sum - disjoint)
- Total meals: (Rule of Product - sequential)
You add within each course (disjoint options), then multiply across courses (sequential stages).
# Restaurant menu
appetizers = {'Soup': 1, 'Salad': 3}
entrees = {'Pasta': 4, 'Steak': 2}
# Total choices at each stage (using Rule of Sum)
total_appetizers = sum(appetizers.values())
total_entrees = sum(entrees.values())
# Total meals (using Rule of Product)
total_meals = total_appetizers * total_entrees
print(f"Appetizer choices: {total_appetizers}")
print(f"Entree choices: {total_entrees}")
print(f"Total meal combinations: {total_meals}")
# Enumerate a few
print(f"\nExample meals:")
print(f" 1. Soup + Pasta (type 1)")
print(f" 2. Soup + Pasta (type 2)")
print(f" 3. Salad (type 1) + Steak (type 1)")
print(f" ... (21 more combinations)")Permutations
A permutation is an ordered arrangement of objects. The number of ways to arrange distinct objects is:
This is read as " factorial."
Special case: (by convention, for mathematical consistency)
Example 3: Arranging Books
You have 5 distinct books. How many ways can you arrange them on a shelf?
Solution:
- Position 1: 5 choices
- Position 2: 4 remaining choices
- Position 3: 3 remaining choices
- Position 4: 2 remaining choices
- Position 5: 1 remaining choice
By the Rule of Product:
import math
# Calculate 5!
n = 5
factorial_n = math.factorial(n)
print(f"{n}! = {factorial_n}")
# Show the calculation step by step
result = 1
steps = []
for i in range(n, 0, -1):
result *= i
steps.append(f"{i}")
print(f"\nCalculation: {' Γ '.join(steps)} = {result}")
# Fun fact: Growth of factorials
print(f"\nFactorial growth:")
for k in range(1, 11):
print(f" {k}! = {math.factorial(k):,}")Exponential Growth: Factorials grow extremely fast! million, quintillion. This is why brute-force enumeration becomes infeasible quickly.
Partial Permutations
What if you only arrange some of the objects?
Example 4: Race Podium
In a race with 10 runners, how many ways can the top 3 finishers be arranged?
Solution: We're arranging 3 out of 10 objects:
- 1st place: 10 choices
- 2nd place: 9 remaining choices
- 3rd place: 8 remaining choices
General formula: Permutations of objects chosen from :
For our example:
import math
def permutations(n, k):
"""Calculate P(n, k) = n! / (n-k)!"""
return math.factorial(n) // math.factorial(n - k)
# Race with 10 runners, top 3 positions
n_runners = 10
k_positions = 3
result = permutations(n_runners, k_positions)
print(f"P({n_runners}, {k_positions}) = {result}")
print(f"\nThere are {result:,} possible podium arrangements")
# Verify with direct calculation
direct = 10 * 9 * 8
print(f"\nDirect calculation: 10 Γ 9 Γ 8 = {direct}")
print(f"Match: {result == direct}")Avoiding Double Counting
A common error: counting the same outcome multiple times.
Example 5: Committee Formation (Wrong Approach)
Select a president and vice president from 5 people. One approach:
Wrong: "Choose president (5 ways), then choose VP (5 ways) = "
Problem: This counts scenarios where the same person is both president and VP!
Correct: "Choose president (5 ways), then choose VP from remaining 4 people = "
Key Insight: When objects are selected without replacement, choices at later stages have fewer options. Always ask: "Does this choice affect future choices?"
Key Takeaways
- Rule of Sum: Add when choosing from disjoint scenarios
- Rule of Product: Multiply for sequential choices
- Factorial:
- Permutation: Ordered arrangement, ways for objects
- Partial permutation: for arranging out of
- Avoid double counting: Account for constraints (e.g., no replacement)
Next Lesson: We'll explore combinations - what if order doesn't matter?
Concept | Formula | Example |
|---|---|---|
| Rule of Sum | $n_1 + n_2 + \cdots + n_k$ | Travel: $5 + 3 + 2 = 10$ options |
| Factorial | $n!$ | $5! = 120$ |
| Permutation (all) | $n!$ | Arrange 5 books: $5! = 120$ |
| Permutation (k of n) | $\frac{n!}{(n-k)!}$ | Top 3 from 10: $\frac{10!}{7!} = 720$ |