1 Solution of difference equations using z-transforms

Using z-transforms, in particular the shift theorems discussed at the end of the previous Section, provides a useful method of solving certain types of difference equation. In particular linear constant coefficient difference equations are amenable to the z-transform technique although certain other types can also be tackled. In fact all the difference equations that we looked at in Section 21.1 were linear:

y n + 1 = y n + d (1st order)

y n + 1 = A y n   (1st order)

y n + 2 = y n + 1 + y n   (2nd order)

Other examples of linear difference equations are

y n + 2 + 4 y n + 1 3 y n = n 2 (2nd order)

y n + 1 + y n = n 3 n     (1st order)

The key point is that for a difference equation to be classified as linear the terms of the sequence { y n } arise only to power 1 or, more precisely, the highest subscript term is obtainable as a linear combination of the lower ones. All the examples cited above are consequently linear. Note carefully that the term n 2 in our fourth example does not imply non-linearity since linearity is determined by the y n terms.

Examples of non-linear difference equations are

y n + 1 = y n + 1 y n + 1 2 + 2 y n = 3 y n + 1 y n = n cos ( y n + 1 ) = y n

We shall not consider the problem of solving non-linear difference equations.

The five linear equations listed above also have constant coefficients ; for example:

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

has the constant coefficients 1 , 4 , 3 .

The (linear) difference equation

n y n + 2 y n + 1 + y n = 0

has one variable coefficient viz n and so is not classified as a constant coefficient difference equation.

1.1 Solution of first order linear constant coefficient difference equations

Consider the first order difference equation

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

The equation could be solved in a step-by-step or recursive manner, provided that y 0 is known because

y 1 = 4 + 3 y 0 y 2 = 4 + 3 y 1 y 3 = 4 + 3 y 2 and so on.

This process will certainly produce the terms of the solution sequence { y n } but the general term y n may not be obvious. So consider

y n + 1 3 y n = 4 n = 0 , 1 , 2 , (1)

with initial condition y 0 = 1 .

We multiply both sides of (1) by z n and sum each side over all positive integer values of n and zero. We obtain

n = 0 ( y n + 1 3 y n ) z n = n = 0 4 z n

or

n = 0 y n + 1 z n 3 n = 0 y n z n = 4 n = 0 z n (2)

The three terms in (2) are clearly recognisable as z-transforms.

The right-hand side is the z-transform of the constant sequence { 4 , 4 , } which is 4 z z 1 .

If Y ( z ) = n = 0 y n z n denotes the z-transform of the sequence { y n } that we are seeking then n = 0 y n + 1 z n = z Y ( z ) z y 0 (by the left shift theorem).

Consequently (2) can be written

z Y ( z ) z y 0 3 Y ( z ) = 4 z z 1 (3)

Equation (3) is the z-transform of the original difference equation (1). The intervening steps have been included here for explanation purposes but we shall omit them in future. The important point is that (3) is no longer a difference equation. It is an algebraic equation where the unknown, Y ( z ) , is the z-transform of the solution sequence { y n } .

We now insert the initial condition y 0 = 1 and solve (3) for Y ( z ) :

( z 3 ) Y ( z ) z = 4 z ( z 1 ) ( z 3 ) Y ( z ) = 4 z z 1 + z = z 2 + 3 z z 1

 so Y ( z ) = z 2 + 3 z ( z 1 ) ( z 3 ) (4)

The final step consists of obtaining the sequence { y n } of which (4) is the z-transform. As it stands (4) is not recognizable as any of the standard transforms that we have obtained. Consequently, one method of ‘inverting’ (4) is to use a partial fraction expansion. (We assume that you are familiar with simple partial fractions. See HELM booklet  3.6) Thus

Y ( z ) = z ( z + 3 ) ( z 1 ) ( z 3 ) = z 2 z 1 + 3 z 3  (in partial fractions)

so Y ( z ) = 2 z z 1 + 3 z z 3

Now, taking inverse z-transforms, the general term y n is, using the linearity property,

y n = 2 ℤ 1 { z z 1 } + 3 ℤ 1 { z z 3 }

The symbolic notation ℤ 1 is common and is short for ‘the inverse z-transform of’.

Task!

Using standard z-transforms write down y n explicitly, where

y n = 2 ℤ 1 { z z 1 } + 3 ℤ 1 { z z 3 }

y n = 2 + 3 × 3 n = 2 + 3 n + 1 n = 0 , 1 , 2 , (5)

Checking the solution:

From this solution (5)

y n = 2 + 3 n + 1

we easily obtain

y 0 = 2 + 3 = 1  (as given)

y 1 = 2 + 3 2 = 7

y 2 = 2 + 3 3 = 25

y 3 = 2 + 3 4 = 79  etc.

These agree with those obtained by recursive solution of the given problem (1):

y n + 1 3 y n = 4 y 0 = 1

which yields

y 1 = 4 + 3 y 0 = 7

y 2 = 4 + 3 y 1 = 25

y 3 = 4 + 3 y 2 = 79  etc.

More conclusively we can put the solution (5) back into the left-hand side of the difference equation (1).

If   y n = 2 + 3 n + 1

then 3 y n = 6 + 3 n + 2

and   y n + 1 = 2 + 3 n + 2

So, on the left-hand side of (1),

y n + 1 3 y n = 2 + 3 n + 2 ( 6 + 3 n + 2 )

which does indeed equal 4, the given right-hand side, and so the solution has been verified.

Key Point 13

To solve a linear constant coefficient difference equation, three steps are involved:

  1. Replace each term in the difference equation by its z-transform and insert the initial condition(s).
  2. Solve the resulting algebraic equation. (Thus gives the z-transform Y ( z ) of the solution sequence.)
  3. Find the inverse z-transform of Y ( z ) .

