**Recurrence Relations**

**How we will
proceed**

##
1.
A definition of recurrence relations.

###
A recurrence
relationship is a **rule** by which a sequence is generated.

##
2.
Given the initial condition and the rule (i.e. the recurrence relations) what
is the sequence?

##
3.
Given the rule and a sequence, is the sequence a solution of the recurrence
relations?

##
Facts
about recurrence relations

##
Modeling
problems with recurrence relations

** **

**Definition of a
recurrence relation**

##
A
recurrence relation for the sequence **{a**_{n}} is an equation that
expresses **a**_{n} in terms of one or more of the previous terms of
the sequence.

###
**a**_{n }is the next term in the sequence

##
The
sequence **{a**_{n}} looks like this: a_{0}, a_{1},
a_{n-1}

###
For all integers n with
n >= n_{0}, where n_{0}
is a nonnegative integer

##
A
sequence is called a **solution of a recurrence relation** if its terms
satisfy the recurrence relation.

** **

**Given the recurrence relation and initial
condition, find the sequence**

## Let **{a**_{n}}
be a sequence that satisfies the recurrence relation

_{
}Rule: **a**_{n} = a _{n-1} a _{n-2}

###
Initial
conditions: **a**_{0}
= 3 and **a**_{1}
= 5

### What is the sequence?

# **Given the rule and a sequence, is the sequence a solution of the recurrence
relations?**

_{
}Rule: **a**_{n} = 2a _{n-1} a _{n-2}

##
Sequence:
**a**_{n} = 3n

## Two ways to solve

### Figure out the sequence, and
see if it satisfies the rule

### the sequence is: **a**_{0}=
0, a_{1}=3, a_{2}=6, a_{3}=9, a_{4 }= 12

### at n = 4: **a**_{4}
?= 2a_{3} a_{2
12 ?=
2(9) - 6}

### Substitute 3n for n in the
rule and simplify

**2a **_{n-1} a _{n-2 }= 2[3(n-1)] 3(n-2)

when simplified, the does indeed = 3a

** **

**Given the rule and a sequence, is
the sequence a solution of the recurrence relations?**

_{
}Rule: **a**_{n} = 2a _{n-1} a _{n-2}

##
Sequence:
**a**_{n} = 2^{n}

##
The
sequence is:

**a**_{0}= 1, a_{1}=2,
a_{2}=4, a_{3}=8, a_{4 }= 16

##

##
Does
this fit the rule?

_{
}At n=4: **a**_{4}
?= 2a_{3} a_{2}

** 16 ?= (2*8) 4**

##
So
a_{n} = 2^{n} is not a
solution

**Facts about
recurrence relations**

## The recurrence relation and
initial conditions uniquely determine a sequence

## **Any term** of the sequence can be
found from the initial conditions using the recurrence relation a sufficient
number of times

## But, for a certain **class
of sequences** defined by a recurrence relation and initial condition there
are better ways to find any term

# Overheads

**Modeling rabbits**

## A young pair of rabbits is
placed on an island. After they are two
months old, each pair of rabbits produces another pair each month. Find a recurrence relation for the number of
pairs of rabbits on the island after 6 months.
After n months. (Assume no
rabbits die.)

**Towers of Hanoi**

##
There
are three pegs and disks of different sizes.

##
The
object is to move all the disks from one peg to another

##
The
Rules

###
One disk is moved at a
time

###
A disk may not be placed
on top of a disk of smaller diameter

##
Let
**H**_{n} denote the number of moves needed to solve with n
disks.

##
Set
up a recurrence relation for the sequence {H_{n}}

**Recurrence
relation for Towers of Hanoi**

## What is the initial
condition H_{1}?

### I.e. how many moves to move
one disk?

## We want to develop a rule to
tell us how many moves it will take to move n disks in terms of moving n-1
disks

** **

**Counting bit strings**

##
Find
a recurrence relation and give initial conditions for the number of bit strings
of length n that do not have two consecutive 0s.

##
a_{1}
= num valid bit strings of length 1

{a_{1}} is 0, 1

##
a_{2} = num valid bit strings of
length 2

{a_{2}} is 01, 10, 11

##
a_{3}
= num valid bit strings of length 3

{a_{3}} is 010, 011, 101, 110, 111

##
By
the sum rule, the total number of bit strings of length n without two
consecutive 0 bits is equal to the **number ending with 0** **plus** **the
number ending with 1**

