Lesson32 Second Order Difference Equations Slides

Post on 13-Jun-2015

7.545 views 1 download

Tags:

description

Fibonacci sequence and other second-order difference equations

Transcript of 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

Recap

Example: Fibonacci

Another example

Acceleration model of GDP growth

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

Applet fun

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

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.

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.

Recap

Example: Fibonacci

Another example

Acceleration model of GDP growth

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)

Diagram of rabbits

f (0) = 1

f (1) = 1

f (2) = 2

f (3) = 3

f (4) = 5

f (5) = 8

Diagram of rabbits

f (0) = 1

f (1) = 1

f (2) = 2

f (3) = 3

f (4) = 5

f (5) = 8

Diagram of rabbits

f (0) = 1

f (1) = 1

f (2) = 2

f (3) = 3

f (4) = 5

f (5) = 8

Diagram of rabbits

f (0) = 1

f (1) = 1

f (2) = 2

f (3) = 3

f (4) = 5

f (5) = 8

Diagram of rabbits

f (0) = 1

f (1) = 1

f (2) = 2

f (3) = 3

f (4) = 5

f (5) = 8

Diagram of rabbits

f (0) = 1

f (1) = 1

f (2) = 2

f (3) = 3

f (4) = 5

f (5) = 8

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)

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)

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

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

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

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ϕ̄

]

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ϕ̄

]

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ϕ̄

]

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

−ϕ̄

]

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

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

Recap

Example: Fibonacci

Another example

Acceleration model of GDP growth

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?

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

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

Guessing the first few values

k Arrangements r(k)

0

∅ 1

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

Guessing the first few values

k Arrangements r(k)

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

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)

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)

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)

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)

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)

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

]

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

]

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.

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.

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.

Recap

Example: Fibonacci

Another example

Acceleration model of GDP growth

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 .

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.

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.