Exponential Generating Functions
Master EGFs for labeled structures, derangements, and exponential series.
Introduction
When objects are labeled (distinguishable), Ordinary GFs fail us. Exponential Generating Functions (EGFs) handle permutations and labeled structures by dividing by factorials.
Learning Objectives:
- Understand when to use EGFs vs OGFs
- Work with exponential series
- Apply EGFs to derangements and labeled problems
Exponential Generating Functions
For sequence , the EGF is:
Key difference from OGF: coefficients are instead of .
Why EGFs?
Labeled objects: When arranging labeled items, there are permutations. EGFs automatically handle this by incorporating factorials.
Example: Permutations of objects ()
The EGF is simple despite growing rapidly!
import math
def egf_coefficient(a_n, n):
"""Extract coefficient from EGF: a_n / n!"""
return a_n / math.factorial(n)
# Permutations: a_n = n!
print("EGF for permutations (a_n = n!):")
print("\nCoefficients a_n / n!:")
for n in range(6):
a_n = math.factorial(n)
coef = egf_coefficient(a_n, n)
print(f" n={n}: {a_n} / {math.factorial(n)} = {coef}")
print("\nSum equals 1/(1-x) for |x| < 1")Derangements
Application: Derangements
A derangement is a permutation where no element stays in its original position.
EGF for derangements:
Number of derangements of objects:
Formula:
import math
def derangements(n):
"""Count derangements using inclusion-exclusion"""
result = 0
for k in range(n + 1):
result += ((-1) ** k) * math.factorial(n) // math.factorial(k)
return result
print("Derangements D_n:")
for n in range(1, 11):
d_n = derangements(n)
perm = math.factorial(n)
ratio = d_n / perm
print(f" D_{n} = {d_n:>7,} / {perm:>9,} = {ratio:.6f}")
print(f"\nAs nโโ, ratio approaches 1/e โ {1/math.e:.6f}")Key Takeaways
- EGF: Use for labeled structures,
- vs OGF: OGFs for unlabeled, EGFs for labeled
- Derangements: ,
- Exponential series:
Next Module: Recurrence Relations and how to solve them!