Soving Recurrence Relations



Similar documents
CS103A Handout 23 Winter 2002 February 22, 2002 Solving Recurrence Relations

S. Tanny MAT 344 Spring be the minimum number of moves required.

2-3 The Remainder and Factor Theorems

Infinite Sequences and Series

Here are a couple of warnings to my students who may be here to get a copy of what happened on a day that you missed.

SECTION 1.5 : SUMMATION NOTATION + WORK WITH SEQUENCES

Trigonometric Form of a Complex Number. The Complex Plane. axis. ( 2, 1) or 2 i FIGURE The absolute value of the complex number z a bi is

Sequences and Series

Example 2 Find the square root of 0. The only square root of 0 is 0 (since 0 is not positive or negative, so those choices don t exist here).

.04. This means $1000 is multiplied by 1.02 five times, once for each of the remaining sixmonth

FIBONACCI NUMBERS: AN APPLICATION OF LINEAR ALGEBRA. 1. Powers of a matrix

Asymptotic Growth of Functions

In nite Sequences. Dr. Philippe B. Laval Kennesaw State University. October 9, 2008

CHAPTER 3 THE TIME VALUE OF MONEY

1. MATHEMATICAL INDUCTION

THE REGRESSION MODEL IN MATRIX FORM. For simple linear regression, meaning one predictor, the model is. for i = 1, 2, 3,, n

Present Value Factor To bring one dollar in the future back to present, one uses the Present Value Factor (PVF): Concept 9: Present Value

I. Chi-squared Distributions

Basic Elements of Arithmetic Sequences and Series

5.4 Amortization. Question 1: How do you find the present value of an annuity? Question 2: How is a loan amortized?

Repeating Decimals are decimal numbers that have number(s) after the decimal point that repeat in a pattern.

Factoring x n 1: cyclotomic and Aurifeuillian polynomials Paul Garrett <garrett@math.umn.edu>

Chapter 6: Variance, the law of large numbers and the Monte-Carlo method

Solutions to Exercises Chapter 4: Recurrence relations and generating functions

Hypothesis testing. Null and alternative hypotheses

THE ARITHMETIC OF INTEGERS. - multiplication, exponentiation, division, addition, and subtraction

7.1 Finding Rational Solutions of Polynomial Equations

CS103X: Discrete Structures Homework 4 Solutions

Chapter 5: Inner Product Spaces

INFINITE SERIES KEITH CONRAD

A probabilistic proof of a binomial identity

CURIOUS MATHEMATICS FOR FUN AND JOY

Building Blocks Problem Related to Harmonic Series

SAMPLE QUESTIONS FOR FINAL EXAM. (1) (2) (3) (4) Find the following using the definition of the Riemann integral: (2x + 1)dx

Solving equations. Pre-test. Warm-up

Department of Computer Science, University of Otago

Chapter 5 Unit 1. IET 350 Engineering Economics. Learning Objectives Chapter 5. Learning Objectives Unit 1. Annual Amount and Gradient Functions

Your organization has a Class B IP address of Before you implement subnetting, the Network ID and Host ID are divided as follows:

WHEN IS THE (CO)SINE OF A RATIONAL ANGLE EQUAL TO A RATIONAL NUMBER?

Hypergeometric Distributions

1 Computing the Standard Deviation of Sample Means

Solving Logarithms and Exponential Equations

Section 11.3: The Integral Test

AP Calculus AB 2006 Scoring Guidelines Form B

MATH 083 Final Exam Review

Chapter 7 Methods of Finding Estimators

Time Value of Money, NPV and IRR equation solving with the TI-86

Incremental calculation of weighted mean and variance

Heat (or Diffusion) equation in 1D*

Elementary Theory of Russian Roulette

5 Boolean Decision Trees (February 11)

Confidence Intervals for One Mean

Fast Fourier Transform

The Binomial Multi- Section Transformer

UC Berkeley Department of Electrical Engineering and Computer Science. EE 126: Probablity and Random Processes. Solutions 9 Spring 2006

GCE Further Mathematics (6360) Further Pure Unit 2 (MFP2) Textbook. Version: 1.4

