180 likes | 214 Views
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., a n = c 1 a n-1 + c 2 a n-2 , a 1 = 0, a 2 = 1
E N D
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 = c1an-1 + c2an-2 , a1 = 0, a2 = 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 = c1an-1 + c2an-2+ . . . + cran-r • an = c1an-1 + c2 • an = c1an-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 iterativeprogram 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 a1?
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 F0 = 1, the pair is just born. • F1 = 1, the pair is 1 month old. • F2 = 2, the 1st pair produces a 2nd pair. • F3 = 3, the 1st pair produces a 3rd pair. • F4 = 5, the 1st & 2nd 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 per period. • Let an represent the amount due after n periods. • What is a0 ? • 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 a1 ? • What is a a2 ? • What is a a5 ? • 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 p1? p5? p10? 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 r0? r1? r2? r3? rn?
Tower of Hanoi Ending position Starting 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 m1? • What is m2? • What is m3? • What is mn? • Prove that mn = 2n - 1.
Lancaster Equations of Combat • 2 Armies A & B engage in combat. • Let a0 & b0 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 a1& b1? a2& b2? an& bn?
Forbidden subsequences • Find a recurrence relation for an, the # of n-digit ternary sequences without the subsequence “012”. • What is a1? a2? a3? a4? a5? a6? 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 • • • • • •