A recurrence relation is an equation that defines a sequence based on previous terms in the sequence.
It expresses the nth term of a sequence as a function of its earlier terms.
Fibonacci Sequence:
aₙ = aₙ₋₁ + aₙ₋₂, with initial conditions a₀ = 0, a₁ = 1.
aₙ = 2aₙ₋₁, a₀ = 3
General Solution: aₙ = 3(2ⁿ)
aₙ = aₙ₋₁ + 2, a₀ = 1
General Solution: aₙ = 2n + 1
Break down recursive calls like a tree to visualize the sequence.
Useful for analyzing recursive algorithms, like mergesort or binary search.
Helps solve recurrence relations for divide-and-conquer algorithms.
T(n) = aT(n/b) + f(n)
Example: Mergesort → T(n) = 2T(n/2) + n ⇒ O(n log n)
Modeling with recurrence relations involves describing a real-world process or problem using recursive formulas. You define how a system evolves over time based on previous states.
Suppose a population grows by a fixed percentage every year, and we start with an initial population.
Recurrence Relation:
Pₙ = Pₙ₋₁ + rPₙ₋₁
Where:
This is a geometric sequence, so we get:
Pₙ = P₀(1 + r)ⁿ
A pair of rabbits produces another pair every month starting from their second month. How many pairs will there be after n months?
Recurrence Relation:
Fₙ = Fₙ₋₁ + Fₙ₋₂
With initial conditions: F₀ = 0, F₁ = 1
This is the famous Fibonacci sequence:
F₀, F₁, F₂, F₃, F₄, F₅... = 0, 1, 1, 2, 3, 5...
Recurrence relations are crucial for analyzing recursive algorithms.
Binary search splits the array in half at each step, so the runtime can be modeled with:
T(n) = T(n/2) + c
Where:
T(n) = O(log n)
Imagine a factory produces widgets, but each widget needs components from the previous batch.
Recurrence Relation:
Wₙ = 2Wₙ₋₁ + 10
Where:
W₀ = 5
W₁ = 2(5) + 10 = 20
W₂ = 2(20) + 10 = 50
General Solution: Wₙ = 5(2ⁿ) + 10(2ⁿ - 1)
Modeling disease spread with recurrence relations:
Recurrence Relation:
Sₙ = Sₙ₋₁ - βSₙ₋₁Iₙ₋₁
Iₙ = Iₙ₋₁ + βSₙ₋₁Iₙ₋₁ - γIₙ₋₁
Rₙ = Rₙ₋₁ + γIₙ₋₁
Where:
This creates a recursive model for predicting the spread of disease over time.
A homogeneous linear recurrence relation expresses each term as a linear combination of previous terms, with constant coefficients, and without any external (non-recursive) terms.
General Form:
aₙ = c₁aₙ₋₁ + c₂aₙ₋₂ + ... + cₖaₙ₋ₖ
Where:
Example: aₙ = 3aₙ₋₁ - 2aₙ₋₂
Initial conditions: a₀ = 2, a₁ = 3
Replace aₙ with rⁿ:
r² - 3r + 2 = 0
Factor the equation:
(r - 1)(r - 2) = 0
Roots: r = 1, r = 2
aₙ = A(1)ⁿ + B(2)ⁿ
Substitute the initial values:
Solve the system of equations:
Solution:
aₙ = (1)(1)ⁿ + (1)(2)ⁿ
aₙ = 1 + 2ⁿ
Example: aₙ = 4aₙ₋₁ - 5aₙ₋₂ + aₙ₋₃
Initial conditions: a₀ = 1, a₁ = 2, a₂ = 4
r³ - 4r² + 5r - 1 = 0
Let’s say the roots are r₁, r₂, r₃ (you can solve using factorization or trial roots).
Suppose roots: r = 1, 1, 2
aₙ = (A + Bn)(1)ⁿ + C(2)ⁿ
(The repeated root introduces the n term.)
Plug in initial conditions to find A, B, and C.
A non-homogeneous recurrence relation is a relation where the right-hand side is not zero — it includes an external function (forcing term).
General Form:
aₙ - c₁aₙ₋₁ - c₂aₙ₋₂ - ... - cₖaₙ₋ₖ = f(n)
Or using the shift operator (E):
F(E)aₙ = f(n)
Where:
Example: aₙ - 3aₙ₋₁ = 2ⁿ
Initial condition: a₀ = 1
aₙ - 3aₙ₋₁ = 0 → Characteristic equation: r - 3 = 0
Root: r = 3
Complementary solution: aₙᶜ = A(3)ⁿ
f(n) = 2ⁿ, so use the inverse operator:
aₙᵖ = (1 / (1 - 3E⁻¹))(2ⁿ)
Substitute E(2ⁿ) = 2 × 2ⁿ:
aₙᵖ = (1 / (1 - 3/2))(2ⁿ)
aₙᵖ = (1 / (-1/2))(2ⁿ)
aₙᵖ = -2(2ⁿ)
aₙ = aₙᶜ + aₙᵖ
aₙ = A(3)ⁿ - 2(2ⁿ)
a₀ = 1 → A(3)⁰ - 2(2)⁰ = 1
A - 2 = 1 → A = 3
aₙ = 3(3)ⁿ - 2(2ⁿ)
Example: aₙ - 2aₙ₋₁ + aₙ₋₂ = n
Characteristic equation: r² - 2r + 1 = 0
(r - 1)² = 0 → Double root r = 1
Complementary solution: aₙᶜ = (A + Bn)(1)ⁿ
f(n) = n, so try a polynomial solution:
aₙᵖ = Cn² + Dn + E
Substitute into the recurrence relation and equate coefficients to solve for C, D, and E.
aₙ = (A + Bn)(1)ⁿ + aₙᵖ
A generating function is a way to encode a sequence as a power series. It helps turn recurrence relations into algebraic equations, which we can solve and then extract the sequence from.
The generating function of a sequence {aₙ} is:
G(x) = a₀ + a₁x + a₂x² + a₃x³ + ... = ∑ aₙxⁿ
Example: aₙ - aₙ₋₁ = 1 (for n ≥ 1), with a₀ = 2
G(x) = ∑ aₙxⁿ
aₙ = aₙ₋₁ + 1 → Shift the index:
∑ aₙxⁿ = ∑ aₙ₋₁xⁿ + ∑ xⁿ
G(x) = xG(x) + ∑ xⁿ
G(x) - xG(x) = ∑ xⁿ = (1 / (1 - x))
G(x)(1 - x) = (1 / (1 - x)) + 2
G(x) = (1 / (1 - x)²) + (2 / (1 - x))
G(x) = ∑ (n + 1)xⁿ + 2∑ xⁿ
aₙ = n + 1 + 2 = n + 3
aₙ = n + 3
Example: aₙ - 3aₙ₋₁ + 2aₙ₋₂ = 0, with a₀ = 1, a₁ = 2
G(x) = ∑ aₙxⁿ
aₙ - 3aₙ₋₁ + 2aₙ₋₂ = 0 → Translate using G(x):
G(x) - 3xG(x) + 2x²G(x) = a₀ + (a₁ - 3a₀x)
G(x)(1 - 3x + 2x²) = 1 + 2x
G(x) = (1 + 2x) / (1 - 3x + 2x²)
Factor the denominator:
G(x) = (1 + 2x) / ((1 - x)(1 - 2x))
Use partial fraction decomposition:
G(x) = A / (1 - x) + B / (1 - 2x)
Solve for A and B:
A = 1, B = 1
G(x) = ∑ xⁿ + ∑ 2ⁿxⁿ
aₙ = 1 + 2ⁿ
aₙ = 1 + 2ⁿ