Running Time ( 3.1) Analysis of Algorithms. Experimental Studies ( 3.1.1) Limitations of Experiments. Pseudocode ( 3.1.2) Theoretical Analysis

Determining the sample size

Confidence Intervals. CI for a population mean (σ is known and n > 30 or the variable is normally distributed in the.

INVESTMENT PERFORMANCE COUNCIL (IPC)

5: Introduction to Estimation

Solutions to Selected Problems In: Pattern Classification by Duda, Hart, Stork

The Stable Marriage Problem

Convexity, Inequalities, and Norms

Lecture 4: Cauchy sequences, Bolzano-Weierstrass, and the Squeeze theorem

CHAPTER 11 Financial mathematics

where: T = number of years of cash flow in investment's life n = the year in which the cash flow X n i = IRR = the internal rate of return

Output Analysis (2, Chapters 10 &11 Law)

5.3. Generalized Permutations and Combinations

1. C. The formula for the confidence interval for a population mean is: x t, which was

Class Meeting # 16: The Fourier Transform on R n

Discrete Mathematics and Probability Theory Spring 2014 Anant Sahai Note 13

MARTINGALES AND A BASIC APPLICATION

FM4 CREDIT AND BORROWING

Systems Design Project: Indoor Location of Wireless Devices

SEQUENCES AND SERIES

REVIEW OF INTEGRATION

Approximating Area under a curve with rectangles. To find the area under a curve we approximate the area using rectangles and then use limits to find

I. Why is there a time value to money (TVM)?

Escola Federal de Engenharia de Itajubá

LECTURE 13: Cross-validation

Simple Annuities Present Value.

Listing terms of a finite sequence List all of the terms of each finite sequence. a) a n n 2 for 1 n 5 1 b) a n for 1 n 4 n 2

Chair for Network Architectures and Services Institute of Informatics TU München Prof. Carle. Network Security. Chapter 2 Basics

Properties of MLE: consistency, asymptotic normality. Fisher information.

Modified Line Search Method for Global Optimization

CHAPTER 3 DIGITAL CODING OF SIGNALS

Professional Networking

Integer Factorization Algorithms

Baan Service Master Data Management

AP Calculus BC 2003 Scoring Guidelines Form B

Partial Di erential Equations

Lesson 17 Pearson s Correlation Coefficient

CDs Bought at a Bank verses CD s Bought from a Brokerage. Floyd Vest

Week 3 Conditional probabilities, Bayes formula, WEEK 3 page 1 Expected value of a random variable

3. Greatest Common Divisor - Least Common Multiple

Lecture 7: Stationary Perturbation Theory

BENEFIT-COST ANALYSIS Financial and Economic Appraisal using Spreadsheets

CHAPTER 7: Central Limit Theorem: CLT for Averages (Means)

Transcription:

Sovig Recurrece Relatios Part 1. Homogeeous liear 2d degree relatios with costat coefficiets. Cosider the recurrece relatio ( ) T () + at ( 1) + bt ( 2) = 0 This is called a homogeeous liear 2d degree recurrece relatio with costat coefficiets: 2d degree because it gives T () i terms of T ( 1) ad T ( 2), liear ad costat coefficiets because of the form of the left side, ad homogeeous because of the zero o the right had side. The idea for solvig this relatio is to guess a solutio of the form T () = x for some umber x, ad the to simply substitute this expressio ito the equatio to determie the value(s) of x that work. Sice T ( 1) = x 1 ad T ( 2) = x 2 we get the equatio x + ax 1 + bx 2 = 0 Sice x is clearly ot zero, we ca divide by x 2 to get x 2 + ax + b = 0 which is called the characteristic equatio for the recurrece relatio ( ). Case 1: If this equatio factors as (x r 1 )(x r 2 ) = 0 with r 1 r 2 (so that the characteristic equatio has two distict roots), the the geeral solutio to ( ) is T () = c 1 (r 1 ) + c 2 (r 2 ) where c 1 ad c 2 are costats. This is called a geeral solutio because every fuctio T () that is a solutio to the relatio ( ) has this form. If we also have iitial coditios T (0) = t 0 ad T (1) = t 1 the we ca determie the values of c 1 ad c 2 ad thus get the exact formula for T (). We ll illustrate the process with a typical example. Example 1. Solve the recurrece relatio T () 4T ( 1) + 3T ( 2) = 0, T (0) = 0, T (1) = 2 Note: This could also be writte as 0 = 0 T () = 2 = 1 4T ( 1) 3T ( 2) > 1 Solutio: The characteristic equatio is x 2 4x + 3 = 0, or (x 3)(x 1) = 0, so the geeral solutio is T () = c 1 3 + c 2 1 = c 1 3 + c 2. To fid c 1 ad c 2 we plug i the iitial coditios to get two equatios i those two variables: 0 = T (0) = c 1 3 0 + c 2 = c 1 + c 2 2 = T (1) = c 1 3 1 + c 2 = 3c 1 + c 2

