mixed recursion: sec. 8.4

22
Mixed Recursion: Sec. 8.4 Exercise 3. The closed-form formula for the Towers of Hanoi problem, M n = 2 n – 1, can be proved by mathematical induction. You might be wondering at this point, “What’s mathematical induction?” I’m so glad you asked!

Upload: fritz-dale

Post on 04-Jan-2016

30 views

Category:

Documents


1 download

DESCRIPTION

Mixed Recursion: Sec. 8.4. Exercise 3. The closed-form formula for the Towers of Hanoi problem, M n = 2 n – 1, can be proved by mathematical induction. You might be wondering at this point, “What’s mathematical induction?” I’m so glad you asked!. Mixed Recursion: Sec. 8.4. - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Mixed Recursion: Sec. 8.4

Mixed Recursion: Sec. 8.4

Exercise 3. The closed-form formula for the Towers of Hanoi problem, Mn = 2n – 1, can be proved by mathematical induction.

You might be wondering at this point, “What’s mathematical induction?”

I’m so glad you asked!

Page 2: Mixed Recursion: Sec. 8.4

Mixed Recursion: Sec. 8.4

Mathematical Induction

Mathematical induction is a technique often used for proving formulas that involve counting numbers (1, 2, 3, …).

This technique requires two steps.

Page 3: Mixed Recursion: Sec. 8.4

Mixed Recursion: Sec. 8.4

Mathematical Induction

Step 1: Prove that the formula works for a specific case—typically for the number 1.

Step 2: Assume the formula works for some number, k. Based on that assumption, show that it also works for k + 1.

Page 4: Mixed Recursion: Sec. 8.4

Mixed Recursion: Sec. 8.4

Mathematical Induction

If you can show that the formula works for a specific case, and that if it works for one natural number it will work for the next natural number, then you have proven that the formula will work for all natural numbers.

Page 5: Mixed Recursion: Sec. 8.4

Mixed Recursion: Sec. 8.4

Exercise 3. The closed-form formula for the Towers of Hanoi problem, Mn = 2n – 1, can be proved by mathematical induction.

a. What initial step is necessary?

First we must show that the formula works for a specific case, such as for n = 1.

M1 = 21 – 1 = 2 – 1 = 1

This tells us that having one disc should require one move, which is true.

Page 6: Mixed Recursion: Sec. 8.4

Mixed Recursion: Sec. 8.4

Exercise 3. The closed-form formula for the Towers of Hanoi problem, Mn = 2n – 1, can be proved by mathematical induction.

b. The proof assumes that the formula works for a puzzle with k disks and then attempts to prove the formula must also work for a puzzle with k + 1 disks. Rewrite the assumption and goal of the induction proof in terms of the formula.

Page 7: Mixed Recursion: Sec. 8.4

Mixed Recursion: Sec. 8.4

Exercise 3. The closed-form formula for the Towers of Hanoi problem, Mn = 2n – 1, can be proved by mathematical induction.

b. Write the assumption and the goal.

Assumption: Mk = 2k – 1

Goal: Mk+1 = 2k+1 – 1

Page 8: Mixed Recursion: Sec. 8.4

Mixed Recursion: Sec. 8.4

Exercise 3. The closed-form formula for the Towers of Hanoi problem, Mn = 2n – 1, can be proved by mathematical induction.

c. Show how the proof is completed by applying the recurrence relation.

We know the recurrence relation is

Mn = 2Mn-1 + 1

Apply that recursion to our assumption.

Page 9: Mixed Recursion: Sec. 8.4

Mixed Recursion: Sec. 8.4

Exercise 3. The closed-form formula for the Towers of Hanoi problem, Mn = 2n – 1, can be proved by mathematical induction.

c. Show how the proof is completed by applying the recurrence relation.

Assumption: Mk = 2k – 1

Applying our recursion:

Mk+1 = 2(2k – 1) + 1

Page 10: Mixed Recursion: Sec. 8.4

Mixed Recursion: Sec. 8.4

Exercise 3. c. Show how the proof is completed by applying the recurrence relation.

Goal: Mk+1 = 2k+1 – 1

So far we have: Mk+1 = 2(2k – 1) + 1

Distribute the first 2:

Mk+1 = 2(2k) + 2(-1) + 1 = 2k+1 – 2 + 1

Mk+1 = 2k+1 – 1 Our Goal!

Page 11: Mixed Recursion: Sec. 8.4

Mixed Recursion: Sec. 8.4

Exercise 7. To help him finish his final year of college, Sam took out a loan of $5,000. At the end of the first year after he graduated, there was a $4,500 balance, and at the end of the second year, $3,950 remained. The amount of money left at the end of n years can be modeled by the mixed recurrence relation tn = atn-1 + b.

a. The information stated above is summarized in the following table:

n tn

0 5,000 1 4,500 2 3,900

Page 12: Mixed Recursion: Sec. 8.4