The third step is usually the most difficult. We will consider the problem of finding inverse z-transforms more fully later.

Task!

Solve the difference equation

y n + 1 y n = d n = 0 , 1 , 2 , y 0 = a (6)

where a and d are constants.

(The solution will give the n  th term of an arithmetic sequence with a constant difference d and initial term a .)

Start by replacing each term of (6) by its z-transform:

If Y ( z ) = ℤ { y n } we obtain the algebraic equation

z Y ( z ) z y 0 Y ( z ) = d × z ( z 1 )

Note that the right-hand side transform is that of a constant sequence { d , d , } . Note also the use of the left shift theorem. Now insert the initial condition y 0 = a and then solve for Y ( z ) :

( z 1 ) Y ( z ) = d × z ( z 1 ) + z × a Y ( z ) = d × z ( z 1 ) 2 + a × z z 1

Finally take the inverse z-transform of the right-hand side. [Hint: Recall the z-transform of the ramp sequence { n } .]

We have

y n = d × ℤ 1 { z ( z 1 ) 2 } + a × ℤ 1 { z z 1 }

y n = d n + a n = 0 , 1 , 2 , (7)

using the known z-transforms of the ramp and unit step sequences. Equation (7) may well be a familiar result to you – an arithmetic sequence whose ‘zeroth’ term is y 0 = a has general term y n = a + n d .

i.e. { y n } = { a , a + d , a + n d , }

This solution is of course readily obtained by direct recursive solution of (6) without need for z-transforms. In this case the general term ( a + n d ) is readily seen from the form of the recursive solution: (Make sure you really do see it).

N.B. If the term a is labelled as the first term (rather than the zeroth) then

y 1 = a , y 2 = a + d , y 3 a + 2 d ,

so in this case the n  th term is

y n = a + ( n 1 ) d

rather than (7).

1.2 Use of the right shift theorem in solving difference equations

The problem just solved was given by (6), i.e.

y n + 1 y n = d with y 0 = a n = 0 , 1 , 2 ,

We obtained the solution

y n = a + n d n = 0 , 1 , 2 ,

Now consider the problem

y n y n 1 = d n = 0 , 1 , 2 , (8)

with y 1 = a .

The only difference between the two problems is that the ‘initial condition’ in (8) is given at n = 1 rather than at n = 0 . Writing out the first few terms should make this clear.

( 6 ) ( 8 ) y 1 y 0 = d y 0 y 1 = d y 2 y 1 = d y 1 y 0 = d ⋮ ⋮ y n + 1 y n = d y n y n 1 = d y 0 = a y 1 = a

The solution to (8) must therefore be the same as for (6) but with every term in the solution (7) of (6) shifted 1 unit to the left.

Thus the solution to (8) is expected to be

y n = a + ( n + 1 ) d n = 1 , 0 , 1 , 2 ,

(replacing n by ( n + 1 ) in the solution (7)).

Task!

Use the right shift theorem of z-transforms to solve (8) with the initial condition y 1 = a .

  1. Begin by taking the z-transform of (8), inserting the initial condition and solving for Y ( z ) :

    We have, for the z-transform of (8)

    Y ( z ) ( z 1 Y ( z ) + y 1 ) = d z z 1 [ Note that here d z means d × z ] Y ( z ) ( 1 z 1 ) a = d z z 1 Y ( z ) z 1 z = d z ( z 1 ) + a Y ( z ) = d z 2 ( z 1 ) 2 + a z z 1

    (9)

    The second term of Y ( z ) has the inverse z-transform { a u n } = { a , a , a , } .

    The first term is less straightforward. However, we have already reasoned that the other term in y n here should be ( n + 1 ) d .

  2. Show that the z-transform of ( n + 1 ) d is d z 2 ( z 1 ) 2 . Use the standard transform of the ramp and step:

    We have

    ℤ { ( n + 1 ) d } = d ℤ { n } + d ℤ { 1 }

    by the linearity property

    ℤ { ( n + 1 ) d } = d z ( z 1 ) 2 + d z z 1 = d z 1 + z 1 ( z 1 ) 2 = d z 2 ( z 1 ) 2

    as expected.

  3. Finally, state y n :

    Returning to (9) the inverse z-transform is

    y n = ( n + 1 ) d + a u n i.e. y n = a + ( n + 1 ) d n = 1 , 0 , 1 , 2 ,

    as we expected.

Task!

Earlier in this Section (pages 37-39) we solved

y n + 1 3 y n = 4 n = 0 , 1 , 2 , with y 0 = 1.

Now solve y n 3 y n 1 = 4 n = 0 , 1 , 2 , with y 1 = 1 . (10)

Begin by obtaining the z-transform of y n :

We have, taking the z-transform of (10),

Y ( z ) 3 ( z 1 Y ( z ) + 1 ) = 4 z z 1

(using the right shift property and inserting the initial condition.)

Y ( z ) 3 z 1 Y ( z ) = 3 + 4 z z 1 Y ( z ) ( z 3 ) z = 3 + 4 z z 1 so Y ( z ) = 3 z z 3 + 4 z 2 ( z 1 ) ( z 3 )

Write the second term as 4 z z ( z 1 ) ( z 3 ) and obtain the partial fraction expansion of the bracketed term. Then complete the z-transform inversion.

z ( z 1 ) ( z 3 ) = 1 2 z 1 + 3 2 z 3

We now have

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

so

y n = 3 × 3 n 2 + 6 × 3 n = 2 + 9 × 3 n = 2 + 3 n + 2 (11)

Compare this solution (11) to that of the previous problem (5) on page 39:

Solution (11) is just the solution sequence (5) moved 1 unit to the left. We anticipated this since the difference equation (10) and associated initial condition is the same as the difference equation (1) but shifted one unit to the left.