2 Second order difference equations

You will learn in this section about solving second order linear constant coefficient difference equations. In this case two initial conditions are required, typically either y 0 and y 1 or y 1 and y 2 . In the first case we use the left shift property of the z-transform, in the second case we use the right shift property. The same three basic steps are involved as in the first order case.

Task!

By solving

y n + 2 = y n + 1 + y n (12)

y 0 = y 1 = 1

obtain the general term y n of the Fibonacci sequence.

Begin by taking the z-transform of (12), using the left shift property. Then insert the initial conditions and solve the resulting algebraic equation for Y ( z ) , the z-transform of { y n } :

z 2 Y ( z ) z 2 y 0 z y 1 = z Y ( z ) z y 0 + Y ( z ) (taking z-transforms )

z 2 Y ( z ) z 2 z = z Y ( z ) z + Y ( z )    (inserting initial conditions)

( z 2 z 1 ) Y ( z ) = z 2

so

Y ( z ) = z 2 z 2 z 1 (solving for Y ( z ) ). Now solve the quadratic equation   z 2 z 1 = 0  and hence factorize the denominator of Y ( z ) :

z 2 z 1 = 0

z = 1 ± 1 + 4 2 = 1 ± 5 2

so if a = 1 + 5 2 , b = 1 5 2

Y ( z ) = z 2 ( z a ) ( z b ) This form for Y ( z ) often arises in solving second order difference equations. Write it in partial fractions and find y n , leaving a and b as general at this stage:

Y ( z ) = z z ( z a ) ( z b ) = A z z a + B z ( z b )  in partial fractions

where A = a a b  and B = b b a

Hence, taking inverse z-transforms

y n = A a n + B b n = 1 ( a b ) a n + 1 b n + 1 (13) Now complete the Fibonacci problem:

With a = 1 + 5 2 b = 1 5 2 so a b = 5

we obtain, using (13)

y n = 1 5 1 + 5 2 n + 1 1 5 2 n n = 2 , 3 , 4 ,

for the n  th term of the Fibonacci sequence. With an appropriate computational aid you could (i) check that this formula does indeed give the familiar sequence

{ 1 , 1 , 2 , 3 , 5 , 8 , 13 , }

and (ii) obtain, for example, y 50 and y 100 .

Key Point 14

The inverse z-transform of

Y ( z ) = z 2 ( z a ) ( z b ) a b is y n = 1 ( a b ) a n + 1 b n + 1

Task!

Use the right shift property of z-transforms to solve the second order difference equation

y n 7 y n 1 + 10 y n 2 = 0 with y 1 = 16 and y 2 = 5 .

[Hint: the steps involved are the same as in the previous Task]

Y ( z ) 7 ( z 1 Y ( z ) + 16 ) + 10 ( z 2 Y ( z ) + 16 z 1 + 5 ) = 0 Y ( z ) ( 1 7 z 1 + 10 z 2 ) 112 + 160 z 1 + 50 = 0 Y ( z ) z 2 7 z + 10 z 2 = 62 160 z 1

Y ( z ) = 62 z 2 z 2 7 z + 10 160 z z 2 7 z + 10 = z ( 62 z 160 ) ( z 2 ) ( z 5 ) = 12 z z 2 + 50 z z 5  in partial fractions  so y n = 12 × 2 n + 50 × 5 n n = 0 , 1 , 2 ,

We now give an Example where a quadratic equation with repeated solutions arises.

Example 1
  1. Obtain the z-transform of { f n } = { n a n } .
  2. Solve

    y n 6 y n 1 + 9 y n 2 = 0 n = 0 , 1 , 2 , y 1 = 1 y 2 = 0

    [Hint: use the result from (1) at the inversion stage.]

Solution
  1. Z { n } = z ( z 1 ) 2 Z { n a n } = z a z a 1 2 = a z ( z a ) 2 where we have used the property Z { f n a n } = F z a
  2. Taking the z-transform of the difference equation and inserting the initial conditions:

    Y ( z ) 6 ( z 1 Y ( z ) + 1 ) + 9 ( z 2 Y ( z ) + z 1 ) = 0

    Y ( z ) ( 1 6 z 1 + 9 z 2 ) = 6 9 z 1

    Y ( z ) ( z 2 6 z + 9 ) = 6 z 2 9 z

    Y ( z ) = 6 z 2 9 z ( z 3 ) 2 = z 6 z 9 ( z 3 ) 2 = z 6 z 3 + 9 ( z 3 ) 2  in partial fractions

    from which, using the result (1) on the second term,

    y n = 6 × 3 n + 3 n × 3 n = ( 6 + 3 n ) 3 n

    We shall re-do this inversion by an alternative method shortly.

Task!

Solve the difference equation

y n + 2 + y n = 0 with y 0 , y 1 arbitrary. (14)

Start by obtaining Y ( z ) using the left shift theorem:

z 2 Y ( z ) z 2 y 0 z y 1 + Y ( z ) = 0 ( z 2 + 1 ) Y ( z ) = z 2 y 0 + z y 1 Y ( z ) = z 2 z 2 + 1 y 0 + z z 2 + 1 y 1

To find the inverse z-transforms recall the results for Z { cos ω n } and Z { sin ω n } from Key Point 6 (page 21) and some of the particular cases discussed in Section 21.2. Hence find y n here:

Taking Z { cos ω n } and Z { sin ω n } with ω = π 2

Z cos n π 2 = z 2 z 2 + 1 Z sin n π 2 = z z 2 + 1

Hence y n = y 0 1 { z 2 z 2 + 1 } + y 1 1 { z z 2 + 1 } = y 0 cos n π 2 + y 1 sin n π 2 (15) Those of you who are familiar with differential equations may know that

d 2 y d t 2 + y = 0 y ( 0 ) = y 0 , y ( 0 ) = y 0 (16)

has solutions y 1 = cos t and y 2 = sin t and a general solution

y = c 1 cos t + c 2 sin t (17)

where c 1 = y 0 and c 2 = y 0 .

This differential equation is a model for simple harmonic oscillations. The difference equation (14) and its solution (15) are the discrete counterparts of (16) and (17).