# Recurrence Relation Models A recurrence relation is a

• Slides: 17

Recurrence Relation Models

• A recurrence relation is a recursive formula that counts the number of ways to do a procedure involving n objects in terms of the number of ways to do it with fewer objects. • E. g. , an = c 1 an-1 + c 2 an-2 , a 1 = 0, a 2 = 1 • A recurrence relation’s starting values are called initial conditions.

• Proving things about a recurrence relation usually is done by mathematical induction. • Typical forms of recurrence relations include: • an = c 1 an-1 + c 2 an-2 +. . . + cran-r • an = c 1 an-1 + c 2 • an = c 1 an-1 + f(n)

• Solve a recurrence relation for a particular value of n by: • Computing the values by hand/calculator, starting from initial conditions. • Writing an iterative program to compute the values, starting from initial conditions. • Deriving a formula for the recurrence, and computing the value directly with it.

Example 1: Permutations • Let an be the number of ways to permute n objects. • Give a recurrence relation for an. • What is a 1?

Example 2: The Fibonacci Relation • Initially, there is 1 pair (i. e. , male & female) of newborn rabbits. • Every month, each pair of rabbits that are over 1 month old produce a new pair. • How many rabbits are there after 12 months?

• • Let Fn = the # of rabbits after n months. Let F 0 = 1, the pair is just born. F 1 = 1, the pair is 1 month old. F 2 = 2, the 1 st pair produces a 2 nd pair. F 3 = 3, the 1 st pair produces a 3 rd pair. F 4 = 5, the 1 st & 2 nd pair each produce a pair. Fn = Fn-1 + Fn-2 , all pairs born 2 months ago produce new pairs.

Compounding Interest • • • Let P be the principal borrowed from a bank. Let r be the interest rate period. Let an represent the amount due after n periods. What is a 0 ? What is a recurrence for an ? How would it change, if D dollars were paid to the bank at the: • End of every month? • Beginning of every month?

Distributing money! • Find a recurrence relation for an the number of ways to distribute either a \$1 bill, a \$5 bill, a \$10 bill, or a \$20 dollar bill on successive days until a total of n dollars has been distributed. • What is a a 1 ? • What is a a 2 ? • What is a a 5 ? • What is a an ?

• Suppose Bill Ashby gives 1 prize away each day, where there are: • 3 kinds of prizes worth \$5 • 7 kinds of prizes worth \$10. • Give a recurrence pn for the number of ways for Bill to give away \$n worth of prizes. • What is p 1? p 5? p 10? pn?

• If n non-parallel lines are drawn in the plane, no 3 lines intersecting at the same point, how many regions rn do these lines divide the plane? • What is r 0? r 1? r 2? r 3? rn?

Tower of Hanoi Starting position Ending position

Tower of Hanoi. . . • Move the discs from the left peg to the center peg, preserving their size order when you are done such that: • Move the top disc from 1 peg; place it on the top of a pile of another peg. • At no time may you move a larger disc on top of a smaller disc (herniating the smaller disc).

Tower of Hanoi. . . • Let mn denote the number of moves needed in an n-disk game. • What is m 1? • What is m 2? • What is m 3? • What is mn? • Prove that mn = 2 n - 1.

Lancaster Equations of Combat • 2 Armies A & B engage in combat. • Let a 0 & b 0 denote the # of soldiers alive before combat begins. • Let an and bn be the # of soldiers alive after the nth day of combat. • The daily decrease in each army equals 1/2 the size of the opposing army (or 0, whichever is larger). • What is a 1 & b 1? a 2 & b 2? an & bn?

Forbidden subsequences • Find a recurrence relation for an, the # of ndigit ternary sequences without the subsequence “ 012”. • What is a 1? a 2? a 3? a 4? a 5? a 6? an? • Partition all such sequences into 3 parts: • Those that begin with ‘ 1’ • Those that begin with ‘ 2’ • Those that begin with ‘ 0’ • For this case, subtract the # of otherwise good sequences that begin with “ 012”. How many are there?

Characters • • •