Solving Linear Homogeneous Recurrence Relations ICS 6 D

  • Slides: 22
Download presentation
Solving Linear Homogeneous Recurrence Relations ICS 6 D Sandy Irani

Solving Linear Homogeneous Recurrence Relations ICS 6 D Sandy Irani

Recurrence Relations to Define a Sequence •

Recurrence Relations to Define a Sequence •

Induction and Recurrence Relations • We used inductive to verify that a formula was

Induction and Recurrence Relations • We used inductive to verify that a formula was a correct closed form solution for a sequence defined by a recurrence relation. • Now we will show to solve recurrence relations without knowing the formula in advance…. . (for a particular class of recurrence relations).

Linear Homogeneous Recurrence Relations • Linear: the coefficient of each term is a constant.

Linear Homogeneous Recurrence Relations • Linear: the coefficient of each term is a constant. – gn = 3 gn-1 + 2 gn-2 + n 2 (linear) – gn = 3(gn-1)2 + 2 gn-2 + n 2 (not linear) – gn = 2 gn-1·gn-2 + n 2 (not linear) – gn = n·gn-2 + n 2 (not linear) • Homogeneous: no additional terms that do not refer to earlier numbers in the sequence. – gn = 3 gn-1 + 2 gn-2 (homogeneous) – gn = 3 gn-1 + 2 gn-2 + n 2 (not homogeneous)

Linear? • gn = 3 gn-1 + 4 gn-2 + n 2 • gn

Linear? • gn = 3 gn-1 + 4 gn-2 + n 2 • gn = 3 gn-1 + (gn-2)/5 • gn = 3 gn-1 + 2 • gn = log(2)·gn-2 + 5 gn-7 • gn = n·gn-2 + 5 gn-7 • gn = gn-1·gn-2 + 5 gn-7 Homogeneous?

Linear Homogeneous Recurrence Relations • A linear homogeneous recurrence relation has the form: fn

Linear Homogeneous Recurrence Relations • A linear homogeneous recurrence relation has the form: fn = c 1· fn-1 + c 2· fn-2 + …. + cd· fn-d • c 1, c 2, …, cd are constants • If cd ≠ 0, degree d recurrence relation

Linear Homogeneous Recurrence Relations • Always has a solution of the form fn =

Linear Homogeneous Recurrence Relations • Always has a solution of the form fn = xn. • Plug into the recurrence and solve for x: • fn = 5 fn-1 – 6 fn-2

Linear Homogeneous Recurrence Relations • Characteristic equation for fn = 5 fn-1 – 6

Linear Homogeneous Recurrence Relations • Characteristic equation for fn = 5 fn-1 – 6 fn-2 is x 2 – 5 x + 6 = 0 (degree d recurrence relation -> characteristic equation is a degree d polynomial) Roots: x = 2, x = 3. (Case: distinct, real roots) Solutions: fn = 2 n and fn = 3 n

Linear Homogeneous Recurrence Relations • Any linear combination fn = α 1· 2 n

Linear Homogeneous Recurrence Relations • Any linear combination fn = α 1· 2 n + α 2· 3 n satisfies: fn = 5 fn-1 – 6 fn-2 fn = α 1· 2 n + α 2· 3 n is called the general solution of the recurrence relation fn = 5 fn-1 – 6 fn-2

Initial Conditions • Initial conditions narrow down the possibilities to one sequence fn =

Initial Conditions • Initial conditions narrow down the possibilities to one sequence fn = 5 fn-1 – 6 fn-2

Initial Conditions • Initial conditions are used to solve for the constants α 1

Initial Conditions • Initial conditions are used to solve for the constants α 1 and α 2 in fn = α 1· 2 n + α 2· 3 n • f 0 = 3 • f 1 = 8

Linear Homogeneous Recurrence Relations 1. 2. 3. 4. Plug in fn = xn to

Linear Homogeneous Recurrence Relations 1. 2. 3. 4. Plug in fn = xn to get characteristic equation Solve for roots of characteristic equation. Set up general solution. Use initial conditions to set up linear equations to solve for constants in general solution: – Degree d recurrence relation -> degree d characteristic equation -> d constants (unknown coefficients) in general solution – d initial conditions -> d equations.

Linear Homogeneous Recurrence Relations: degree 3 example 1. Plug in gn = xn to

Linear Homogeneous Recurrence Relations: degree 3 example 1. Plug in gn = xn to get characteristic equation gn = 4 gn-1 – gn-2 – 6 gn-3 g 0 = 5 g 1 = 0 g 2 = 18

Linear Homogeneous Recurrence Relations: degree 3 example 2. Solve for roots of characteristic equation.

Linear Homogeneous Recurrence Relations: degree 3 example 2. Solve for roots of characteristic equation. 3. Set up general solution.

Linear Homogeneous Recurrence Relations: degree 3 example 4. Use initial conditions to set up

Linear Homogeneous Recurrence Relations: degree 3 example 4. Use initial conditions to set up linear equations to solve for constants in general solution: gn = α 1· 3 n + α 2· 2 n + α 3·(-1)n g 0 = 5 g 1 = 0 g 2 = 18

Linear Homogeneous Recurrence Relations: degree 3 example 5. Solve linear equations for coefficients and

Linear Homogeneous Recurrence Relations: degree 3 example 5. Solve linear equations for coefficients and plug back in to general solution to get the specific solution for this sequence.

Linear Homogeneous Recurrence Relations: non-distinct roots gn = 6 gn-1 – 9 gn-2 g

Linear Homogeneous Recurrence Relations: non-distinct roots gn = 6 gn-1 – 9 gn-2 g 0 = 1 g 1 = 6

Non-distinct roots: Check solution Check that gn = n 3 n is a solution

Non-distinct roots: Check solution Check that gn = n 3 n is a solution to gn = 6 gn-1 – 9 gn-2

Linear Homogeneous Recurrence Relations: non-distinct roots gn = 6 gn-1 – 9 gn-2 general

Linear Homogeneous Recurrence Relations: non-distinct roots gn = 6 gn-1 – 9 gn-2 general solution: gn = α 1· 3 n + α 2·n 3 n g 0 = 1 g 1 = 6

General solution with non-distinct roots: Characteristic equation for {fn}: (x – r)m = 0

General solution with non-distinct roots: Characteristic equation for {fn}: (x – r)m = 0 General solution: fn = α 1·rn + α 2·n·rn+ α 3·n 2·rn + α 4·n 3·rn + …. + αm·nm-1·rn

General solution with non-distinct roots: Characteristic equation for {fn}: (x – 4)3 (x +

General solution with non-distinct roots: Characteristic equation for {fn}: (x – 4)3 (x + 1)2 (x – 5) = 0 General solution:

Example gn = 5 gn-1 – 8 gn-2+ 4 gn-3 g 0 = 5

Example gn = 5 gn-1 – 8 gn-2+ 4 gn-3 g 0 = 5 g 1 = 6 g 2 = 6