# What is the sum
rule?

## If a first task can be done
in n_{1} ways and a second task in n_{2} ways, and if these
tasks cannot be done at the same time, then there are n_{1} + n_{2}
ways to do either task

**Using the sum rule**

## Assume n >= 3

## How many strings of length n
are there ending with 1?

### Its all the strings in {a_{n-1}}
with a 1 added

## How many strings of length n
are there ending with a 0?

### Its all the strings in {a_{n-2}}
with a 10 added

## What is {a_{3}}
given {a_{2}} and {a_{1}}?

## What is {a_{4}}?

**How many code words are valid?**

## A decimal digit code word is
**valid** if it contains an even number of 0 digits

## Find a recurrence relation
for **a**_{n}, the number of valid code words of length n

_{
}What is the initial condition (n=1):
**a**_{1}

###
What
is** {a**_{1}}

###
**{a**_{1}} = 1,2,3,4,5,6,7,8,9, so **a**_{1
}= 9

## How can we form valid strings of length **n **using
strings of length **n-1?**

Forming strings of length n

##
Two
ways to form a valid string of n digits from a string of n-1 digits

##
**First way**

###
Append anything but a 0
to a valid string of n-1 digits

###
How many strings does
this give us?

_{
}**9 * a**_{n-1}

##
**Second way**

###
Add a zero to an invalid
string of length (n-1)

###
How many invalid strings
of length (n-1)

####
(Total number
of strings ) (number of valid strings)

**10**^{n-1} - a_{n-1}

^{}Add first way and second way

**9a**_{n-1} + (10^{n-1}
a_{n-1}) or **8a**_{n-1} + 10^{n-1}

**How many cars produced?**

##
A factory makes custom
sports cars at an increasing rate. In
the first month only one car is made,
in the second month two cars are made, and so on, with **n** cars made in
the** nth** month.

##
Set up a recurrence
relation for the number of cars produced **in the first n months** by this
factory.

##
How many cars are
produced in the first year?

##
Find an **explicit
formula** for the number of cars produced in the first **n** months by
this factory.

###
An
explicit formula is one that used the initial condition rather than the
previous term.

##
**Let Cn = the total
number of cars produced in the first n months**

##
Look on page 76 in Rosen
for a table of some useful summation formulae.

**Solving recurrence relations**

##
We will work on **linear
homogeneous** recurrence relations of **degree k** with **constant
coefficients**.

##
Its form is: **a**_{n} = c_{1}a_{n-1}
+ c_{2}a_{n-2} +
+ c_{k}a_{n-k} where c_{1},
c_{2},
c_{k} are real numbers, and c_{k} != 0

##
This is** linear**
since the right hand side is a sum of the multiples of the previous terms

##
It is **homogeneous**
since all the terms are multiples of **a**

##
All of the **coefficients
are constant**, rather than depend on n.

##
The degree is k because
a_{n} is expressed in terms of the **previous k terms** of the
sequence

##

**The degree of a recurrence relation**

##
P_{n}
= (11.1)P_{n-1} is degree one

##
f_{n}
= f_{n-1} + f_{n-2} is degree two

##
what
is this? C_{n} = C_{n-5}?

##
The
basic approach to solving these type of problems is to look for solutions of
the form **a**_{n} = r^{n}

# Linear homogeneous
recurrence relations of degree 2

_{
}Let c_{1} and c_{2} be real numbers. Suppose that

**r**^{2} c_{1}r c_{2}
has two distinct roots r_{1} and r_{2}

##
Then
the sequence {a_{n}} is a solution of the recurrence relation a_{n}
= c_{1}a _{n-1} + c_{2}a _{n-2} if and only if
a_{n} = "_{1 }r_{1}^{n} + "_{2 }r_{2}^{n} for n = 0, 1,2,
where "_{1 }and_{ }"_{2 }are constants.

##
Look
at a real problem:

### What is the solution of the recurrence relation:

**a**_{n}
= a _{n-1} + 2a _{n-2} with **a**_{0} = 2 and **a**_{1}
= 7

**Solving linear homogeneous recurrence
relations of degree 2**

_{ }First, get the constants C_{1}
and C_{2}

## Next, write the
characteristic equation

## Then find the roots

##
Find "_{1 }and_{ }"_{2 }, usually by_{ }solving
simultaneous equations and using initial conditions

#

#