Presentation is loading. Please wait.

Presentation is loading. Please wait.

A0=0 a1=2 an a2=6 an-1 a3=12 a4=20 a2 a1 a0.

Similar presentations


Presentation on theme: "A0=0 a1=2 an a2=6 an-1 a3=12 a4=20 a2 a1 a0."— Presentation transcript:

1 a0=0 a1=2 an a2=6 an-1 a3=12 a4=20 a2 a1 a0

2 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.

3 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,...

4 10.1 The First-Order Linear Recurrence Relation
Ex 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=$ A nonlinear recurrence relation

5 10.1 The First-Order Linear Recurrence Relation
nonhomogeneous linear recurrence relation Ex 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 = (n-1)=(n2-n)/2

6 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

7 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

8 Case (A): distinct real roots

9 Case (A): distinct real roots

10 Case (A): distinct real roots
Ex 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.

11 Case (A): distinct real roots
Ex 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.

12 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 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

13 10.2 The Second-Order Linear Homogeneous Recurrence Relation
with Constant Coefficients extend to higher order

14 10.2 The Second-Order Linear Homogeneous Recurrence Relation
with Constant Coefficients Case (b) Complex Roots DeMoivre's Theorem y x

15 Case (b) Complex Roots

16 Case (b) Complex Roots =bDn-1-b2Dn-2

17 Case (c) Repeated Real Roots

18 10.3 The Nonhomogeneous Recurrence Relation

19 10.3 The Nonhomogeneous Recurrence Relation

20 10.3 The Nonhomogeneous Recurrence Relation
peg peg peg 3 n+1 disks move to rule: one disk at a time larger one must not on top of a smaller one

21 10.3 The Nonhomogeneous Recurrence Relation
Ex 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

22 10.3 The Nonhomogeneous Recurrence Relation
Ex The snowflake curve 1 1 1 area:

23 10.3 The Nonhomogeneous Recurrence Relation
Ex The snowflake curve

24 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.

25 10.3 The Nonhomogeneous Recurrence Relation
Ex 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.

26 10.3 The Nonhomogeneous Recurrence Relation

27 10.4 The Method of Generating Functions

28 10.4 The Method of Generating Functions

29 10.4 The Method of Generating Functions

30 10.5 A Special Kind of Nonlinear Recurrence Relation

31 10.5 A Special Kind of Nonlinear Recurrence Relation
Ex (continued) for n+1 vertices:bn+1 select one as root b bn b bn-1 bn b0

32 10.5 A Special Kind of Nonlinear Recurrence Relation
Ex (continued)

33 10.5 A Special Kind of Nonlinear Recurrence Relation
Ex (continued)

34 10.5 A Special Kind of Nonlinear Recurrence Relation
Ex 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 an count the number of ways to permute 1,2,...,n using this method.

35 10.5 A Special Kind of Nonlinear Recurrence Relation
Ex 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 n n-1 n

36 Exercise:P423:10 P432,433:1,6 P444: 12 P457: 6


Download ppt "A0=0 a1=2 an a2=6 an-1 a3=12 a4=20 a2 a1 a0."

Similar presentations


Ads by Google