is used to solve difference equations (discrete differential equations) with .... _-M. The z-transform can be applied to Equation (14a) or (14b) to determine the ...
USEFUL APPLICATIONS OF THE Z-TRANSFORM
INTRODUcrION The purpose of this note is to present some useful examples of the z-transform pertaining to everyday science and mathematics. Even though z-transform techniques are well known to those dealing in digital signal processing, digital control theory and image processing, z-transform theory is usually excluded from the main stream university science and math curriculums at both the undergraduate and graduate levels. It has only been in the last few decades that interest in the z-transform has evolved, mostly due to the rapid development of integrated circuit technology and microprocessor architecture. Z-transform techniques have now become a major tool in electrical, computer, and communication engineering. Since the z-transform has roots deep in complex variable theory, this recent trend of popularity will, in the near future, undoubtedly extend into many areas of university science and mathematics. THE Z-TRANSFORM Two types of z-transforms are usually defined, the direct z-transform and the one-sided z-transform.
The Direct z-Trallsform The following definition represents the direct z-transform, X(z), of a number sequence, x(n): ~
X(z)=
2: n ..
x(n) z-n
(la)
_00
where z is a variable in the complex plane and X(z) is the complex plane representation of x(n). X(z) can be viewed as a means of representing x(n) where the value of the lIz term raised to the nth power is the nth value of x(n). The z-transform of a sequence x(n) can often be expressed in closed form which leads to a convenient and compact representation of x(n).
1
The One-Sided z-Transform The following definition represents the olle-sided z-tralls!orm, X(z), of a number sequence, x(n): 00
X(z)
=
2:
x(n) z·'
(lb)
• - 0
where x(n) is a sequence of numbers and z is a variable in the complex plane. In situations where x(n) is unknown or of no interest for n(n) z-n]
(3c)
The delay property of the one-sided z-transform can be illustrated by the following example:
If y(n) = x(n-2), then taking the one-sided transform of each side yields:
Y(z)
~ Z-2 X(z)
+x(-2) + Z-I x(-I)
whereX(z) and Y(z) are the one-sided z-transforms of the number sequences x(n) and yen), as defined by Equation (Ib). CLOSED FORM SOLlITIONS OF RECURSIVE NUMBER SEQUENCES The first application of the z-transform that will be discussed are examples of finding closed form solutions to recursive number sequences. In these cases, the one-sided z-transform will be the best choice since initial conditions are involved.
3
Fibonacci Numbers In this example, the one-sided z-transform will be used to find a closed form solution to the well known Fibonacci sequence [3]: (4a) (4b) (4c)
If F(n) is represented by yen), then y(O)=O and y(1)=1 and Equation (4a) becomes:
__ _ _
__ .___ ________ . _2'lnJ- X('!:-_~) +)I(~:::_Zt _ ______
_ __ _______________ ___ J~a2
Taking the one-sided z-transform of both sides of Equation (Sa) and applying the time delay property yields: Y(Z)-Z-I Y(z)+y(_1)+z-2 Y(z) +y(-Z) +Z-I y(-l)
(3)
Next, the initial conditions from Equations (4b) and (4c) are substituted into Equation (Sb) in order to solve fory(-l) andy(-2):
yeO) - y(-l)+ y(-Z) = 0
(6a)
y(l) - yeO) + y(-l) = 1
(6b)
Solving for the unknowns yields y(-1) =1 and y(-2) =-1. Using these results, Equation (Sb) becomes: Z-I Y(z)
=
-1
l-z -z
a-
-2
z (z -a)(z -b)
(7a)
I-v'S
1 +V'S
(7b)
b=-Z-
Z
A closed form solution for yen) can now be found by taking the Inverse z-transform by applying Equation (Zb) to Equation (7a):
yen)
=
1:
[residues ofY(z) zn-I in C
J
(8a)
(8b) an
_b n
v'S
- Fn
4
,n
~O
(8c)
Equation (8c) is the well known closed form formula for the Fibanocci recursion relation shown in Equation (4a). Chebyshev Polynomials
As a second example of tinding closed form solutions using the z-transform, consider the recursion relation defining the Chebyshev polynomials: Tn - 2cosS Tn_l(cosS) - Tn_2(cosS)
(9a)
.. .. --.... .-- ... - To( cos S) -1 ····-----·· .. ----. - - -··---·------··- (9b)- ... . -..-. ..
(9c)
IfT(n) is represented by yen), yen) - 2cosS yen -1)- yen -2)
(lOa)
Applying the one-sided z-transform and time delay property to Equation (lOa), yields: Y(z)=2cosS VI Y(z)+y(-1)]-V 2 Y(z)+y(-2)+Z-1 y(-l)]
(lOb)
Next, the initial conditions from Equations (9b) and (9c) are substituted into Equation (lOb) in order to solve for y(-l) andy(-2) : yeO) - 2cosS y(-l)- y(-2) = 1
(lla)
y(l) - 2cosS y(O)- y(-l) = cosS
(llb)
Solving for the unknowns yields y(-l) = cos Sand y(-2)=2 cos'S - 1. Using these results, Equation (lOb) becomes:
Y(z)
1 -z-lcosS
= -----,----: 1 -2cosS +Z-2
z-'
z (z - cosS)
(z - a)(z - p)
R -i9 p=e
(12a) (12b)
A closed form solution for yen) can now be found by taking the Inverse z-transform by applying Equation (2b) to Equation (12a):
5
Y(II) -
2:
[residues ofY(z) z· -1 in C]
_ [Z' (Z-COSS J] Z-~
[Z' (Z-COSS)]
+
'-0
un (u - cosS) -
(13a)
z-u
,_~
(13b)
W (~- cosS)
u-~
e i • B (i sinS) - e-inB (-i sinS) 2i sinS - - ------ ------ -- ---cos-nS-- - T;,(cosSJ - ;-n -:.: 0 --- ------ ------ ------------- - ---- (13c)- -------Equation (13c) is the well known closed form formula for the Chebyshev polynomial recursion relation shown in Equation (9a). As a side note, the closed form solution found above shows that Equation (9a), with initial conditions, is an effective way of recursively generating cos(n S). By modifying the initial conditions, the general circular function, A cos(nS + So), can be recursively generated using Equation (9a). This relationship finds many uses in digital signal processing applications. DATA SMOOTHING FUNCTIONS Another important application of the z-transform is found in determining the spectral response of data
smoothing functions. In the following examples, the direct z-transform will be the best choice since initial conditions are not involved. The use of the direct z-transform in this application is common-place in digital signal processing where the sequence x(n) usually represents a sampled signal (at a sample frequency Is) and yen) is a filtered version of the input x(n). The direct z-transform of yen) evaluated on the unit circle of the z-plane where Z = e iB , results in the frequency response function [1,2] Y(S) of the filter output yen), where S is a normalized frequency variable (-:It
S
S s :It) corresponding to
the z-plane polar coordinate angle. The z-transform evaluated at a radius of one and angle S (unit circle) is equivalent to the Fourier transform of y(x), where y(x) is a discrete function of the continuous variable
x.
The
function
y(x)
resembles
a
y(x) - ... y(-l) fl(x + 1) + yeO) flex) + y(l) fl(x -1) + ....
series
of
delta
functions,
The integral defining the Fourier
e iB and y(x) is defined as above. The transfer function frequency response is then Y(S)/X(S) where XeS) is the input frequency response and transform [2,4], reduces to the form of Equation (lb) when Z YeS) is the output frequency response.
6
=
NOll·Recursive Averager As a first example of data smoothing, consider a simple averaging function, the sliding willdow
averager: -
1 X(II) - 2M + 1
M
2: X(II + k ) k __M
(140)
Each output value yen) is the arithmetic average of 2M+ 1 values of the input x(n+k) . A more general form of this function would include a weighting factor for each input value: M
-
....... - .... ....... -- x(n) - ..
2: k.-M
w.x(n+k) "' M · - - --··-· ·-··-·- ---·-·---·- ·(14b ) .-- . -- .. '
2: W. ' _-M The z-transform can be applied to Equation (14a) or (14b) to determine the smoothing effect of the filter. The response S(8) shows the smoothing effect as a function of the frequency variable 8. Low values of 8 correspond to slow variations in time (low frequencies) whereas larger values of 8 correspond to rapid fluctuations in time. Thus, if the frequency response function S(8 has low values when 8 is high
(I 81.. :It) the filter will
smooth out rapid fluctuations. Applying the direct z-transform to
Equation (14a) results in:
-
M
1
X(z) - 2M + 1
2:
Zk
X(z)
(150)
k - -M
The absolute value of Equation (lSa), evaluated at z - e iB (on the unit circle of the z-plane), results in the magnitude frequency response of the smoothing function: 1 S(8) I
=
I I X(Z» X(z
, -e "
1 [1 .-1 ~
=
2M+l
+
COS(k8)]
(ISb)
Figure 1 (solid line) is a plot of Equation (lSb) for M=5. When this smoothing function is applied to the spectroscopy data in Figure 2, the characteristic peaks are readily seen. Processing by a smoothing function is commonly performed on spectroscopy data before peak fitting is attempted (the position of the peaks might identify specific elements, whereas the peak width and height could determine relative concentrations). Recursive Averager
The previous sliding window averageris a based on a non-recursive formula. A commonly used simple first-order recursive averager can be expressed as: (16)
7
Taking the direct z-transform of Equation (16) yields: X(z) -
13 [z-'X(z)] + (1- (3) X(z)
(17a)
The absolute value of Equation (17a), evaluated at z - e i • results in the magnitude frequency response of the smoothing function:
I S(9) I
-
I X(z) I
1-(3
X(Z)
Figure 1 (dotted line) is a plot of Equation (17b) for f3
(17b)
- 0.8. When this smoothing function is applied
to the spectroscopy data in Figure 2, the characteristic peaks again are readily seen. Processing by a recursive smoothing function generally requires far less computer time. However, as can be seen in Figure 2, the recursive function shifts the peaks in a non-linear manner, where the amount of phase
shift is dependent on the frequency content of the data. The amount of phase shift as a function of 8 can be determined by the phase angle (polar coordinate angle) defined by the real and imaginary components of S(8) . The non-recursive function has a zero phase shift so that it is preferable for applications such as locating peaks in spectroscopy data. REFERENCES 1. Lawrence R. Rabiner and Gold, "Theory and Application of Digital Signal Processing", PrenticeHall, 1975. 2. John G. Proakis and Dimitris G. Manolakis, "Digital Signal Processing Principles, Algorithms, and Applications", Macmillan Publishing Company, 1992. 3. David L. Ranum, On Some Applications of Fibonacci Numbers, American Mathematical Monthly, 101 (1995), 640-645. 4. Jon Mathews and R. L. Walker, "Mathematical Methods of Physics", W. A. Benjamin, Inc., 1970.
8
LIST OF FIGURES Figure 1. Magnitude responses of filters used in Figure 2. Figure 2. Data smoothing of spectroscopy data using recursive and non-recursive filters, where y coordinate of data is output from a multi channel analyzer (MCA) and x coordinate is the MCA channel number.
9
0'
1.0 Non - Recursive Response Recursive Response
'-" (/)
0. 8 OJ ""0
~
~
·c 0.6 0>
o
~
OJ
0. 4
Cf)
c o
.. . . .
~ 0.2
. .......... ..... ....... . .. ... .... .. .......... .
OJ
0:::
0.0
0.0
I
O.~
1.0
1 .5
2.0
N ormb li zed Frequency, I I I
e
2.5
3.0
21\k/N
MCA Count I\)
o
o
o
..p..
0J
o
(}1
(j)
o
o
o
D
D
N
D
(]I
o
•
--_Q .
o
D
• o
• o
. . . . . ... . ..... .... •
0
:::J 0J 0 0 0 ::J ::J CD
• D
D
8
•
B .'
...
..... .. ... • • . . . . . .... . . .. •• • ... . . . ....
9 0
Z C
3
•
••
(]I
0
•
0
0-
D
CD
...,
..p..
• •
g•
8
~
(]I
0
.0
::D Z
CD
()
c ...,
D
•
0
B•• 0 : D
0 ::J
I
(JJ
::D