Presentation is loading. Please wait.

Presentation is loading. Please wait.

Recurrence Relations: Selected Exercises. Copyright © Peter Cappello2 Exercise 10 (a) A person deposits $1,000 in an account that yields 9% interest compounded.

Similar presentations


Presentation on theme: "Recurrence Relations: Selected Exercises. Copyright © Peter Cappello2 Exercise 10 (a) A person deposits $1,000 in an account that yields 9% interest compounded."— Presentation transcript:

1 Recurrence Relations: Selected Exercises

2 Copyright © Peter Cappello2 Exercise 10 (a) A person deposits $1,000 in an account that yields 9% interest compounded annually. Set up a recurrence relation for the amount in the account at the end of n years.

3 Copyright © Peter Cappello3 Exercise 10 (a) Solution A person deposits $1,000 in an account that yields 9% interest compounded annually. Set up a recurrence relation for the amount in the account at the end of n years. Let a n represent the amount after n years. a n = a n a n-1 = 1.09a n-1 a 0 = 1000.

4 Copyright © Peter Cappello4 Exercise 10 (b) A person deposits $1,000 in an account that yields 9% interest compounded annually. Find an explicit formula for the amount in the account at the end of n years.

5 Copyright © Peter Cappello5 Exercise 10 (b) Solution After 1 year, a 1 = 1.09a 0 = 1.09x1000 = 1000x After 2 years, a 2 = 1.09a 1 = 1.09( 1000x(1.09) 1 ) = 1000x(1.09) 2 After n years, a n = 1000x(1.09) n Since a n is recursively defined, we prove the formula, for n 0, by mathematical induction (The problem does not ask for proof).

6 Copyright © Peter Cappello6 Exercise 10 (b) Solution Basis n = 0: a 0 = 1000 = 1000x(1.09) 0. The 1 st equality is the recurrence relations initial condition. Induction hypothesis: a n = 1000x1.09 n. Induction step: Show: a n+1 = 1000x1.09 n+1. a n+1 = 1.09a n = 1.09 ( 1000x1.09 n ) = 1000x1.09 n+1. The 1 st equality: the definition of the recurrence relation. The 2 nd equality: the induction hypothesis.

7 Copyright © Peter Cappello7 Exercise 10 (c) A person deposits $1,000 in an account that yields 9% interest compounded annually. How much money will the account contain after 100 years?

8 Copyright © Peter Cappello8 Exercise 10 (c) Solution The account contains a 100 dollars after 100 years: a 100 = 1000x = $5,529,041. That is before taxes. With 30% federal + 10% CA on interest earned, it becomes 1000x = $131,500

9 Copyright © Peter Cappello9 Exercise 20 A country uses as currency coins with pesos values of 1, 2, 5, & 10 pesos Find a recurrence relation, a n, for the # of payment sequences for n pesos. E.g., a bill of 4 pesos could be paid with any of the following sequences: 1.1, 1, 1, 1 2.1,1, 2 3.1, 2, 1 4.2, 1, 1 5.2, 2

10 Copyright © Peter Cappello10 Exercise 20 Solution The sequences that start w/ a 1 peso coin differ from the sequences that dont. Use the sum rule: Partition the set of sequences, based on which kind of coin starts the sequence. It could be a: 1 peso coin, in which case we have a n-1 ways to finish the bill 2 peso coin, in which case we have a n-2 ways to finish the bill 5 peso coin, in which case we have a n-5 ways to finish the bill 10 peso coin, in which case we have a n-10 ways to finish the bill The recurrence relation is a n = a n-1 + a n-2 + a n-5 + a n-10 with 10 initial conditions, a 1 = 1, a 2 = 2, a 3 = 3, a 4 = 5, a 5 = 9, a 6 = 15, a 7 = 26, a 8 = 44, a 9 = 75, a 10 = 125.

11 Copyright © Peter Cappello11 Exercise 30 (a) A string that contains only 0s, 1s, & 2s is called a ternary string. Find a recurrence relation for the # of ternary strings of length n that do not contain 2 consecutive 0s.

12 Copyright © Peter Cappello12 Exercise 30 (a) Solution Subtract the # of bad strings (contain 2 consecutive 0s), b n,, from the # of ternary strings, 3 n. To count b n,, use the sum rule: Partition the set of strings, depending on what digit starts the string: 1.The string starts with a 1: b n-1 ways to finish the string. 2.The string starts with a 2: b n-1 ways to finish the string. 3.The string starts with a 0: 1.The remaining string starts with a 0: 3 n-2 ways to finish the string. 2.The remaining string starts with a 1: b n-2 ways to finish the string. 3.The remaining string starts with a 2: b n-2 ways to finish the string. Summing, b n = 2b n-1 + 2b n n-2

13 Copyright © Peter Cappello13 Exercise 30 (b) What are the initial conditions?

14 Copyright © Peter Cappello14 Exercise 30 (b) Solution What are the initial conditions? b 0 = b 1 = 0. Why do we need 2 initial conditions?