It s easy to solve these equatios for the solutio c 1 = 1, c 2 = 1, so the fial aswer is T () = 3 1 Check: We ca check our aswer quickly ad easily. The recurrece formula gives us T (2) = 4T (1) 3T (0) = 4(2) 0 = 8 T (3) = 4T (2) 3T (1) = 4(8) 3(2) = 26 T (4) = 4T (3) 3T (2) = 4(26) 3(8) = 80 It appears that the sequece is ideed givig us umbers that are oe less tha the powers of 3 (1, 3, 9, 27, 81,... ), so the formula T () = 3 1 seems to be correct. Case 2: If the characteristic equatio factors as (x r) 2 = 0 (with a sigle root), the we use as our geeral solutio the formula T () = c 1 r + c 2 r As before, iitial coditios ca be used to solve for c 1 ad c 2. Here is a typical example. Example 2. Solve the recurrece relatio 3 = 0 T () = 17 = 1 10T ( 1) 25T ( 2) > 1 Solutio: The characteristic equatio is x 2 10x + 25 = 0, or (x 5) 2 = 0, so the geeral solutio is T () = c 1 5 + c 2 5. As before, we fid c 1 ad c 2 by pluggig i the iitial coditios: 3 = T (0) = c 1 5 0 + c 2 (0) = c 1 17 = T (1) = c 1 5 1 + c 2 (1)5 1 = 5c 1 + 5c 2 The solutio here is c 1 = 3 ad c 2 = 2/5, so the exact solutio is T () = (3)5 + (2/5)5 = (15 + 2)5 1 Check: The recurrece formula gives us values T (2) = 10T (1) 25T (0) = 10(17) 25(3) = 95 T (3) = 10T (2) 25T (1) = 525 These are ideed the values give by our formula as well: T (2) = (15 + 4)5 1 = 95, ad T (3) = (15 + 6)5 2 = 525. Case 3: It ca happe i geeral recurrece relatios that the characteristic equatio x 2 + ax + b = 0 has o real roots, but istead has two complex umber roots. There is a method of solutio for such recurreces, but we will ot cocer ourselves with this case sice it does ot typically arise i recurreces that come from studyig recursive algorithms. 2

