360 likes | 378 Vues
a 0 =0. a 1 =2. a n. a 2 =6. a n -1. a 3 =12. a 4 =20. a 2. a 1. a 0. 10.1 The First-Order Linear Recurrence Relation. geometric progression. a first-order, linear, and homogeneous recurrence relation (difference equation) with constant coefficient. The arithmetic progression.
E N D
a0=0 a1=2 an a2=6 an-1 a3=12 a4=20 a2 a1 a0
10.1 The First-Order Linear Recurrence Relation geometric progression a first-order, linear, and homogeneous recurrence relation (difference equation) with constant coefficient The arithmetic progression is nonhomogeneous.
10.1 The First-Order Linear Recurrence Relation There are many sequences that satisfy For example, 5,15,45,135,... or 7,21,63,189,.... To pinpoint the particular sequence described, we need to know one of the terms of the sequence. (boundary condition, or initial condition since usually a0 is specified) determines the sequence 5,15,45,135,...
10.1 The First-Order Linear Recurrence Relation Ex. 10.2 A bank pays 6% (annual) interest on savings, compounding the interest monthly. If Boonie deposits $1000 on the first day of May, how much will this deposit be worth a year later? Let pn denote the value of deposit at the end of n months. Then pn+1=pn+(6%/12)pn=1.005pn. With p0=$1000, we have pn=p0(1.005)n. The answer is p12=$1000(1.005)12=$1061.68. A nonlinear recurrence relation
10.1 The First-Order Linear Recurrence Relation nonhomogeneous linear recurrence relation Ex. 10.4 time complexity of bubble sort algorithm an=an-1+(n-1), n>1, a1=0, where an=the number of comparisons to sort n numbers an- an-1= n-1 an-1- an-2= n-2 an-2- an-3= n-3 a2- a1= 1 + an =1+2+3+...+(n-1)=(n2-n)/2
10.1 The First-Order Linear Recurrence Relation find the recurrence pattern nonconstant coefficients Ex. 10.5 Ex. 10.6 a0=0 a1- a0=2 a1=2 a2 -a1=4 a2=6 a3- a2=6 a3=12 a4=20 a4- a3=8 an- an-1=2n + an=n2+n
10.2 The Second-Order Linear Homogeneous Recurrence Relation with Constant Coefficients three cases for the characteristic roots: (a) distinct real numbers (b) complex conjugates (c) duplicate roots
Case (A): distinct real roots Ex. 10.11 number of legal arithmetic expressions, without parentheses, that are made up of the digits 0,1,2,...,9 and the binary operator +,*,/. Let an be the number of expressions made up of n symbols. Then a1=10 (0,1,...,9), a2=100 (00,01,...,99). For n>2, two cases: (a) the last two symbols are digits: remove the last digit, we have a legal expression for an-1. (10an-1) (b) the last two symbols are operator and digit: remove the two symbols, we have a legal expression for an-2 (29an-2, no /0) Therefore, an=10an-1+29an-2, and a1=10, a2=100.
Case (A): distinct real roots Ex. 10.13 Find a recurrence relation for the number of binary sequences of length n that have no consecutive 0's. Let an be the number of such sequences with length n,n>0. Then a1=2, a2=3. There are two cases for an: (1) the nth symbol is 1: the preceding n-1 symbols sequence is counted in an-1 (2) the nth symbol is 0: an ends in 10 and the preceding n-2 symbols sequence is counted in an-2. Therefore, an=an-1+an-2.
10.2 The Second-Order Linear Homogeneous Recurrence Relation with Constant Coefficients Be careful not to draw conclusions from a few (or even, perhaps, many) particular instances. Ex. 10.14 Arrange pennies contiguously in each row where each penny above the bottom row touches two pennies in the row below it. a1=1,a2=1,a3=2,a4=3,a5=5,a6=8,... Is an=Fn? NO
10.2 The Second-Order Linear Homogeneous Recurrence Relation with Constant Coefficients extend to higher order
10.2 The Second-Order Linear Homogeneous Recurrence Relation with Constant Coefficients Case (b) Complex Roots DeMoivre's Theorem y x
Case (b) Complex Roots =bDn-1-b2Dn-2
10.3 The Nonhomogeneous Recurrence Relation peg 1 peg 2 peg 3 n+1 disks move to rule: one disk at a time larger one must not on top of a smaller one
10.3 The Nonhomogeneous Recurrence Relation Ex. 10.25 Pauline takes out a loan of S dollars that is to be paid back in T periods of time. If i is the interest rate per period for the loan, what constant payment P must she make at the end of each period? an:the amount still owed on the loan at the end of the nth period (following the nth payment) Example: S=5,000,000 i=10%/12 T=20 years=240 months P=48251
10.3 The Nonhomogeneous Recurrence Relation Ex. 10.27 The snowflake curve 1 1 1 area:
10.3 The Nonhomogeneous Recurrence Relation Ex. 10.27 The snowflake curve
Summary r=1 1. Linear combinations work. 2. If f(n) contains rn and r is a characteristic root of multiplicity k, then multiply by nk.
10.3 The Nonhomogeneous Recurrence Relation Ex. 10.30 For n>1 suppose that there are n people at a party and that each of these people shakes hands (exactly one time) with all of the other people there (and no one shakes hands with himself or herself). If an counts the total number of handshakes, then an+1=an+n, a2=1, n>1, because when the (n+1)th person arrives, he or she will shake hands with the n other people already arrived.
10.5 A Special Kind of Nonlinear Recurrence Relation Ex. 10.36 (continued) for n+1 vertices:bn+1 select one as root b0bn b1bn-1 bnb0
10.5 A Special Kind of Nonlinear Recurrence Relation Ex. 10.36 (continued)
10.5 A Special Kind of Nonlinear Recurrence Relation Ex. 10.36 (continued)
10.5 A Special Kind of Nonlinear Recurrence Relation Ex. 10.37 Use stacks to permute the ordered list 1,2,...,n. output 1,2,...,n input We can generate 1,2 or 2,1 from 1,2. We can not generate 3,1,2 from 1,2,3. stack Let ancount the number of ways to permute 1,2,...,n using this method.
10.5 A Special Kind of Nonlinear Recurrence Relation Ex. 10.37 Use stacks to permute the ordered list 1,2,...,n. Suppose the output list for 1,2,...,n,n+1is: 1 j numbers k numbers j+k=n 0 n 1 n-1 n 0
Exercise:P423:10 P432,433:1,6 P444: 12 P457: 6