15 Copyright © Peter Cappello15 Exercise 30 (c) How many ternary strings of length 6 contain 2 consecutive 0s?

16 Copyright © Peter Cappello16 Exercise 30 (c) Solution The number of such strings is the value of b 6. Using b n = 2b n-1 + 2b n n-2, we compute: b 0 = b 1 = 0. (Initial conditions) b 2 = 2b 1 + 2b = 2x0 + 2x = 1 b 3 = 2b 2 + 2b = 2x1 + 2x = 5 b 4 = 2b 3 + 2b = 2x5 + 2x = 21 b 5 = 2b 4 + 2b = 2x21 + 2x = 79 b 6 = 2b 5 + 2b = 2x79 + 2x = 281.

17 Copyright © Peter Cappello17 Exercise 40 Find a recurrence relation, e n, for the # of bit strings of length n with an even # of 0s.

18 Exercise 40 Solution Strings are sequences: Order matters: There is a 1 st bit. Use the sum rule: Partition the desired set of bit strings, based on the strings 1 st bit: Strings with an even # of 0s that begin with 1: e n-1 Strings with an even # of 0s that begin with 0: 2 n-1 - e n-1 Summing, e n = e n n-1 - e n-1 = 2 n-1 Copyright © Peter Cappello18

19 Copyright © Peter Cappello19 End

20 Copyright © Peter Cappello20 Exercise 40 Solution Strings are sequences: Order matters: There is a 1 st bit. Use the sum rule: Partition the desired set of bit strings, based on the strings 1 st bit: Strings with an even # of 0s that begin with 1: e n-1 Strings with an even # of 0s that begin with 0: 2 n-1 - e n-1 Summing, e n = e n n-1 - e n-1 = 2 n-1 Does this answer suggest an alternate explanation? Does this question relate to our study binomial coefficients?

21 Copyright © Peter Cappello21 Use the Binomial Theorem ( x + y ) n = Σ j=0 to n C( n, j )x n-j y j = C( n, 0 )x n y 0 + C( n,1 )x n-1 y 1 + … + C( n, j )x n-j y j + … + C( n, n )x 0 y n. Evaluate at x = 1, y = -1: (1 – 1) n = Σ j=0 to n C( n, j )1 n-j ( -1 ) j = C( n, 0 ) - C( n,1 ) + C( n,2 ) - C( n,3 ) (-1) n C( n, n ). C( n,1 ) + C( n,3 ) + C( n,5 )... = C( n, 0 ) + C( n,2 ) + C( n,4 )... = 2 n-1 Example: C(4,0) + C(4,2) + C(4,4) = C(4,1) + C(4,3) = 2 3 The # of bit strings of length 4 that have an even number of 0s is 2 3.

22 Copyright © Peter Cappello The variation we consider begins with people numbered 1, …, n, standing around a circle. In each stage, every 2 nd person still alive is killed until only 1 survives. We denote the number of the survivor by J(n). Determine the value of J(n) for 1 n 16.

23 Copyright © Peter Cappello Solution Put 5 people, named 1, 2, 3, 4, & 5, in a circle. Starting with 1, kill every 2 nd person until only 1 person is left. The sequence of killings is: So, J(5) = 3. Continuing, for each value of n, results in the following table.

24 Copyright © Peter Cappello Solution nJ(n)n

25 Copyright © Peter Cappello Use the values you found in Exercise 49 to conjecture a formula for J(n). Hint: Write n = 2 m + k, where m, k N & k < 2 m.

26 Copyright © Peter Cappello Solution nJ(n)n 1 = = = = = = = = = = = = = = = =

27 Copyright © Peter Cappello Solution continued nJ(n)n 1 = = 2* = = 2* = = 2* = = 2* = = 2* = = 2* = = 2* = = 2* = = 2* = = 2* = = 2* = = 2* = = 2* = = 2* = = 2* = = 2*0 + 1

28 Copyright © Peter Cappello Solution continued So, if n = 2 m + k, where m, k N & k < 2 m, then J(n) = 2k + 1. Check this for J(17).

29 Copyright © Peter Cappello29 Exercise 20 Solution continued But, we also can use bills. If the 1 st currency object is a bill, it could be a 1.5 peso, in which case we have a n-5 ways to finish the bill 2.10 peso, in which case we have a n-10 ways to finish the bill 3.20 peso, in which case we have a n-20 ways to finish the bill 4.50 peso, in which case we have a n-50 ways to finish the bill peso, in which case we have a n-100 ways to finish the bill Using both coins & bills, we have a n = a n-1 + a n-2 + a n-5 + a n-10 + a n-5 + a n-10 + a n-20 + a n-50 + a n-100 = a n-1 + a n-2 + 2a n-5 + 2a n-10 + a n-20 + a n-50 + a n-100, with 100 initial conditions, which I will not produce.


Download ppt "Recurrence Relations: Selected Exercises. Copyright © Peter Cappello2 Exercise 10 (a) A person deposits $1,000 in an account that yields 9% interest compounded."

Similar presentations


Ads by Google