Lesson32 Second Order Difference Equations Slides

45
Lesson 32 Second-order Difference Equations Math 20 May 2, 2007 Announcements I PS 12 due Wednesday, May 2 I MT III Friday, May 4 in SC Hall A I Final Exam: Friday, May 25 at 9:15am, Boylston 110 (Fong Auditorium) I Review Session: Tuesday, May 22 I Please do evaluations

description

Fibonacci sequence and other second-order difference equations

Transcript of Lesson32 Second Order Difference Equations Slides

Page 1: Lesson32   Second Order Difference Equations Slides

Lesson 32Second-order Difference Equations

Math 20

May 2, 2007

AnnouncementsI PS 12 due Wednesday, May 2I MT III Friday, May 4 in SC Hall AI Final Exam: Friday, May 25 at 9:15am, Boylston 110 (Fong

Auditorium)I Review Session: Tuesday, May 22I Please do evaluations

Page 2: Lesson32   Second Order Difference Equations Slides

Recap

Example: Fibonacci

Another example

Acceleration model of GDP growth

Page 3: Lesson32   Second Order Difference Equations Slides

FactThe solution to the homogeneous system of linear differenceequations y(k + 1) = Ay(k) is

y(k) = Aky(0)

FactLet A have a complete system of eigenvalues and eigenvectorsλ1,λ2, . . . ,λn and v1,v2, . . . ,vn. Then the solution to thedifference equation y(k + 1) = Ay(k) is

y(k) = Aky(0) = c1λk1 v1 + c2λ

k2 v2 + · · ·+ cnλ

kn vn

where c1,c2, . . . ,cn are chosen to make

y(0) = c1v1 + c2v2 + · · ·+ cnvn

Page 4: Lesson32   Second Order Difference Equations Slides

Applet fun

http://neuron.eng.wayne.edu/bpDynamics/TimeDynSys.html

Page 5: Lesson32   Second Order Difference Equations Slides

The big idea

GoalSolve second-order difference equations such as

f (k) = f (k −1) + f (k −2)

MethodTreat a second-order equation as a system of two first-orderequations.

Page 6: Lesson32   Second Order Difference Equations Slides

The big idea

GoalSolve second-order difference equations such as

f (k) = f (k −1) + f (k −2)

MethodTreat a second-order equation as a system of two first-orderequations.

Page 7: Lesson32   Second Order Difference Equations Slides

Recap

Example: Fibonacci

Another example

Acceleration model of GDP growth

Page 8: Lesson32   Second Order Difference Equations Slides

Setting up the Fibonacci sequence

Recall the Fibonacci sequence defined by

f (k + 2) = f (k) + f (k + 1), f (0) = 1, f (0) = 1

Let’s let g(k) = f (k + 1). Then

g(k + 1) = f (k + 2) = f (k) + f (k + 1) = f (k) + g(k).

So if y(k) =

[f (k)g(k)

], we have

y(k + 1) =

[f (k + 1)g(k + 1)

]=

[g(k)

f (k) + g(k)

]=

[1 01 1

]y(k)

Page 9: Lesson32   Second Order Difference Equations Slides

Diagram of rabbits

f (0) = 1

f (1) = 1

f (2) = 2

f (3) = 3

f (4) = 5

f (5) = 8

Page 10: Lesson32   Second Order Difference Equations Slides

Diagram of rabbits

f (0) = 1

f (1) = 1

f (2) = 2

f (3) = 3

f (4) = 5

f (5) = 8

Page 11: Lesson32   Second Order Difference Equations Slides

Diagram of rabbits

f (0) = 1

f (1) = 1

f (2) = 2

f (3) = 3

f (4) = 5

f (5) = 8

Page 12: Lesson32   Second Order Difference Equations Slides

Diagram of rabbits

f (0) = 1

f (1) = 1

f (2) = 2

f (3) = 3

f (4) = 5

f (5) = 8

Page 13: Lesson32   Second Order Difference Equations Slides

Diagram of rabbits

f (0) = 1

f (1) = 1

f (2) = 2

f (3) = 3

f (4) = 5

f (5) = 8

Page 14: Lesson32   Second Order Difference Equations Slides

Diagram of rabbits

f (0) = 1

f (1) = 1

f (2) = 2

f (3) = 3

f (4) = 5

f (5) = 8

Page 15: Lesson32   Second Order Difference Equations Slides

Setting up the Fibonacci sequence

Recall the Fibonacci sequence defined by

f (k + 2) = f (k) + f (k + 1), f (0) = 1, f (0) = 1

Let’s let g(k) = f (k + 1). Then

g(k + 1) = f (k + 2) = f (k) + f (k + 1) = f (k) + g(k).

So if y(k) =

[f (k)g(k)

], we have

y(k + 1) =

[f (k + 1)g(k + 1)

]=

