Linear recurrences relation

34 Views Asked by At

These are from my textbook examples, introduced as Theorem 1,

If $T(n)=rT(n-1)+a,$ $T(0)=b$ and $r\ne 1$,

$T(n)=r^nb+\left[\frac{a(1-r^n)}{(1-r)}\right]$

And I supposed to solve other recurrence problems applying the Theorem 1

But I don't understand how they reached to that point - I don't get the point where they had $\left[\frac{(1-r^n)}{(1-r)}\right]$ value.

1

There are 1 best solutions below

3
On

Notice that

$$\frac{1-r^n}{1-r} = \sum_{k=0}^{n-1} r^k$$

Then it's easy to see that :

$$T(1) = rT(0)+a$$

$$T(2) = r(rT(0)+a)+a = r^2T(0) + a(1 + r)$$

$$T(3) = r(r^2T(0) + a(1 + r)) + a = r^3T(0) + a(1 + r + r^2)$$

So you get by induction

$$T(n) = r^nT(0) + a(1 + r + r^2 + \cdots + r^{n-1})$$

$$T(n) = r^nT(0) + a\frac{1-r^n}{1-r}$$