Presentation is loading. Please wait.

Presentation is loading. Please wait.

Review of Recursion Remember that recursion involves applying the same process over and over.

Similar presentations


Presentation on theme: "Review of Recursion Remember that recursion involves applying the same process over and over."— Presentation transcript:

1 Review of Recursion Remember that recursion involves applying the same process over and over.

2 Review of Recursion Remember that recursion involves applying the same process over and over. We have looked at two types so far: arithmetic and geometric recursion. Do you remember the difference between them?

3 Review of Recursion Arithmetic Recursion: We proceed from one term to the next by addition.

4 Review of Recursion Arithmetic Recursion: We proceed from one term to the next by addition. Example: Place $1,000 into a good, safe hiding place, and then add $200 at the end of each month.

5 Review of Recursion Arithmetic Recursion Example

6 Review of Recursion Arithmetic Recursion Example How could we find the pattern, if no one had told us the scenario?

7 Review of Recursion Arithmetic Recursion Example Consider the 1st differences:

8 Review of Recursion Arithmetic Recursion Example For an arithmetic recursion, the difference, d, which is added each time gives us our recurrence relation: H n = H n-1 + d

9 Review of Recursion Arithmetic Recursion Example For an arithmetic recursion, the difference, d, which is added each time gives us our recurrence relation: H n = H n-1 + d Or for our example: B n = B n-1 + 200

10 Review of Recursion For a geometric recursion, we get from one term to the next by multiplying by the same number over and over.

11 Review of Recursion For a geometric recursion, we get from one term to the next by multiplying by the same number over and over. Example: You invest $1,000 in an account that earns 6% interest annually. To obtain the new balance at the end of each year, multiply the current balance by 1.06.

12 Review of Recursion Geometric Recursion Example $1,000 deposit with 6% interest annually:

13 Review of Recursion Geometric Recursion Example $1,000 deposit with 6% interest annually: Here the 1st differences will not help us. The ratios of successive balances will, though.

14 Review of Recursion Geometric Recursion Example $1,000 deposit with 6% interest annually:

15 Review of Recursion Geometric Recursion Example $1,000 deposit with 6% interest annually: That ratio of successive balances, 1.06, leads us to the recursive relation: B n = B n-1 (1.06)

16 Review of Recursion So far we have considered two scenarios. In the first case, you add to your account monthly, but earn no interest. In the second case, you earn interest, but do not make any more deposits after the initial deposit.

17 Review of Recursion So far we have considered two scenarios. In the first case, you add to your account monthly, but earn no interest. In the second case, you earn interest, but do not make any more deposits after the initial deposit. What if you made an initial deposit into an account that earns interest, and then continued to deposit money regularly?

18 Review of Recursion Say you deposit $1,000 into a money market account that earns 5% interest annually, and you deposit an additional $500 at the end of each year. Now you are adding to your account, and also multiplying by an interest rate. This gives us a mixed recursion.

19 Mixed Recursion $1,000 initial deposit; 5% annual interest; $500 additional deposit each year Can you find a pattern?

20 Mixed Recursion Try looking at the 1st Differences:

21 Mixed Recursion Try looking at the 1st Differences: The 1st differences will not help us.

22 Mixed Recursion Try looking at the 1st Differences: The 1st differences will not help us. Neither will the 2nd, or the 3rd, or...

23 Mixed Recursion How about the ratios of successive balances? That worked for our geometric recursion:

24 Mixed Recursion How about the ratios of successive balances? That worked for our geometric recursion:

25 Mixed Recursion How about the ratios of successive balances? That worked for our geometric recursion: Hmm…that did not seem to work, either.

26 Mixed Recursion Our arithmetic recursion example gave us a constant first difference.

27 Mixed Recursion Our arithmetic recursion example gave us a constant first difference. Our geometric recursion example gave us a constant ratio of successive terms.

28 Mixed Recursion Our arithmetic recursion example gave us a constant first difference. Our geometric recursion example gave us a constant ratio of successive terms. For our mixed recursion, try finding the ratio of successive first differences.

29 Mixed Recursion

30 Aha! There is our trick for a mixed recursion-- we get a constant ratio of successive differences. Does that 1.05 look familiar?

31 Mixed Recursion What if we had been given this table, and were asked to find the recursive relation?

32 Mixed Recursion Consider any two successive rows of the table, and compare the balances.

33 Mixed Recursion

34 Since we know that 1.05 is the magic number (because that is the ratio of successive 1st differences) multiply the Year 0 balance by 1.05.

35 Mixed Recursion 1,000(1.05) = 1,050 So if this were only a geometric recursion, the Year 1 balance should be 1,050.

36 Mixed Recursion How did we get from the 1,050 that a geometric recursion would have given us to the 1,550 that our mixed recursion gives us?

37 Mixed Recursion 1,550 - 1,050 = 500 So besides multiplying by 1.05, we are also adding 500 for each successive term.

38 Mixed Recursion We are multiplying by 1.05 and adding 500: B n = B n-1 (1.05) + 500 or 1.05B n-1 + 500


Download ppt "Review of Recursion Remember that recursion involves applying the same process over and over."

Similar presentations


Ads by Google