[g(k)

f (k) + g(k)

]=

[1 01 1

]y(k)

Page 16: Lesson32   Second Order Difference Equations Slides

Setting up the Fibonacci sequence

Recall the Fibonacci sequence defined by

f (k + 2) = f (k) + f (k + 1), f (0) = 1, f (0) = 1

Let’s let g(k) = f (k + 1). Then

g(k + 1) = f (k + 2) = f (k) + f (k + 1) = f (k) + g(k).

So if y(k) =

[f (k)g(k)

], we have

y(k + 1) =

[f (k + 1)g(k + 1)

]=

[g(k)

f (k) + g(k)

]=

[1 01 1

]y(k)

Page 17: Lesson32   Second Order Difference Equations Slides

Diagonalize

The eigenvalues of A =

[1 01 1

]are found by solving

0 =

∣∣∣∣−λ 11 1−λ

∣∣∣∣= (−λ )(1−λ )−1

= λ2−λ −1

The roots are

ϕ =1 +√

52

ϕ̄ =1−√

52

Notice thatϕ + ϕ̄ = 1, ϕϕ̄ =−1

(These facts make later calculations simpler.)

Page 18: Lesson32   Second Order Difference Equations Slides

Diagonalize

The eigenvalues of A =

[1 01 1

]are found by solving

0 =

∣∣∣∣−λ 11 1−λ

∣∣∣∣= (−λ )(1−λ )−1

= λ2−λ −1

The roots are

ϕ =1 +√

52

ϕ̄ =1−√

52

Notice thatϕ + ϕ̄ = 1, ϕϕ̄ =−1

(These facts make later calculations simpler.)

Page 19: Lesson32   Second Order Difference Equations Slides

Diagonalize

The eigenvalues of A =

[1 01 1

]are found by solving

0 =

∣∣∣∣−λ 11 1−λ

∣∣∣∣= (−λ )(1−λ )−1

= λ2−λ −1

The roots are

ϕ =1 +√

52

ϕ̄ =1−√

52

Notice thatϕ + ϕ̄ = 1, ϕϕ̄ =−1

(These facts make later calculations simpler.)

Page 20: Lesson32   Second Order Difference Equations Slides

Eigenvectors

We row reduce to find the eigenvectors:

A−ϕI =

[−ϕ 11 1−ϕ

]=

[−ϕ 11 ϕ̄

]←−−ϕ̄

+

[−ϕ 10 0

]

So[

]is an eigenvector for A corresponding to the eigenvalue

ϕ.

Similarly,[

1ϕ̄

]is an eigenvector for A corresponding to the

eigenvalue ϕ̄. So now we know that

y(k) = c1ϕk[

]+ c2ϕ̄

k[

1ϕ̄

]

Page 21: Lesson32   Second Order Difference Equations Slides

Eigenvectors

We row reduce to find the eigenvectors:

A−ϕI =

[−ϕ 11 1−ϕ

]=

[−ϕ 11 ϕ̄

]←−−ϕ̄

+

[−ϕ 10 0

]

So[

]is an eigenvector for A corresponding to the eigenvalue

ϕ.

Similarly,[

1ϕ̄

]is an eigenvector for A corresponding to the

eigenvalue ϕ̄.

So now we know that

y(k) = c1ϕk[

]+ c2ϕ̄

k[

1ϕ̄

]

Page 22: Lesson32   Second Order Difference Equations Slides

Eigenvectors

We row reduce to find the eigenvectors:

A−ϕI =

[−ϕ 11 1−ϕ

]=

[−ϕ 11 ϕ̄

]←−−ϕ̄

+

[−ϕ 10 0

]

So[

]is an eigenvector for A corresponding to the eigenvalue

ϕ.

Similarly,[

1ϕ̄

]is an eigenvector for A corresponding to the

eigenvalue ϕ̄. So now we know that

y(k) = c1ϕk[

]+ c2ϕ̄

k[

1ϕ̄

]

Page 23: Lesson32   Second Order Difference Equations Slides

What are the constants?

To find c1 and c2, we solve[11

]= c1

[1ϕ

]+ c2

[1ϕ̄

]=

[1 1ϕ ϕ̄

][c1c2

]=⇒

[c1c2

]=

[1 1ϕ ϕ̄

]−1[11

]=

1ϕ̄−ϕ

[ϕ̄ −1−ϕ 1

]=

1ϕ̄−ϕ

[ϕ̄−1ϕ + 1

][11

]=

1√5

−ϕ̄

]

Page 24: Lesson32   Second Order Difference Equations Slides

Finally

Putting this all together we have

y(k) =ϕ√5

ϕk[

]− ϕ̄√

5ϕ̄

k[

1ϕ̄

][

f (k)g(k)

]=

1√5

[ϕk+1− ϕ̄k+1

ϕk+2− ϕ̄k+2

]

