The Discrete Fourier Transform
The Discrete Fourier Transform
The Discrete Fourier Transform Theory, Algorithms and Applications
D. Sundararajan
,@ World Scientific It
Singapore • New Jersey 'London • Hong Kong
Published by World Scientific Publishing Co. Pte. Ltd. P O Box 128, Farrer Road, Singapore 912805 USA office: Suite IB, 1060 Main Street, River Edge, NJ 07661 UK office: 57 Shelton Street, Covent Garden, London WC2H 9HE
British Library Cataloguing-in-Publication Data A catalogue record for this book is available from the British Library.
THE DISCRETE FOURIER TRANSFORM Theory, Algorithms and Applications Copyright © 2001 by World Scientific Publishing Co. Pte. Ltd. All rights reserved. This book, or parts thereof, may not be reproduced in any form or by any means, electronic or mechanical, including photocopying, recording or any information storage and retrieval system now known or to be invented, without written permission from the Publisher.
For photocopying of material in this volume, please pay a copying fee through the Copyright Clearance Center, Inc., 222 Rosewood Drive, Danvers, MA 01923, USA. In this case permission to photocopy is not required from the publisher.
ISBN 981-02-4521.-1
Printed in Singapore by U t o P r i n t
To my mother Dhanabagyam and my late father Duraisamy
Preface
Fourier transform is one of the most widely used transforms for the analysis and design of signals and systems in several fields of science and engineering. The primary objective of writing this book is to present the discrete Fourier transform theory, practically efficient algorithms, and basic applications using a down-to-earth approach. The computation of discrete cosine transform and discrete Walsh-Hadamard transforms are also described. The book is addressed to senior undergraduate and graduate students in engineering, computer science, mathematics, physics, and other areas who study the discrete transforms in their course work or research. This book can be used as a textbook for courses on Fourier analysis and as a supplementary textbook for courses such as digital signal processing, digital image processing, digital communications engineering, and vibration analysis. The second group to whom this book is addressed is the professionals in industry and research laboratories involved in the design of general- and special-purpose signal processors, and in the hardware and software applications of the discrete transforms in various areas of engineering and science. For these professionals, this book will be useful for self study and as a reference book. As the discrete transforms are used in several fields by users with different mathematical backgrounds, I have put considerable effort to make things simpler by providing physical explanations in terms of real signals, and through examples, figures, signal-flow graphs, and flow charts so that the reader can understand the theory and algorithms fully with minimum effort. Along with other forms of description, the reader can easily understand that the mathematical version presents the same information in a vii
Vlll
Preface
more abstract and compact form. In addition, I have deliberately made an attempt to present the material quite explicitly and describing only practically more useful methods and algorithms in very simple terms. With the arrival of more and more new computers, the user needs a deep understanding of the algorithms and the architecture of the computer used to achieve an efficient implementation of algorithms for a given application. By going through the mathematical derivations, signal-flow graphs, flow charts, and the numerical examples presented in this book, the reader can get the necessary understanding of the algorithms. Large number of exercises are given, analytical and programming, that will further consolidate the readers' confidence. Answers to selected analytical exercises marked * are given at the end of the book. Answers are given to all the programming exercises on the Internet at www.wspc.com/others/software/4610/. Important terms and expressions are defined in the glossary. A list of abbreviations is also given. For readers with little or no prior knowledge of discrete Fourier analysis, it is recommended that they read the chapters in the given order. I assume the responsibility for all the errors in this book and would very much appreciate receiving readers' suggestions and pointing of any errors (email address:
[email protected]). I thank my friend Dr. A. Pedar for his help and encouragement during the preparation of this book. I thank my family for their support during this endeavor. D. Sundararajan
Contents
Preface
vii
Abbreviations
xiii
Chapter 1 Introduction 1.1 The Transform Method 1.2 The Organization of this Book
1 1 3
Chapter 2 The Discrete Sinusoid 2.1 Signal Representation 2.2 The Discrete Sinusoid 2.3 Summary and Discussion
7 7 11 27
Chapter 3 The Discrete Fourier Transform 3.1 The Fourier Analysis and Synthesis of Waveforms 3.2 The DFT and the IDFT 3.3 DFT Representation of Some Signals 3.4 Direct Computation of the DFT 3.5 Advantages of Sinusoidal Representation of Signals 3.6 Summary
31 32 37 44 51 54 58
Chapter 4 Properties of the D F T 4.1 Linearity 4.2 Periodicity 4.3 Circular Shift of a Time Sequence 4.4 Circular Shift of a Spectrum
61 61 62 62 66
ix
x
4.5 4.6 4.7 4.8 4.9 4.10 4.11 4.12
Contents
Time-Reversal Property Symmetry Properties Transform of Complex Conjugates Circular Convolution and Correlation Sum and Difference of Sequences Padding the Data with Zeros Parseval's Theorem Summary
Chapter 5 Fundamentals of the P M D F T Algorithms 5.1 Vector Format of the DFT 5.2 Direct Computation of the DFT with Vectors 5.3 Vector Format of the IDFT 5.4 The Computation of the IDFT 5.5 Fundamentals of the PM DIT DFT Algorithms 5.6 Fundamentals of the PM DIF DFT Algorithms 5.7 The Classification of the PM DFT Algorithms 5.8 Summary
69 71 81 82 85 86 90 91 95 96 101 104 104 106 112 114 117
Chapter 6 The u X 1 P M D F T Algorithms 121 6.1 The u x 1 PM DIT DFT Algorithms 122 6.2 The 2 x 1 PM DIT DFT Algorithm 125 6.3 Reordering of the Input Data 128 6.4 Computation of a Single DFT Coefficient 130 6.5 The u x 1 PM DIF DFT Algorithms 132 6.6 The 2 x 1 PM DIF DFT Algorithm 134 6.7 Computational Complexity of the 2 x 1 PM DFT Algorithms . 135 6.8 The 6 x 1 PM DIT DFT Algorithm 138 6.9 Flow Chart Description of the 2 x 1 PM DIT DFT Algorithm . 141 6.10 Summary 149 Chapter 7 The 2 x 2 P M D F T Algorithms 151 7.1 The 2 x 2 PM DIT DFT Algorithm 151 7.2 The 2 x 2 PM DIF DFT Algorithm 154 7.3 Computational Complexity of the 2 x 2 PM DFT Algorithms . 158 7.4 Summary 161
Contents
x
'
Chapter 8 D F T Algorithms for Real Data - I 163 8.1 The Direct Use of an Algorithm for Complex Data 163 8.2 Computation of the DFTs of Two Real Data Sets at a Time . . 166 8.3 Computation of the DFT of a Single Real Data Set 169 8.4 Summary 173 Chapter 9 D F T Algorithms for Real Data - II 175 9.1 The Storage of Data in PM RDFT and RIDFT Algorithms . . 175 9.2 The 2 x 1 PM DIT RDFT Algorithm 176 9.3 The 2 x 1 PM DIF RIDFT Algorithm 180 9.4 The 2 x 2 PM DIT RDFT Algorithm 187 9.5 The 2 x 2 PM DIF RIDFT Algorithm 190 9.6 Summary and Discussion 193 Chapter 10 Two-Dimensional Discrete Fourier Transform 10.1 The 2-D DFT and IDFT 10.2 DFT Representation of Some 2-D Signals 10.3 Computation of the 2-D DFT 10.4 Properties of the 2-D DFT 10.5 The 2-D PM DFT Algorithms 10.6 Summary
195 195 196 200 205 212 220
Chapter 11 Aliasing and Other Effects 11.1 Aliasing Effect 11.2 Leakage Effect 11.3 Picket-Fence Effect 11.4 Summary and Discussion
225 226 231 244 246
Chapter 12 The Continuous-Time Fourier Series 12.1 The 1-D Continuous-Time Fourier Series 12.2 The 2-D Continuous-Time Fourier Series 12.3 Summary
249 249 262 268
Chapter 13 The Continuous-Time Fourier Transform 13.1 The 1-D Continuous-Time Fourier Transform 13.2 The 2-D Continuous-Time Fourier Transform 13.3 Summary
273 273 282 284
xii
Contents
Chapter 14 Convolution and Correlation 14.1 The Direct Convolution 14.2 The Indirect Convolution 14.3 Overlap-Save Method 14.4 Two-Dimensional Convolution 14.5 Computation of Correlation 14.6 Summary
287 287 289 292 295 298 301
Chapter 15 Discrete Cosine Transform 15.1 Orthogonality Property Revisited 15.2 The 1-D Discrete Cosine Transform 15.3 The 2-D Discrete Cosine Transform 15.4 Summary
303 303 305 309 310
Chapter 16 Discrete Walsh-Hadamard Transform 16.1 The Discrete Walsh Transform 16.2 The Naturally Ordered Discrete Hadamard Transform 16.3 The Sequency Ordered Discrete Hadamard Transform 16.4 Summary
313 313 320 325 329
Appendix A
The Complex Numbers
333
Appendix B
The Measure of Computational Complexity
341
Appendix C
The Bit-Reversal Algorithm
343
Appendix D
Prime-Factor D F T Algorithm
347
Appendix E
Testing of Programs
349
Appendix F
Useful Mathematical Formulas
353
Answers to Selected Exercises
357
Glossary
365
Index
369
Abbreviations
dc Constant D C T Discrete cosine transform D F T Discrete Fourier transform DIF Decimation-in-frequency DIT Decimation-in-time D W T Discrete Walsh transform F T Fourier transform FS Fourier Series I D F T Inverse discrete Fourier transform I m Imaginary part of a complex number lsb Least significant bit LTI Linear time-invariant msb Most significant bit N D H T Naturally ordered discrete Hadamard transform P M Plus-minus R D F T Discrete Fourier transform of real data R e Real part of a complex number R I D F T Inverse discrete Fourier transform of the transform of real data S D H T Sequency ordered discrete Hadamard transform SFG Signal-flow graph 1-D One-Dimensional 2-D Two-Dimensional
Xlll
The Discrete Fourier Transform
Chapter 1
Introduction
Fourier analysis is the representation of signals in terms of sinusoidal waveforms. This representation provides efficiency in the manipulation of signals in a large number of practical applications in science and engineering. Although the Fourier transform has been a valuable mathematical tool in the linear time-invariant (LTI) system analysis for a long time, it is the advent of digital computers and fast numerical algorithms that has made the Fourier transform the single most important practical tool in many areas of science and engineering. Fourier representation of signals is extremely useful in spectral analysis as well as a frequency-domain tool. In this book, we will be dealing mostly with the discrete Fourier transform (DFT), which is the discrete version of the Fourier transform. The main purpose of this book is to present: (i) the DFT theory and some basic applications using a down-to-earth approach and (ii) practically efficient DFT algorithms and their software implementations. In the rest of this chapter, we explain the transform concept and describe the organization of this book.
1.1
T h e Transform M e t h o d
Transform methods are used to reduce the complexity of an operation by changing the domain of the operands. The transform method gives the solution of a problem in an indirect way more efficiently than direct methods. For example, multiplication operation is more complex than addition operation. In using logarithms, we find the logarithm of the two operands to be multiplied, add them, and find the antilogarithm to get the product. l
2
Introduction
By computing the common logarithm of a number, for example, we find the exponent to which 10 must be raised to produce that number. When numbers are represented in this form, by a law of exponents, the multiplication of numbers reduces to the addition of their exponents. In addition to providing faster implementation of operations, the transformed values give us a better understanding of the characteristics of a signal. The reader might have used the log-magnitude plot for better representation of certain functions. The output of an LTI system can be found by using the convolution operation, which is more complex than the multiplication operation. When a given signal is represented in terms of complex exponentials (a functionally equivalent mathematical representation of sinusoidal waveforms), the response of a system is found by multiplying the complex coefEcients of the complex exponentials representing the input signal by the corresponding complex coefficients representing the system impulse response. This is because a complex exponential input signal is a scaled version of itself at the output of an LTI system. Note that this procedure is very similar to the use of logarithms just described: in using common logarithms, we represent numbers as powers of ten to get advantages in number manipulation whereas, in using the Fourier transform, we represent signals in terms of complex exponentials to get advantages in signal manipulation and understanding. We use transform methods quite often in system analysis. Apart from logarithms, we usually prefer to use the Laplace transform to solve a differential equation rather than using a direct approach. Similarly, we prefer to use the z-transform to solve a difference equation. The time- and frequency-domain approaches are two different ways of presenting the interaction between signals and systems. An arbitrary signal can be considered as a linear combination of frequency components. The time-domain representation is the superposition sum of the frequency components. The DFT is the tool that separates the frequency components. Viewing the signal in terms of its frequency components gives us a better understanding of its characteristics. In addition, it is easier to manipulate the signal. After manipulation, the inverse DFT (IDFT) operation can be used to sum all the frequency components to get the processed time-domain signal. Obviously, this procedure of manipulating signals is efficient only if the effort required in all the steps is less than that of the direct signal manipulation. The manipulation of signals, using DFT, is efficient because of the availability of fast algorithms.
The. Organization of this Book
1.2
3
The Organization of this Book
In Fourier analysis, the principal object is the sinusoidal waveform. Therefore, it is imperative to have a good understanding of its representation and properties. In Chapter 2, The Discrete Sinusoid, we describe the discrete sinusoidal waveform and, its representation and properties. The two principal operations, in Fourier analysis, are the decomposition of an arbitrary waveform into its constituent sinusoids and the building of an arbitrary waveform by summing a set of sinusoids. The first operation is called signal analysis and the second operation is called signal synthesis. The discrete mathematical formulation of these two operations are, respectively, called DFT and IDFT operations. In Chapter 3, The Discrete Fourier Transform, we derive the DFT and the IDFT expressions and provide examples of finding the DFT of some simple signals analytically. The advantages of sinusoidal representation of signals are also listed. The existence of fast algorithms and the usefulness of the DFT in applications is due to its advantageous properties. In Chapter 4, Properties of the D F T , we present the various properties and theorems of the DFT. In Chapter 5, Fundamentals of the P M D F T Algorithms, we present the fundamentals of the practically efficient PM family of DFT algorithms. The classification of the PM DFT algorithms is also presented. In Chapter 6, The u X 1 P M D F T Algorithms, the subset of u x 1 PM DFT algorithms for complex data are derived and the software implementation of an algorithm is presented. In Chapter 7, The 2 x 2 P M D F T Algorithms, the 2 x 2 PM DFT algorithms for complex data are derived. When the data is real, usually it is, there are more efficient ways of computing the DFT and IDFT rather than using the algorithms for complex data directly. In Chapter 8, D F T Algorithms for Real D a t a - I, the efficient use of DFT algorithms for complex data for the computation of the DFT of real data (RDFT) and for the computation of the IDFT of the transform of real data (RIDFT) is described. In Chapter 9, D F T Algorithms for Real Data - II, the PM DFT and IDFT algorithms, specifically suited for real data, are deduced from the corresponding algorithms for complex data. In the analysis of a 1-D signal, the signal, which is an arbitrary curve, is decomposed into a set of sinusoidal waveforms. In the analysis of a 2-D signal, typically an image, the signal, which is an arbitrary surface, is decomposed into a set of sinusoidal surfaces. In Chapter 10, Two-Dimensional
4
Introduction
Discrete Fourier Transform, the theory and properties of the 2-D DFT is presented. The practically efficient way of computing the 2-D DFT is to compute the row DFTs followed by the computation of the column DFTs and vice versa. Using this approach, the 2-D PM DFT algorithms are derived. In practice, most of the naturally occurring signals are continuous-time signals. It is by representing this signal by a set of finite samples, we are able to use the DFT. This creation of a set of samples to represent a continuous-time signal necessitates sampling and truncation operations. These operations introduce some errors in the signal representation but, fortunately, these errors can be reduced to a desired level by using an appropriate number of samples of the signal taken over proper record length. Therefore, the level of truncation and the number of samples used are a trade-off between accuracy and computational effort. A good understanding of the effects of truncation and sampling is essential in order to analyze a signal with minimum computational effort while meeting the required accuracy level. In Chapter 11, Aliasing and Other Effects, the problems created by sampling and truncation operations, namely aliasing, leakage, and picket-fence effects, are discussed. The continuous-time Fourier series (FS) is the frequency-domain representation of a periodic continuous-time signal by an infinite set of harmonically related sinusoids. In Chapter 12, The Continuous-Time Fourier Series, the approximation of the continuous-time Fourier Series, 1-D and 2-D, by the DFT coefficients is described. The inability of the Fourier representation to provide uniform convergence in the vicinity of a discontinuity of a signal is also discussed. The continuous-time Fourier transform (FT) is the frequency-domain representation of an aperiodic continuous-time signal by an infinite set of sinusoids with continuum of frequencies. In Chapter 13, The Continuous-Time Fourier Transform, the approximation of the samples of the continuous-time Fourier transform, 1-D and 2-D, by the DFT coefficients is described. A major application of the DFT is the fast implementation of fundamentally important operations such as convolution and correlation. In Chapter 14, Convolution and Correlation, the fast implementation of the convolution and correlation operations, 1-D and 2-D, using the DFT is presented. The even extension of a signal eliminates discontinuity at the edges, if present, thereby enabling the signal to be represented by a smaller set
The Organization of this Book
5
of DFT coefficients. This special case of the DFT is called the discrete cosine transform and it is widely used in practice for signal compression. In Chapter 15, Discrete Cosine Transform, the computation of the discrete cosine transform, 1-D and 2-D, is presented. While the sinusoids are the basis waveforms in the DFT representation of signals, a set of orthogonal rectangular waveforms is used to represent signals in the discrete Walsh-Hadamard transforms. These transforms, often used in image processing, are computationally efficient since only addition operations are required for their implementation. Algorithms for their computations are very similar to those of the DFT algorithms. The study of these transforms provides a contrast in representing an arbitrary waveform using a different set of orthogonal waveforms. In Chapter 16, Discrete Walsh-Hadamard Transform, the computation of the discrete WalshHadamard transforms, 1-D and 2-D, is described. In the Appendices, the complex numbers, the measure of computational complexity, the bit-reversal algorithm, the prime-factor DFT algorithm for a data size of six, and the testing of programs are briefly described. A list of useful mathematical formulas is also given. The theory of the Fourier analysis is that any periodic signal satisfying certain conditions, which are met by most signals of practical interest, can be represented uniquely as the sum of a constant value and an infinite number of sinusoids with frequencies those are integral multiples of the frequency of the signal under analysis. In short, almost everything that is said in this book is concerned with this one line.
Chapter 2
The Discrete Sinusoid
A signal represents some information. Manipulation of signals, such as removing noise from a signal, is a major activity in applications in science and engineering. An arbitrary signal can be easily manipulated only by representing it as a linear combination of simple and mathematically welldefined signals. There are many ways a signal can be represented. The proper representation of a signal is crucial for the efficient manipulation of it. For the analysis and design of LTI systems, most often, signals are represented as a linear combination of the impulse signal in the time-domain and the sinusoidal signal in the frequency-domain. In Sec. 2.1, we briefly describe the time- and frequency-domain representations of signals. The sinusoidal waveform is the principal object in Fourier analysis. In Sec. 2.2, we study the characteristics of the discrete sinusoidal waveform and its representation by complex exponentials. The orthogonality property of the sinusoids is also presented.
2.1
Signal Representation
Time-domain
signal
representation
Signals occur, mostly, in a form that is called the time-domain representation. In this form, the signal amplitude, x(t), is represented against time, t. If the signal is denned at all instants of time, it is referred as a continuous-time or analog signal. If the signal is defined only at discrete instants of time, then the signal is referred as a discrete signal. It is assumed that the interval between instants of time is uniform. Figures 2.1(a) 7
The Discrete
Sinusoid
(b)
(a) 0.9659
0.9239 0.7071
0.7071 0.5
0.3827
0.2588 0 -0.1951
0
-0.5556 -0.8315 -0.9808
-0.866 -1 0
4
8 12 16 20 24 28 n (c)
0
3
6
9 12 15 18 21 (d)
Fig. 2.1 (a) The continuous-time cosine signal, x{t) = cos(f t). (b) The continuous time sine signal, x(t) = s i n ( | t ) . (c) The discrete cosine signal, x(n) = cos( f^n). (d) The Thi discrete sine signal, x(n) = sin(y^n).
and (b) show, respectively, one cycle of the continuous-time cosine and sine signals x(t) = cos(ft) and x{t) = sin(ft). Figures 2.1(c) and (d) show, respectively, the discrete cosine and sine signals x(n) = cos(f^n) and x(n) — s i n ( ^ n ) , obtained by sampling the continuous signals shown in Figs. 2.1(a) and (b) with a sampling interval of 0.25 seconds. For the most part, we deal with discrete signals in this book. However, the relationship between the continuous-time and discrete signal representations will be presented. The time and amplitude variables of a digital signal take on only discrete values and this form is suitable for processing using digital devices. We use the term time-domain although the independent variable is
Signal Representation
9
not time for all the signals. For example, in a speech signal, the amplitude of the signal varies with time whereas the intensity values of an image vary with two spatial coordinates. Signals such as speech signal, which vary with respect to a single independent variable, is called a one-dimensional (1-D) signal. An image is a two-dimensional (2-D) signal since it varies with respect to two independent variables. A discrete signal is represented, mathematically, as a sequence of numbers {x(n), —oo < n < oo}, where the independent variable n is an integer and x(n) denotes the nth element of the sequence. Although it is not strictly correct, x{n) is also used to refer a sequence as the sequence x(n). The element x(n) of a sequence is often referred as the nth sample of the sequence regardless of the way the sequence is obtained. Usually, a discrete sequence is obtained by sampling an analog signal. However, discrete signals can also be generated directly. Even if the signal is obtained by sampling a continuous-time signal, the sampling instant is shown explicitly only when it is required as x(nTs), where Ts is the sampling interval. The unit-impulse signal, shown in Fig. 2.2(a), is defined as r, . '(B)
=
( 1 for n = 0 \ 0 forn^O
In practice, the input signal to a system, most often, is quite arbitrary and it is difficult to represent and manipulate it analytically. To circumvent this problem, it is a necessity to represent the signal as a linear combination of elementary signals. An arbitrary signal can be represented as the sum of delayed and scaled unit-impulses. An arbitrary discrete signal, {x(—1) = - l , x ( 0 ) = l,ar(l) = - 3 , z ( 2 ) = 2}, is shown in Fig. 2.2(b). This signal can be expressed as 2 x n
()
=
]C
x m
( )ti(n-™>)
or x n
() =
-6(n+l)+6(n)-36(n-l)+26(n-2)
m=—1
and the constituent impulses are shown in Figs. 2.2(c) to (f). With this type of representation, if the unit-impulse response of an LTI system is known, the response of the system to an arbitrary input sequence can be obtained by summing the responses to all the individual impulses.
10
The Discrete
•
1
2 1 c •sr-1
0
•
•
•
1
0 2 4
• 1
0
n
1
1
2
0
n
(a)
1
(b)
(c)
•
2
•
•
•
*
£ °
2
n
•
1 0
•
"sr-l
-3
-4-2
Sinusoid
"? 0
i
•
1
0
•
"ST
•
-3
-1
0
1
1
2
n
0
1
2
n
(•)
(d)
1
2
n
(0
Fig. 2.2 (a) Unit-impulse signal, S(n), —5 < n < 5. (b) An arbitrary discrete signal. (c), (d), (e), and (f): The representation of the signal shown in (b) in terms of delayed and scaled impulses, (c) -S(n + 1), (d) 8(n), (e) -3<J(n - 1), and (f) 2S(n - 2).
Frequency-domain
signal
representation
An alternate representation of signals is called the frequency-domain representation. In this representation, the variation of a signal in terms of frequency is used to characterize the signal. At each frequency, the amplitude and phase or, equivalently, the amplitudes of the cosine and sine components of the sinusoid are required for representing a signal. Figure 2.3(a) shows two sinusoidal waveforms that are the components of a periodic signal. The sum of the projection of the two waveforms on the time axis is the time-domain representation of the signal, shown in Fig. 2.3(b). Figure 2.3(c) shows the representation of the signal on the frequency axis. The amplitude and the phase shift of the first sinusoid are, respectively, 1 and -60 degrees and those of the second sinusoid are, respectively, 1 and 90 degrees. It is evident that either representation completely specifies the signal. The independent variable is time in the time-domain representation. In the frequency-domain, the independent variable is frequency thereby explicitly specifying the frequency components of a signal. This book is about the frequency-domain representation of signals. Therefore, we have to explore the characteristics of the sinusoidal waveform.
The Discrete
frequency, Hz
0
11
Sinusoid
0
time
(a) • (1,-60)
1 frequency, Hz (b)
•(1,90)
2
(c)
Fig. 2.3 (a) Two sinusoidal components of a periodic signal, (b) Time-domain representation of the signal, (c) Frequency-domain representation of the signal.
2.2
The Discrete Sinusoid
The two waveforms we usually remember are the cosine and sine waveforms. We have already seen one cycle of the discrete versions of the cosine, cos(j^n), and sine, sin(j^n), waveforms, respectively, in Figs. 2.1(c) and (d). The magnitude of a peak value from the horizontal axis is called the amplitude of the waveform. The wave oscillates with equal amplitudes about the horizontal axis. There are two zero crossings in a cycle. In order to compare the positions of two or more waveforms of the same frequency along the horizontal axis, we have to specify a reference position. Let the occurrence of the positive peak of the waveform at Oth instant (n = 0) be the reference point and we define the phase shift of the waveform zero. Therefore, the phase shift of the cosine waveform is zero and it is used as the reference waveform in this book (The sine waveform can also be considered as the reference waveform.). The phase shift of a waveform is defined as the amount of the shift of the cosine waveform to the right or left to
The Discrete Sinusoid
12
obtain that waveform. If the shifting is to the right we define the phase shift to be negative and a shift to the left is positive. For example, the sine waveform has a -90 degrees or — | radians phase shift since we have to shift the cosine wave to the right by that amount to get the sine wave. What is called a sinusoid is a cosine or sine wave with arbitrary phase shift. The cosine and sine waveforms are important special cases of the sinusoid with phase shifts of zero and -90 degrees, respectively. The polar
form
A discrete sinusoidal waveform is mathematically characterized as x(n) = Acos(u>n + 0), n = - c o , . . . , — 1 , 0 , 1 , . . .,oo
(2.1)
where A is the amplitude (half the peak-to-peak length), cu is the angular frequency of oscillation in radians per sample, and 9 is the phase shift in radians. The cyclic frequency of oscillation / is ^ cycles per sample. The period N is 4 samples (The period of a discrete sinusoidal waveform is j only when \ is an integer. We will consider the more general case later.). For the waveform shown in Fig. 2.1(c), the amplitude is 1, the phase shift is 0 (that is the positive peak of the waveform occurs at the point n = 0), the angular frequency, u, is f^ radians per sample, and the cyclic frequency / is ^ cycles per sample. The period is 32 samples, that is, the waveform repeats any 32-point sequence of its sample values, at intervals of 32 samples, indefinitely, x(n) = x(n ± 32) for any n. The interval between two samples is ^ = 11.25 degrees. Therefore, the values of the cosine and sine functions at intervals of 11.25 degrees can be read from this figure. For the waveform shown in Fig. 2.1(d), the amplitude is 1 and the phase shift is — ^ radians (shift of the cosine waveform by six samples (6/u — —6) to the right), that is, the positive peak of the waveform occurs after f radians from the point n = 0. The angular frequency, ui, is y^, and the cyclic frequency / is ^ cycles per sample. The period is 24 samples, that is, the waveform repeats any 24-point sequence of its sample values, at intervals of 24 samples, indefinitely. The values of the sine and cosine functions at intervals of 15 degrees can be read from this figure. A shift by an integral number of periods does not change a sinusoid. If a sinusoid is given in terms of a phase-shifted sine wave, then it can be, equivalently, expressed in terms of a phase-shifted cosine wave as x (n) = Asm(un+9) = A cos(am+(#-§)). Conversely, x(n) = Acos(um + 9) = Asm(uin + (9 + f)).
The Discrete Sinusoid
13
4.3301 -5- 1.2941 "ST -2.5 -4.8296
Fig. 2.4 The sinusoid, x(n) = 5cos(f n - ^ ) .
Example 2.1 Determine the amplitude, angular and cyclic frequencies, the period, and the phase shift of the following sinusoid. x{n) = —5 cos(—n + —) Solution By adding a phase shift of —7r (as the amplitude is always a positive quantity, —ACOS(LJTI + 8) = Acos(am + 8 ± 7r)), we get x(n) = 5cos(— n — — ) T:
O
Now, A = 5,w = j radians per sample, / = 2V = g cyc^es P e r sample, N = 8 samples, and the phase shift is — ^ radians. One cycle of the sinusoid is shown in Fig. 2.4. I In Fig. 2.4 (and in most of the figures in this book), we have shown the corresponding continuous waveform for clarity. However, it should be remembered that, in discrete signal analysis, a signal is represented only by its samples. Even if the peak value does not occur at a sample point, for a given LJ, the amplitude and phase of a sinusoid can be obtained by solving the equations x(n) = A cos(um + 8)
and
x(n + 1) = Acos(u(n
+ 1) + 8)
Values x{n) and x(n+l) are, respectively, the nth and the ( n + l ) t h samples, assuming that the number of samples in a period is, at the least, one more than twice the number of cycles. Solving these equations for 6 and A, we get 8 — tan
_x x(n) cos(w(n + 1)) - x(n + 1) cos(wn) x(ri) sin(w(n + 1)) — x(n + 1) sin(wn)
(2.2)
14
The Discrete Sinusoid
A =
*( n ) cos(am + 0)
(2 v
3) ' '
Since the tangent function has period TT, the signs of the numerator and denominator must be taken into account in determining the angle 9. Example 2.2 Let a;(l) = 1 and x(2) = —1 be the two samples of a sinusoid with frequency / = \ cycles/sample. Find the polar form of the sinusoid. Solution u) = 2nf = f radians/sample. Substituting the values in Eqs. (2.2) and (2.3), we get 0_
*
t a n
-l
l c O 8
- t a n
(
7 r
)-(-
1
)
C O S
(?)_
*
lsin(7r)-(-l)sin(f) -
AA
4'
1
-
,/n
~ cos(f - f) "
VZ
Therefore, the sinusoid is x(n) = \ / 2 c o s ( | n — f ) . The rectangular
form
In the polar form, a sinusoid is represented by its amplitude and phase. In the rectangular form, a sinusoid is represented in terms of the amplitudes of its cosine and sine components. By expanding Eq. (2.1), the rectangular form of representing a sinusoid is obtained as x(n) = Ccos(am) + -Dsin(wn), where C = A cos 6 and D = —A sin 9. The inverse relation is A = VC 2 + D2 and 9 = c o s " 1 ^ ) = s i i T 1 ^ ) . Example 2.3
Express the following sinusoid in rectangular form. x(n) = 5cos(— n
—)
Solution C = 5 c o s ( - y ) = - 2 . 5 , J? = - 5 s i n ( - y ) = 5 ^ Therefore, the sinusoid, in the rectangular form, is given by x(n) = - 2 . 5 c o s ( - n ) + 5 — s i n ( - n )
I
The Discrete
Sinusoid
1.7678
15
3.0619
- #
0
°
-4.3301
-2 5 D
2
3
6
4 n
2
(a)
4
6
(b)
Fig. 2.5 (a) The cosine component, x(n) = — 2.5cos( j n ) , and (b) the sine component, x(n) = \ / 3 ( 2 . 5 ) s i n ( ^ n ) , of the sinusoid shown in Fig. 2.4.
The sinusoid, and its cosine and sine components are shown, respectively, in Figs. 2.4, 2.5(a), and (b). We can easily verify that each sample value of the sinusoid is the sum of the corresponding samples of its cosine and sine components. I E x a m p l e 2.4
Express the following sinusoid in polar form. in
= cos(—n) + sm(—n) 6 6
Solution A = \ / l 2 + l 2 = y/2, 9 = cos
_1
I —= I = sin \V2j
Hence, the sinusoid is given by x(n) = y/2cos(fn
x
I —=. ) = — — radians \V2j 4
— j) in the polar form. I
The rectangular form of a sinusoid shows clearly that a sinusoid is a linear combination of sine and cosine waveforms of the same frequency. This point is so important that we provide an alternate viewpoint. Any function x(n) can be expressed as the sum of an even function *W+2*(-") a n d an odd function x\n)-*\-n) _ N 0 te that, for a periodic function with period N, x(N — n) can also be used instead of x(—n). Therefore, an arbitrary sinusoid, which is neither odd nor even, can be expressed as the sum of an odd function and an even function. For a sinusoid, the odd function is a sine function and the even function is a cosine function of the same frequency. Acosjun + 6) + Acos(w(N -n) + 6) = Acos(6)cos(u:n) 2 vlcos(um + 0) - Acos{u(N - n) +6) = -Asm(0)sm(un)
16
The Discrete
Sinusoid
Example 2.5 Use even and odd split to find the sample values of the cosine and sine components of the sinusoid, x(n) = \/2cos(fn — J ) . Solution The sample values of the sinusoid for n = 0,1,2,3 are {1,1, —1, —1}. Using the even and odd split, we get the sample values of the cosine and sine components, respectively, as {1,0, - 1 , 0 } and { 0 , 1 , 0 , - 1 } . I The sum of sinusoids
of the same
frequency
The sum of discrete sinusoids of the same frequency but arbitrary amplitudes and phases is a sinusoid of the same frequency. Let #i (n) = A\ cos(um + 9\)
and
#2(71) = A2 cos(om + 92)
Then, £3 (n) = x\ (n) + x2(n) = A3 cos(un + #3). Expressing the waveforms in rectangular form, we get x\(n) = a\ cos(um) + 61 sin(um),
a\ = A\ cos(#i), 61 = —Ai sin(#i)
£2(71) = a 2 cos(wn) + 62 sin(um),
02 = A2 cos(92), b2 = —A2 sin(#2)
x3(n) = a 3 cos(wn) + 63 sin(um),
a 3 = A3 cos(0 3 ), b3 = -A3 sin(03)
It is obvious that a3 = ai + 02 and 63 = &i +62- Converting from rectangular form to the polar form, we get y/(ai + a2)2 + (&i + b2)2 = yJA\ +A\+
A3
=
63
— cos
2AXA2 cos(91 - 92)
_, Ai cos(^i) + A2 cos(92) . _, Ai sin(0i) + A2 sin(0 2 ) -——. - — = sin -—'— A3 A3
By repeatedly adding, any number of sinusoids of the same frequency can be combined into a single sinusoid. Example 2.6 Determine the sinusoid that is the sum of the two sinusoids = - 4 . 3 c o s ( | n - f$) and x2(n) = 3 . 2 c o s ( f n - f ) . Xl(n) Solution The first sinusoid can also be expressed as xi (n) = 4.3 c o s ( | n + ^jf )• Now, A1=4.3,
A2=3.2,