# Solving Some Recurrence Equations

We consider the following four types of equations:

1. T(n) = T(n – 1) + f(n), T(1) = f(1)
2. T(n) = a * T(n – 1) + f(n), T(1) = f(1)
3. T(n) = T(n / b) + f(n), T(1) = f(1)
4. T(n) = a * T(n / b) + f(n), T(1) = f(1)

The first type of equation is solved using telescoping technique:

T(n)      = T(n – 1)                                            + f(n)

T(n–1)  =          T(n – 2)                                    + f(n – 1)

T(n-2)  =                      T(n – 3)                        + f(n – 2)

T(2)     =                                              T(1)     + f(2)

Summing up all the equations and noticing that we will get terms T(n – 1), T(n – 2), …, T(2) on both sides and therefore they can be cancelled, we obtain:

T(n) = f(n) + f(n – 1) + f(n – 2) + … + f(2) + T(1) = Sf(i), i runs from 1 to n

The second type of equation is reduced to the first type using range transformation technique:

T(n) = a * T(n – 1) + f(n), T(1) = f(1)

Multiplying both sides of equation by a-n, we get:

a-n * T(n) = a * a-n * T(n – 1) + a-n * f(n)

a-n * T(n) = a-(n-1) * T(n – 1) + a-n * f(n)

Let us denote R(n) = a-n * T(n), then a-(n-1) * T(n – 1) = R(n – 1)

R(n) = R(n – 1) + a-n * f(n), R(1) = a-1 * T(1) = T(1) / a = f(1) / a

Now we can solve for R(n) using telescoping technique and then we would get the answer for T(n) using the formula T(n) = an * R(n)

The third type of equation is reduced to the first type using domain transformation technique:

T(n) = T(n / b) + f(n), T(1) = f(1)

To be able to continuously divide by b, we assume that n is a perfect power of b, i.e. n = bk

n / b = bk / b = bk-1

T(bk) = T(bk-1) + f(bk), T(b0) = f(1)

Let us denote R(k) = T(bk), then we get:

R(k) = R(k – 1) + g(k), R(0) = f(1), where g(k) = f(bk)

Now we can solve for R(k) using telescoping technique and then we would get the answer for T(n) by using logbn instead of k.

The fourth type of equation is solved by applying combination of domain and range transformations. It is imperative that at first domain transformation is made and only then the range one.