So

f (k) =1√5

(1 +√

52

)k+1

(1−√

52

)k+1

Page 25: Lesson32   Second Order Difference Equations Slides

Finally

Putting this all together we have

y(k) =ϕ√5

ϕk[

]− ϕ̄√

5ϕ̄

k[

1ϕ̄

][

f (k)g(k)

]=

1√5

[ϕk+1− ϕ̄k+1

ϕk+2− ϕ̄k+2

]So

f (k) =1√5

(1 +√

52

)k+1

(1−√

52

)k+1

Page 26: Lesson32   Second Order Difference Equations Slides

Recap

Example: Fibonacci

Another example

Acceleration model of GDP growth

Page 27: Lesson32   Second Order Difference Equations Slides

QuestionSuppose that we have a large number of blocks of three colors:yellow, red, and gree. Each yellow block fills one space, andeach red or green block fills two spaces. How many differentways are there to arrange the block in a line so that they fill kspaces?

Page 28: Lesson32   Second Order Difference Equations Slides

Guessing the first few values

k Arrangements r(k)

0

∅ 1

1 Y 1

2 YY, R, G 33 YYY, RY, YR, GY, YG 5

Page 29: Lesson32   Second Order Difference Equations Slides

Guessing the first few values

k Arrangements r(k)

0

∅ 1

1 Y 12 YY, R, G 3

3 YYY, RY, YR, GY, YG 5

Page 30: Lesson32   Second Order Difference Equations Slides

Guessing the first few values

k Arrangements r(k)

0

∅ 1

1 Y 12 YY, R, G 33 YYY, RY, YR, GY, YG 5

Page 31: Lesson32   Second Order Difference Equations Slides

Guessing the first few values

k Arrangements r(k)

0 ∅ 11 Y 12 YY, R, G 33 YYY, RY, YR, GY, YG 5

Page 32: Lesson32   Second Order Difference Equations Slides

Deriving a difference equationThink about a row of k blocks. Let r(k) be the number ofarrangements.

I Suppose we put a yellow block in the last spot. We can fillk spaces by filling the first k −1 spaces anyway we want,then stick on a yellow block. This accounts for r(k −1)ways to fill k spaces.

I Suppose the last two spots are taken up by a red block.We can fill k spaces by filling the first k −2 spaces anywaywe want, then stick on a red block. This accounts forr(k −2) ways to fill k spaces.

I Suppose the last two spots are taken up by a green block.We can fill k spaces by filling the first k −2 spaces anywaywe want, then stick on a green block. This accounts forr(k −2) ways to fill k spaces.

Thus

r(k) = r(k −1) + 2r(k −2) ⇐⇒ r(k + 2) = r(k + 1) + 2r(k)

Page 33: Lesson32   Second Order Difference Equations Slides

Deriving a difference equationThink about a row of k blocks. Let r(k) be the number ofarrangements.I Suppose we put a yellow block in the last spot. We can fill

k spaces by filling the first k −1 spaces anyway we want,then stick on a yellow block. This accounts for r(k −1)ways to fill k spaces.

I Suppose the last two spots are taken up by a red block.We can fill k spaces by filling the first k −2 spaces anywaywe want, then stick on a red block. This accounts forr(k −2) ways to fill k spaces.

I Suppose the last two spots are taken up by a green block.We can fill k spaces by filling the first k −2 spaces anywaywe want, then stick on a green block. This accounts forr(k −2) ways to fill k spaces.

Thus

r(k) = r(k −1) + 2r(k −2) ⇐⇒ r(k + 2) = r(k + 1) + 2r(k)

Page 34: Lesson32   Second Order Difference Equations Slides

Deriving a difference equationThink about a row of k blocks. Let r(k) be the number ofarrangements.I Suppose we put a yellow block in the last spot. We can fill

k spaces by filling the first k −1 spaces anyway we want,then stick on a yellow block. This accounts for r(k −1)ways to fill k spaces.

I Suppose the last two spots are taken up by a red block.We can fill k spaces by filling the first k −2 spaces anywaywe want, then stick on a red block. This accounts forr(k −2) ways to fill k spaces.

I Suppose the last two spots are taken up by a green block.We can fill k spaces by filling the first k −2 spaces anywaywe want, then stick on a green block. This accounts forr(k −2) ways to fill k spaces.

Thus

r(k) = r(k −1) + 2r(k −2) ⇐⇒ r(k + 2) = r(k + 1) + 2r(k)

Page 35: Lesson32   Second Order Difference Equations Slides

Deriving a difference equationThink about a row of k blocks. Let r(k) be the number ofarrangements.I Suppose we put a yellow block in the last spot. We can fill

k spaces by filling the first k −1 spaces anyway we want,then stick on a yellow block. This accounts for r(k −1)ways to fill k spaces.