Part 2. No-homogeeous liear 2d degree relatios with costat coefficiets. Now cosider what happes whe the right side of equatio ( ) (from page 1) is ot zero. We get a equatio of the form ( ) T () + at ( 1) + bt ( 2) = f() We ll lear how to solve ( ) i the special case that f() =(polyomial i )r. Actually, this requires oly a slight modificatio of the method for the homogeeous case. We simply multiply the characteristic equatio by (x r) k+1 where k is the degree of the polyomial part of f(). The solutio method the proceeds as before. This is best illustrated by examples. Example 3. Solve the recurrece relatio { 1 = 0 T () = 3T ( 1) + 2 > 0 Note: This is actually a 1st degree relatio (sice T ( 2) does ot appear), but the same method applies. Solutio: If the ohomogeeous term 2 were ot preset, the characteristic equatio would be simply x 3 = 0. I the presece of the ohomogeeous term, however, we must multiply this by (x 2) 0+1 (I this case f() = 2 is a 0-degree polyomial [the costat 1] times a 2 term.) So, the characteristic equatio is actually (x 3)(x 2) = 0, so the geeral solutio is T () = c 1 3 + c 2 2. Note that sice the relatio is oly 1st degree, we oly have oe iitial coditio. Yet we ll eed two equatios to fid the costats c 1 ad c 2. We ca get a secod value to use by simply applyig the recurrece formula for = 1: T (1) = 3T (0) + 2 1 = 3(1) + 2 = 5. We ow proceed as usual: 1 = T (0) = c 1 3 0 + c 2 2 0 = c 1 + c 2 5 = T (1) = c 1 3 1 + c 2 2 1 = 3c 1 + 2c 2 These equatios have solutio c 1 = 3 ad c 2 = 2, so the exact solutio is T () = (3)3 (2)2 = 3 +1 2 +1 Check: The recurrece formula gives us values T (2) = 3T (1) + 2 2 = 3(5) + 4 = 19 T (3) = 3T (2) + 2 3 = 3(19) + 8 = 65 These are boure out by our solutio: T (2) = 3 3 2 3 = 27 8 = 19, ad T (3) = 3 4 2 4 = 81 16 = 65. 3

Example 4. Solve the recurrece relatio { + 1 = 0, 1 T () = 5T ( 1) 6T ( 2) + 3 2 > 1 Solutio: Here agai, the ohomogeeous term ivolves a zero-degree polyomial, so the modified characteristic equatio will be (x 2 5x + 6)(x 2) 0+1 = 0, or (x 3)(x 2) 2 = 0. The geeral solutio must ow ivolve three terms: a 3 term, a 2 term, ad (because the (x 2) factor appears twice i the characteristic equatio) a 2 term. Thus: T () = c 1 3 + c 2 2 + c 3 2. We ll eed three equatios to solve for the three costats, yet we have oly the two iitial coditios T (0) = 1 ad T (1) = 2 to use. As i the last example, we ca geerate oe more value by usig the recurrece formula: T (2) = 5T (1) 6T (0) + 3 2 2 = 5(2) 6(1) + 12 = 16. This gives us the three equatios 1 = T (0) = c 1 3 0 + c 2 2 0 + c 3 (0) = c 1 + c 2 2 = T (1) = c 1 3 1 + c 2 2 1 + c 3 (1)2 1 = 3c 1 + 2c 2 + 2c 3 16 = T (2) = c 1 3 2 + c 2 2 2 + c 3 (2)2 2 = 9c 1 + 4c 2 + 8c 3 A little effort gives the solutio c 1 = 12, c 2 = 11, ad c 3 = 6. The exact solutio is the T () = 12 3 11 2 62 Note that we could have safely cocluded that T () is i Θ(3 ) simply from its geeral solutio (without eve solvig for c 1, c 2, ad c 3 ). Check: I additio to T (2) = 16, the recurrece formula gives us T (3) = 5T (2) 6T (1) + 3 2 3 = 5(16) 6(2) + 24 = 92 Checkig these agaist our solutio, we fid T (2) = 12 3 2 11 2 2 6(2)2 2 = 108 44 48 = 16 ad T (3) = 12 3 3 11 2 3 6(3)2 3 = 324 88 144 = 92. Example 5. Predict the big-theta behavior of a fuctio T () satisfyig the recurrece relatio T () = 7T ( 1) 10T ( 2) + (2 + 5)3. Solutio: The modified characteristic equatio is (x 2 7x + 10)(x 3) 1+1 = 0, or factorig, (x 2)(x 5)(x 3) 2 = 0. The geeral solutio is thus T () = c 1 2 + c 2 5 + c 3 3 + c 4 3. This will clearly be i Θ(5 ). Part 3. Chage of variable techique for decrease-by-costat-factor recurrece relatios. May recursive algorithms (such as biary search or merge sort ) work by dividig the iput i half ad callig itself o the ow-half-sized iput. Aalyzig the efficiecy of such algorithms leads to recurrece relatios that give T () i terms of T ( 2 ) istead of i terms of T ( 1). These decrease by a costat-factor recurrece relatios ca be coverted ito stadard liear recurrece relatios by applyig a simple chage of variable. Let s say we have a recurrece relatio of the form T () = at ( b ) + f() 4

where b is some positive iteger (usually b = 2). We will defie a ew fuctio S(k) by the rule S(k) = T (b k ). Our recurrece relatio the gives S(k) = T (b k ) = at ( ) + f(b k ) b k b = at (b k 1 ) + f(b k ) = as(k 1) + f(b k ) which is a first-order liear recurrece relatio for S. This ca the be solved by the methods we ve already covered. Example 6. Solve the recurrece relatio { 2 = 1 T () = 3T ( 2 ) + log2 () > 1 Solutio: Usig the substitutio S(k) = T (2 k ) this recurrece formula becomes S(k) = T (2 k ) = 3T ( ) + (2 k )log 2 (2 k ) 2 k 2 = 3T (2 k 1 ) + (2 k )k = 3S(k 1) + k2 k The characteristic equatio of this relatio is (x 3)(x 2) 1+1 = 0, so its geeral solutio is S(k) = c 1 3 k + c 2 2 k + c 3 k2 k. What about iitial coditios for S? We ca use the recurrece formula for T to get T (1) = 2, T (2) = 3T (1) + 2 = 8, ad T (4) = 3T (2) + 8 = 32. So, S(0) = T (2 0 ) = T (1) = 2, S(1) = T (2 1 ) = T (2) = 8, ad S(2) = T (2 2 ) = T (4) = 32. We ca ow use these values to get equatios for c 1, c 2, ad c 3 : 2 = S(0) = c 1 3 0 + c 2 2 0 + 0 8 = S(1) = c 1 3 1 + c 2 2 1 + c 3 (1)2 1 = 3c 1 + 2c 2 + 2c 3 32 = S(2) = c 1 3 2 + c 2 2 2 + c 3 (2)2 2 = 9c 1 + 4c 2 + 8c 3 Solvig this three-by-three system of equatios (by whatever method you prefer) leads to the solutio c 1 = 8, c 2 = 6, ad c 3 = 2. This gives the solutio to the recurrece relatio for S as S(k) = 8 3 k 6 2 k 2k2 k But we wat a formula for T, ot S. Rememberig that S(k) = T (2 k ) ad assumig is a power of 2, we ca say T () = S(log 2 ) = 8 3 log 2 6 2 log 2 2(log 2 )2 log 2 = 8 3 log 2 6 2log 2 valid for all values of that are powers of 2. Here we have used the familiar logarithm law that says 2 log 2 is equal to. What ca we do to simplify the term 3 log 2? This just requires a bit of logarithmic trickery: 3 log 2 = (2 log 2 3 ) log 2 = (2 log 2 ) log 2 3 = log 2 3 So, we ca rewrite our aswer as 5

T () = 8 log 2 3 6 2log 2 for = 1, 2, 4, 8,... Two otes about this solutio are i order: First, sice log 2 3 is clearly betwee 1 ad 2 (sice 3 is betwee 2 1 ad 2 2 ) we ca say that our solutio is i O( 2 ) (at least for the values = 1, 2, 4, 8,... ). Secod, we kow that our formula for T () is valid for powers of 2 that is, it correctly computes T (1), T (2), T (4), T (8), ad so o. What about the other values of? Thaks to somethig called the Smoothess Rule we ca at least say that our formula for T () has the correct big-theta behavior. See your text for the exact statemet, but the basic idea is this: Smoothess Rule: Suppose T () is i Θ(f()) for values of that are powers of a costat b 2. The if f() is a ice fuctio (here ice icludes the polyomials, 2, 3, etc. but ot expoetial or factorial fuctios) we ca say that T () really is i Θ(f()). Homework Problems Solve each of the followig recurrece relatios. 1 = 0 (A) T () = 4 = 1 8T ( 1) 15T ( 2) > 1 5 = 0 (B) T () = 9 = 1 6T ( 1) 9T ( 2) > 1 (C) T () = { 1 = 0 2T ( 1) + 3 > 0 1 = 0 (D) T () = 2 = 1 4T ( 1) 3T ( 2) + 1 > 1 Hit: The ohomogeeous term is 1. { 2 = 1 (E) T () = T ( 3 ) + 7 > 1 { 2 = 1 (F) T () = 5T ( 2 ) + 3 > 1 6