Upload
jose-miguel-ochoa
View
217
Download
0
Embed Size (px)
Citation preview
8/13/2019 Solving by Iteration
1/9
Section 2: Solving Recurrence
Relations by Iteration As we noted at the end of the last lecture, when
analyzing recurrence relations, we want to rewrite
the general term as a function of the index andindependent of predecessor terms.
This will allow us to compute any arbitrary term
in the sequence without having to compute all the
previous terms.
In this section, we will look at one method for
solving recurrence relations.
8.2.1
8/13/2019 Solving by Iteration
2/9
The Method of Iteration
Let {ai} be the sequence defined by:ak= ak1+ 2 with a0= 1.
Plugging values of kinto the relation, we get:
a1= a0+ 2 = 1 + 2
a2= a1+ 2 = 1 + 2 + 2 = 1 + 2(2)
a3= a2+ 2 = 1 + 2 + 2 + 2 = 1 + 3(2)
a4= a3+ 2 = 1 + 2 + 2 + 2 + 2 = 1 + 4(2)
Continuing in this fashion reinforces the apparentpattern that an= 1 + n(2) = 1 + 2n.
This brute forcetechnique is theMethod of
Iteration.
8.2.2
8/13/2019 Solving by Iteration
3/9
The Tower of Hanoi
Recall the Tower of Hanoi relation:mk= 2mk1+ 1 with m1= 1.
Plugging values of kinto the relation, we get:
m2= 2m1+ 1 = 2 + 1
m3= 2m2+ 1 = 2(2 + 1) + 1 = 22+ 2 + 1
m4= 2m3+ 1 = 2(22+ 2 + 1) + 1
= 23+ 22+ 2 + 1
m5= 2m4+ 1 = 2(23
+ 22
+ 2 + 1)= 24+ 23+ 22+ 2 + 1.
Thus, weguess: mn= 2n1+ 2n2+...+ 22+ 2 + 1.
This is a Geometric Series, so mn= 2
n
1.
8.2.3
8/13/2019 Solving by Iteration
4/9
Another Example
Let {ai} be the sequence given by:ak= ak1+ k with a0= 0.
Solve this recurrence relation and find a100.
Now, a1= a0+ 1 = 1 + 0a2= a1+ 2 = 2 + 1 + 0
a3= a2+ 3 = 3 + 2 + 1 + 0
a4= a3+ 4 = 4 + 3 + 2 + 1 + 0 Thus an= n+ (n1) + (n2) +...+ 3 + 2 + 1 + 0
so an= n(n+1)/2.
Plugging in n= 100: a100
= 100(101)/2 = 5050.
8.2.4
8/13/2019 Solving by Iteration
5/9
A Geometric Sequence
Let aand bbe non-zero constants, and consider:
sk= ask-1 withs0= b.
Thus: s1= as0= ab
s2= as1= a(ab) = a2b
s3= as2= a(a2b) = a3b
s4= as3= a(a3b) = a4b.
From this, we can make the conjecture that:sn= a
nb.
Note: if b= 1, thensn= an.
8.2.5
8/13/2019 Solving by Iteration
6/9
A Perturbed Geometric Sequence
Let abe non-zero constants, and consider:
sk= ask-1 + 1 withs0= 1.
Thus: s1= as0 + 1 = a+ 1
s2= as1 + 1 = a(a+ 1) + 1 = a2 + a+ 1
s3= as2 + 1 = a(a2 + a+ 1) + 1
= a3 +a2 + a+ 1
s4= as3 + 1 = a(a3 +a2 + a+ 1)= a4+ a3 +a2 + a+ 1.
It appears thatsn= an + an1 +...+a2 + a+ 1, so
sn= (a
n+1
1) / (a
1) .
8.2.6
8/13/2019 Solving by Iteration
7/9
Some Observations
In solving these recurrence relations, we point out
the following observations:
1. Each recurrence relation looks only 1 step back; that is
each relation has been of the formsn= F(sn1);2. We have relied on luckto solve the relation, in that we
have needed to observe a pattern of behavior and
formulated the solution based on the pattern;
3. The initial condition has played a role in making thispattern evident;
4. Generating a formula from the generalization of the
pattern looks back to our study of induction.
8.2.7
8/13/2019 Solving by Iteration
8/9
Verifying Solutions
Once we guess the form of the solution for a
recurrence relation, we need to verify it is, in fact,
the solution.
We use Mathematical Induction to do this. For example, in the Tower of Hanoi game, we
conjecture that the solution is mn= 2n1.
Basis Step: m1= 1 (by playing the game), and211 = 2 1 = 1, therefore m1= 2
11.
Inductive Step: Recall the recurrence relation is
mk= 2mk1+ 1. Assume mk= 2k1.
8.2.8
8/13/2019 Solving by Iteration
9/9
Verifying Solutions (contd.)
Inductive Step: Show mk+1= 2k+11.
Now, mk+1= 2mk+ 1
= 2(2k1) + 1
= 22k2 + 1= 2k+11.
Therefore mk= 2k1 is the solution to
mk= 2mk1+ 1, when m1= 1. QED A similar verification process will work for all
the other formulas we discovered in this section.
8.2.9