Mixed Recursion: Sec. 8.4

Exercise 7.

Please note there is a mistake in the book. The answers in the back of the book for this problem would be correct if t2 were 3,950, instead of 3,900. We’ll proceed with the values given in the table, and our answers will be different from those in the back of the book.

n tn

0 5,000 1 4,500 2 3,900

Page 13: Mixed Recursion: Sec. 8.4

Mixed Recursion: Sec. 8.4

Exercise 7. a. Use the general form of a mixed recurrence relation and the data in the table to write a system of equations. Solve for a and b. What is the recurrence relation for the amount of money in Sam’s account after n years?

General form: tn = atn-1 + b

For n = 1: 4,500 = a(5,000) + b

For n = 2: 3,900 = a(4,500) + b

Page 14: Mixed Recursion: Sec. 8.4

Mixed Recursion: Sec. 8.4

Exercise 7. a. What is the recurrence relation for the amount of money in Sam’s account after n years?

For n = 1: 4,500 = a(5,000) + b

For n = 2: 3,900 = a(4,500) + b

We can solve this using matrices:

X

1500,4

1000,5

b

a

900,3

500,4 =

Page 15: Mixed Recursion: Sec. 8.4

Mixed Recursion: Sec. 8.4

Exercise 7. a. What is the recurrence relation for the amount of money in Sam’s account after n years?

X

1500,4

1000,5

b

a

900,3

500,4 =

X

1500,4

1000,5

b

a

900,3

500,4 =

1500,4

1000,5

1500,4

1000,5 X

-1 -1 X

b

a =

1.2

1,500

So for the balance: tn = 1.2tn-1 – 1,500

Page 16: Mixed Recursion: Sec. 8.4

Mixed Recursion: Sec. 8.4

Exercise 7. a. What is the recurrence relation for the amount of money in Sam’s account after n years?

We could also solve this by looking at the ratio of successive 1st differences:

n tn 1st Diff Ratio of Diff0 5,0001 4,500 -5002 3,900 -600 1.2

Page 17: Mixed Recursion: Sec. 8.4

Mixed Recursion: Sec. 8.4

Exercise 7. a. What is the recurrence relation for the amount of money in Sam’s account after n years?

n tn 1st Diff Ratio of Diff0 5,0001 4,500 -5002 3,900 -600 1.2

Multiply 1.2 times the first balance of 5,000 and we get 6,000. From there we need to subtract 1,500 in order to get to the second balance of 4,500. Thus,

tn = 1.2tn-1 - 1500

Page 18: Mixed Recursion: Sec. 8.4

Mixed Recursion: Sec. 8.4

Exercise 7. b. What will be the balance owed on the loan at the end of the third year? The fourth year?

Recurrence relation: tn = 1.2tn-1 – 1,500

End of second year: t2 = $3,900

End of third year: t3 = 1.2(3,900) – 1,500 = $3,180

End of fourth year: t4 = 1.2(3,180) – 1,500 = $2,316

Page 19: Mixed Recursion: Sec. 8.4

Mixed Recursion: Sec. 8.4

Exercise 7. c. What is the rate of interest on this loan?

tn = 1.2tn-1 – 1,500

The value of a, which in this case is 1.2, tells us the interest rate. Take that value and subtract 1, which gives us .2, and then multiply by 100 to get the percent.

.2(100) = 20% interest

Page 20: Mixed Recursion: Sec. 8.4

Mixed Recursion: Sec. 8.4

Exercise 7. d. Find the fixed point for this recurrence relation. What is the significance of this amount of money?

tn = 1.2tn-1 – 1,500

x = 1.2x – 1,500

Subtract x from each side, and add 1,500 to each side.

1,500 = .2x

Divide each side by .2, or multiply each side by 5.

7,500 = x

If the original balance were $7,500, the loan would never be paid off. The $1,500 payment each year would exactly cover the interest.

Page 21: Mixed Recursion: Sec. 8.4

Mixed Recursion: Sec. 8.4

Exercise 8. Suppose a college’s tuition over the past 3 years has risen from $8,000 to $8,700 to the present cost of $9,435. Use a mixed recurrence relation of the form

tn = atn-1 + b to predict next year’s tuition.

n tn 1st Diff Ratio of Diff1 8,0002 8,700 7003 9,435 735 1.05

Page 22: Mixed Recursion: Sec. 8.4

Mixed Recursion: Sec. 8.4

Exercise 8. Use a mixed recurrence relation of the form

tn = atn-1 + b to predict next year’s tuition.

n tn 1st Diff Ratio of Diff1 8,0002 8,700 7003 9,435 735 1.05

Multiply 8,000 by 1.05 to get 8,400. We need to add 300 to reach the year 2 value of 8,700. So our recurrence relation is

tn = 1.05tn-1 + 300

This leads us to predict next year’s tuition as 1.05(9,435) + 300, or $10,206.75.