Docsity

Recursion - Discrete Mathematics - Lecture Slides, Slides of Discrete Mathematics

Partial preview of the text

Download Recursion - Discrete Mathematics - Lecture Slides and more Slides Discrete Mathematics in PDF only on Docsity!

Recursion

Recursively defined sequences

 To define a sequence recursively:

  • give initial conditions, i.e., the values of the first few terms explicitly;
  • give a recurrence relation, i.e., an equation that relates later terms in the sequence to earlier terms.

 Example:

  • Define the following sequence recursively:

1, 4, 7, 10, 13, …

  • Solution: a 1 = 1, a (^) n = a (^) n-1 + 3 for n≥

RULES:

You may only move one disk at a time. A disk may only be moved to one of the three columns. You must never place a larger disk on top of a smaller disk.

INITIAL STATE GOAL STATE

Tower of Hanoi: Move disks from left pole to right pole

Pole A Pole B Pole C Pole A Pole B Pole C

Recursive formula for Compound Interest

  • Suppose $10K is deposited in an account paying 3% interest compounded annually.
  • For each positive integer n, let

a 0 = the initial amount deposited; a (^) n = the amount on deposit at the end of year n.

  • Find a recursive relation for a 0 , a 1 , a 2 ,…

assuming no additional deposits or withdrawals.

  • We have the following recursive formula:

a 0 = 10, a (^) n = a (^) n-1 + 0.03a (^) n-1 = 1.03a (^) n-1 for n≥

Finding an explicit formula for a

recursively defined sequence

It is often helpful to know an explicit formula for the sequence, especially if you need

  • to compute terms with very large subscripts;
  • to examine general properties of the sequence.

Examples

  • Recall the recursive formula for the compound interest example: a 0 = 10, a (^) n = 1.03a (^) n-1 for n≥ The explicit formula is a (^) n = 10000(1.03) n^ for n≥

Note : this formula can be generalized to any geometric sequence.

Finding an explicit formula for a

recursively defined sequence

Examples (cont.)

  • Recall the recursive formula for the Hanoi tower example: a 1 = 1

a (^) n = 2a (^) n-1 + 1 for n≥

  • How to get explicit formula?
  • Compute the first few terms of this sequence:

a 1 = 1, a 2 = 3, a 3 = 7, a 4 = 15, a 5 = 31, a 6 = 63

  • Based on the pattern, a (^) n = 2 n^ – 1 for n≥
  • But need a proof!
  • The proof by induction (blackboard)