Z-TRANSFORMS. 1 Introduction The Z-transform is a tranform for sequences. Just like the Laplace transform takes a function of t and replaces it with another function of an auxillary variable s, well, the Z-transform takes a sequence and replaces it with a function of an auxillary variable, z. The reason for doing this is that it makes difference equations easier to solve, again, this is very like what happens with the Laplace tranform, where taking the Laplace tranform makes it easier to solve differential equations. A difference equation is an equation which tells you what the k + 2th term in a sequence is in terms of the k + 1th and kth terms, for example. Difference equations arise in numerical treatments of differential equations, in discrete time sampling and when studying systems that are intrinsically discrete, such as population models in ecology and epidemiology. 2 Review of Sequences A sequence is a list of numbers, sequences can be finite, like (2, 2, 3, 4) or infinite, like (1, 2, 3, 4, 5, . . .). We are interested in infinite sequences. These all have the general form (x0 , x1 , x3 , . . .) with the xk ’s standing for the numbers in the sequence. We use the short hand: (xk )∞ k=0 = (x0 , x1 , x2 , . . .) In otherwords, on the righthand side, we are saying the sequence is formed by writing out the xk ’s with k put equal to zero, then one and so on up to infinity. Often we are lazy and just write (xk ) when we mean (xk )∞ k=0 . 1 The sequence (2, 5, 8, 11, 14, . . .) is an arithmetic sequence, each term is calculated by adding three to the term before it. In fact, you can write a formula telling you what the kth term is: xk = 2 + 3k, and so (2 + 3k)∞ k=0 = (2, 5, 8, 11, 14, . . .) This is really the most you can know about the sequence, if you have a formula saying xk is such and such a thing involving k then you have solved the sequence and you can easily work out xk for any k, for example, we know that x1000 = 3002 in the example above. Another way of writing down the information in the sequence is to say: xk+1 = xk + 3 x0 = 2 This tells you how to find the next term in the sequence in terms of the previous one and it tells you where to start, at x0 = 2. This is a difference equation.1 It allows you to work out the sequence, but only step by step. To calculate x1000 you would first of all have to know x999 and to work this out you need x998 and so on and so on. We will see later how to use Z-tranforms to solve a sequence when we only know the difference equation. Another common sort of sequence is a geometric sequence, an example is (3, 15, 75, 375, . . .) Here, each term is given by multiplying the previous term by five, so, the difference equation is xk+1 = 5xk 1 x0 = 3 There is another name also used for a difference equation, it can be called an induction step, the difference usually is that you called it a difference equation if you intend to solve it and an induction step if you intend to use it as it is to work out the sequence term by term. 2 We also know the solution in this case: xk = 3 × 5k That is: (3 × 5k )∞ k=0 = (3, 15, 75, 375, . . .) More generally, a geometric sequence has the form: 2 3 (cαk )∞ k=0 = (c, cα, cα , cα , . . .) (1) and x0 = c and α is called the ratio. Example 1 The sequence: 15 15 60, 30, 15, , , . . . 2 4 is a geometrical sequence with c = 60 and α = 1/2. And the sequence (1, 1, 1, 1, 1, . . .) is a geometrical sequence with c = 1 and α = 1. A series is what you get when you sum up all the terms in a sequence. That is if the sequence is: (xk ) = (x0 , x1 , x2 ...) then the series is: ∞ X xk . k=0 Remark: This sum could be ∞ in some cases but we will not use anything that does not converge ;o) what is more, we will care a lot about geometric sequences and its series, nothing else... 3 Example 2 Consider the sequence: ∞ 1 1 1 1 = 1, , , , . . . 2k k=0 2 4 8 The corresponding series (sum) is: S= ∞ X 1 1 1 1 + + + ... = 1 + k 2 2 4 8 k=0 and if you think about it, S = 2 since at each step you are adding half the distance from where you are to two, if you keep adding for infinity you will finally get to two.2 Hey! what is coming is important: In fact, you can sum any geometric sequence with ratio less than one. When the ration is less than one we write r instead of α. Let S= ∞ X k cr = c ∞ X rk k=0 k=0 Next, we remember the formula that ∞ X 1 = rk 1−r k=0 (2) for |r| < 1. You can check this formula either using the Taylor series or the binomial expansion. Hence S= c 1−r (3) If the ratio is bigger than or equal to one then the corresponding series diverges, that is, it doesn’t sum up to finite amount. 2 Zeno’s paradox was based on this, Zeno, a philosopher in ancient Greece, worried about the fact that to get from A to B you had to first cross half the distance from A to B, then half of the distance remaining and so on for infinity. He thought that, since you had to cross an infinity of shorter and shorter distances, it must take you an infinite amount of time. He is wrong, of course, each shorter and shorter distance takes less and less time to cross and it all adds up to a finite number. Zeno had two paradoxes, the other has to do with asking when something moves, since at any instant it is in just one place. 4 3 The Definition of Z-transform The Z-transform of a sequence (xk ) is defined as Z[(xk )∞ k=0 ] = ∞ X xk k=0 (4) zk We often write: X(z) = Z[(xk )∞ k=0 ] (5) You can see that when you do the Z-transform it sums up all the sequence, and so the individual terms affect the dependence on z, but the resulting function is just a function of z, it has no k in it. It will become clearer later why we might do this, first, we will look at how to calculate the Z-tranform of a few example. Example 3 Lets find the Z-tranform of a geometric sequence (αk ). We have: Z[(αk )∞ k=0 ] = ∞ X αk k=0 Using (3) and supposing zk = ∞ X α k k=0 z = 1 z , = α z−α 1− z |α| < 1 or equivalently |α| < |z|. In particular, this |z| means that Z[(1, 1, 1, . . .)] = z z−1 Another Z-transform can be derived from this by differenciating with repect to α. This is a usefull trick, you might worry about whether it is okay to differenciate through the sum and so on, but we just assume everything works. So: z = z− α d Z[(αk )∞ ] = d z k=0 dα dα z − α d k ∞ z Z dα (α )k=0 = (z − α)2 z Z[(kαk−1 )∞ k=0 ] = (z − α)2 Z[(αk )∞ k=0 ] 5 and this means: Z[(0, 1, 2, 3, . . .)] = z (z − 1)2 Hence, we now have two entries in our table of Z-transforms: z z−α z Z[(kαk−1 )∞ k=0 ] = (z − α)2 Z[(αk )∞ k=0 ] = (6) (7) Example 4 Considerer the sequence (e−kT ) = (1, e−T , e−2T , e−3T , ...), T > 0, constant. Compute its Z-Transform. Z[(e−kT )∞ k=0 ] = ∞ X e−kT zk k=0 = ∞ −T k X e k=0 z −T If we suppose that | e z | < 1 (which is equivalent to say that the |z| > e−T ) then −T −2T −T (1, e z , e z2 ...) = (( e z )k )∞ k=0 is a geometric sequence of ratio less than 1. And therefore we can apply equation (2) as follows: 1 e−T 1− z z = z − e−T Z[(e−kT )∞ k=0 ] = Example 5 Find the Z-tranforms of 1 (a) (b) (3k ) (c) ((−2)k ) 4k (d) (4, 16, 64, 256, . . .) (e) (1, −3, 9, −27, . . .) (f ) (0, 1, 4, 12, 64, 160, . . .) TRY THEM!!! For (a) we have r = 1/4 so 1 z 4z Z = = k 4 z − 1/4 4z − 1 For (b) r = 3 giving For (a) we have r = 1/4 so Z[(3k )] = 6 z z−3 In (c) r = −2 but this makes no difference Z[((−2)k )] = z z+2 In (d) we see that r = 4 so z z−4 Z[(4, 16, 6, 64, 256, . . .)] = and in (e) r = −3 so Z[(1, −3, 9, −27, . . .)] = z z+3 Finally, looking carefully at (f ) you realize (k2k−1 ) = (0, 1, 4, 12, 64, 160, . . .) and hence: z (z − 2)2 Z[(0, 1, 4, 12, 64, 160, . . .)] = The unit pulse Another entry to the table of standard Z-tranforms is supplied by the unit pulse: (δk )∞ k=0 = (1, 0, 0, 0, . . .) so only the first term of this sequence is non-zero: x0 = 1 and xk = 0 for all k > 0. The Z-transform of this sequence can be worked out directly, remember the definition of the Z-tranform Z[(xk )∞ k=0 ] = ∞ X xk z=0 zk . In this case there is only one term in the sequence and hence only one term in the sum: Z[(δk )∞ k=0 ] = 7 1 =1 z0 4 Linearity of the Z-tranform It is possible to add sequences and to multiply them by constants. Say (xk )∞ k=0 and (yk )∞ k=0 are two sequences and a and b are two constants then we have a sequence ∞ ∞ (axk + byk )∞ k=0 = a(xk )k=0 + b(yk )k=0 Example 6 The sequence (2k +3)∞ k=0 = (4, 5, 7, 11, . . .) is the sum of the sequence (2k ) = (1, 2, 4, 8, . . .) and the sequence (3, 3, 3, . . .). Another example is the sequence (cαk ) which is c times the sequence (αk ). Theorem 1 The Z-tranform is linear. This means that: ∞ ∞ Z[(axk + byk )∞ k=0 ] = aZ[(xk )k=0 )] + bZ[(yk )k=0 ] Proof: Easy!!!! P∞ axk + byk , by definition 0 zk P xk P∞ yk = a ∞ , by linearity of the sum k +b 0 0 z zk ∞ = aZ((xk )∞ k=0 ) + bZ((xk )k=0 ) Z((axk + byk )∞ k=0 ) = Example 7 Z[(4, 5, 7, 11, . . .)] = Z[(2k + 3)∞ k=0 ] = Z[(2k )∞ k=0 ] + 3Z[(1, 1, 1, . . .)], by linearity z + 3z (♣) = z− 2 z−1 z(z − 1) + 3z(z − 2) = (z − 2)(z − 1) 2 4z = 2 − 7z z − 3z + 2 Recall that k Z((2 )) = ∞ X 2k 0 z k = z , z−2 8 provided |z| > 2 and Z((3, 3, 3, ...)) = 3 ∞ X 1 z = 3 , k z − 1 z 0 provided |z| > 1 and both things happen at the same time in (♣), which implies that Z= z 3z + , z−2 z−1 provided |z| > 2. And other example is: k ∞ Z[(cαk )∞ k=0 ] = cZ[(α )k=0 ] = 5 cz z−α The Delay Theorem or First Shifting Thereom A delayed sequence is one that starts later than some other known sequence. It has the form (xk−k0 )∞ k=0 so for k < k0 the subscript is negative and, since xj = 0 for j < 0, all the entries up to k = k0 are zero. Here is an example, say: (xk )∞ k=0 = (4, 5, 7, 11, . . .) then: (xk−2 )∞ k=0 = (0, 0, 4, 5, 7, 11, . . .) so, the sequence is delayed by k0 = 2 steps. Here is another example: (δk−4 )∞ k=0 = (0, 0, 0, 0, 1, 0, 0, 0, . . .) In this example the unit pulse has been delayed by four steps. The delay theorem tells us how to related the Z-tranform of a delayed sequence to the Z-tranform of the corresponding undelayed sequence: Theorem 2 The Delay Theorem. Z[(xk−k0 )] = 1 Z[(xk )] z k0 This Theorem is also called the First Shifting Theorem for Z-transforms. 9 (8) Proof: By definition of Z-transform: Z[(xk−k0 )] = ∞ X xk−k k=0 0 zk Now do a change of index: let j = k − k0 . Hence, k = j + k0 ; when k = 0, j = −k0 and when k = ∞, j = ∞. Thus: Z[(xk−k0 )] = ∞ X j=−k0 xj z j+k0 However, because xj = 0 for j < 0 the sum starts at j = 0. Thus: ∞ ∞ X 1 X xj xj 1 Z[(xk−k0 )] = = k0 = k0 Z[(xk )], j+k j 0 z z j=0 z z j=0 as required. (Because the subscript is ‘mute’). k ∞ ∞ Example 8 The sequence (0, 0, 1, 3, 9, 27, . . .) = (xk−2 )∞ k=0 where (xk )k=0 = (3 )k=0 = (1, 3, 9, 27, . . .) so the Z-tranform is: Z[(0, 0, 1, 3, 9, 27, . . .)] = Note: 1 1 z Z[(1, 3, 9, 27, . . .)] = 2 , 2 z z z−3 provided |z| > 3. 3k−2 , k > 3 (0, 0, 1, 3, 9, 27, ...) = 0, otherwise Example 9 Consider: Z[(δk−4 )∞ k=0 ] = 1 1 Z[(δk )] = 4 4 z z since Z[(δk )] = 1. Example 10 The seqence (0, 1, 1, 1, 1, . . .) is the one step delay of (1, 1, 1, 1, . . .) so we have: 1 1 z 1 Z[(0, 1, 1, 1, 1, . . .)] = Z[(1, 1, 1, 1, . . .)] = = z zz−1 z−1 10 There is anther way of doing the same question: by using linearity. We can write: (0, 1, 1, 1, 1, . . .) = (1, 1, 1, 1, . . .) − (1, 0, 0, 0, . . .) so Z[(0, 1, 1, 1, 1, . . .)] = Z[(1, 1, 1, 1, . . .)] − Z[(1, 0, 0, 0, . . .)] z z − (z − 1) 1 = −1= = z−1 z−1 z−1 More examples! Work out the Z-transform of the following sequences: 1. (2, 4, 10, 28, . . .) 2. (2, −2, 10, −26, . . .) 3. (3, 0, 0, 0, . . .) 4. (0, 0, 1, 1, 1, . . .) 5. (0, 2, 4, 10, 28, . . .) 6. (0, 0, 1, 2, 4, 8, . . .) 7. (1, 1, 0, 1, 1, 1, . . .) −→Try to do it yourself before reading the solution←− Solutions: 1. So this sequence is: (2, 4, 10, 28, . . .) = (1, 1, 1, 1, . . .) + (1, 3, 9, 27, . . .) so we use linearity Z[(2, 4, 10, 28, . . .)] = Z[(1, 1, 1, 1, . . .)] + Z[(1, 3, 9, 27, . . .)] z z 2z 2 − 4z = + = 2 , z−1 z−3 z − 4z + 3 provided |z| > 3. 11 2. So this sequence is: (2, −2, 10, −26, . . .) = (1, 1, 1, 1, . . .) + (1, −3, 9, −27, . . .) so we use linearity: Z[(2, −2, 10, −27, . . .)] = Z[(1, 1, 1, 1, . . .)] + Z[(1, −3, 9, −27, . . .)] z 2z 2 + 2z z + = 2 , = z−1 z+3 z + 2z − 3 provided |z| > 3. 3. (3, 0, 0, 0, . . .) = 3(δk ) so Z[(3, 0, 0, 0, . . .)] = 3. 4. (0, 0, 1, 1, 1, . . .) is the k0 = 2 delay of (1, 1, 1, 1, . . .) which means that: Z[(0, 0, 1, 1, 1, . . .)] = 1 z , z2 z − 1 provided |z| > 1. 5. (0, 2, 4, 10, 28, . . .) is (xk−1 ) where (xk ) = (2, 4, 10, 28, . . .) as in first exercise, hence: Z[(0, 2, 4, 10, 28, . . .)] = 1 2z 2 − 4z 2z − 4 = 2 2 z z − 4z + 3 z − 4z + 3 6. (0, 0, 1, 2, 4, 8, . . .) = (2k−2 ) and Z[(2k )] = z/(z − 2), so, Z[(0, 0, 1, 2, 4, 8, . . .)] = 1 z 1 = , z2 z − 2 z(z − 2) provided |z| > 2. 7. This one is a bit trickier. Notice that: (1, 1, 0, 1, 1, 1, . . .) = (1, 1, 1, 1, 1, . . .) − (0, 0, 1, 0, 0, . . .) and (0, 0, 1, 0, 0, . . .) = (δk−2 ). Hence, using linearity and the delay theorem we get: Z[(1, 1, 0, 1, 1, 1, . . .)] = Z[(1, 1, 1, 1, 1, . . .)] − Z[(0, 0, 1, 0, 0, . . .)] 12 1 z z3 − z + 1 − 2 = 2 , z−1 z z (z − 1) = provided |z| > 1. The Inverse Z transform. 6 The inverse Z transform is defined in a similar way to the inverse Laplace transform. Suppose that X(z) = Z((xk )∞ k=0 ), then: Z −1 (Z((xk ))) = (xk )∞ k=0 and Z(Z −1 (X(z)) = X(z). The best way to understand is through examples so let’s go! Example 11 An easy one, straight away from the table: Z −1 ( z ) = (2k )∞ k=0 z−2 Example 12 One with a fraction: 3 2 Suppose X(z) = z + 2z3 + 1 . Then: z X(z) = z 3 2z 2 1 2 1 + 3. 3 + 3 + 3 = 1+ z z z z z By the Delay Theorem: Z −1 (1) = (δk )∞ k=0 = (1, 0, 0, 0, ...) 1 Z −1 ( ) = (δk−1 )∞ k=0 = (0, 1, 0, 0, ...) z and Z −1 ( 1 ∞ 3 ) = (δk−3 )k=0 = (0, 0, 0, 1, 0, ...) z 13 Recall that the term in the sequences with negative subscripts are 0. Hence, using linearity: Z −1 ( z 3 + 2z 2 + 1 1 1 ) = Z −1 (1) + 2Z −1 ( ) + Z −1 ( 2 ) = (1, 2, 0, 1, 0, ...). 3 z z z Example 13 One with partial fractions: z . (z − 1)(z − 2) Since we cannot identify any sequence first hand, we proceed as we did with Compute the inverse Z transform of X(z) = Laplace transforms, splitting the fraction in two which are simpler: X(z) 1 −1 1 = = + , z (z − 1)(z − 2) z−1 z−2 check it!. Therefore: X(z) = z −z z = + , (z − 1)(z − 2) z−1 z−2 so via the table we conclude: Z −1 ( z −z z ) = Z −1 ( ) + Z −1 ( ) = (−1, −1, −1, ...) + (2k )∞ k=0 (z − 1)(z − 2) z−1 z−2 −1 + 2k , k > 0 k ∞ = (2 − 1)k=0 = 0, otherwise Another way of solving this examples is not getting rid of the z in the partial fraction decomposition: X(z) = z A B = + , (z − 1)(z − 2) z−1 z−2 so: X(z) = z A(z − 2) B(z − 1) = + , (z − 1)(z − 2) (z − 1)(z − 2) (z − 1)(z − 2) and therefore: z = A(z − 2) + −B(z − 1) = Az − 2A + Bz − B = (A + B)z − 2A − B, 14 so we conclude: 1 = A + B, 0 = −2A − B ⇒ A = −1, B = 2, hence: X(z) = z −1 2 = + , (z − 1)(z − 2) z−1 z−2 but we cannot identify in the table any sequence that go these Z transforms, so we do the following trick (that you should have always in mind :o) in case you do not remember to divide by z in the exam!): X(z) = 1 −z 1 2z z = + . (z − 1)(z − 2) zz−1 zz−2 and therefore z1 indicates a delayed sequence by one step by Delay Theorem 2z −1 and we know that Z −1 ( z−z − 1 ) = (−1, −1, −1, ...) and Z ( z − 2 ) = (2, 4, ...) = 2(1, 2, 4, ..). Hence: −1 + 22k−1 , k > 0 z −1 Z ( ) = (0, −1, −1, −1, ...)+2(0, 1, 2, 4, ..) = 0, otherwise (z − 1)(z − 2) −1 + 2k , k > 0 = 0, otherwise that is exactly the same result we obtained before!! Example 14 And the last one: 2z + 1 ). (z + 1)(z − 3) Notice that the only way we have to solve it is by partial fractions decomFind Z −1 ( position since there is not a constant alone in the numerator to divide by z the numerator and denominator as it happened in previous example :o[ 2z + 1 A B = + , (z + 1)(z − 3) z+1 z−3 15 so 2z + 1 A(z − 3) B(z + 1) = + , (z + 1)(z − 3) (z + 1)(z − 3) (z + 1)(z − 3) then: 2z + 1 = A(z − 3) + B(z + 1) = Az − 3A + Bz + B = (A + B)z + B − 3A which implies that: 7 B= . 4 1 A= , 4 Therefore: 2z + 1 1 7 = + . (z + 1)(z − 3) 4(z + 1) 4(z − 3) We use the same trick as in previous example, multiply and dividing by z: 2z + 1 1 z 1 7z = . (z + 1)(z − 3) z 4(z + 1) z 4(z − 3) Via the table and using linearity: 1 (−1)k , if k > 0 z 1 −1 k ∞ 4 Z (((−1) ))k=0 ) = = 4 4(z + 1) 0, if k=0 and 7 3k , if k > 0 7 −1 k ∞ 7z 4 Z ((3 ))k=0 ) = = , 4 4(z − 3) 0, if k=0 and z1 indicates delayed sequences by one step, so by the Delay Theorem: 1 (−1)k + 7 3k , if k > 0 2z + 1 −1 4 4 Z ( )= 0, if k=0 (z + 1)(z − 3) 7 The Advancing Theorem or Second Shifting Theorem The Advancing Theorem is used for finding the Z-tranform of a sequence which has been advanced. Here is an example, say we have the sequence: (xk ) = (3, 6, 12, 24, . . .) 16 then the first advance of this is the sequence: (xk+1 ) = (6, 12, 24, 48, . . .) and the second advance is: (xk+2 ) = (12, 24, 48, 96, . . .) Theorem 3 The Advancing Theorem. Z[(xk+1 )] = zZ[(xk )] − zx0 Z[(xk+2 )] = z 2 Z[(xk )] − z 2 x0 − zx1 , this Theorem can be called as The Second Shifting Theorem. Proof: Let us do it! Going back to first principals and use a change of index: Z[(xk+1 )] = ∞ X xk+1 zk k=0 now, let j = k + 1, so k = j − 1 and when k = 0 we have j = 1, when k = ∞, then j = ∞ as well. Hence: Z[(xk+1 )] = ∞ X xk+1 zk k=0 = ∞ X xk 0 z j−1 j=1 Next we use: 1 z j−1 =z 1 zj and the z can come to the front of the sum since it has no index: 1 z j−1 =z 1 zj and the z can come to the front of the sum since it has no index: Z[(xk+1 )] = z ∞ X xj j=1 17 zj Now, the sum starts at one instead of zero, we fix this by adding and subtracting the zeroth term: Z[(xk+1 )] = z = z ∞ X xj j=1 ∞ X j=1 = z zj xj + zx0 − zx0 zj ∞ X xj j=0 zj − zx0 Finally, the sum is just Z[(xk )], remember, it doesn’t matter what we call an index if we are summing over it, Z[(xk )] means exactly the same thing as Z[(xj )], this finishes the proof: Z[(xk+1 )] = zZ[(xk )] − zx0 To do the second advance we just apply the first advance formula twice. In short, as well as being the second advance of (xk ), (xk+2 ) is the first advance of (xk+1 ). The first term in the sequence (xk+1 ) is x1 . Applying the formula for the first advance we have: Z[(xk+2 )] = zZ[(xk+1 )] − zx1 and then applying it again: Z[(xk+2 )] = z(zZ[(xk )] − zx0 ) − zx1 = z 2 Z[(xk )] − z 2 x0 − zx1 Example 15 Consider (xk ) = (3, 6, 12, 24, . . .) above, we have: Z[(xk )] = Z[(3, 6, 12, 24, . . .)] = Z[3(1, 2, 4, 8, . . .)] = Z((3 · 2k )) = Then: Z[(xk+1 )] = zZ[(xk )] − zx0 2 = z3z − 2 − 3z 2 3z 2 − 6z = z3z − −2 z−2 6z = z−2 18 3z z−2 and Z[(xk+2 )] = z 2 Z[(xk )] − z 2 x0 − zx1 3 2 = z3z − 2 − 3z − 6z 3 3z 3 − 6z 2 − 6z 2 − 12z − = z3z −2 z−2 z−2 12z = z−2 8 Difference equations As mentioned before, the main use for Z-tranforms is solving difference equations. An example of a difference equation is: xk+1 − xk = 0, with x0 = 1 You see that the equation tells you that the (k + 1)th term in the sequence is equal to the kth term. This doesn’t tell you how to start off, but there is also an initial condition given: x0 = 1. So, if x0 = 1, the difference equation says xk+1 = xk and with k = 0 this tells us x1 = x0 = 1, next, with k = 1, the difference equation tells us that x2 = x1 = 1, and so on, clearly every term in this sequence is one and the solution to the difference equation is: (xk ) = (1, 1, 1, 1, . . .) Although this is too easy an example for it to be worthwhile, we could have solved this difference equation by taking the Z-tranform of both sides. Bearing in mind that the Z-transform of the sequence (0, 0, 0, . . .) is zero, we have: Z[(xk+1 ) − (xk )] = 0 and, hence, if we write Z[(xk )] = X(z) we have: zX − zx0 − X = 0 19 and then, we put in that x0 = 1 and find: (z − 1)X = z so X= z z−1 This is z/(z − r) with r = 1 and from the table of Z-tranforms, we see that this means (xk ) = (1, 1, 1, . . .). This is what we expected. Example 16 Another difference equation: xk+2 − xk+1 − 2xk = 0 with x0 = 0 and x1 = 1. This is called a two-step difference equation because it relates xk+2 to the two terms below it in the sequence, xk+1 and xk . We can work the sequence out term by term. With k = 0 we have: x2 − x1 − 2x0 = 0 Putting in x0 = 0 and x1 = 1 x2 = 1 Next, with k = 1 the difference equation is: x3 − x2 − 2x1 = 0 Putting in x0 = 0 and x1 = 1 x2 = 1 Next, with k = 1 the difference equation is: x3 − x2 − 2x1 = 0 and we know x2 = 1 and x1 = 1, therefore: x3 = 3 20 and so on it goes, with k = 2 x4 − x3 − 2x2 = 0 and we know x3 = 3 and x2 = 1, so x4 = 5 So far we have worked out that the sequence start off (0, 1, 1, 3, 5, . . .). What we really want is to be able to write xk in terms of k, we can do this using the Z-tranform. First, we take the Z-tranform of both sides of the equation: Z[(xk+2 ) − Z[(xk+1 )] − 2Z[(xk )] = 0 Using the advancing theorem this means: z 2 X − z 2 x0 − zx1 − zX − zx0 − 2X = 0 Putting in x0 = 0 and x1 = 1 z 2 X − z − zX − 2X = 0 or X= z z2 − z − 2 Now that we know X = Z[(xk )] we want to find xk . To do this we use partial fractions on the right hand side. Recalling the basic Z-tranform Z[(rk )] = z/(z − r) we see that we want a z on the top after the partial factions expansion has been done. If we did a partial fraction expansion on z/(z 2 − z − 2) we would end up 21 with something that has no z on top of the fractions. To avoid this we move the z over to the left hand side: 1 1 X= 2 z z −z−2 and then write: z2 1 1 A B = = + −z−2 (z − 2)(z + 1) z−2 z+1 Multiplying across: 1 = A(z + 1) + B(z − 2) z = 2 gives A = 1/3 and z = −1 gives B = −1/3. Now: 1 1 1 1 X= 2 = − z z −z−2 3(z − 2) 3(z + 1) so X= z z − 3(z − 2) 3(z + 1) and hence: 1 1 xk = 2k − (−1)k 3 3 We can quickly check that this gives the same values as those we calculated above, k=0 x0 = 1 1 − =0 3 3 k=1 1 1 x1 = 2 − (−1) = 1 3 3 k=2 1 1 4 1 x2 = 4 − (−1)2 = − = 1 3 3 3 3 k=3 1 1 x2 = 8 − (−1)3 = 3 3 3 22 and k = 4 1 1 x2 = 16 − (−1)4 = 5 3 3 The difference now is that we could also work out k = 8 say: 1 1 x8 = 256 − = 85 3 3 without having to work out all the lower terms first. More Examples So far we have studied a difference equation which conveniently has zero on the right hand side and has initial conditions x0 = 0 and x1 = 1. In the next note we will look at examples that aren’t quite so convenient, but for now, it is a good idea to pratise some more examples like the one above. 1. Solve the difference equation xk+2 −4xk+1 −5xk = 0 with x0 = 0 and x1 = 1. 2. Solve the difference equation xk+2 − 9xk+1 + 20xk = 0 with x0 = 0 and x1 = 1. 3. Solve the difference equation xk+2 +5xk+1 +6xk = 0 with x0 = 0 and x1 = 1. 4. Solve the difference equation xk+2 + 2xk+1 − 48xk = 0 with x0 = 0 and x1 = 1. 5. Solve the difference equation xk+2 + 7xk+1 − 18xk = 0 with x0 = 0 and x1 = 1. 6. Solve the difference equation xk+2 −6xk+1 +5xk = 0 with x0 = 0 and x1 = 1. −→Try them to check that you understood before reading the solution←− 23 1. So, take the Z-transform of both sides z 2 X − z − 4zX − 5X = 0 hence: X= z z 2 − 4z − 5 Move the z to the left and do partial fractions, 1 1 1 1 1 X= 2 = = − z z − 4z − 5 (z − 5)(z + 1) 6(z − 5) 6(z + 1) Thus: X= z z − 6(z − 5) 6(z + 1) and 1 1 xk = 5k − (−1)k 6 6 2. So, take the Z-transform of both sides z 2 X − z − 9zX + 20X = 0 3. So, take the Z-transform of both sides z 2 X − z − 9zX + 20X = 0 hence: X= z z 2 − 9z + 20 Move the z to the left and do partial fractions, 1 1 1 1 1 X= 2 = = − z z − 9z + 20 (z − 5)(z − 4) z−5 z−4 Thus X= z z − z−5 z−4 and xk = 5k − 4k 24 4. So, take the Z-transform of both sides: z 2 X − z + 5zX + 6X = 0 hence: X= z2 z + 5z + 6 Move the z to the left and do partial fractions, 1 1 1 1 1 X= 2 = = − z z + 5z + 6 (z + 2)(z + 3) z+2 z+3 Thus: X= z z − z+2 z+3 and xk = (−2)k − (−3)k 5. So, take the Z-transform of both sides z 2 X − z + 2zX − 48X = 0 hence: X= z2 z + 2z − 48 Move the z to the left and do partial fractions, 1 1 1 1 1 X= 2 = =− + z z + 2z − 48 (z + 8)(z − 6) 14(z + 8) 14(z − 6) Thus: X=− z z + 14(z + 8) 14(z − 6) and xk = − 1 1 (−8)k + 6k 14 14 25 6. So, take the Z-transform of both sides z 2 X − z + 7zX − 18X = 0 hence: X= z2 z + 2z − 48 Move the z to the left and do partial fractions, 1 1 1 1 1 X= 2 = =− + z z + 2z − 48 (z + 8)(z − 6) 14(z + 8) 14(z − 6) Thus: X=− z z + 14(z + 8) 14(z − 6) and xk = − 1 1 (−8)k + 6k 14 14 7. So, take the Z-transform of both sides z 2 X − z + 7zX − 18X = 0 hence: X= z2 z + 7z − 18 Move the z to the left and do partial fractions, 1 1 1 1 1 X= 2 = = − z z + 7z − 18 (z − 2)(z + 9) 11(z − 2) 11(z + 9) Thus: X= z z − 11(z − 2) 11(z + 9) and xk = 1 1 (−2)k − (−9)k 11 11 26 8. So, take the Z-transform of both sides z 2 X − z − 6zX + 5X = 0 hence: X= z2 z − 6z + 5 Move the z to the left and do partial fractions: 1 1 1 1 1 X= 2 = = − z z − 6z + 5 (z − 5)(z − 1) 4(z − 5) 4(z − 1) Thus: X= z z − 4(z − 5) 4(z − 1) and 1 1 xk = 5k − 4 4 Example 17 As another example of how to solve difference equations, let us solve: xk+2 − 6xk+1 − 55xk = 0 with x1 = 1 and x0 = 0. We begin by taking the Z-tranform of both sides, remember, if we write Z[(xk )] = X(z) then: Z[(xk+1 )] = zX − zx0 Z[(xk+2 )] = z 2 X − z 2 x0 − zx1 so, in this case we get: z 2 X − z − 6zX − 55X = 0 or X= z2 z − 6z − 55 27 As before, we do a partial fraction expansion, but, first we move the z over to the right hand side: 1 1 1 A B X= 2 = = + z z − 6z − 55 (z − 11)(z + 5) z − 11 z + 5 giving 1 = A(z + 5) + B(z − 11) Choose z = 11 to learn A = 1/16 and z = −5 to learn B = −16. Therefore: 1 1 1 X=− + z 16(z − 11) 16(z + 5) X=− z z + 16(z − 11) 16(z + 5) Both terms of the form z/(z − r) and so xk = − 1 1 (11)k + (−5)k 16 16 The basic process is simple, you take the Z-tranform of both sides, you solve for X, you use partial fractions to put it into a convenient form and then work out xk . In the rest of this note we will look at a variety of examples which exhibit the various difficulties that might be encountered doing this. Example 18 Not zero on the right hand side Consider the difference equation: xk+2 − 6xk+1 − 55xk = −(−3)k with x1 = 0 and x0 = 0. This is different than the previous example in that the right hand side is not zero, it is 3k . This doesn’t make such a difference, take the Z-tranform of both sides, and noting the trivial initial data (x0 = 0 and x1 = 0), z 2 X − 6zX − 55X = Z[(3k )] = − 28 z z+3 thus: 1 1 X=− z (z − 11)(z + 5)(z + 3) (9) Now, use partial fractions: 1 A B C = + + (z − 11)(z + 5)(z + 3) z − 11 z + 5 z + 3 or 1 = A(z + 5)(z + 3) + B(z − 11)(z + 3) + C(z − 11)(z + 5) Now, the usual, z = 11 gives A = 1/224, z = −5 gives B = 1/32 and z = −3 gives C = −1/28. Not forgetting the minus in equation (9) this gives: X=− 1 z 1 z 1 z − + 224 z − 11 32 z + 5 28 z + 3 and so xk = − 1 1 1 11k − (−5)k + (−3)k 224 32 28 Example 19 Remember that the sequence on the right hand side might be a sequence of ones, 1 = 1k , so, consider: xk+2 − 6xk+1 − 55xk = 1 with x1 = 0 and x0 = 0. Take the z-tranform of both sides: X − 6zX − 55X = Z[(1)] = Z[(1k )] = z z−1 and so 1 1 X= z (z − 11)(z + 5)(z − 1) Without going through the calculation, the partial fraction expansion is: 1 1 1 1 1 1 1 = + − (z − 11)(z + 5)(z − 1) 160 z − 11 96 z + 5 60 z − 1 and so, xk = 1 1 1 11k + (−5)k − 160 96 60 29 Example 20 Repeated root As happens with Laplace transforms, there can be a repeated root. Consider: xk+2 − 6xk+1 − 55xk = 11k with x1 = 0 and x0 = 0. Take the z-tranform of both sides: X − 6zX − 55X == Z[(11k )] = z z − 11 and so 1 1 X= z (z − 11)2 (z + 5) Now, remember that for repeated root the partial fraction expansion has a term with the root and a term with its square: 1 A B C = + + (z − 11)2 (z + 5) z − 11 (z − 11)2 z + 5 Thus: 1 = A(z − 11)(z − 5) + B(z + 5) + C(z − 11)2 Now, z = 11 gives B = 1/16 and z = −5 gives C = 1/256. The problem is that no choice of z gives A on its own, instead we chose any value that hasn’t been used before, z = 0 for example: 1 = −55A + 5B + 121C and now, we substitute for the known values of B and C: 1 = −55A + 5 121 201 + = −55A + 16 256 256 Hence: −55A = 1 − 201 55 = 256 256 so A = −1/256. This means that: X=− 1 z 1 z 1 z + + 2 256 z − 11 16 (z − 11) 256 z + 5 30 The only problem now is that the z/(z − 11)2 term might look unfamiliar, but recall: Z[(krk−1 )] = z (z − r)2 has this form. We get: xk = − 1 k 1 11k + 11k−1 + (−5)k 256 16 256 Example 21 Less convenient inital data So far the values of x0 and x1 have been chosen to keep things as simple as possible. More general values of x0 and x1 might be less convenient, but there is no big change in the method. Consider: xk+2 − 6xk+1 − 55xk = 0 with x1 = 2 and x0 = 6. Taking the Z-tranform of both sides gives: zX 2 − z 2 x0 − zx1 − 6(zX − zx0 ) − 55X = 0 and substituting for the initial data: zX 2 − 6z 2 − 2z − 6zX + 36z − 55X = 0 Moving everything around, this gives: 6z 2 − 34z X= 2 z − 6z − 55 We still want a z on top when we are finished, so move one over: 1 6z − 34 X= 2 z z − 6z − 55 and now, remember that the partial fraction expansion works fine provided whats on top is a polynomial of degree less than than the polynomial on the bottom, so we have 6z − 34 A B = + (z − 11)(z + 5) z − 11 z + 5 31 or 6z − 34 = A(z + 5) + B(z − 11) Choose z = 11 to get 66 − 34 = 16A or A = 2. z = −5 gives: −30 − 34 = −16B or B = 4. Thus: X= 2 4 + z − 11 z + 5 and xk = 2(11)k + 4(−5)k Example 22 Examples involving the delay theorem Consider: xk+2 − 6xk+1 − 55xk = δk with x1 = 0 and x0 = 0. δk is the unit pulse: (δk ) = (1, 0, 0, 0, . . .) and Z[(δk )] = 1. Hence: z 2 X − 6zX − 55X = Z[(δk )] = 1 so X= 1 (z − 11)(z + 5) Using the partial fraction expansion, this gives: X= 1 1 1 1 − 16 z − 11 16 z + 5 32 The problem now is that there are no z’s on top. However, if we rewrite it as 1 1 z 1 z X= − z 16 z − 11 16 z + 5 Now, the part inside the square brackets has the form we are familiar with, we can see: Z 1 1 k 11 − (−5)k 16 16 = 1 z 1 z − 16 z − 11 16 z + 5 and we also know from the delay theorem that the affect of multiplying by 1/z k0 is to delay the sequence by k0 steps. Hence, the sequence here is delayed by one step and: 0 xk = 1 11k−1 − 16 z=0 1 (−5)k−1 16 z≥1 Of course, the sequence on the right might be more complicated, consider: xk+2 − 6xk+1 − 55xk = yk with x1 = 0 and x0 = 0 where (yk ) = (0, 2, 0, 0, 0, . . .) We have to calculate Z[(yk )] before we can make any progress. However, it is easy to see that (yk ) is the first delay of twice the unit pulse (yk ) = 2(δk−1 ) so: Z[(yk )] = 2 z Thus the Z-tranform of the difference equation gives: z 2 X − 6zX − 55X = 2 z so, X= 2 z(z − 11)(z + 5) 33 There are two ways to go on from here, the first is to use the previous partial fractions expansion: 2 1 1 1 1 X = − z 16 z − 11 16 z + 5 2 1 z 1 z = 2 − z 16 z − 11 16 z + 5 so now we are dealing with a two step delay and, keeping the extra factor of two in mind 0 z≤1 xk = 1 11k−2 − 1 (−5)k−2 z ≥ 2 8 8 (10) The other way to make progress is to work out the partial fraction expansion: 1 1 1 1 1 1 1 =− + + z(z − 11)(z + 5) 55 z 176 z − 11 80 z + 5 This means that 1 1 z 2 1 z + X= − + z 55 176 z − 11 80 z + 5 and using the delay theorem: 0 xk = −2δ 55 k−1 + z=0 1 (11k−1 88 + 1 (−5)k−1 40 (11) z≥1 Now, it might look like this is a very different answer, but it isn’t, expression (10) and expression (11) are actually the same. Now that putting k = 1 in (11) gives: − 1 1 2 1 1 2 δ0 + 110 + (−5)0 = − + + =0 55 88 40 55 88 40 and, what’s more, 11k−1 = 11 × 11k−2 and (−5)k−1 = −5 × (−5)k−2 . And More Examples! 1. Solve the difference equation xk+2 −4xk+1 −5xk = 0 with x0 = 0 and x1 = 1. 34 2. Solve the difference equation xk+2 − 9xk+1 + 20xk = 2k with x0 = 0 and x1 = 0. 3. Solve the difference equation xk+2 + 5xk+1 + 6xk = (−2)k with x0 = 0 and x1 = 0. 4. Solve the difference equation xk+2 + 2xk+1 − 48xk = 0 with x0 = 4 and x1 = 2. 5. Solve the difference equation xk+2 + 7xk+1 − 18xk = δk with x0 = 0 and x1 = 0. TRY THEM!!! 1. So take the Z-transform of both sides z 2 X − z − 4zX − 5X = 0 and move things around to get X/z on one side and then do partial fractions 1 1 A B 1 X= 2 = = + z z − 4z − 5 (z − 5)(z + 1) z−5 z+1 In the usual way, we have: 1 = A(z + 1) + B(z − 5) and putting z = 5 gives A = 1/6 and putting z = −1 gives B = −1/6. Now X= z 1 − 6(z − 5) 6(z + 1) and hence: 1 1 xk = 5k − (−1)k 6 6 35 2. So, in this example, the right hand side of the difference equation is not zero. Taking the Z-transform of both sides we get: z 2 X − 9zX + 20X = Z[(2k )] = z z−2 Hence, since z 2 − 9z + 20 = (z − 5)(z − 4) 1 1 X= z (z − 5)(z − 4)(z − 2) The usual partial fractions tells us that 1 1 1 1 = − + (z − 5)(z − 4)(z − 2) 3(z − 5) 2(z − 4) 6(z − 2) and so 1 1 1 xk = 5k − 4k + 2k 3 2 6 3. Again, taking the Z-tranform of both sides we have z 2 X + 5zX + 6X = z z+2 Now, since z 2 + 5z + 6 = (z + 2)(z + 3) 1 1 X= z (z + 2)2 (z + 3) and there is a repeated root. The partial fraction expansion with a repeated root includes the root and its square, so we get A B C 1 = + + (z + 2)2 (z + 3) z + 2 (z + 2)2 z + 3 and so 1 = A(z + 2)(z + 3) + B(z + 3) + C(z + 2)2 Choosing z = −2 gives B = 1 and z = −3 gives C = 1. No value of z will give A on its own, so we choose another convenient value and put in the known values of B and C: 1 = 6A + 3 + 4 36 so A = −1. Now, this means X=− z z z + + z + 2 (z + 2)2 z + 3 and so xk = (−2)k + k(−2)k−1 + (−3)k 4. Take the Z-tranform of both sides, taking care to note the initial conditions: z 2 X − 4z 2 − 2z + 2(zX − 4z) − 48X = 0 Thus: z 2 X + 2zX − 48X = 4z 2 − 10z giving: 1 4z − 10 A B X= = + z (z + 8)(z − 6) z+8 z−6 Multiplying across we get: 4z − 10 = A(z − 6) + B(z + 8) Choosing z = −8 we have −42 = −14A implying A = 3. Choosing z = 6 14 = 14B so B = 1 and we get X= z 3z + z+8 z−6 and xk = 3(−8)k + 6k 37 5. Now, taking the Z-transform and using Z[(δk )] = 1 z 2 X + 7zX − 18X = 1 and so: X= z2 1 1 1 1 = = − + 7z − 18 (z − 9)(z + 2) 11(z − 9) 11(z + 2) Thus: 1 X= z z z − 11(z − 9) 11(z + 2) and so, using the delay theorem, we have 0 k=0 xk = 1 9k−1 − 1 (−2)k−1 k > 0 11 11 38