Chapter 7 Z Transforms 7.1 Introduction In continuous time, the linear systems we try to analyse and design have output responses y(t) that satisfy differential equations. In general, it is hard to solve a differential equation, but we make our job easier by taking Laplace Transforms, and then examining the Laplace Transform Y (s) of the output solution. We gain qualitative information on the nature of y(t) just by observing the locations of the poles in Y (s). In discrete time, the digital filters we implement all satisfy a basic digital filter equation yk+n + an−1 yk+n−1 + · · · + a1 yk+1 + a0 yk = bm uk+m + · · · + b1 uk+1 + b0 uk . which is a difference equation, which is quite different to the differential equations governing our linear filters in continuous time. However, completely analogous to the continuous time case, we don’t solve the time domain difference equation directly. We use a transform to gain qualitative information (and quantitative too if we are prepared to do some arithmetic) about the output solution sequence {yk }. The transform we use in discrete time is called the Z Transform. 7.2 Relationship between Z Transforms and Laplace Transforms In continuous time, a linear system is one whose input-output relationship satisfies a differential equation. For example the output y(t) might be related to the input u(t) according to dy(t) du(t) d2 y(t) +2 + y(t) = 3 dt dt dt (7.1) Now, in general it is too involved to solve this equation in the time domain, and so we move to the frequency domain. That is, we suppose that the input u(t) and output y(t) are sinusoidal in nature. How much of y(t) is due to a sine wave at frequency ω is measured by the Fourier Transform y! of y evaluated at ω. That is, the Fourier transform tells us that y(t) has a component in it of the form y!(ω)ejωt . Also, we can easily work out that d2 d jωt e = jωejωt , 2 ejωt = (jω)2 ejωt , . . . dt dt 385 CHAPTER 7. Z TRANSFORMS 386 and so if y!(ω)ejωt is a component of y(t) and y(t) satisfies the differential equation (7.1) then we can substitute the component y!(ω)ejωt into (7.1) and obtain (jω)2 y!(ω)ejωt + 2(jω)! y (ω)ejωt + y!(ω)ejωt = 3(jω)! u(ω)ejωt . Now the ejωt term cancels on both sides of this equation to give a relationship between u !(ω) and y!(ω) as y!(ω) 3 = 2 u !(ω) (jω) + 2jω + 1 and this ratio y!(ω)/! u(ω) is called the frequency response of the system. Quite often this frequency domain knowledge is sufficient for the design of systems, and we avoid the need to solve (7.1). What is missing from the frequency domain analysis is information on the transient response of the system. Frequency response analysis tells us only about the steady state response to a sine wave input. What happens if we want to know how quickly the system recovers after we shock it, say with a step input? Laplace Transform analysis tells us this. Instead of assuming the input and output are sinusoidal, we assume they are exponential. How much of y(t) is due to an exponential est is measured by the Laplace Transform Y (s) of y . That is, the Laplace Transform tells us that y(t) has a component in it of the form Y (s)est and (as with Fourier Analysis) we can substitute this into the differential equation (7.1) to obtain s2 Y (s)ejst + 2sY (s)ejst + Y (s)est = 3s · U (s)est to obtain the relationship between Y (s) and U (s) as 3s Y (s) ∆ = 2 = H(s) U (s) s + 2s + 1 and this ratio is called the Transfer Function of the system. It shows that if the input contains an exponential component U (s)est then the output will contain a component H(s)U (s)est . This gives us more information about the nature of the solution of the differential equation (7.1) without requiring it’s explicit solution. It is also a generalisation of Fourier analysis since sine wave signals of the form ejωt are special cases of exponential signals est if we put s = jω. We therefore have the following diagram illustrating out understanding of continuous time systems Time Domain Frequency Domain Fourier Transform −−−−−−−−−−→ (jω)2 y!(ω) + 2(jω)! y (ω) + y!(ω) = 3(jω)! u(ω) dy(t) du(t) d2 y(t) + 2 + y(t) = 3 ↑ s = jω dt2 dt dt Laplace Transform −−−−−−−−−−→ s2 Y (s) + 2sY (s) + Y (s) = 3sU (s) This gives us a complete bag of tools to work with in continuous time. What about discrete time? So far we’ve only looked at the sinusoidal steady state analysis of systems in discrete time. What I mean is in discrete time we’ve considered the input-output response of our systems to be described by the digital filter difference equation (4.2) of which a particular example is say yk+2 − 1.5yk+1 + 0.56yk = 3uk+1 . (7.2) As for the differential equation case in (7.1) it is possible, but involved to find the time domain solution of the difference equation (7.2). Instead, as for the continuous time case, we start by considering only sinusoidal inputs of the form uk = U ejωk∆ ; ∆ = sampling period (7.3) 7.2. RELATIONSHIP BETWEEN Z TRANSFORMS AND LAPLACE TRANSFORMS 387 which we assume generates a sinusoidal output at the same frequency yk = Y ejωk∆ (7.4) We then notice that yk+n = Y ejω(k+n)∆ = ejωn∆ Y ejωk∆ and similarly for uk so that substitution of (7.3) and (7.4) into the filtering difference equation (7.2) gives ejω2∆ Y ejωk∆ − 1.5ejω∆ Y ejωk∆ + 0.56Y ejωk∆ = 3ejω∆ ejωk∆ and after canceling the common ejωk∆ on both sides we find that the ratio of the strength U of the input sine wave at frequency ω to the strength of the output sine wave due to the input is Y 3ejω∆ = j2ω∆ . U e − 1.5ejω∆ + 0.56 (7.5) This information on how sine wave inputs travel through the discrete time system (7.2) is often sufficient enough for us. However, as for the continuous time case, because it only considers sinusoids in steady state it doesn’t tell us anything about the transient response of the system. To find out about this we follow the lead of Laplace Transform analysis and assume that the input has an exponential component uk = U esk∆ of strength U which produces an exponential output yk = Y esk∆ of strength Y . Substituting into the difference equation (7.2) then leads to e2s∆ Y esk∆ + 1.6es∆ Y esk∆ + 0.64Y e5k∆ = 3es∆ U esk∆ If we denote z = es∆ then we arrive at 3z Y ∆ = 2 = H(z) U z − 1.5z + 0.56 (7.6) This transfer function H(z) tells how exponentials decaying like z k = esk∆ map through the system defined by the digital filter difference equation (7.2). You might notice that with s = jω we have z k = ejωk∆ = cos ωk∆+j sin ωk∆ which means the general expression (7.6) will give the sinusoidal steady state frequency response (7.5) for the special choice z = ejω∆ . The question we haven’t answered yet is how in discrete time we judge what the strength U is of the component of the discrete sequence {uk } due to the sinusoidal sequence {ejωk∆ }. The answer is of course provided by Fourier Transforms. More specifically, {uk } is a sequence of numbers not a physical quantity, so it doesn’t have a spectrum. However, we are assuming that the numbers {uk } are derived from a physical quantity. This physical quantity is the continuous time signal u(t) which when ideally impulse sampled at period ∆ gives the perfectly sampled signal up (t) = ∞ & uk δ(t − k∆) ; uk = u(k∆) k=−∞ and this perfectly sampled signal up (t) has a Fourier Transform u !p (ω) = ∞ & k=−∞ uk e−jωk∆ CHAPTER 7. Z TRANSFORMS 388 which is often called the Discrete Fourier Transform (DFT) of the sequence {uk }. However, you can see it is really more accurate to say it is the continuous time Fourier Transform of the continuous time impulse signal up (t). There is an advantage with maintaining this physical link in our thinking since we found in section 6.1 on page 6.1 that u !p (ω) is the spectrum u !(ω) of the underlying continuous 2π time signal u(t) repeated every ωs = ∆ radians per second: ∞ & k=−∞ uk e−jωk∆ = u !p (ω) = ∞ 1 & u !(ω − kωs ). ∆ k=−∞ Therefore the strength U of the component ejωk∆ in {uk } is U = u !p (ω) which, if the Nyquist Sampling condition is satisfied, is also U = u !p (ω) = u !(ω) the component in the continuous time signal u(t) at frequency ω rad/s. The same sort of arguments apply to the strength Y of ejωk∆ in the sequence {yk }. Again, {yk } has no spectrum since it is just a sequence of numbers, but the impulse train ∞ & yp (t) = yk δ(t − k∆) k=−∞ does have a spectrum given by the Fourier Transform y!p (ω) of yp (t): y!p (ω) = ∞ & yk e−jωk∆ k=−∞ and this is often called the Discrete Fourier Transform of the sequence {yk] }. However, there is really no need to introduce this artificial new quantity called the DFT, since it is really the standard continuous time Fourier Transform of an impulse signal. At any rate, the strength Y of the component ejωk∆ in {yk } is Y = y!p (ω), the DFT of {yk }. In discrete time we therefore get the following commutative diagram Time Domain yk+2 − 1.5yk+1 + 0.56yk = 3uk+1 Frequency Domain Discrete Fourier X’form −−−−−−−−−−−→ ej2ω∆ y!p (ω) − 1.5ejω∆ y!p (ω) + 0.56! yp (ω) = 3ejω∆ u !p (ω) jω∆ ↑z=e Z Transform −−−−−−−−−−−→ z 2 Y (z) − 1.5zY (z) + 0.56Y (z) = 3zU (z) This diagram is of exactly the same form as we had in continuous time. The major differences are 1. Sampling has been assumed in order for the discrete time sequences to exist st 2. In continuous time we used the symbol and made the substitution ' jωte for a general exponential ( s = jω to get the special case of e = cos ωt + )j sin ωt sinusoidal analysis. In discrete time we introduce a new symbol z as z = es∆ = est )t=∆ and this means that to get sinusoidal analysis we have to substitute z = ejω∆ so that z k = ejω∆k = cos ωk∆ + j sin ωk∆. 3. In continuous time we just substitute the relationship dp st e = (s)p est dtp 7.3. CALCULATION OF Z -TRANSFORMS 389 into the differential equation in order to relate the strength Y (s) of the component in y(t) at est to the strength U (s) of the component in u(t) at est . In discrete time we substitute the relationship q p z k = z k+p in order to relate the strength Y (z) of the component of {yk } at z k = esk∆ to the strength U (z) of the component in {uk } at z k . Now, with reference to this last point, the functions Y (s) and U (s) of s are well defined as Laplace transforms. For example, if we have a signal u(t) = e−st then we know that the function U (s) giving the strength of components in u(t) at est is the Laplace Transform of u(t): U (s) = L{u(t)} = * ∞ eαt e−st dt = 0 1 s−α But we don’t know, in discrete time, how to calculate the equivalent strength function U (z) that tells us how much of {uk } is due to the exponential {z k }. 7.3 Calculation of Z-Transforms The function U (z) is called the ZTransform of {uk }. Now, remember, that the Fourier Transform y!(ω) of y(t) is * ∞ y!(ω) = y(t)e−jωt dt −∞ and that is we want to know the spectral content of a discrete sequence of numbers {yk } we pretend that the {yk } are the weights on impulses. This gives the new signal yp (t) and we take the Fourier Transform y!p (ω) of this signal ∞ & y!p (ω) = yk e−jωk∆ k=−∞ + , as a measure of the strength of ejωk∆ in {yk }. We follow the same method of argument to get the ZTransform of {yk }. The strength of est in y(t) is Y (s) given by Y (s) = L{y(t)} = * ∞ y(t)e−st dt −∞ If we want to know the strength of est the sequence {yk } we first have to form an impulse sampling signal out of the {yk } as ∞ & yk δ(t − k∆) yp (t) = k=−∞ CHAPTER 7. Z TRANSFORMS 390 and then take the strength as Yp (s) = L{yp (t)} * ∞ yp (t)e−st dt = −∞ . * ∞- & ∞ = yk δ(t − k∆) e−st dt −∞ = = k=−∞ ∞ & * yk k=−∞ ∞ & ∞ δ(t − k∆)e−st dt −∞ yk e−sk∆ k=−∞ With the notation z = e−s∆ we call the Laplace transform of yp (t) by a new name - the Z Transform of {yk }. ∞ & Y (z) ! Z{yk } = yk z −k . k=−∞ This is just like the way we renamed the Fourier transform y!p (ω) of yp (t) as the Discrete Fourier Transform. We rename the Laplace Transform Yp (s) of yp (t) as the Z Transform Y (z). Indeed, if we substitute z = ejω∆ we get ∞ & ' ( Y ejω∆ = yk e−jωk∆ = y!p (ω) k=−∞ so the Discrete Fourier Transform (DFT) of a sequence is a special case of the Z Transform of the sequence. Notice that most of the time in text books you will see Y (z) defined with k starting from 0: Y (z) = ∞ & yk z −k k=0 since these books implicitly assume all the signals are causal and so yk = 0 for k < 0. Let’s see what the Ztransforms of some common signals are. Throughout all these calculations we use the result that if we have the sum of a geometric series SN = N −1 & ar k k=0 then there is a formula for SN SN = a(1 − r N ) 1−r Notice now that if |r| < 1 then r N → 0 as N → ∞. This allows us to conclude that S∞ = ∞ & k=−∞ = a 1−r Using this formula for the infinite sum of a geometric series we can evaluate the following examples 7.3. CALCULATION OF Z -TRANSFORMS 391 Example 7.1 yk = Y (z) = = = / λk ; k ≥ 0 0 ;k < 0 ∞ & yk z −k k=−∞ ∞ & k −k λ z k=0 ∞ & (λz −1 )k k=0 = Y (z) = ) ) )λ) ; )) )) < 1 z 1 1 − λ/z z z−λ ; |z| > |λ| " Example 7.2 / cos ωk∆ ; k ≥ 0 0 ;k < 0 ∞ & Y (z) = (cos ωk∆)z −k yk = = = = = k=0 ∞ 0 & 1 2 jωk∆ e k=0 +e −jωk∆ 1 z −k ∞ ∞ 1 & ' jω∆ −1 (k 1 & ' −jω∆ −1 (k e z + e z 2 2 k=0 k=0 / 2 1 1 1 + 2 1 − z −1 ejω∆ 1 − z −1 e−jω∆ / 2 1 2 − z −1 (ejω∆ + e−jω∆ ) 2 1 − z −1 (ejω∆ + e−jω∆ ) + z −2 ; |z| > 1 That is Y (z) = z2 z(z − cos ω∆) − 2z cos ω∆ +1 ; |z| > 1 " CHAPTER 7. Z TRANSFORMS 392 Example 7.3 / sin ωk∆ ; k ≥ 0 0 ;k < 0 ∞ & (sin ωk∆)z −k Y (z) = yk = = = = = k=0 ∞ 0 & j 2 k=0 1 e−jωk∆ − ejωk∆ z −k ∞ ∞ j & ' −jω∆ −1 (k j & ' jω∆ −1 (k e z − e z 2 2 k=0 k=0 / 2 1 1 j − 2 1 − z −1 e−jω∆ 1 − z −1 ejω∆ 2 / j z −1 (e−jω∆ − ejω∆ ) 2 1 − z −1 (ejω∆ + e−jω∆ ) + z −2 That is Y (z) = z2 z sin ω∆ − 2z cos ω∆ +1 ; |z| > 1 ; |z| > 1 " Example 7.4 In example 7.1 we found ∞ & (λz −1 )k = k=0 z z−λ ; |z| > λ Now, I can differentiate both sides with respect to λ and obtain z d & −1 k d z = (λz ) = dλ dλ z − λ (z − λ)2 ∞ k=0 But ∞ ∞ & d & −1 k d k −k (λz ) = λ z dλ dλ k=0 k=0 = ∞ & kλk−1 z −k k=0 = Therefore if yk = then Y (z) = / 1 Z{kλk } λ kλk ; k ≥ 0 0 ;k < 0 λz (z − λ)2 ; |z| > λ. 7.3. CALCULATION OF Z -TRANSFORMS 393 In fact, we can be a bit more general than this by differentiating p times instead of 1 time to get ∞ ∞ dp & k −k 1 & p k −k λ z = k λ z dλp λp k=0 and also (7.7) k=0 z p!z dp = p dλ (z − λ) (z − λ)p+1 (7.8) So that we get, on equating (7.7) and (7.8), that if {yk } is defined by / p k k λ ;k ≥ 0 yk = 0 ;k < 0 then its Z transform is given by Y (z) = p!λp z (z − λ)p+1 ; |z| < λ " Example 7.5 / λk cos ωk∆ ; k ≥ 0 0 ;k < 0 ∞ & Y (z) = λk cos ωk∆z −k yk = = = = = k=0 ∞ 0 & 1 2 k=0 ∞ & 1 λk ejωk∆ + λk e−jωk∆ z −k ∞ ' jω∆ −1 (k 1 & ' −jω∆ −1 (k λe z + λe z 2 k=0 k=0 / 2 1 1 1 + ; |z| > 1 2 1 − λejω∆ z −1 1 − λe−jω∆ z −1 3 4 ' ( 2 − λz −1 ejω∆ + e−jω∆ 1 2 1 − λ (ejω∆ + e−jω∆ ) z −1 + λ2 z −2 1 2 So that on simplifying we get Y (z) = z2 z(z − λ cos ω∆) − 2λ cos ω∆z + λ2 " Example 7.6 / λk sin ωk∆ ; k ≥ 0 0 ;k < 0 ∞ 1 &0 Y (z) = λk sin ωk∆z −k yk = k=0 = z2 λz sin ω∆ − 2λz cos ω∆ + λ2 CHAPTER 7. Z TRANSFORMS 394 " Example 7.7 k d k λ sin ωk∆ = λk sin ωk∆ dλ λ and d dλ 5 λz sin ω∆ 2 z − 2λz cos ω∆ + λ2 So if yk = / Then Y (z) = 6 = z sin ω∆(z 2 − λ2 ) (z 2 − 2λz cos ω∆ + λ2 )2 kλk sin ωk∆ ; k ≥ 0 0 ;k < 0 λz(z 2 − λ2 ) sin ω∆ (z 2 − 2λz cos ω∆ + λ2 )2 " Example 7.8 d k k λ cos ωk∆ = λk cos ωk∆ dλ λ and d dλ 5 z(z − λ cos ω∆) 2 z − 2λz cos ω∆ + λ2 So if yk = Then Y (z) = / 6 = z[cos ω∆(z 2 + λ2 ) − 2λz] (z 2 − 2λz cos ω∆ + λ2 )2 kλk cos ωk∆ ; k ≥ 0 0 ;k < 0 λz[cos ω∆(z 2 + λ2 ) − 2λz] (z 2 − 2λz cos ω∆ + λ2 )2 " We could go on calculating these Ztransforms, but these ones cover the most common cases. They are summarised in table 7.1 7.4 Properties of ZTransforms Now we know how to calculate the functions U (z) and Y (z) that gives the strength of the sequence z k in {uk } and {yk }. So, for example, if we return to the example of the digital filter yk+2 − 1.5yk+1 = 0.56yk = 3uk+1 we worked out in (7.6) that if {uk } was considered as {U (z)z k } and the output {yk } was considered as {Y (z)z k } then the “strength” functions Y (z) and U (z) were related as Y (z) = z2 3z U (z). − 1.5z + 0.56 7.4. PROPERTIES OF Z TRANSFORMS 395 Time Domain Sequence {yk } yk = / λk ; k ≥ 0 0 ;k < 0 yk = / cos ωk∆ ; k ≥ 0 0 ;k < 0 yk = / sin ωk∆ ; k ≥ 0 0 ;k < 0 yk = / kp λk ; k ≥ 0 0 ;k < 0 Z Transform of {yk } Y (z) = Y (z) = Y (z) = z z−λ ; |z| > |λ| z(z − cos ω∆) z − 2z cos ω∆ +1 2 z sin ω∆ z 2 − 2z cos ω∆ + 1 Y (z) = p!λp z (z − λ)p+1 ; |z| > 1 ; |z| > 1 ; |z| < λ yk = / λk cos ωk∆ ; k ≥ 0 0 ;k < 0 Y (z) = z(z − λ cos ω∆) z 2 − 2λ cos ω∆z + λ2 yk = / λk sin ωk∆ ; k ≥ 0 0 ;k < 0 Y (z) = λz sin ω∆ z 2 − 2λz cos ω∆ + λ2 yk = / kλk sin ωk∆ ; k ≥ 0 0 ;k < 0 yk = / kλk cos ωk∆ ; k ≥ 0 0 ;k < 0 Y (z) = Y (z) = λz(z 2 − λ2 ) sin ω∆ 2 2 (z − 2λz cos ω∆ + λ ) 2 λz[cos ω∆(z 2 + λ2 ) − 2λz] 2 2 2 (z − 2λz cos ω∆ + λ ) Table 7.1: Z transforms of some common discrete time sequences CHAPTER 7. Z TRANSFORMS 396 Solution y_k 50 45 40 35 30 25 20 15 10 5 0 0 10 20 30 40 50 Sample Number k 60 70 80 90 Figure 7.1: Solution {yk } of difference equation. Therefore, if U (z) is a step function, then from table 7.1 U (z) = z z−1 and so Y (z) = = 6 3z z 2 z − 1.5z + 0.56 (z − 1) 120z 50z 70z − + (z − 0.7) (z − 0.8) (z − 1) 5 so that Y (z) is made up of a bunch of “strength” functions that we know from table 7.1 correspond to the sequences {0.7k }, {0.8}k and {1k } respectively so that the output sequence {yk } with “strength” function Y (z) is yk = 70(0.7)k − 120(0.8)k + 50 ;k ≥ 0 which is plotted in figure (7.1). Therefore, using the Ztransforms U (z) and Y (z) of the input and output sequences {uk } and {yk } we can work out the response {yk } of a digital filter when driven by {uk }. However, in the calculations we just performed we glossed over a few things. 1. We assumed the Ztransform was linear. That is, we assumed that if Y (z) = 120z 50z 70z − + z − 0.7 z − 0.8 z − 1 and z{λk } = λ/(z − λ) then it was true that yk = 70(0.7)k − 120(0.8)k + 50(1)k 7.4. PROPERTIES OF Z TRANSFORMS 397 and for this to be true it is necessary that Y (z) = Z{yk } = Z{70(0.7)k − 120(0.8)k + 50(1)k } = 70Z{(0.7)k } − 120Z{(0.8)k } + 50Z{(1)k } which means that the Ztransform must be linear 2. We assumed that the Ztransform was unique. That is, we assumed that if Y (z) = 70z z − 0.7 then only one sequence {yk = {70(0.7)k } can have this Ztransform 3. We assumed that {yk } was causal when in fact it is possible that {yk } may have non-zero values for k < 0. Luckily, the first 2 of these assumptions are correct. The last assumption is one we shall have to consider more carefully. Since these assumptions are so important and are necessary whenever we use Ztransform methods to study a digital filter we should state and prove them formally: Linearity of ZTransform Suppose {uk } and {xk } are two sequences and that we make up a sequence {yk } by yk = αuk + βxk where α and β are real numbers. Then ∞ & Y (z) = = yk z −k k=−∞ ∞ & (αuk + βxk )z −k k=−∞ ∞ & = α uk z −k + β k=−∞ ∞ & xk z −k k=−∞ = αU (z) + βX(z) so that the ZTransform is linear. Uniqueness of Z Transform Suppose {uk } and {yk } are 2 sequences with Ztransforms U (z) and Y (z). Suppose that U (z) = Y (z). Then by the definition of the Ztransform U (z) = ∞ & k=−∞ uk z −k = ∞ & yk z −k = Y (z) k=−∞ Now both sides of this equation are polynomials in z −1 whose co-efficients are the samples {uk } and {yk }. Furthermore, 2 polynomials are equal if and only if all its co-efficients are equal. Therefore Y (z) = U (z) if and only if yk = uk for every k. This means each Ztransform is uniquely associated with only one discrete time sequence. CHAPTER 7. Z TRANSFORMS 398 Time Shifting Property So far, we’ve been using the idea that Z{qyk } = Z{yk+1 } = zY (z) but as we shall see, this implicitly assumes that {yk } is causal. Of course, if {uk } is causal and our digital filter has a causal impulse then the component of {yk } due to {uk } must be causal. However, {yk } might have non-causal components (yk &= 0for k < 0) not due to {uk } since they existed before {uk } was applied to the filter. These non-causal components, sometimes called initial conditions, have an effect on {yk } for k < 0 that has to be calculated. In order to perform this calculation it actually turns out to be easier to look at backward shifts in time. Z{q −n yk } = ∞ & q −n yk z −k k=0 = ∞ & yk−n z −k k=0 That is = y−n z −0 + y1−n z −1 + y2−n z −2 + . . . −1 −2 −n n −(1−n) −(2−n) + . . . + y0 + y1 z + y2 z + . . . = z y−n z + y1−n z + y2−n z ;< = : initial conditions ∞ n & & −k −n k + yk z = z . y−k z :k=1 ;< = :k=0 ;< = Y (z) initial conditions Z{q −n yk } = z −n Y (z) + z −n n & y−k z k k=1 For the common examples of n = 1, 2, 3 this becomes Z{q −1 yk } = z −1 Y (z) + y−1 Z{q −2 yk } = z −2 Y (z) + z −1 y−1 + y−2 Z{q −3 yk = z −3 Y (z) + z −2 y−1 + z −1 y−2 + y−3 There is an equivalent result using forward time shifts n n Z{q yk } = z Y (z) − z n n−1 & yk z −k k=0 which for n = 1, 2 and 3 is Z{qyk } = zY (z) − zy0 Z{q 2 yk } = z 2 Y (z) − z 2 y0 − zy1 Z{q 3 yk } = z 3 Y (z) − z 3 y0 − z 2 y1 − zy2 7.4. PROPERTIES OF Z TRANSFORMS 399 but this result is not so useful in practice since it implicitly moves the point k = 0. If q 3 is the largest time advance in an equation then the Ztransform of the solution Y (z) will depend on y0 , y1 and y2 . But these are precisely the things we are trying to calculate since we don’t know them! Examples make these points about time shifting, causality and initial conditions clearer. Example 7.9 Let’s look at the case of borrowing money from the bank. Suppose we do the following • Borrow C dollars. • Repay in equal installments of P dollars. • Interest rate per payment period is 100α% of unpaid principle. • yk = amount owed after k th payment • uk = payment per period. Then we can write an equation for how much we owe by the time the (k + 1)th payment is due as yk+1 = yk + αyk − uk which using the forward shift operator q becomes qyk = (1 + α)yk − uk . Taking the ZTransform of both sides and using the linearity and time shifting properties of Ztransforms then gives zY (z) − zy0 = (1 + α)Y (z) − U (z) so Y (z) = zy0 U (z) − . z − (1 + α) z − (1 + α) (7.9) Now y0 = C the amount initially borrowed. Furthermore, if I repay a constant amount P (starting from when I borrow the money, but not before) then / P ;k ≥ 0 uk = 0 ;k < 0 and so U (z) = P z/(z − 1). Substituting these values into (7.9) then gives Y (z) as Y (z) = = Pz Cz − z − (1 + α) (z − 1)(z − (1 + α)) / 2 z Cz P z + − z − (1 + α) α z − 1 z − (1 + α) Now, by the uniqueness and linearity properties of Z transforms, there is only one sequence {yk } that can have this Z transform. Reference to table 7.1 and use of the linearity property of Z transforms then tells us that the amount owed must be ? P > 1 − (1 + α)k yk = C(1 + α)k + α6 5 P P = + C− (1 + α)k α α CHAPTER 7. Z TRANSFORMS 400 Amount owed versus time 12000 p=$60 10000 p=$100 Dollars owing 8000 6000 p=$200 4000 2000 p=$300 0 -2000 0 5 10 15 20 25 Month Number 30 35 40 45 Figure 7.2: Diagram showing our example problem solution where we calculate how much money we owe on a loan. Notice that this discrete time system is unstable unless α < 0. But negative α corresponds to the bank paying you interest for borrowing money! Of course, the fact that we have instability when we pay the bank interest (α > 0) is not a problem, since if it wasn’t, we would never pay off the loan. We just have to make sure that our repayment amount p is big enough that C− p <0 α so that the instability of the system drives us through $0 owed (and not through $ + ∞ owed !). A plot of the solution for C = $10, 000, α = 8/12% per month, and various payment amounts per month is shown in figure 7.2 " Let’s pick a more difficult 2nd Order example Example 7.10 Suppose I have designed a digital filter whose transfer function H(q) is H(q) = q2 q − 1.7q + 0.72 so that the input sequence {uk } to the filter is related to the output sequence from the filter {yk } as yk = H(q)uk 5 6 q = uk . q 2 − 1.7q + 0.72 (7.10) 7.4. PROPERTIES OF Z TRANSFORMS 401 So that the input-output relationship is yk+2 − 1.7yk+1 + 0.72yk = uk+1 . (7.11) If I take Ztransforms of both sides of this difference equation and use the time shifting properties Z{q 2 yk } = z 2 Y (z) − z 2 y0 − zy1 Z{qyk } = zY (z) − zy0 Z{quk } = zU (z) − zu0 (7.12) then I obtain z 2 Y (z) − z 2 y0 − zy1 − 1.7zY (z)(z) + 1.7zy0 + 0.72Y (z) = zU (z) − zu0 which on factoring out Y (z) and U (z) becomes 5 6 z(z − 1.7)y0 + zy1 − zu0 z . Y (z) = U (z) + 2 z − 1.7z + 0.72 z 2 − 1.7z + 0.72 (7.13) Therefore, we can find what the response {yk } of the filter will be to a step input {uk } by substituting z U (z) = z−1 into the above equation and then finding what sequence {yk } has the transform Y (z). However, as you can see from (7.13), the answer we get will depend on y0 and y1 . But we don’t know them yet, we are trying to calculate them! How did this situation come about? It happens because (7.11) implicitly takes k = 2 as being the division between past and future, whereas we want it to be at k = 0. We can achieve this latter goal by rewriting (7.11) as yk − 1.7yk−1 + 0.72yk−2 = uk−1 . (7.14) This is completely equivalent to (7.13), since all that really matters is how one sample is related to the samples before it. You can also arrive at (7.14) by dividing both numerator and denominator of H(q) in (7.10) by q 2 to obtain q −1 H(q −1 ) = . 1 − 1.7q −1 + 0.72q −2 Now, if we use the ZTransform time shifting properties Z{q 2 yk } = z −2 Y (z) + z −1 y−1 + y−2 Z{q −1 yk } = z −1 Y (z) + y−1 Z{q −1 uk } = z −1 U (z) + u−1 on equation (7.14) then we arrive at Y (z) − 1.7z −1 Y (z) − 1.7y−1 + 0.72z −2 Y (z) + 0.72z −1 y−1 + 0.72y−2 = z −1 U (z) + u−1 which on factoring out Y (z) and U (z) becomes Y (z) = = (1.7 − 0.72z −1 )y−1 − 0.72y−2 + u−1 z −1 U (z) + 1 − 1.7z −1 + 0.72z −2 1 − 1.7z −1 + 0.72z −2 z(1.7z − 0.72)y−1 − 0.72z 2 y−2 + z 2 u−1 z U (z) + z 2 − 1.7z + 0.72 z 2 − 1.7z + 0.72 CHAPTER 7. Z TRANSFORMS 402 This looks better, since Y (z) will now only depend on the past via y−1 , y−2 and u−1 . Suppose now, as we suggested before, that {uk } is a unit step at k = 0. Then since in this case u−1 = 0 Y (z) = z(1.7z − 0.72)y−1 − 0.72z 2 y−2 z2 + . (z − 0.9)(z − 0.8)(z − 1) (z − 0.9)(z − 0.8) (7.15) The only way we know so far to find a {yk } that corresponds to Y (z) (i.e. to invert the Ztransform Y (z)) is to match what we see with Table 5.1. To do this matching we’ll have to perform a partial fraction expansion Az Bz Cz z2 = + + (z − 0.9)(z − 0.8)(z − 1) z − 0.9 z − 0.8 z − 1 So that A, B, C must satisfy A(z − 0.8)(z − 1) + B(z − 0.9)(z − 1) + C(z − 0.8)(z − 0.9) = z for any value of z. Since we get equality for any value of z, it must be equal for the special cases z = 0.8, 0.9, and z = 1 to give z = 0.8 ⇒ B(0.8 − 0.9)(0.8 − 1) = 0.8 ⇒ B = 40 z = 0.9 ⇒ A(0.9 − 0.8)(0.9 − 1) = 0.9 ⇒ A = −90 z = 1 ⇒ C(1 − 0.8)(1 − 0.9) = 1 ⇒ C = 50 So that −90z 40z 50z z2 = + + . (z − 0.9)(z − 0.8)(z − 1) z − 0.9 z − 0.8 z − 1 Performing similar, but more arithmetically complicated calculations I get @ A −81z 32z 49z z(1.7z − 0.72) y−1 = + + y−1 (z − 0.9(z − 0.8)(z − 1) (z − 0.9) (z − 0.8) (z − 1) (7.16) (7.17) Substituting (7.16) and (7.17) into (7.15) then allows me to rewrite Y (z) as (I use the fact that I know u−1 = 0) 5 6 5 6 z z Y (z) = − (90 + 81y−1 − 64.8y−2 ) + (40 + 32y−1 − 23.04y−2 ) z − 0.9 z − 0.8 5 6 z + (50 + 49y−1 − 36y−2 ) . (7.18) z−1 Looking at table 7.1 I see that the sequence / k λ ;k ≥ 0 yk = 0 ; Otherwise is uniquely associated with the ZTransform Y (z) = z z−λ 7.4. PROPERTIES OF Z TRANSFORMS 403 Response y_k of digital filter 50 45 40 35 30 25 20 15 10 5 0 0 10 20 30 40 50 60 Sample Number 70 80 90 100 Figure 7.3: Plot of solution sequence {yk }. and so I can conclude from the rewriting of (7.15) in (7.18) that the step response of my filter is −(90 + 81y−1 − 64.8y2 )(0.9)k +(40 + 32y−1 − 23.04y−2 )(0.8)k ;k ≥ 0 +(50 + 49y−1 − 36y−2 )7 yk = ; k = −1 y−1 y−2 ; k = −2 If the initial conditions (or non-causal components) for my filter output y−1 and y−2 are zero, then the answer becomes much simpler. / (−90)(0.9)k + 40(0.8)k + 50 ; k ≤ 0 yk = 0 ; Otherwise and this response is plotted below: " There are 2 important points to come out of this example 1. The d.c. gain of this filter is obviously 50 since a unit magnitude step eventually becomes a d.c. value of 50 at the output. You also know that the frequency response of a digital filter H(q) is obtained by substituting ejω∆ for q. So for H(q) in the example I get a frequency response H(ejω∆ ) = ejω∆ . ej2ω∆ − 1.7ejω∆ + 0.72 CHAPTER 7. Z TRANSFORMS 404 So the d.c. gain of the filter is ) H(ejω∆ ))ω=0 d.c. gain = = H(1) 1 = 50 1 − 1.7 + 0.72 = 2. It is arithmetically very complicated to do the calculations to find {yk }. This is mainly due to the partial fraction expansion that we had to do to separate Y (z) into parts we could recognise from table 5.1. Fortunately, we can in most cases significantly alleviate the arithmetic difficulties mentioned in item 2. We do this by avoiding partial fraction expansion to identify {yk }. Instead we directly calculate {yk } from Y (z) using a formula for the Inverse ZTransform. 7.5 Inverting ZTransforms Using Contour Integration In the introduction to this chapter we motivated the definition of the Ztransform Y (z) of {yk } as ∞ & Y (z) = yk z −k (7.19) k=−∞ by first looking at how the Discrete Fourier Transform (Continuous Time Fourier Transform of an impulse sampled sequence) was defined as y!p (ω) = ∞ & yk e−jωk∆ (7.20) k=−∞ We can continue using this analogy between ZTransforms and DFT’s to derive a formula for the Inverse ZTransform. Specifically, we know that we can invert y!p (ω) to recover {yk } by recognising that y!p (ω) is periodic, so the righthand side of (7.20) is the Fourier series representation of y!p (ω), so the {yk } must be the Fourier co-efficients of y!p (ω), so they must be given by yk = ∆ 2π * 2π ∆ 0 y!p (ω)ejωk∆ dω (7.21) and this expression is sometimes known as the Inverse Discrete Fourier Transform. Now let’s suppose that I make the substitution z = ejω∆ in (7.20). Then I get y!p (ω) = ∞ & ∆ yk z −k = Y (z) k=−∞ If I also make the substitution z = ejω∆ in (7.21) and also substitute (7.22) in (7.21) I have dz dz = j∆ejω∆ = j∆z ⇒ dω = dω zj∆ (7.22) 7.5. INVERTING Z TRANSFORMS USING CONTOUR INTEGRATION 405 and so I get B ∆ 1 Y (z) k · z dz 2π j∆ C z B 1 Y (z) k z dz 2πj C z yk = = (7.23) and this formula is known as the inverse ZTransform. It is a contour integral around C = the unit circle. This might look complicated at first, but actually it makes our job of calculating {yk } from Y (z) much easier since we can use Cauchy’s Residue Theorem to calculate contour integrals: 1 2πj B f (z)dz = C m & n=1 Res F (z) pn Where m is the number of poles of F (z) inside C, pk is the position of the kth pole, and Respk F (z) is the residue of F (z) at pk . If we apply this to (7.23) we get yk = m & n=1 Res z=pn Y (z) k z z (7.24) k Finally, if the pole in Y (z) zz only occurs once, then there is a very simple formula for the Residue Res z=pn Y (z) k Y (z) k z = lim (z − pn ) z z→p z n z (7.25) so that (7.24) becomes m & Y (z) k z z→pn z n=1 . ) m & (z − pn )Y (z) )) = (pn )k ) z yk = n=1 lim (z − pn ) (7.26) z=pn This probably looks quite confusing since it has been presented quite quickly. It becomes clear when we try some examples. Example 7.11 In example 7.10, we arrived at (for zero initial conditions) Y (z) = z2 (z − 0.8)(z − 0.9)(z − 1) for the Ztransform of the output of a digital filter when fed with a unit step input. Now in example 7.10, we deduced the {yk } corresponding to this Y (z) by messy partial fraction expansion. Let’s try to do it now by using the Contour integral inversion formula (7.23): 1 yk = 2πj B C z k+1 dz. (z − 0.8)(z − 0.9)(z − 1) CHAPTER 7. Z TRANSFORMS 406 The integrand has m = 3 poles at p1 = 0.8, p2 = 0.9 and p3 = 1 within C. Cauchy’s Residue Theorem says the integral only depends on the position of these poles as follows: yk = 3 1 & z k+1 . Res z=pk (z − 0.8)(z − 0.9)(z − 1) 2πj n=1 All the poles only occur once, so we can use the simple formula in (7.25) to calculate each residue and we end up with: 3 & (z − pn )z k+1 z→pn (z − 0.8)(z − 0.9)(z − 1) n=1 ) ) ) ) ) ) z k+1 z k+1 z k+1 ) ) ) = + + ) ) (z − 0.9)(z − 1) z=0.8 (z − 0.8)(z − 1) z=0.9 (z − 0.8)(z − 0.9) )z=1 yk = = lim 0.8(0.8)k 0.9(0.9)k 1 + + (0.8 − 0.9)(0.8 − 1) (0.9 − 0.9)(0.9 − 1) (1 − 0.9)(1 − 0.9) = 40(0.8)k − 90(0.9)k + 50. Which is exactly the same answer we obtained before in example 7.10. " You can see now from the previous example that if the poles in Y (z)/z only occur once for each pole, then (7.26) boils down to a simple set of rules 1. Cancel each pole one by one 2. When you cancel a pole at pn , substitute pn into what is left. 3. Multiply this number by pkn 4. Add all these results up and you’ve found the inverse ZTransform. Example 7.12 Y (z) = So z2 z − 1.5 − 0.7z + 0.1 Y (z) (z − 1.5) = z z(z − 0.2)(z − 0.5) This has poles at z = 0, 0.2 and 0.5. Therefore, using my simple rule for singly occuring poles I get yk = (0.2 − 1.5)(0.2)k (0.5 − 1.5)(0.5)k (0 − 1.5)0k + + (0 − 0.2)(0 − 0.5) 0.2(0.2 − 0.5) (0.5)(0.5 − 0.2) = −15(0)k + 21.67(0.2)k − 6.67(0.5)k Now 00 = 1 and 0k = 0 for k > 0 so my final answer is / −15 + 21.67 − 6.67 = 0 yk = (21.67)(0.2)k − 6.67(0.5)k ;k = 0 ;k ≥ 0 7.5. INVERTING Z TRANSFORMS USING CONTOUR INTEGRATION 407 " Example 7.13 Y (z) = So z2 (z 2 − 1.2944z + 0.64)(z − 1) Y (z)z k z k+1 = π π z (z − 0.8ej 5 )(z − 0.8e−j 5 )(z − 1) Using Contour integration the inverse Ztransform of Y (z) then is yk = = = = = = = B Y (z)z k dz z C Y (z)z k Y (z)z k Y (z)z k Res π + Res π + Res z=1 z z z z=0.8ej 5 z=0.8e−j 5 3 4 j(k+1) π5 j(k+1) π5 e e 1 k+1 (0.8) − + π π j π5 π −j π5 j1.6 sin 5 (e − 1) j1.6 sin 5 (e − 1) |1 − 0.8ej 5 |2 4 3 π 1 (0.8)k+1 ej(k+1) 5 + j2Im π 2 j π5 j1.6 sin π5 (1 − 0.8 cos ) + (0.8 sin π5 )2 e −1 5 3 π 4 π ej 5 k − ej(k+1) 5 1 (0.8)k + π Im π sin 5 2(1 − cos 5 ) 1.64 − 1.6 cos π5 2 / (0.8)k π(k + 1) πk − sin + 2.8938 sin (sin π5 )(1 − cos π5 ) 5 5 2 / π(k + 1) πk k − sin + 2.8938 (4.454)(0.8) sin 5 5 1 2πj A plot of this is shown on the next page. " The only difficulty with this method of inverting ZTransform using Contour integration occurs when a pole is repeated. When this happens, evaluation of the residue at the repeated pole gets a little trickier. To be specific, suppose Y (z)z k /z has a pole at z = p, and that this pole occurs m times. In other words, suppose Y (z)z k /z has a term of the form (z − p)m in its denominator. Then the residue at z = p is given by 2πj dm−1 Y (z)z k Y (z)z k = lim m−1 (z − p)m Res z=p z (m − 1)! z→p dz z In the case when m = 1, this reduces to the rule we’ve already encountered of canceling the pole at p and substituting p into what is left. However, when m is bigger than one, we have to introduce an extra step. After canceling the poles at p, but before substituting in p, we have to differentiate the pole canceled expression m − 1 times. Example 7.14 Suppose I want to find the inverse ZTransform of Y (z) = (z + 0.2)(z 2 z − 0.4z + 0.04) CHAPTER 7. Z TRANSFORMS 408 Response y_k of digital filter 4 3.5 3 2.5 2 1.5 1 0.5 0 0 2 4 6 8 10 12 Sample Number 14 16 18 20 Figure 7.4: Plot of solution sequence {yk }. Then Y (z)z k zk = z (z + 0.2)(z − 0.2)2 So B Y (z)z k dz z C zk zk = Res + Res z=−0.2 (z + 0.2)(z − 0.2)2 z=0.2 (z + 0.2)(z − 0.2)2 ) ) ) ) zk zk d ) ) = + ) 2 (z − 0.2) z=−0.2 dz (z + 0.2) )z=0.2 ) (z + 0.2)kz k−1 − z k )) k = 6.25(−0.2) + ) (z + 0.2)2 yk = 1 2πj z=0.2 = 6.25(−0.2)k − 6.25(0.2)k + 2.5k(0.2)k−1 D C = 6.25 (−0.2)k − (0.2)k + 2k(0.2)k C D = 6.25 (2k − 1)(0.2)k + (0.2)k "