I Suppose the last two spots are taken up by a red block.We can fill k spaces by filling the first k −2 spaces anywaywe want, then stick on a red block. This accounts forr(k −2) ways to fill k spaces.

I Suppose the last two spots are taken up by a green block.We can fill k spaces by filling the first k −2 spaces anywaywe want, then stick on a green block. This accounts forr(k −2) ways to fill k spaces.

Thus

r(k) = r(k −1) + 2r(k −2) ⇐⇒ r(k + 2) = r(k + 1) + 2r(k)

Page 36: Lesson32   Second Order Difference Equations Slides

Deriving a difference equationThink about a row of k blocks. Let r(k) be the number ofarrangements.I Suppose we put a yellow block in the last spot. We can fill

k spaces by filling the first k −1 spaces anyway we want,then stick on a yellow block. This accounts for r(k −1)ways to fill k spaces.

I Suppose the last two spots are taken up by a red block.We can fill k spaces by filling the first k −2 spaces anywaywe want, then stick on a red block. This accounts forr(k −2) ways to fill k spaces.

I Suppose the last two spots are taken up by a green block.We can fill k spaces by filling the first k −2 spaces anywaywe want, then stick on a green block. This accounts forr(k −2) ways to fill k spaces.

Thus

r(k) = r(k −1) + 2r(k −2) ⇐⇒ r(k + 2) = r(k + 1) + 2r(k)

Page 37: Lesson32   Second Order Difference Equations Slides

So let y(k) =

[r(k)

r(k + 1)

]. Then

y(k + 1) =

[r(k + 1)r(k + 2)

]=

[r(k + 1)

r(k + 1) + 2r(k)

]=

[0 12 1

]y(k)

The eigenvalues of[0 12 1

]are 2 and −1 with eigenvectors

[12

]and

[−11

]. We have r(0) = 1 and r(1) = 1, so

[c1c2

]=

[1 −12 1

]−1[11

]=

13

[1 1−2 1

][11

]=

13

[2−1

]

Page 38: Lesson32   Second Order Difference Equations Slides

So let y(k) =

[r(k)

r(k + 1)

]. Then

y(k + 1) =

[r(k + 1)r(k + 2)

]=

[r(k + 1)

r(k + 1) + 2r(k)

]=

[0 12 1

]y(k)

The eigenvalues of[0 12 1

]are 2 and −1 with eigenvectors

[12

]and

[−11

]. We have r(0) = 1 and r(1) = 1, so

[c1c2

]=

[1 −12 1

]−1[11

]=

13

[1 1−2 1

][11

]=

13

[2−1

]

Page 39: Lesson32   Second Order Difference Equations Slides

Solution

So [r(k)

r(k + 1)

]=

23

(2)k[12

]− 1

3(−1)k

[−11

]

meaning

r(k) =13

(2k+1 + (−1)k+2

)=

13

(2k+1 + (−1)k

)You can check that this does match up with the sequence.

Page 40: Lesson32   Second Order Difference Equations Slides

Solution

So [r(k)

r(k + 1)

]=

23

(2)k[12

]− 1

3(−1)k

[−11

]meaning

r(k) =13

(2k+1 + (−1)k+2

)=

13

(2k+1 + (−1)k

)

You can check that this does match up with the sequence.

Page 41: Lesson32   Second Order Difference Equations Slides

Solution

So [r(k)

r(k + 1)

]=

23

(2)k[12

]− 1

3(−1)k

[−11

]meaning

r(k) =13

(2k+1 + (−1)k+2

)=

13

(2k+1 + (−1)k

)You can check that this does match up with the sequence.

Page 42: Lesson32   Second Order Difference Equations Slides

Recap

Example: Fibonacci

Another example

Acceleration model of GDP growth

Page 43: Lesson32   Second Order Difference Equations Slides

Model of national income

Y (k) = C(k) + I(k) + G(k)

whereI Y (k) is national incomeI C(k) is consumer expenditureI I(k) is induced investmentI G(k) is government expenditure

all at time step k .

Page 44: Lesson32   Second Order Difference Equations Slides

Assumptions and Equation

I Consumer expenditure is proportional to national incomeat each time step

I Induced investment proportional to the increase in thenational income at the previous time step

I Government expenditure remains constant.

Putting this together gives an inhomogeneous second-orderequation

Y (k) + aY (k −1) + bY (k −2) = c

which we can solve using these same techniques.

Page 45: Lesson32   Second Order Difference Equations Slides

Assumptions and Equation

I Consumer expenditure is proportional to national incomeat each time step

I Induced investment proportional to the increase in thenational income at the previous time step

I Government expenditure remains constant.

Putting this together gives an inhomogeneous second-orderequation

Y (k) + aY (k −1) + bY (k −2) = c

which we can solve using these same techniques.