Professional Documents
Culture Documents
Tips - The Discrete Fourier Transform Theory Algorithms A PDF
Tips - The Discrete Fourier Transform Theory Algorithms A PDF
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
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 engineer-
ing. The primary objective of writing this book is to present the discrete
Fourier transform theory, practically efficient algorithms, and basic applica-
tions 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 anal-
ysis. 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 ap-
plications 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 dif-
ferent 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 under-
stand that the mathematical version presents the same information in a
vii
Vlll Preface
D. Sundararajan
Contents
Preface vii
Abbreviations xiii
Chapter 1 Introduction 1
1.1 The Transform Method 1
1.2 The Organization of this Book 3
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
1.1 T h e Transform M e t h o d
l
2 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 ap-
propriate 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 understand-
ing of the effects of truncation and sampling is essential in order to analyze
a signal with minimum computational effort while meeting the required ac-
curacy 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 repre-
sentation of a periodic continuous-time signal by an infinite set of harmon-
ically 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 rep-
resentation 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 fundamen-
tally important operations such as convolution and correlation. In Chap-
ter 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 sig-
nals 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 com-
putations 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 Walsh-
Hadamard 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
7
The Discrete Sinusoid
(a) (b)
0.9239 0.9659
0.7071 0.7071
0.5
0.3827
0.2588
0 0
-0.1951
-0.5556
-0.8315 -0.866
-0.9808 -1
0 4 8 12 16 20 24 28 0 3 6 9 12 15 18 21
n
(c) (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 rela-
tionship 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 num-
bers {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 dis-
crete 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, . ( 1 for n = 0
'(B) =
\ 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 = x m or x n
() ]C ( )ti(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 Sinusoid
1 • 2 •
1 •
c • •
1 "sr-l
•sr-1
0 -3 •
-4-2 0 2 4 1 0 1 2 1 0 1 2
n n n
(a) (b) (c)
2 •
1 •
0 • • * • i • •
£ ° "? 0
"ST
-3 •
-1 0 1 2 1 0 1 2 1 0 1 2
n n n
(d) (•) (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, Hz 0 0 time
(a)
• (1,-60) •(1,90)
1 2
frequency, Hz
(b) (c)
Fig. 2.3 (a) Two sinusoidal components of a periodic signal, (b) Time-domain repre-
sentation of the signal, (c) Frequency-domain representation of the signal.
The two waveforms we usually remember are the cosine and sine wave-
forms. We have already seen one cycle of the discrete versions of the co-
sine, 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 consid-
ered 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
12 The Discrete Sinusoid
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.
4.3301
-5- 1.2941
"ST
-2.5
-4.8296
x{n) = —5 cos(—n + —)
Solution
By adding a phase shift of —7r (as the amplitude is always a positive quan-
tity, —ACOS(LJTI + 8) = Acos(am + 8 ± 7r)), we get
x(n) = 5cos(— n — — )
T: O
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
_x x(n) cos(w(n + 1)) - x(n + 1) cos(wn)
8 — tan (2.2)
x(ri) sin(w(n + 1)) — x(n + 1) sin(wn)
14 The Discrete Sinusoid
A = *( n ) (2 3)
v
cos(am + 0) ' '
Since the tangent function has period TT, the signs of the numerator and
denominator must be taken into account in determining the angle 9.
x(n) = 5cos(— n —)
Solution
C = 5 c o s ( - y ) = - 2 . 5 , J? = - 5 s i n ( - y ) = 5 ^
x(n) = - 2 . 5 c o s ( - n ) + 5 — s i n ( - n )
The Discrete Sinusoid 15
1.7678 3.0619
0 - # °
-2 5 -4.3301
D 2 4 6 3 2 4 6
n
(a) (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 x
I —=. ) = — — radians
\V2j \V2j 4
Hence, the sinusoid is given by x(n) = y/2cos(fn — 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
Example 2.6 Determine the sinusoid that is the sum of the two sinusoids
Xl(n) = - 4 . 3 c o s ( | n - f$) and x2(n) = 3 . 2 c o s ( f n - f ) .
Solution
The first sinusoid can also be expressed as xi (n) = 4.3 c o s ( | n + ^jf )• Now,
0
A1=4.3, A2=3.2, <?i = ^ , 2 = - |
The Discrete Sinusoid 17
2.9782
3.7239
1.6583
1.1129
^T-0.6329
-2.15
-2.5534
-4.1535
0 2 4 6 0 2 4 6
n n
(b) (c)
A3 = W 4 . 3 2 + 3 . 2 2 + 2 ( 4 . 3 ) ( 3 . 2 ) c o s ( ^ + | ) = 3.0447
_14.3cos(^)+3.2cos(-f) _, 4 . 3 s i n ( ^ f ) + 3 . 2 s i n ( - f )
63 = cos Hr^rTT^ — =sin — —
3.0447 3.0447
= —2.5656 radians
The waveforms of the two sinusoids and their sum, X3(n) = 3.0447 cos(fn-
2.5656), are shown, respectively, in Figs. 2.6(a), (b), and (c). I
Periodicity
The condition for a discrete sinusoid to be periodic is that the cyclic fre-
quency / is a rational number (a ratio of two integers). For a discrete
sinusoid to be periodic with period N,
Acos(un + 6) = Acos(uj(n + N) + 9)
Since a sinusoid is periodic only with an integer multiple of 27r, this implies
LJN = 2nfN = 2irl, where / and N are integers. That is, / = jj.
Example 2.7 Is the waveform periodic? If periodic, what is the period?
(a) x(n) = cos(^ L n)
(b) x(n) = 4cos(|n)
Solution
(a) From inspection, the cyclic frequency, / = ^ , is a rational number.
Therefore, the waveform, shown in Fig. 2.7(a), is periodic with a period
18 The Discrete Sinusoid
•S- o
(a) (b)
Fig. 2.7 (a) The sinusoid x(n) = cos( ^-n) is periodic with a period of AT = 16 samples.
(b) The sinusoid x(n) = 4cos(|n) is not periodic.
x[n) = 4 s m ( - n + - )
Solution
Two of the innumerable number of sinusoids with the same set of sample
The Discrete Sinusoid 19
0 1 2 3
n
values are
/ \ J . /57T 71". . . .37T 7T.
Solution
This is an approximation of the triangular waveform with amplitude one.
The period is 16. Only the fundamental harmonic is shown in Fig. 2.10(a)
with dotted line. The error in this representation is shown in Fig. 2.10(b).
Figures 2.10(c) and (d) show, respectively, an approximation and the error
with the sum of the first and third harmonics. Figures 2.10(e) and (f) show,
20 The Discrete Sinusoid
0 5 10 15
n
Fig. 2.9 The fundamental x(n) = 3cos(y|-7i + | - ) , the second harmonic x(n) =
- 2 c o s ( | ^ 2 r a + j), and the third harmonic x(n) = c o s ( ^ 3 n + j). All the three si-
nusoids are periodic with a period of N = 16 samples.
respectively, the sum of the first, third, and fifth harmonics, and the result-
ing error in the approximation. Note that the error in the approximation
of the triangular waveform reduces as more and more harmonics are used.
I
Example 2.10 Find the fundamental cyclic frequency of the sum and
the harmonic numbers of the two sinusoids.
xi(n) = c o s ( y n - — ) , x2{n) = s i n ( y n - - )
Solution
The cyclic frequency of the waveforms are / i = | and fi = \- There are no
common factors of the numerators and denominators. The least common
multiple of the denominators (5,3) is 15. The greatest common divisor of
the numerators (2,1) is one. Therefore, the fundamental cyclic frequency
is TE-. T n e fundamental period is 15 samples. Frequency / i is the 6th
harmonic and /•! is the 5th harmonic. The first sinusoid completes 6 cycles
The Discrete Sinusoid 21
0.2
0
t °
-0.2
10 15 10 15
(b)
0.1
-0.1
10 15
(d)
0.05
I o
-0.05
5 10 15
n
(e) (f)
Fig. 2.10 The approximation of a triangular wave, (a) The approximation with the
fundamental and (b) the resulting error, (c) The approximation with the fundamen-
tal and third harmonics, and (d) the resulting error, (e) The approximation with the
fundamental, third, and fifth harmonics, and (f) the resulting error.
(Fig. 2.11(a)) and the second sinusoid completes 5 cycles (Fig. 2.11(b)) in
the period. The combined waveform, shown in Fig. 2.11(c), completes one
cycle. |
*M *M *i*
0 5
n
10 15 0 5
n
10 15 0 5
n
10 15
Fig. 2.11 (a) The sinusoid xi(n) = c o s ( ^ n — f^) completes 6 cycles during 15 samples.
(b) The sinusoid X2{n) = s i n ( ^ n - | ) completes 5 cycles during 15 samples, (c) The
sum of the two sinusoids completes one cycle during 15 samples. All the three waveforms
are periodic with a period of N = 15 samples.
The term e JW " is the complex sinusoid with unit amplitude and zero
phase shift. This form of the sinusoid is more commonly used in theoret-
ical and practical Fourier analysis due to its compact form and ease and
efficiency of manipulation. By multiplying with the complex (amplitude)
coefficient Ae^, we can generate a complex sinusoid with arbitrary am-
plitude and phase shift. The complex coefficient Aeje is a single complex
number containing both the amplitude and phase of a sinusoid.
The complex conjugate of the complex exponential is Ae~j(-un+0\ By
adding the complex exponential with its conjugate and dividing by two,
The Discrete Sinusoid 23
The right side of this equation is a real sinusoid described earlier, which is
of interest in practical applications. Note that the terms appearing on the
left-hand side are complex conjugates which combine to represent the real
function A cos (am + 6). The plot of the amplitude and phase (or the real
and imaginary parts) of the complex coefficients of the complex sinusoids
of a signal against frequency is its complex s p e c t r u m .
/ \ /I* 27T.
x(n) = 8 c o s ( - n - —)
Solution
The waveform is shown in Fig. 2.12(a). Since u = 2nf = | , / = i
cycles/sample. Expressing the waveform in terms of complex sinusoids, we
get
a; (n) = ^(e^t«-¥)+e-i(f«-¥))
The complex frequency coefficients are 4e~J~3L and 4e-7"3L. Therefore, the
amplitude and phase of the spectrum at / = ^ are 4 and — ^p radians
and those at / = — ^ are 4 and ^-, respectively. The spectrum, in terms
of amplitude and phase, is shown in Fig. 2.12(b). The real and imaginary
parts of the spectrum and the corresponding cosine and sine components
of the sinusoid are shown, respectively, in Figs. 2.12(c) and (d).
It should be observed that the real part (as well as the amplitude) of the
spectrum is even-symmetric and the imaginary part (as well as the phase)
is odd-symmetric. We use four real values to represent a real sinusoid
instead of two. This redundancy, in terms of storage and operations, can
be eliminated as described in a later chapter. I
Both the dc and the frequency component with frequency index y (with
N even) have only real spectral values, A or —A, for real signals. That
means the phase shift of these frequency components is 0 or ±n. It should
be noted that real sinusoids are easy to visualize, while complex sinusoids
are easy to manipulate.
24 The Discrete Sinusoid
8 4
2.0944 •amplitude
0 ophase
0
-8 -2.0944
10 15 -1/16 0 1/16
/ cycles/sample
(a) (b)
. 3.4641 o • real • cpsine
00 osine
o imaginary
a 0
1 -2 • •
^ -3.4641 . , 9
-1/16 0 1/16
/ cycles/sample
(c) (d)
Fig. 2.12 (a) The sinusoid x(n) = 8 c o s ( | n - ^ p ) . (b) The spectrum of the sinusoid
showing the amplitude and phase, (c) The spectrum showing the real and imaginary
parts, (d) The cosine and sine components of the sinusoid.
Orthogonality
If the sum of pointwise products of two real discrete signals (for complex
signals, the pointwise products of a signal with the complex conjugate of
the other signal) is zero over a specified interval, the signals are said to be
orthogonal in that interval. This property allows us to represent and ma-
nipulate a single frequency component of a signal as though other frequency
components do not exist.
The sum of the samples of a discrete cosine or sine function is zero
over an integral number of periods with any staring point. This is ob-
vious due to the symmetry of these functions about the horizontal axis.
The product of two harmonically related discrete cosine and sine signals,
over an integral number of periods, will be odd. Therefore, they are or-
thogonal. Figures 2.13(a) and (b) show, respectively, signals cos(f n) and
sin(f n). Figure 2.13(c) shows the product of these signals, cos(f n) sin(fn)
= 0.5(sin(^n) - sin(f n)). From the odd symmetry of the waveform, it is
obvious that the sum of the samples is zero.
Consider the products of the form cos(Zam) cos(mwn), I, m = 0 , 1 , 2
• « 1 1 o
• B • B + + sum = 0 o o
+ + o o
*° S B B S
+
+ +
+
o o
o o
1 +4-+ 1
0 5 10 15 0 5 10 15 0 5 10 15
n n n
(a) (b) (c)
B B 1 +++ 1
S B S B + +
+ + o o
t ° 5 0
S ° S B S B
+
+ +
+ o o
oo o°
+4.+ 1
0 5 10 15 0 5 10 15 0 5 10 15
n n n
(d) (e) (f)
B 1 1 3
B B B B + + ° sum = 0 °
+ + o o
f ° S ° + + 1 ° o
o o
o
B • B B + +
1 +4-+ 1
0 5 10 15 0 5 10 15 0 5 10 15
n n n
(g) (h) (i)
Fig. 2.13 (a) The sinusoid, x(n) = c o s ( ^ n ) . (b) The sinusoid, x(n) = s i n ( ^ n ) . (c) The
product of the waveforms of (a) and (b). (d) The sinusoid, x(n) = sin( J n ) . (e) The
sinusoid, x(n) = s i n ( J u ) . (f) The product of the waveforms of (d) and (e). (g) The
sinusoid, x(n) = c o s ( ^ n ) . (h) The sinusoid, x(n) = cos(^n). (i) The product of the
waveforms of (g) and (h). The sum of the samples of each of the waveforms shown in
(c), (f), and (i) is zero.
0.1464
0
(a)
Fig. 2.14 (a) The product cos(£ n)cos( J n ) , with N = 16, and the sum of the samples
is 8. (b) The product sin(f n)sm(^n), with N = 8, and the sum of the samples is 4.
e
£ ei^(m-0n = 2ir(_t) = 0, for m * l
n=0 l-eJ—w—
Reference
Exercises
2.1 Determine the amplitude, angular and cyclic frequencies, the period,
and phase of the sinusoid.
2.1.1. x(n) = 7 s i n ( f n + f )
* 2.1.2 x(n) = - 7 . 1 s i n ( f n - 2=)
2.1.3 i(r») = -2.2cos^fn)
2.1.4 i ( n ) = 3 c o s ( | n + f )
2.1.5 x(n) = - 1 . 1 sin(ffn)
2.2 Given two adjacent samples and the frequency of a sinusoid, find the
polar form of the sinusoid.
2.2.1. x(0) = 2>/2,a:(l) = (-%/2)(V3 - l),w = f
2
2.2.2 x(0) = ^ , x ( l ) = =^,u= f
* 2.2.3 ar(l) = ( ^ ) ( V 5 - l),z(2) = (=^)(V3 - l),a, = f
2.2.4 x(2) = ( = ^ ) , x ( 3 ) = ( = ^ ) ( V 3 + l),u = f
2.2.5 a:(0) = >/3,a:(l) - ( ^ ) ( \ / 3 - l),w = |
2.3 Express the sinusoid in rectangular form.
2.3.1 x(n) = 5 c o s ( | n + f )
2.3.2 x(n) = cos(f n - \)
2.3.3z(n) = 4sin(fn + f )
2.3.4 x{n) = 2cos(f|n)
2.3.5 x(n) = 7 c o s ( f f n - f ) .
Exercises 29
* 2.3.6z(n) = 3cos(fn + f )
2.3.7 x(n) = s i n ( ^ n )
2.9 Find the spectrum of the signal in terms of: (i) amplitude and phase
and (ii) real and imaginary parts.
2.9.1 x(n) = 6 c o s ( f n + f )
30 The Discrete Sinusoid
Programming Exercises
2.1 Write a program to generate the sample values of a real discrete sinu-
soid, Acos(jj-n + 6), with period N, phase 6, and amplitude A.
2.2 Write a program to generate the sample values of a complex discrete
sinusoid, Ae^^n+8\ with period N, phase 6, and amplitude A.
Chapter 3
The Discrete Fourier Transform
In this chapter, the tools that enable the conversion between the time-
and frequency-domain representations of discrete signals, the DFT and the
IDFT, are derived. These are the mathematical formulations of the problem
of waveform analysis and synthesis, respectively, with harmonically related
discrete sinusoids as the basis functions. An infinite number of sinusoids
with various frequencies, in general, are required for the accurate analysis
and synthesis of an arbitrary waveform. But, out of necessity, only a finite
number of sinusoids are used in practice. The consequences of this limi-
tation will be considered in Chapter 11. For the time being, we assume
that, unless otherwise stated, the constituent frequency components of a
real periodic signal, with N (N even) samples in a cycle, are sinusoids with
frequency indices 0 , 1 , . . . , y only. Note that the sinusoid with zero fre-
quency index is a dc signal and the sinusoid that can be represented with
the frequency index y is a cosine waveform. The DFT is defined for any
length. But, due to the availability of fast algorithms with high regularity,
the lengths those are integral powers of two are most often used in prac-
tice. Therefore, we put emphasis on these lengths in the development of
the DFT theory and algorithms.
In Sec. 3.1, the DFT and the IDFT expressions are obtained through
a simple example. In Sec. 3.2, the DFT and the IDFT expressions are
formally derived and the symmetry property of the DFT kernel matrix is
analyzed. In Sec. 3.3, the closed-form expressions of the DFT of some
simple signals are derived. In Sec. 3.4, the direct computation of the DFT
is described. In Sec. 3.5, the advantages of sinusoidal representation of
signals are listed.
31
32 The Discrete Fourier Transform
(b)
(c)
(d)
4 • • • real
o imaginary
«. 1.73? • •
o
X 1
0 o o
-1 •. 9
(e)
Fig. 3.1 (a) A dc signal, (b) The sinusoid cos(f n - | ) . (c) The sinusoid COS(TTO).
(d) The sum of the signals shown in (a), (b), and (c). (e) The spectrum of the signal
shown in (d).
34 The Discrete Fourier Transform
x(n) = cos(nn)
x(n) = c o s ( | n - | )
x(n) = 1 + cos(f n - f ) + cos(7rn)
• • • •
x(n) = 1
(a) (b)
Fig. 3.2 The signal shown in Fig. 3.1(d) can be considered as the output of a single
complex signal generator, (a), or, equivalently, it can be considered as the output of
three simple signal generators connected in series, (b).
The contributions of the frequency components to the sample x{0) are each
coefficient multiplied by unity, because the zeroth sample values of the
complex sinusoids are unity. Therefore, the sum of these products must be
equal to x(0). For the waveforms shown in Fig. 3.1, we get
a ( l ) = i(0)e-^(»)W+i(l)e-^(1)W+x(2)e-^(J)(1)+i(3)e-^(3)(1)
Now, we can deduce a formula that can be used to compute any of the four
frequency coefficients.
3
1
X(k) = -Y,<n)e-^nk, fc = 0,l,2,3 (3.1)
n=0
The contributions of the data samples to the coefficient X(0) is each data
sample multiplied by unity, because the sample values of the conjugate of
the complex sinusoid with frequency index zero are unity. Therefore, the
36 The Discrete Fourier Transform
sum of these products must be equal to AX (0). For the waveform shown in
Fig. 3.1, we get
(2 + ^ ) ( 1 ) + (\)(1) + (2 - ^ ) ( 1 ) + ( - ! ) ( ! ) = 4(1)
ar(l)e-^(o)(iV¥(°)(i) = 4X(0)e^(o)(i)
a;(l)e-^(i)(i)e^(i)(i) = 4X(l)e^(i)W
^lJe-^eWVTPXi) = 4X(2)e^( 2 )( 1 )
i(l)e-'T(3)WeiT(3)W = 4Y(3)e*T(3)(i)
Substituting specific values for the example, we see that the equation is
satisfied.
Now, we can deduce a formula that can be used to compute any of the four
time-domain samples.
3
x(n) = ^X(ifc)e J 'T"*, n = 0,1,2,3 (3.2)
Jfe=0
becomes
3
X{k) = ^x{n)WZk, ft = 0,1,2,3 (3.3)
n=0
1 3
ar(n) = i 5 ] j r ( * ) W 7 n * , n = 0 , l , 2 , 3 (3.4)
k=o
These two equations, called, respectively, DFT and IDFT, are a transform
pair. What one does the other undoes. In the literature, one can find some
variations in the definitions and a particular variation must be consistently
used.
In general, we get
N_ 1
JV-l
71=0 n—0
71=0 m=0
771=0
7N-l
V-1 J VN-l
-l
= J2 X(TO) Yl e^ n ( m - f c ) = NX(k)
771=0 71=0
N-l
Y ej%-n(m-k) = f N for m = k
for m / k
7J=0
n k
X(k) = ^ x ( n ) e - ^
71=0
The constant factor ^ is usually suppressed and the iV-point DFT of the
sequence x(n) is defined as
N-l
X{k)=J2 ( ) Nk>
x n W
fc = 0,l,...,iV-l (3.6)
71=0
The DFT and the IDFT 39
(] 1 2 x{n) = cos(7rn)
ra)
x(n) = 1+ cos(f n - f ) + cos(7rn) 0 12 x(n) = cos(f n - f )
0 12 x(n) = 1
(a)
a:(n) = l ...•••• fc
a:(n)=cos(fn-f)...-^. summing
unit x(n) = 1 + cosff n — | )
x(n) = cos(7rn) + cos(7rn)
*
(b)
Fig. 3.3 (a) The operation of D F T is similar to that of a set of bandpass filters with
a narrow passband. (b) The operation of I D F T is similar to t h a t of a summing unit.
It should be noted that the output of the D F T are the coefficients of the corresponding
sinusoids. Similarly, the input to the IDFT operation is a set of coefficients.
The IDFT operation is summing over the responses at all frequency samples
for determining each time-domain sample. The DFT operation is summing
over the responses at all time samples for determining each frequency coef-
ficient. The separation of the various frequency components by the DFT is
similar to the operation of a set of bandpass filters with a narrow passband
as shown in Fig. 3.3(a), for the waveform in Fig. 3.1. The combining of the
various frequency components by the IDFT is similar to the operation of a
summing unit as shown in Fig. 3.3(b).
40 The Discrete Fourier Transform
It can be verified that Eqs. (3.6) and (3.7) form a transform pair. Sub-
stituting for X(k) in the ID FT definition, we get
fc=0 ro=0
m=0 Jfe=0
in Fig. 3.4. The sample values of sines and cosines used in DFT for evalu-
ating frequency coefficients are represented compactly by the complex ex-
ponential and the notation used is Wfik = cos(^nfc) — j sin(^nA;), called
the twiddle factor. The sine function of the twiddle factor is the negative
of that shown in Fig. 3.4 because of the conjugation of the basis function.
Note that, from the sample values of the fundamental shown in Fig. 3.4(b),
the sample values of the other waveforms in Fig. 3.4 can be easily deduced
as the waveforms are harmonically related.
The discrete complex exponential is a periodic function of nk with a pe-
riod N. Therefore, the twiddle factors are periodic, as shown in Fig. 3.5 for
N = 8. They are iVth roots of unity. The roots of unity are called twiddle
factors, because multiplying a number by a twiddle factor is changing the
phase of that number or rotating a vector without changing its magnitude.
Frequencies, called DFT bins, at which the spectral values are computed
are also shown in Fig. 3.5. For example, the point marked 0 corresponds
to dc, that is / = 0. The point marked | corresponds to the fundamental
frequency f = h cycles per sample. This is also the frequency increment of
the DFT spectrum.
The DFT and the IDFT 41
•cc^r^
* -1
I e—e—e——e—e—o o—e- \ o
H
1 p" "X^ ^ i ^ . ^ ^ "
0 2
*-
4
«_-^*^-_o
6
-®^^
n
(a) (b)
r^z^^ -.
^
K
1
o
1
p^?
* S
\/7^
**P7/7C\
\5G/ Vw
/
(c) (d)
,j f y / V W »;Ry?^*^
(e) (f)
~1 i ^ Q x C ^ >0*C-^
(g) (h)
Fig. 3.4 The cosine and sine components of the D F T basis functions, with N = 8 and
frequency indices varying from 0 to 4, are shown, respectively, in (a), (b), (c), (d), and
(e). Note that (f), (g), and (h) are, respectively, the same for cosine and the negative
for sine as that of (d), (c), and (b). This duplication is due t o the use of complex
exponentials in the D F T problem formulation. The sine function with frequency indices
0 and 4 have all sample values equal to zero.
2
8
8 8" "
o g o
8
Fig. 3.5 The periodicity of the twiddle factors, with N = 8, and the discrete frequencies
at which the spectral values are computed.
Since the odd-indexed sines and cosines complete an odd number of cycles,
they are odd half-wave symmetric, x(n) = —x{n ± T£). At n = %, we start
getting the first-half sample values with sign reversed since they start the
second half of a cycle.
X(0)1 ' W8° W8° W8° W8° Wi W8° W8° W8° ' • x(0)
X(l) ^8° Ws1 W£ Wi -Wg -Wg1 -Wi -W$ x(l)
X(2) w$ wi wi w§ w§ wi wi wi x{2)
X(3) wi wi wi wi -wi -wi -wi -wi x(3)
X(4) wi -wi wi -wi wi -wi wi -wi x{4)
X(5) wi -w^ wi -wi -wi w£ -wi wi x(5)
X(6) wi -wi wi -wi wi -wi wi -wi x(6)
X(7) . wi -wi wi -wi -wi wi -wi wi . *(7)
The twiddle factor matrix is called the kernel matrix of the DFT. Exploiting
the symmetry, as will be seen in Chapter 5, this equation can be written
more compactly. Note that, in the DFT definition, the time-domain index
starts from zero. It does not necessarily mean that the signal always start
from zeroth instant. Since periodicity is implied in computing the DFT,
we can always get the time-domain samples starting from the index zero.
Of course, we can also change the limits of the summation as orthogonality
of complex exponentials holds for any interval of N samples. A particular
case of interest is described below.
f-1
x(n) = ± J2 ^WW^k,n = -(j),-(^-l),...,~ -1(3.9)
The values of these forms of DFT and IDFT results in a better display with
the value with index zero in the middle and these forms are also convenient
to derive certain derivations. The spectrum of the waveform shown in
Fig. 3.1(d) in the usual format is X(0) = 4, X(l) = V3 - jl, X{2) = 4,
X(3) — y/3+jl. The same spectrum in center-zero format is X(—2) — 4.
X(-l) = y/3 + jl, X(0) = 4, X{1) = V3 - jl. Getting one format of
the spectrum or the signal from the other involves a circular shift by ^
positions (swapping of the positive and negative halves).
o
X{k) = ^ 1 = 1 and S(n) & 1
n=0
(The double-headed arrow indicates that the two quantities are a DFT
pair, that is the frequency-domain function is the DFT of the time-domain
function.) Since the impulse signal is zero except at n = 0, for all k, the
DFT coefficient is unity. All the frequency components exist with equal
amplitude and zero phase.
Example 3.1 Figures 3.6(a) and (b) show, respectively, the unit-impulse
signal and its spectrum, with N = 16. The representation of the impulse
signal, in terms of complex exponentials, is given by
15
1
k=0
DFT Representation of Some Signals 45
_ 1 • _ 1
c
0 5 10 15 0 5 10 15
n k
(a) (b)
c
'Sf
0 * 0 , f f f
0 5 10 15 0 5 10 15
n k
(c) (d)
Fig. 3.6 (a) The unit-impulse signal, with N = 16, and (b) its spectrum, (c) A dc
signal, with N = 16, and (d) its spectrum.
To find the real sinusoids that constitute the impulse signal, we add the
corresponding positive and negative frequency components. For example,
the sinusoid with frequency index one is obtained as
Example 3.2 Figures 3.7(a) and (b) show, respectively, the waveform
eJ if"" and its spectrum, with N = 16. This is a complex exponential with
frequency index one and amplitude one and, therefore, its spectrum consists
of an impulse at frequency index k — 1 with amplitude sixteen.
Figures 3.7(c) and (d) show, respectively, the waveform 3 e J ( i t 1 4 n + e ) =
3 e if eii?-i4n a n d its spectrum. This is a complex exponential with frequency
index 14 and complex amplitude 3 e J t . Therefore, its spectrum consists
of an impulse at frequency index A; = 14 with amplitude (3)(16)(cos | +
j s i n | ) = 24(V3 + j l ) .
Figures 3.7(e) and (f) show, respectively, the waveform e _ ^ i t 1 4 " + ^ ^ =
e te^ie" 1 4 ™ and its spectrum. This is a complex exponential with fre-
_J
16 • real
o imaginary
10 15
(a) (b)
3 41.569'
24
I ° o o
o
-3 °•» g o •»
10 15 10 15
(c) (d)
o -13.856
10 15
(e) (0
Fig. 3.7 (a) The complex exponential e'TB"™ and (b) its spectrum, (c) The com-
plex exponential 3e J ''i6' 1 4 n +6') and (d) its spectrum, (e) The complex exponential
e -j'Cif-i4n+f) a n d ^ its spectrum.
2TT N
sin(—mn) ^ — (-jS(k - m) + jd{k - (N - m)))
Example 3.3 Figures 3.8(a) and (b) show, respectively, the cosine wave-
form cos(ffn) and its spectrum, with N = 16. The magnitude and the
phase shift of the frequency coefficient (8) at frequency index A; = 1 are 8
and 0 degrees, respectively. A sinusoid with these characteristics is a cosine
wave with amplitude one. Remember that the spectrum of a cosine wave
is pure real, that of a sine wave is pure imaginary, and that of a sinusoid
48 The Discrete Fourier Transform
1
• real
0 o imaginary
-1
10 15 10 15
(a) (b)
X 0
-8L
10 15
(c) (d)
1 . • •6.928
0
X
-1
10 15 10 15
(e) (f)
Fig. 3.8 (a) The sinusoid c o s ( ^ n ) and (b) its spectrum, (c) The sinusoid s i n ( ^ 2 n )
and (d) its spectrum, (e) The sinusoid c o s ( | | 4 4 n 4- | ) and (f) its spectrum.
other than a cosine or sine consists of both real and imaginary parts.
Figures 3.8(c) and (d) show, respectively, the sine waveform sin(f|-2n)
and its spectrum. The magnitude and the phase shift of the frequency co-
efficient (-J8) at frequency index k — 2 are 8 and - f radians, respectively.
A sinusoid with these characteristics is a sine wave with amplitude one.
Figures 3.8(e) and (f) show, respectively, the sinusoid cos(^f 14n + f )
and its spectrum. The magnitude and the phase of the frequency coefficient
(6.9282 - j4) at frequency index k = 2 are 8 and - f radians, respectively.
This is a sinusoid with amplitude one and phase — f radians. There are
two points to observe: (i) a real sinusoid with frequency index in the second
half of the frequency range cannot be distinguished from a sinusoid with a
corresponding frequency in the first half, as mentioned in Section 2.2, and
(ii) the phase shift is negated. The sinusoid yields a spectrum that is the
same as that of cos(f|2n — | ) . I
DFT Representation of Some Signals 49
0.9619
0.8536
0.6913
0.5
0.3087
0.1464
0.0381
10 15 10 15
(a) (b)
Fig. 3.9 (a) The Hann function, 0.5 - 0.5cos(^n), and (b) its spectrum.
2n
x(n) = 0 . 5 - 0 . 5 c o s ( — n ) , n = 0 , 1 , . . .,N - 1
Example 3.4 Figures 3.9(a) and (b) show, respectively, the waveform
and its spectrum, with N = 16. A value of 8 at A; = 0 indicates a dc signal
with amplitude 0.5. A value of -4 at A; = 1 and A; = 15 indicates a sinusoid
with frequency index one, amplitude 0.5, and phase 180 degrees, that is
-0.5cos(ffn). I
Rectangular waveform
_f 1 forn = 0 , l , . . . , L - l
x(n)
~ { 0 for n = L, L + 1 , . . . , N - 1
L-\
-J¥nk = l-e~^Lk = _^(-li fc sin(ffcf)
X(k) = £ \
n=0
o J N K
sin(^|)
sin(ffc)
50 The Discrete Fourier Transform
1
*? =? 1
"sr
ok . . •••• g1 0
0 10 20 30 5 10 15
n k
(a) (b)
1
oL , ««
0 10 20 30 5 10 15
n k
(c) (d)
Fig. 3.10 (a) The rectangular function with four zeros and N = 32 and (b) its spectrum.
(c) The rectangular function with eight zeros and (d) its spectrum.
3.4 Direct C o m p u t a t i o n of t h e D F T
1 3
x(n) = -Y^X(k)W^k, n = 0,l,2,3
fc=0
x(0) = J ( 1 0 x l + (l + j l ) x l + ( - 4 ) x l + ( l - j l ) x 1) = 2
x(l) = i ( 1 0 x l + (l + j l ) x j + ( - 4 ) x ( - l ) + ( l - j l ) x ( - j ) ) = 3
x{2) = i ( i 0 x l + (l + j l ) x ( - l ) + ( - 4 ) x l + ( l - j l ) x ( - l ) ) = l
ar(3) = i ( 1 0 x l + (l + j l ) x ( - j ) + ( - 4 ) x ( - l ) + ( l - j l ) x j ) = 4 l
M3tartJ f Start *)
I
f Stop ") tfc(i) — cos(arg)
tfs(i) = sin(arg)
3.11(a) arg = arg + inc
i =i+l
(start) 3.11(b)
3.11(c) 3.11(d)
(Start)
k =0
• N no/ \
Return)* (k < JV>
Iyes
n = l,nk = k,
tr = xr(0),ti = xi(Q)
XR(k) = tr,XI(k) = ti
k=k+ l
ind — nk mod N
c = tfc(ind), s = tfs(ind)
tr = tr + xr(n) * c + xi(n) * s
ti = ti + xi(n) * c — xr(n) * s
nk = nk + k,n = n + 1
i
3.11(e)
Fig. 3.11 (a) The main module for direct implementation of the D F T . (b) The twiddle
factor module, (c) The input module, (d) The output module, (e) The D F T module.
cosines and sines, respectively. The setting up of the twiddle factor arrays
can be made faster by using identities such as cos(^(iV — n)) = c o s ( ^ n )
and s i n ( ^ ( i V - 7 j ) ) = - s i n ( ^ n ) . Note that this module can be eliminated
by computing the twiddle factors each time they are required. However, it
is costly in terms of run-time.
The next module, shown in Fig. 3.11(c), reads the real and imaginary
parts of the complex input data, respectively, into the arrays xr and xi,
each of size N. It is assumed that the real parts of the input data are stored
before the imaginary parts in the input file. If the data is real, initialize
the values of the array xi to zero and read the data into the array xr. This
module is called in-put.
The next module, shown in Fig. 3.11(e), computes the DFT coefficients.
This module is called dir-dft. The computation is carried out in two nested
54 The Discrete Fourier Transform
loops, the outer loop controlling the frequency index and the inner loop
controlling the access of the data values. In each iteration of the outer
loop, one coefficient is computed. The real and imaginary parts of the
coefficients are stored, respectively, in arrays XR and XI, each of size N.
The access of correct twiddle factor values is carried out using the mod
function. Inside the inner loop, each coefficient is computed according to
the DFT definition. The next module, shown in Fig. 3.11(d), prints the real
and imaginary parts of the coefficients, respectively, from the arrays XR
and XI, one coefficient in each iteration. This module is called out-put.
2.866 7 • •
| 6.64 • •
•£ 1.134*1 •
« 6.36 •
0.5
6.16 *
. R§ . *
6.04
-0.5
0.5 1 1.5
x(n)
(a) (b)
Fig. 3.12 (a) An arbitrary waveform and its dc component with amplitude one. (b) The
least squares error in approximating the waveform with only its dc component, the
amplitude varying from 0.5 to 1.5.
process signals more efficient compared with alternate methods. The IDFT
can be computed by a DFT algorithm with trivial modifications.
(3) The accuracy of representation: Let
N N N
x{n) and xa{n), n = -(—), - ( — - 1),..., — - 1
X n
°( ) = jt E *«(*W**, n = - ( y ) , - ( y - l ) , . . . , y - l
In order to prove that the DFT provides coefficients with optimum val-
ues with respect to the least squares error criterion, we express the error
equation in a form so that the result is evident. Substituting for xa(n), we
get
SS-—1 M-l
M-l
Adding and subtracting the term ^ YJ^III M-I ) X(k)X(-k) and using the
M-l M-l
JV _ j M-l
= E * » - ^ E *(*)*(-*)
M-l
-1 J2 X(k)X(-k)
Using the fact that the two expressions forming the product in the last two
terms are complex conjugates, we get
<¥._! M-l M-l
2
error = £ x (n)+± £ \(Xa(k)-X(k))f-± £ \X(k)f
The error is minimum only when Xa(k) = X(k), since x{n) and X(fc) are
fixed. This implies that an optimal representation of a signal is provided
by the DFT coefficients with respect to the least squares error criterion.
When constrained to use only M < N coefficients to represent a signal,
the minimum error is obtained by using the M largest coefficients (not
necessarily the first M coefficients).
(4) The finality of coefficients: Because of the orthogonality property,
the coefficient value of a specific frequency component is independent of the
number of coefficients used to approximate a signal. This property allows
the computation of additional coefficients to improve the approximation of
a signal without the need to compute already found coefficients again.
(5) Representation of signal power: The signal power can be expressed
in terms of the frequency coefficients.
58 The Discrete Fourier Transform
3.6 Summary
References
Exercises
3.4 Given the coefficients with N = 4, find the individual sinusoids. Note
that the coefficients are as defined by Eq. (3.3).
3.4.1 X(0) = - 2 , X ( 1 ) = 2v/2(l - jl),X(2) = 1,X(3) = 2^2(1 + j l )
*3.4.2 X(0) = 1,X(1) = 3(V3 + j l ) , X ( 2 ) = - 1 , X ( 3 ) = 3(V5 - j l )
3.4.3 X(0) = 3,X(1) = | ( 1 + jy/3),X{2) = - 2 , X ( 3 ) = | ( 1 - jy/i)
3.5 Write the DFT equation in matrix form with N = 8 showing the
numerical values of the twiddle factors.
3.6 Prove that the sum of the cosines, the frequency components of an
impulse signal, yields the impulse signal.
3.16 Compute the DFT. Verify the transform pair by computing the IDFT
of the transform to get back x(n).
3.16.1 x(n) = { 3 , 2 , 1 , - 4 }
3.16.2 x{n) = {2 + j3,10 + j 2 , - 4 + jl, 6 - j 4 }
Programming Exercises
In this chapter, we study the properties of the DFT. The existence of advan-
tageous properties is the major reason for the widespread use of the DFT.
In applications of the DFT or in deriving DFT algorithms, the properties
are repeatedly used.
4.1 Linearity
61
62 Properties of the DFT
4.2 Periodicity
x(2) = ar(10) = •
X{2) = X{10) =
•
x(3) = x ( l l ) = • • • x(l) = x(9) = •••
t
X(3) = X(11) = --- ' * X ( 1 ) = X(9) = -
x(6) =x(U) = •
X(6) = X(U) =
Fig. 4.1 The periodicity of the time- and frequency-domain sequences x(n) and X(k)
with a period of 8.
x(l)
X(2)Wi
•
x{2) x(0)
X(3)W$ *
ar(4) 1(6)
X(5)W85 #
*X(7)W 8 7
•
X{G)W$
Fig. 4.2 The delayed time-domain sequence x(n - 1) and its DFT, X{k)w£.
64 Properties of the DFT
sequence x{n + m) can be obtained by rotating the circle in Fig. 4.1 in the
clockwise direction by m positions. If there are N values in a sequence,
then only N — 1 unique shifts are possible. x(n — m) is the signal delayed
by m sample intervals and x(n + m) is the signal advanced by m sample
intervals. Substituting n — m for n in the IDFT definition, we get
z(n) = { 0 , 1 , 1 , 0 } ^ X ( f c ) = { 2 , - 1 - j , 0 , - 1 + j }
Now,
Example 4.4 Figure 4.3(a) shows one cycle of the cosine waveform
cos(^-n). Its frequency coefficients 8 and 8 are shown in Fig. 4.3(b). Fig-
ure 4.3(c) shows the signal delayed by one sample, cos(f|(n — 1)), and
its DFT coefficients, shown in Fig. 4.3(d), are related to the coefficients
of the original signal by the constants, respectively, Wl& and W^ (a de-
lay of one sample interval and, k = 1 and k = 15). These constants
represent phase delays of - 1 ^ = -22.5 degrees and - 1 5 ^ = -337.5
degrees, respectively. The DFT coefficients, shown in Fig. 4.3(d), of the
shifted signal are 8 ^ = 8cos(-22.5) + j8sin(-22.5) = 7.391 - j'3.0615
and 8W$ = 8cos(-337.5) + j8sin(-337.5) = 7.391 + J3.0615.
Circular Shift of a Time Sequence 65
• real .
o imaginary
S °
10 15 5 10 15
*;
(a) (b)
1 7.391 • •
£ ° I 0
o
-1 -3.0615 0
0 5 10 15 0 5 10 15
n k
(c) (d)
8 o
1
r\ v 4A
/ \
/*\
* \
* ° I ^\ / \ \7 \ l 1°
-1 V \J -8 0
0 5 10 15 0 5 10 15
n k
(e) (f)
1 f\ A n 5.6569 • •
S ° \\
1
I \
1 \J \\J/
t\ /
1 0
-1 ^ \S -5.6569 o
0 5 10 15 0 5 10 15
n k
(g) (h)
Fig. 4.3 (a) The cosine waveform cos(^|-n) and (b) its DFT. (c) The delayed cosine
waveform cos(|^(n - 1)) and (d) its DFT. (e) The sine waveform sin(||3n) and (f) its
DFT. (g) The sine waveform, advanced by 2 samples, sin(||-3(n + 2)) and (h) its DFT.
Table 4.1 Computing the 4-point DFTs of overlapping segments of a sequence, x(n).
x(n) 2+ j \ 1+J4 4 + ^3 3+j5 5+j6 6 + J4 4 + J3
X(k) lO + j'13 - 3 + j O 2-j5 -1-J4
X(k) 13 + jl8 - 5 + j O - 5 + JO 1 - J 2
X(k) I 8 + 7 I 8 0+jO 0+jO - 2 - j6
X(k) 18 + j l 8 0+jO 0 + jO - 6 + j 2
W±mnx{n)&X(k±m)
Circular Shift of a Spectrum 67
X(l)
x(2)Ws~2
•
X(2) X(0)
x(3)Wi3 *
X(4) X(6)
x(5)W8~5 * 'x(7)W8~7
X(5)
x(6)Wf6
Fig. 4.4 The delayed DFT sequence X(k — 1) and the corresponding time-domain se-
quence, x(ra)Vl^~n.
Figure 4.4 shows the spectrum shifted by one position in the counterclock-
wise direction and the corresponding time-domain sequence. Substituting
k — m for k in the DFT definition, we get
JV-l N-l
1
^ ( f c - m ) ^ ^ ^ ) ^ - " ^ ^ ^ ^ " ^ ) ) ^ , k= 0,l,...,N-l
n=0 n=0
• real .
o imaginary
Ow o ' L2
10 15 0 10 15
(a) (b)
16
0HL2J Li
0 10 15
(c) (d)
8 •
X
0 bto
10 15
(f)
1
0 X
-1 0 w»*»»»»»o»o»»»»«
5 10 15 -8-6-4-2 0 2 4 6
n
(g) (h)
Fig. 4.5 (a) The cosine waveform cos(||-n) and (b) its DFT. (c) The complex expo-
nential e*'ff"' and (d) its DFT. (e) The product of the waveforms shown in (a) and
(c), and (f) its DFT, which is a shifted version of that shown in (b). (g) The waveform
shown in (e) multiplied by ( — 1)" and (h) its DFT, which is the same as that shown in
(f) but approximately centered.
Time-Reversal Property 69
shown, respectively, in Figs. 4.5(e) and (f). We can specify the spectrum
from looking at Fig. 4.5(e). The waveform corresponding to the real part
consists of a dc and a cosine wave with frequency index two, each with an
amplitude of 0.5. The imaginary part is a sine waveform with frequency
index two and amplitude 0.5. These waveforms produce a spectral value of
8 at frequency indices 0 and two, which is a shifted version of the spectrum
shown in Fig. 4.5(b).
A particular case, which is often used in practice, is the multiplication
N n
of the input signal with W^ = ( - 1 ) " , with N even. Figure 4.5(g) shows
the signal that is the product of the signal in Fig. 4.5(e) and (-1)"- Fig-
ure 4.5(h) shows its spectrum which is the same as that of Fig. 4.5(f) with
a shift of ~ = 8 sample intervals. Since we are multiplying the given signal
by a complex sinusoid with frequency index ^» the spectrum is shifted by
half the number of sample intervals ( ^ ) so that the origin is at about the
center (center-zero format). Note that neither the magnitude nor the phase
of the DFT coefficients changes. Only the position of the coefficients on
the frequency scale changes. I
The sum of the products a;(n)W _nfc is, obviously, equal to the sum of the
products x(N - n)Wnk. That is,
JV-l
X{N-h)=^x{N- n)W£k
n=0
70 Properties of the DFT
x(6)
X(6)
•
x(5) x(7)
X(5) * *X(7)
x(3) x(l)
X{3) * *X(1)
x(2)
X(2)
Fig. 4.6 The time-reversal, x(8 - n), of the sequence x(n) and its DFT, X(8 - k).
Now,
x(4-n) = {2-jl,4-j2,2-j2,2 + j 3 } ^
X(4-fc) = { 1 0 - j 2 , - 5 - j l , - 2 - j 4 , 5 + j3} I
x{n) = l(DFT(X(AT-fc)))
x(n) = i ( D F T ( D F T ( x ( n ) ) ) ) = i ( D F T ( X ( * ) ) )
Symmetry Properties 71
This property brings out the almost duality of the time- and frequency-
domain sequences. If x(n) •& X(fc),then jjX(N=fn) <S> x(N±k). If x(n)
is even, then ^X{n) & x(k).
Real signal
The definition of DFT can be rewritten expressing x{n), X(k), and W#*
in terms of their real and imaginary parts as
2n . . . 27T
Xr(k) + jXi(k) = 2 J (%r(n) + jxi(n))(cos jrnk — j sin -rj-nk) (4.1)
n=0
If x(n) is real, its imaginary parts are zero. Then, Eq. (4.1) reduces to
x(n) r e a l ^ X ( f c ) hermitian
Example 4.8
Figures 4.7(a) and (b) show, respectively, an arbitrary real signal and its
hermitian-symmetric spectrum. I
This symmetry implies that the DFT coefficients X ( 0 ) , X ( y ) , and X(k),
k = 1,2,..., y — 1 are sufficient to uniquely specify the spectrum of a
real signal. Since the coefficients X(0) and X ( y ) are real, for even N,
and the rest of the required coefficients are generally complex, a total of N
Symmetry Properties 73
• • peal
4 o imaginary
5 0
* o k> •
10 15
(b)
8 • •
• •
5 4 •
•
0
10 15
(d)
*°
8 . o
10 15
(e) (f)
4
I° 0 o
10 15 10 15
(g) (h)
0* • •••o»o»»
S °
10 15 10 15
(i) G)
Fig. 4.7 (a) A real signal and (b) its hermitian-symmetric spectrum, (c) An even-
symmetric real signal and (d) its real and even-symmetric spectrum, (e) An odd-
symmetric real signal and (f) its imaginary and odd-symmetric spectrum, (g) A real
signal with even half-wave symmetry and (h) its spectrum with even-indexed harmonics
only, (i) A real signal with odd half-wave symmetry and (j) its spectrum with odd-
indexed harmonics only.
74 Properties of the DFT
Example 4.10
Figures 4.7(e) and (f) show, respectively, an odd-symmetric real signal and
its imaginary and odd-symmetric spectrum. I
Symmetry Properties 75
x(n) even half-wave symmetric •& X(k) even-indexed only and hermitian
Example 4.11
Figures 4.7(g) and (h) show, respectively, an even half-wave symmetric real
signal and its hermitian-symmetric spectrum consisting of even-indexed
harmonics only. I
x(n) odd half-wave symmetric <$ X(k) odd-indexed only and hermitian
Example 4.12
Figures 4.7(i) and (j) show, respectively, an odd half-wave symmetric real
signal and its hermitian-symmetric spectrum consisting of odd-indexed har-
monics only. I
Imaginary signal
This case is similar to that of the real-valued signal except that the data
values are multiplied by the complex constant j . Therefore,
Example 4.13
Figures 4.8(a) and (b) show, respectively, an imaginary signal and its anti-
hermitian spectrum. I
Example 4.14
Figures 4.8(c) and (d) show, respectively, an imaginary signal with even
symmetry and its imaginary and even-symmetric spectrum. I
E x a m p l e 4.15
Figures 4.8(e) and (f) show, respectively, an imaginary signal with odd
symmetry and its real and odd-symmetric spectrum. I
Example 4.16
•real
o^X^^ 3? 4 o imaginary
-4
10 15 5 10 15
k
(a) (b)
8
5 °
$< o •
-4 ,
5 10 15
k
(d)
8f
10 15 5 10 15
k
(0
4
£ 0Oh. •
-4(<
5 10 15
k
(h)
0
4 • : o
0
-4 o o
. •
5 10 15
k
(i) G)
Fig. 4.8 (a) An imaginary signal and (b) its antihermitian-symmetric spectrum, (c) An
even-symmetric imaginary signal and (d) its imaginary and even-symmetric spectrum.
(e) An odd-symmetric imaginary signal and (f) its real and odd-symmetric spectrum.
(g) An imaginary signal with even half-wave symmetry and (h) its spectrum with even-
indexed harmonics only, (i) An imaginary signal with odd half-wave symmetry and (j)
its spectrum with odd-indexed harmonics only.
78 Properties of the DFT
Figures 4.8(g) and (h) show, respectively, an imaginary signal with even
half-wave symmetry and its antihermitian spectrum consisting of even-
indexed harmonics only. I
Example 4.17
Figures 4.8(i) and (j) show, respectively, an imaginary signal with odd half-
wave symmetry and its antihermitian spectrum consisting of odd-indexed
harmonics only. I
Complex signal
Example 4.18
Figures 4.9(a) and (b) show, respectively, an arbitrary complex signal with
no symmetry and its spectrum, which also has no symmetry. I
Example 4.19
Figures 4.9(c) and (d) show, respectively, a complex signal with even sym-
metry and its even-symmetric spectrum. I
Symmetry Properties 79
•
^yw J*
8 o
_^ 1
^ •
"Br o V ^ / J? 0 o •
\& ( o • real
-1 ^ % • o imaqinarv
0 5 10 15 0 5 10 15
k
(a) (b)
V^' ^>
2
^/Va
a f*
8 o a
•
O O • o o •
I o vlj \ ^ A./ /n 1
1 o o •
V V^\^y V
0 5 10 15
-8
0
a
5
o o
10
•
15
n k
(c) (d)
• o
4 • o
a o
"*r o' , ^ l .A 1° • • 0 a O • • • • • o • O a
-1
/ > / \
'\7
0
^
5
r \A 10 15
-4
0
0
o
5 10
•
•
o a
15
n k
(0
1.5 8 •
W)H!)dt
•
o
5 0.5 1 o
H ^ •
o •
-0.5 y v uy>Af W -8
0 5 10 15 0 5 10 15
n k
(g) (h)
8
•
W
"? n a/30? / \j£^m\ A£ 5"
• • •
o
^r
ty $
J'V V w\j W $< 0
-8
o
•
10 15 10 15
0) (J)
Fig. 4.9 (a) A complex signal and (b) its spectrum, (c) An even-symmetric complex
signal and (d) its even-symmetric spectrum, (e) An odd-symmetric complex signal and
(f) its odd-symmetric spectrum, (g) A complex signal with even half-wave symmetry
and (h) its spectrum with even-indexed harmonics only, (i) A complex signal with odd
half-wave symmetry and (j) its spectrum with odd-indexed harmonics only.
80 Properties of the DFT
Example 4.20
Figures 4.9(e) and (f) show, respectively, a complex signal with odd sym-
metry and its odd-symmetric spectrum. I
Example 4.21
Figures 4.9(g) and (h) show, respectively, a complex signal with even half-
wave symmetry and its spectrum consisting of even-indexed harmonics only.
I
Example 4.22
Figures 4.9(i) and (j) show, respectively, a complex signal with odd half-
wave symmetry and its spectrum consisting of odd-indexed harmonics only.l
• real .
Si
X OP o ( o
imaginary
0 5 10 15 0 5 10 15
n
(a) (b)
-. 16 o
* 0
_ ^ •0
0 10 20 30 0 10 20 30
« k
(c) (d)
Fig. 4.10 (a) A real signal and (b) its spectrum with several nonzero coefficients, (c) The
extension of the signal shown in (a), and (d) its spectrum with only a pair of nonzero
coefficients.
of the signal can be made in several ways and the DFT representation of
all of them will represent the signal correctly in the defined range.
Given the freedom to arbitrarily extend the signal, it is desirable to ex-
tend so that the signal is adequately represented by as few coefncients as
possible. The basic consideration is to extend the signal so that the exten-
sion does not create any discontinuities. The more smoother the extension
the smaller is the set of coefficients required to represent the signal.
Example 4.23 Figures 4.10 (a) and (b) show, respectively, half period
of a sine waveform and its spectrum. In this representation, the half period
waveform is considered as the fundamental period. If we extend the signal
as shown in Fig. 4.10(c) and compute the DFT, we get the spectrum shown
in Fig. 4.10(d). The difference between the spectra is that the first spectrum
has several nonzero frequency coefficients whereas the second spectrum has
only two and is, obviously, a more efficient representation. I
X*(N-k)=J2x*(n)W%k, k= 0,l,...N-l
71=0
Example 4.24
Note that for a real signal x*(n) = x{n) and X{k) = X*(N — k).
Figures 4.11(a) and (b) show, respectively, a signal and its spectrum.
Figures 4.11(c) and (d) show, respectively, the signal x*(16 - n) and its
spectrum which is the same as that shown in Fig. 4.11(b) with the spectral
values conjugated. Figures 4.11(e) and (f) show, respectively, the signal
x*(n) and its spectrum which is the same as that shown in Fig. 4.11(b)
with the spectral values conjugated and frequency-reversed. I
As the DFT of a data set and the IDFT of a transform are periodic quan-
tities, the convolution operation carried out using the transform as a tool
results in a periodic output sequence. This convolution is referred to as
circular, cyclic, or periodic convolution. The linear convolution, which is
of interest in the analysis of LTI systems, can be simulated by the circular
convolution. The method to do that is discussed in Chapter 14. In this
section, we just present the theorems.
Circular Convolution and Correlation 83
16
n * _ * • A Q O 8
a • real .
S u B'5 " " °» o imaginary
»«»»»•" • t t t • •
5 10 15 0 5 10 15
n k
(a) (b)
16
T 2 5 8
s "'»•;'" *~ Qp • • • • • • o • • • •
0 T*o
-8
-2C
5 10 15 5 10 15
n k
(c) (d)
4 16
? 8 •
1 0 ) • • • • • • O B • • • • •
X 0 w S'S' 9
'" ' 5°a i -8 O
-2 -_ . . a
5 10 15 5 10 15
n k
(•) (0
Fig. 4.11 (a) A complex signal x(n) and (b) its spectrum, X(k). (c) The signal
i*(16 —n) and (d) its spectrum, X"(k). (e) The signal x*(n) and (d) its spectrum,
X*(16-ifc).
JV-l JV-1
y(ri) = 22 x(m)h(n — m)
m=0
where Y(k) is the convolution of the sequences X(k) and H(k) and k =
0,l,...,iV-l.
Example 4.26 The product of x(n) and h(n) given in Example 4.25 is
{2,12,0,0}. The DFT of this sequence is { 1 4 , 2 - j 12, - 1 0 , 2 +jl2}= ^ . 1
Sum and Difference of Sequences 85
where x*(m) is the complex conjugate of x(m). Note that, for real sig-
nals, x*(m) = x(m). This equation can also be written, in terms of the
convolution operation, as
JV-l
yxx(n)= IDFTof(|X(fc)| 2 )
Since A; = 0, the values of all the Wfik terms in the DFT definition is just
one and the value of X(0) is the sum of the input sequence x(n).
N-l
X(0) = £ x(n)
71=0
86 Properties of the DFT
With an even N and k = y-, the input sequence values are alternately
multiplied by 1 and - 1 . Therefore,
N-2 JV-1
X
*(°) = Jf E W
With an even N,
^y 2 TV —1
Example 4.30 For the x(n) and X(k) given in the earlier example,
a:(0) = i ( 1 0 - l + j 3 + 0 - l - j 3 ) = ^= 2
3
a:(2) = | ( 1 0 + l - j 3 + 0 + l + i 3 ) = j = '
These values can be used as a preliminary check of the output of an algo-
rithm to compute the DFT or the IDFT.
, . _ f x(n) for n = 0 , l , . . . , i V - l
VW - | Q otherwise
Padding the Data with Zeros 87
Y(mk)=X{k), fc = 0,l,...,iV
y(n) = {2,1,4,3,0,0,0,0}^
Y{k) = {10,*,-2 + j 2 , * , 2 , * , - 2 - j 2 , * }
2 5f
~W
£
?K
0
n X:
^ ~
£ °
-2 • real
o imaginary
2 4 6
n
(a) (b)
5
8" oS «.
£ ° Sf 0
8
o ° o
-5
5 10 15 5 10 15
n
(c) (d)
-4 o
2 4 6
k
(e)
5 10 15
k
(9) (h)
Fig. 4.12 (a) A real signal and (b) its spectrum, (c) The signal shown in (a) with zero
padding at the end and (d) its spectrum with even-indexed values same as in (b). (e) A
spectrum and (f) the corresponding time-domain signal, (g) The spectrum shown in
(e) with zero padding and (h) the corresponding time-domain signal with even-indexed
values one-half of those shown in (f).
Padding the Data with Zeros 89
, . _ . x{n) for n = 0 , 1 , . . . , N
{?
' n otherwise
y(n) = {2,0,1,0,3,0,4,0}^
Y{k) = {10,-l+j3,0,-l-A10,-l+A0,-l-j3} I
Figures 4.13(a) and (b) show, respectively, the signal in Fig. 4.12(a) padded
up with eight zeros placed in between the samples and the corresponding
spectrum. The spectrum shown in Fig. 4.12(b) repeats itself, in Fig. 4.13(b).
A similar effect is observed in padding with zeros in the frequency-
domain. Figures 4.13(c) and (d) show, respectively, the spectrum in
Fig. 4.12(e) padded up with eight zeros placed in between the samples and
90 Properties of the DFT
2 • 5
• • o . . o
S o • • • •
H • sr ° • • • • • • • •
-2 • o
o° 0°
-5 o
0 5 10 15 0 5 10 15
n k
(a) (b)
o 0.5
4
/ \ / \
3~ | 0 / \ / \
X \
o
/ \ /
-4
3 5 10 15
-0.5
3
V
5
/ 10
\S15
k n
(c) (d)
Fig. 4.13 (a) The signal shown in Fig. 4.12(a) with zero padding in between the samples
and (b) its spectrum which is the same as that shown in Fig. 4.12(b), but repeats, (c) The
spectrum shown in Fig. 4.12(e) with zero padding in between the samples and (d) the
corresponding time-domain signal which is the same as that shown in Fig. 4.12(f) with
one-half amplitude, but repeats.
the corresponding time-domain signal. The signal shown in Fig. 4.12(f) re-
peats itself, in Fig. 4.13(d) with one-half amplitude. Note that the indices
of the frequency coefficients in Fig. 4.13(c) are 2 and 14 whereas they are
1 and 7 in Fig. 4.12(e). With the same frequency coefficients but with a
frequency index of 2 and double the number of samples, we get two cycles
of the same waveform with one-half amplitude as shown in Fig. 4.13(d).
4.11 Parseval's T h e o r e m
This theorem implies that the sums of the squared magnitudes of the input
and DFT sequences are related by the constant N, the number of samples.
That is the signal power can also be computed from the DFT coefficients
of the sequence. Let x(n) & X(k), n, k = 0 , 1 , . . . , N — 1. Then,
JV-l iV-l
2
E wi = i fc=0
71=0
E i*(*)i
Summary 91
5>(n)| 2 =5>(n)z>)
n=0 n=0
= ^EE^*HE^n(M
fc=0 m=0 n=0
If fe = m, this expression becomes
The sum of the squared magnitude of the data sequence is 30 and that of
the DFT coefficients divided by 4 is also 30. I
The generalized form of this theorem applies for two different signals x(n)
and y(n) as given by
JV-l 1 JV-l
n=0 fc=0
4.12 Summary
Reference
(1) Brigham, E. O. (1988) The Fast Fourier Transform and Its Appli-
cations, Prentice-Hall, New Jersey.
Exercises
4.1 Verify the linearity property ax{n) + by(n) & aX(k) + bY(k).
4.1.1 x(n) = {2+j3,l-j4,2-j2,l+jl},y(n) = {2-j3,l-jl,2+j4,l-j2},
a = j3, and 6 = 2.
4.1.2 X(k) = {l-j4,2+j3,l-jl,2-j2}, Y(k) = {3 - j l , 4 + jl,2 +
j2,1 + j3}, a = -j3, and b = 4.
4.2 Verify the periodicity of the DFT and the IDFT.
* 4.2.1 Compute the DFT of x(n) = {1 - j 4 , 2 + j3,1 - jl, 2 + j 4 } . Find
X(23), X ( - 4 7 ) .
4.2.2 Compute the IDFT of X(k) = {2 - jA, 2 + j2,1 + j5,1 - jl}. Find
3(27), x ( - 3 5 ) .
4.3 Verify the time-domain shift property.
4.3.1 Find the DFT of x(n) = {2+jl, 1+J2, l-jl,4-j2}. Compute the
DFT of x(n + 3) using the shift property.
* 4 . 3 . 2 T h f i D F T o f x ( n - 2 ) i s { 2 + j 3 , l - i l , 3 - j l , 2 + j 2 } . Findx(n + 1)
using the shift property.
4.3.3 Compute the DFT of Ae~^e^n. Using the shift property, compute
theDFTof4e^'fe^("-2).
4.3.4 Compute the DFT of — 2sin(|7i). Using the shift property, compute
the DFT of - 2 sin(f (n + 1)).
4.3.5 Let x(n) = {2,1,3,5,7,2,3,2,1,2,3}. Compute 4-point DFT of the
overlapping segments of x{n) with an overlap of 3 data values.
4.4 Verify the frequency-domain shift property.
4.4.1 Let x{n) = {1 - jA, 2 - j2,1 - j3,2 + j5}. Find X(k). What is the
input that would generate the spectrum, (a) X(k + 1). (b) X(k — 1). (c)
X(k-2).
4.4.2 Find the DFT of x(n) = {1 - jl, 2 + jl, 1 - j3,2 + j4}.
Deduce the spectrum of: (a) x(n) cos(^ L n) and (b) x(n)sm(^n).
4.5 Compute the DFT of x(n) = {1 - jl, 2 - j2,1 + j3,2 - jl}. Deduce
the DFT of x (4 -n).
Exercises 93
4.6 Find the symmetry of x(n). Compute the DFT and verify that the
transform exhibits the anticipated property.
4.6.1 x(n) = { 2 , - 4 , 2 , - 4 } .
4.6.2 s(n) = { 0 , - 3 , 0 , 3 } .
* 4.6.3 x{n) = { - 1 , 2 , 1 , - 2 } .
4.6.4z(n) = { 2 , 3 , l , 4 } .
4.6.5z(n) = { l , 2 , 3 , 2 } .
4.7 Find the symmetry of x(n). Compute the DFT and verify that the
transform exhibits the anticipated property.
4.7.1 x(n) = {-j4,-j2,j4,j2}.
* 4.7.2 x(n) = { 0 , - j 4 , 0 , j 4 } .
4.7.3 x(n) = {J2,j3,j2, j 3 } .
4.7.4 z(n) = { j l , - j 2 , - j 3 , j 4 } .
4.7.5 x(n) = { - j 2 , j l , - j 4 , j l } .
4.8 Find the symmetry of x(n). Compute the DFT and verify that the
transform exhibits the anticipated property.
* 4.8.1 x(n) = {0,1 - j2,0, - 1 + j 2 } .
4.8.2 x(n) = {2 + j 3 , 1 - j l , - 2 - j 3 , - 1 + j l } .
4.8.3 x(n) = {1 + j 3 , 2 + j2,4 - j 3 , 2 - j l } .
4.8.4 x{n) = {2 + j 3 , 1 + j2, - 2 - j 4 , 1 + j2}.
4.8.5 x{n) = {1 - j 2 , 2 - j 3 , 1 - j 2 , 2 - j 3 } .
4.9 Find the DFT of x{n) = {0,1,1,0} and x{n) = { 0 , 1 , 1 , 0 , - 1 , - 1 } .
What are the number of nonzero frequency coefficients in each case.
95
96 Fundamentals of the PM DFT Algorithms
X(0)1 r W2 w° •
X(l) w2 wl • a,(0) "
X(2) w2 -w2 . a,(l) .
X(3) J w2 -wl .
where a 0 (0) = x(0)+x{2), ai(0) = x(0)-x(2), a 0 (l) = a?(l) + a;(3), a i ( l ) =
a;(l) — x(3), and q = k mod 2. Let us say we want to compute the DFT of
x(n) = { 2 + j l , 3 — j l , 4 + j ' 2 , —1+J2}. Then, the input vectors are given as
ag(n) = {(a0(0),ai(0)),(ao(l),ax(l))} = {(6+A-2-jl),(2+iM-j3)}.
The half-wave symmetry of the twiddle factor matrix along the columns can
Vector Format of the DFT 97
(2 + j l ) ± ( 4 + j2) = {8 + j 4 , 4 + j 2 }
{6 + j 3 , - 2 - j l }
(3-jl)±(-l+j2) = ^ b { - 5 - j 5 , l + j3}
{2+jl,4-j3}
(b)
Fig. 5.1 (a) The SFG for the computation of 4-point DFT using vectors of length two.
(b) A specific example of (a).
P (0) w2 (-l)0pa,(0)
AP(1) L (-l) lp a g (l) J
where A o (0) = X(0), A^O) = X{2), A0{l)=X(l), Ai(l) = X(3), p = 0,1
and q — k mod 2. The matrix equation can be written in algebraic form as
MQ = £ ( - i ) p n a » w T * , * = o,i (5.1)
n=0
where p = 0,1 and 9 = k mod 2. Equation (5.1) seems more complex than
the direct definition, Eq. (3.3). But it is actually easy and more efficient to
implement. For JV = 4, the definition of the DFT, Eq. (5.1), using vectors
itself is the optimum algorithm. The computation is shown in Figs. 5.1(a)
and (b) using a signal-flow graph (SFG).
SFG for the vector length of two. It consists of unfilled circles indicating
nodes, and arrows indicating the signal flow path. Each node, except at the
beginning, represents an add-subtract operation. The nodes at the begin-
ning of a SFG just receive the input vector values. In Figs. 5.1(a) and (b),
the input vectors are placed close to the input nodes. The arrows terminat-
ing at an upper node originate from the nodes whose first element of their
vectors contributes to form the elements of the vector at the upper node
by add-subtract operation. The lower node receives the second elements
of its source vectors and the elements of the vector at a lower node are
also formed by add-subtract operation. At both type of nodes, the result
of the add operation forms the first element and the result of the subtract
operation forms the second element of the vector. Each data value along
an arrow is multiplied by a twiddle factor, W^, where N is the data length.
The exponent of the twiddle factor, s, is indicated close to the arrowhead.
No value or a zero near an arrowhead indicates that the value of the twiddle
factor is unity. Operations other than add-subtract and multiplication, and
any other objects will be indicated by special symbols.
The output vectors and the equations relating them to the input vectors
are shown at the output nodes in Fig. 5.1(a). Figure 5.1(b) shows the
operation of Eq. (5.1) for a specific example. Before we proceed to generalize
the DFT definition for any vector length, we try to answer the question
why do we usually use complex signals in DFT algorithms although we are
almost always interested in real signals.
8=0
For each value of n, the inner summation is a u-point DFT and when
evaluated will give rise to u distinct values for k = 0 , 1 , . . . , u — 1. Let
a(n),n = 0 , 1 , . . . , ^ — 1 denote the nth input vector (Vectors will be shown
in boldface.) consisting of the u-point DFT values aq (n), q = 0 , 1 , . . . , u — 1
as defined below.
a(n) = { a 0 ( n ) , a i ( n ) , . . . A - i W } = V i ( n + 8-)B' u , «,
z
—' u
8=0
0 = 0,1,...,u-l, n = 0,l,..., 1 (5.2)
u
Now, the last but one equation can be rewritten as
X(k) = J2 aq(n)W£k, fc = 0 , l , . . . , i V - l
n=0
100 Fundamentals of the PM DFT Algorithms
Since the values of the u-point DFT aq(n) are periodic with a period of u,
for values of k equal to or greater than u, the values aq (n) repeat. Therefore,
q = k mod u
n = 0,l,...,y-l (5.5)
Direct Computation of the DFT with Vectors 101
N
4(*) = £ (-l)pna„(n)WZk, k = 0 , 1 , . . . , - - 1 (5.7)
n=0
5.2(b)
( s t a r t *)
5.2(c) 5.2(e)
The next module, shown in Fig. 5.2(d), computes the DFT coefficients.
This module is called vec-dft. First, input vectors are formed by computing
the 2-point DFT of pairs of values taken from the first and second half of
the input data. The vectors are stored in arrays ar and ai, each of size
N. The coefficient computation is carried out in two nested loops, the
outer loop controlling the frequency index and the inner loop controlling
the data index. In each iteration of the outer loop, the DFT values with
indices A; and k + y are computed. The real and imaginary parts of the
DFT coefficients are stored, respectively, in arrays xr and xi. The sum
of products for the even and odd indexed terms are computed separately.
Direct Computation of the DFT with Vectors
('start')
N
n l = 0,n2 =
no
( Return)
n l = 0, n2 = nl + 1, n3 = y,nfc = 0,
sumer = 0, sumei = 0, sumor = 0, sumoi = 0
i/(fc mod 2 ^ 0), {nl = f, n2 = n l + 1, n3 = iV}
5.2(d)
Fig. 5.2 The flow chart description of the computation of the D F T with vector length
two. (a) The main module, (b) The twiddle factor module, (c) The input module.
(d) The D F T module, (e) The output module.
104 Fundamentals of the PM DFT Algorithms
The sum of these yields a;(fe) and difference yields x(k + —•). The access of
correct twiddle factor values is carried out using the mod function. Inside
the inner loop, the coefficient computation is carried out according to the
DFT definition. The next module, shown in Fig. 5.2(e) prints the real and
imaginary parts of the DFT values, respectively, from the arrays xr and xi,
one complex coefficient in each iteration. This module is called out-put.
A set of expressions similar to those given by Eqs. (5.5), (5.6), and (5.7)
can be obtained for computing the IDFT.
* = 0,l,...,y-l (5.9)
M«) = ^ £ ( - l ) P * ^ ( * W n * , n = 0 , l , . . . , y - l (5.11)
fc=0
where p = 0,1 and q = (n + p y ) mod 2. The SFG for the computation of
IDFT with TV = 4 is shown in Fig. 5.3(a) and a specific example, which
computes the IDFT of the DFT values shown in Fig. 5.1(b), is shown in
Fig. 5.3(b). By dividing the output values by N = 4, we get the time-
domain values.
Any DFT algorithm can be used to compute the IDFT with very little
additional effort. Let x{n) — xr{n) + jxi(n) and X(k) = Xr(k) + jXi(k).
The IDFT is defined as
N-l
(n)+jxi(n) = ^Y^Xr(k) + 3Uk))W^nk,
=o
k=0
n = 0,l,...,JV-l (5.12)
The Computation of the IDFT 105
(8 + j 4 ) ± ( 4 + j 2 ) = o ^ — ^ ^ { 8 + j4,16 + j 8 }
{12+j6,4 + j2}
1 JV_1
xr(n) - jXi(n) = T7 E ^(k) - 3Xi(k))Wp (5.13)
N k=0
Equation (5.13) represents a DFT with the input and output data conju-
gated, in addition to a constant divisor. This implies that a DFT algorithm
can be used to compute the IDFT by conjugating the input, computing the
DFT, and conjugating the output. An alternate algorithm is obtained by
multiplying both sides of Eq. (5.13) by j .
N-l
Xi{n) + jxr(n) = - J2 (Xi(k) +jXr(k))Wtf (5.14)
fc=0
Equation (5.14) represents a DFT with the real and imaginary parts of the
input and output data interchanged. This implies that a DFT algorithm
can be used to compute the IDFT by suitably reading the input and writing
the output. The output values must be divided by N in order to get the
actual values of the IDFT. Figure 5.4 shows the computation of the IDFT
using the DFT for the same input used in Fig. 5.3(b).
106 Fundamentals of the PM DFT Algorithms
{6 + j l 2 , 2 + j 4 } <v » p { 4 + j 8 ; 8 + jl6}
Fig. 5.4 A specific example of computing 4-point I D F T of the D F T values in Fig. 5.1(b)
using the D F T .
Efficient DFT algorithms are obtained by decomposing Eq. (5.4) into sev-
eral stages of computation. In this section, we derive the DIT type of algo-
rithms. In order to do that, we have to study two properties on which this
type of algorithms is based. For simplicity, we will develop the algorithm
for the specific case with N = 8 and u = 2.
ai(0)(-l)°W8°4<ll(l)(-l)lpW81^1(2)(-l)2W82^1(3)(-l)3W83 (5.15)
The expression for AP{1) of the vectors shown in Fig. 5.5(c) is given by
Oi(3)(-l)0pW8°+a1(0)(-l)1^81^1(l)(-l)2pW82^i(2)(-l)3W83 (5.16)
The first three terms in this expression are exactly same as the correspond-
ing terms in Eq. (5.16). As all the elements of the input vector aq(3) are
Fundamentals of the PM DIT DFT Algorithms 107
a,(l) Ap(l)
• •
a g (3) = 0 Ap{3)
(a) (b)
aq(0) W%W£AP(1)
o,(2) W%WiAp(3)
(c) (d)
Fig. 5.5 (a) A set of 4 input vectors with the last vector having all zero elements and (b)
its DFT. (c) The shifted vectors of (a) by one position in the counterclockwise direction
and (d) its DFT in terms of the DFT vectors shown in (b).
zero, the term involving this vector does not contribute to the summation.
Therefore, Eqs. (5.16) and (5.17) yield the same value.
A Z) k
i ( ) = E Wraq(n)W?*, k = 0,1,..., 1
U
n=0
108 Fundamentals of the PM DFT Algorithms
R , r * = £ , £ + l,...,2£-l,weget
A^{k) = Y, Wgv+Vnaq(2n)W%
rnkk
n=0
Since Ap(k) is periodic of period u with respect to the variable p, we get
For an even vector length, when the number of input vectors is doubled
by inserting vectors with all zero elements in between the vectors, the even
subscripted vector elements of the smaller DFT repeat for the first-half of
the DFT of the zero padded input vectors and the odd subscripted DFT
vector elements repeat for the second half. For example,
{(a,b),(e,f)}&{(A,B),(E,F)}
implies
{(a,b),{0,0),(e,f),(0,0)}^{(A,A),(E,E),(B,B),(F,F)}
a e A E c 9 C G
&
b f B F d h D H
(a)
a 0 e 0 A E B F
b 0 / 0 A E B F
(b)
c 0 9 0 C G D H
&
d 0 h 0 C G D H
(c)
a c e 9 a 0 e 0 0 c 0 9
b d / h b 0 / 0 + 0 d 0 h o
zero padded even and odd indexed vectors as shown in Fig. 5.6(e). The sum
of the two groups of the input vectors is equal to the given input vectors. If
we compute the DFT of the two groups of input vectors and add, due to the
linearity property of the DFT, we get the DFT of the given input vectors.
Note that, due to zero padding, the computation of the DFT of each group
of vectors can be reduced to the computation of a 2-vector DFT.
Consider the DFT vector pairs shown in Fig. 5.6(a). Due to zero padding
110 Fundamentals of the PM DFT Algorithms
Fig. 5.7 The SFG of the 2 x 1 PM DIT D F T algorithm, with N = 8. Twiddle factor of
the form Wg is represented only by its exponent s near the arrowheads. For example,
the number 1 represents Wg.
property described above, we can deduce the DFT of the vectors shown
on the left side of Figs. 5.6(b) and (c) as shown on the right side. The
DFT of the shifted input vectors shown in Fig. 5.6(d) can be obtained by
multiplying the DFT vectors shown in Fig. 5.6(c) with appropriate twiddle
factors. Due to the linearity property of the DFT, the sum of the DFTs
shown in Figs. 5.6(b) and (d) is the DFT of the sum of the input vectors
shown in those figures. The point is that we are able to compute a longer
DFT (a 4-vector DFT) by combining the coefficients of two 2-vector DFTs
as shown in Fig. 5.6(e).
The SFG of the 2 x 1 PM DIT DFT algorithm is shown in Fig. 5.7. Note
that the computation module shown, with N = 4, in Fig. 5.1 is used four
times, with N = 8. We will say more about the structure of the SFG in
the next few chapters. While Figs. 5.6 and 5.7 depict the same algorithm,
the SFG shown in Fig. 5.7 is a more compact description whereas Fig. 5.6
shows explicitly the use of properties in deriving the algorithm.
In order to understand the algorithm, let us use an algorithm trace. A
trace of an algorithm is a table of values of the variables at various stages
of the algorithm from input to output. Figure 5.8 shows the trace of the
algorithm shown in the SFG of Fig. 5.7. The input data is {x(n),n =
0,1,2,3,4,5,6,7} = {3 + j l , l + j 2 , 2 - j l , - 2 + j3,4 + j2,l + j4,2-
j2, —1 + j 3 } . With N = 8 and u = 2, four vectors are required and the
input values are read into the vector locations as shown in column 1. For
example, a;(0) = 3 + j l and x(4) = 4 + j 2 are stored in the storage locations
of the first vector. Vector formation consists of computing 2-point DFT
of the values stored in each vector locations. For example, the first vector
Fundamentals of the PM DIT DFT Algorithms 111
Fig. 5.9 The trace of the computation of IDFT using the DFT algorithm shown in
Fig. 5.7.
In this section, we derive the DIF type of algorithms. This type of algo-
rithms are also based on certain properties of the DFT. Assume that N = 8
and u = 2.
Ap(l) (0,ai(l))
Ap(2) = 0 W£(ai(l),0)
Ap(0) = 0 W83M3),0)
(c) (d)
Fig. 5.10 (a) A set of 4 DFT vectors with the elements of the even indexed vectors zero
and (b) the corresponding input vector elements, (c) The shifted vectors of (a), and (d)
the corresponding input vector elements in terms of the input vector elements in (b).
the computation of odd indexed DFT vectors, odd subscripted input vector
elements combine to produce the new set of input vectors of one-half the
number.
a c e 9 A C E G
<$ B D F H
b d f h
A 0 E 0 0 C 0 G
B 0 F 0 + 0 D 0 H
(a)
a c e 9 <£• A 0 E 0
0 0 0 0 B 0 F 0
(b)
0 0 0 0 G
b d / h D H
(c)
Fig. 5.12 The SFG of the 2 x 1 P M DIF D F T algorithm, with N = 8. Twiddle factor
of the form Wg is represented only by its exponent s near the arrowheads. For example,
the number 1 represents Wg.
Fig. 5.13 The trace of the algorithm shown in Fig. 5.12 for the same input values in
Fig. 5.8.
Summary 117
operation in the algorithm. Hence, the name plus-minus (PM). The term
radix-z specifies the way a problem is decomposed into smaller problems.
While we can design algorithms with any radix, the practically most useful
value for z is two and, therefore, the algorithms described in this book are
exclusively of the type radix-2. In a radix-2 algorithm, a problem is split
into two smaller independent problems of the same type, each of half the
size, recursively from the input or output end. The solutions of two smaller
problems are combined to form the solution of a larger problem. A radix-2
algorithm requires that the length of the data N divided by the vector
length u is equal to an integral power of 2, that is ^ = 2 m where m is an
integer.
The letter u indicates the number of elements in a vector. Although
general expressions are developed in the following chapter, with one excep-
tion for vector length six, all the algorithms described, in detail, in this
book use a vector length of two since that length is practically the most
useful. It is possible to combine fully or partially the multiplication opera-
tions of two or more consecutive stages of an algorithm in order to reduce
the total number of arithmetic operations. However, the partial merging
of multiplication operations of adjacent stages leads to practically ineffi-
cient and irregular algorithms. Therefore, the letter v, in the range 1 to
m = log2 —, specifies the number of adjacent stages whose multiplications
are combined. Although the set of PM algorithms is quite large, the prac-
tically more useful algorithms are those with z = 2, u — 2, and v = 1 or
v = 2. A good understanding of these algorithms will enable the reader to
derive algorithms with other parameters, if necessary.
5.8 Summary
and outputs were derived. The computation of the IDFT using the
DFT was presented. The fundamental principles and the relevant
theorems on which the fast algorithms are based were explained.
The classification of PM DFT algorithms was presented. In the
next few chapters, the PM DFT algorithms will be described in
detail.
References
Exercises
5.1 Using the SFG shown in Fig. 5.1, compute the DFT of:
5.1.1. x(n) = {2,3,5,4}.
* 5.1.2. x(n) = {2+jl,l-j2,2 + j2,l-j3}.
5.2 Starting from the DFT definition, derive the expression Eq. (5.7) with
N = 8.
5.3 Starting from the IDFT definition, derive the expression Eq. (5.11)
with N = 8.
5.4 Using the SFG shown in Fig. 5.3, compute the IDFT of
X(k) = {2-jl,l-j2,3 + j2,l-j3}.
* 5.5 Using the SFG shown in Fig. 5.4, compute the IDFT of
X(k) = {2 - jl, 1 - j2,3 + j 2 , 1 - j3} using DFT.
5.6 Verify that the transform vectors shown in Fig. 5.5(d) corresponds to
the input vectors shown in Fig. 5.5(c).
5.7 Compute the input vectors, {aq(0), aq(l)}, with vector length 2 if
x(n) = {1 - j 4 , 2 + j 3 , 1 - j l , 2 - j l } . Find the DFT using the vectors.
Deduce the DFT if the input vectors are {aq(0),0,aq(l),0}.
Exercises 119
5.8 Using the SFG shown in Fig. 5.7, compute the DFT of x(n) = {1 -
j4,2-j3,l-jl,2-j4,2-j2,l+j3,l-jl,2 + j2}.
* 5.9 Using the SFG shown in Fig. 5.7, compute the IDFT of X(k) =
{ l - j 3 , 2 - j 3 , 3 - j l , 2 - j 4 , 3 + j3,2-j2,l + j3,2+;4}.
* 5.10 Using the SFG shown in Fig. 5.12, compute the DFT of x(n) =
{1 - jA, 2 - j3,1 - j l , 2 - j 4 , 2 - j 2 , 1 + j 3 , 1 - j l , 2 + j2}.
5.11 Using the SFG shown in Fig. 5.12, compute the IDFT of X(k) =
{ l - j 3 , 2 - j 3 , 3 - j l , 2 - j 4 , 3 + j 3 , 2 - j 2 , l + j3,2 + j4}.
Programming Exercise
5.1 Write a program to directly implement Eq. (5.7) to compute the DFT.
Chapter 6
The u X 1 P M D F T Algorithms
121
122 The uxl PM DFT Algorithms
Mk)= Y, W^naq(2n)Wf
/•nk
n=0
Ap(k+^) ) == £
* W^+l>ag(2n)WZk
2u 71=0
-Nil
4*)(fc)= Y Wra9{2n)W£
4?mod„(*) = £ W^aq{2n)Wf,
Theuxl PM DIT DFT Algorithms 123
ra=0
size of the problem is reduced, the difference between the indices h and /
is also reduced by a factor of two. The expressions for the twiddle factor
exponent and the indices of the nodes of each group of butterflies are given
as follows.
h = imod2r"1, z= 0,1,..., ^ - 1
/ = h + r-1 (6.6)
a = h(2m~r)
Using the expressions given above, algorithms can be derived for any value
of N and u for which ^ is an integral power of 2. As a consequence of
splitting the even and odd indexed input vectors over m stages, the input
vectors to the first stage are placed in the bit-reversed order.
The specific algorithm with u = 2, that is each vector with two complex
elements, is practically very useful. Therefore, we give a detailed description
of this algorithm.
Fig. 6.1 The SFG of the butterfly of the 2 x 1 PM DIT D F T algorithm, where 0 < s <
^-. Twiddle factors are represented only by their exponents. The symbol s represents
vvN.
Fig. 6.2 The SFG of the 2 x 1 PM DIT DFT algorithm, with N = 16. Twiddle factors
are represented only by their exponents. For example, the number 4 represents Wj 6 .
Example 6.1 Figure 6.3 shows the trace of the algorithm shown in
Fig. 6.2. The values, given to a precision of two decimal places, were ob-
tained from running a program with a much higher precision. The first
column values are 16 complex input values to the DFT. The input values
are stored sequentially in the storage locations assigned for 8 vectors each
with 2 complex elements, the first half values in the first element of the vec-
tors and the second half values in the second element. Vectors are formed
by adding and subtracting the elements stored in the individual vector lo-
cations. For example, the elements of the vector in the first row of the
second column are (2 + jO) + (1 + JO) and (2 + jO) - (1 + JO). In addition
128 The u X 1 PM DFT Algorithms
OS
Vs. Vs.
to to
1 +
x(0) 2 + jO 3 + jO 19.00 + J7.00 37.00 + J14.00 X(0)
x(8) 1 + j O 1 + jO -7.00 - J3.00 1.00 + jO.OO X(8)
O
x(l) 3 + jO 3 + J2 1 - j l 1.00 - J3.83 1.61-J6.82 X(l)
x(9) 3 + jO 1 + jO 1 + j l l.OO + j l . 8 3 0.39 - jO.83 X{9)
x{2) 4 + jO 7 + jO 13+J5 -5.00 - J3.00 -8.54 - J7.95 X{2)
x(10) 3 + jO 1 + jO 1 - J 5 5.00 - jl.00 -1.46 + J1.95 XilO)
x(3) 4 + jO 6 + j 5 2 - J 2 2.41 - J0.41 -2.43 - jO.57 X{2)
ar(ll) 1 + j O 2 + j l 0 + J 2 -0.41 + J2.41 7.26 - jO.26 X(ll)
s(4) 2 + j l 6 + jO 9 + j 5 18.00 + J7.00 -4.00 - J3.00 X(4)
x(12) 1 + j l 0 + jO 3 - J 5 0.00 + J3.00 -10.00-J3.00 X(12)
s(5) 1 + J 3 3 + J5 1 + j l 1.71 - J2.54 5.08 - jO.18 X(5)
x(13) 2 + J2 - 1 + j l - 1 - j l 0.29 + J4.54 -3.08 + J3.83 X(13)
Vs. Vs.
1 +
to to
>_i to
to forming the vectors, the vectors are swapped at the same time so that
they are placed in the bit-reversed order. The result of vector formation
and swapping is shown in column two. The third, fourth, and fifth column
vectors are obtained after the first, second, and third stage operations of
the algorithm are carried out. The 16 DFT coefficients are stored sequen-
tially, the first half in the first element of the vectors and the second half
in the second element as shown. I
The input vectors, in Fig. 6.2, are placed in bit-reversed order (see Ap-
pendix C) while the output vectors are placed in natural order. The bit-
reversed order is necessary for in-place computation, that is with storage
locations just enough for y vectors. This advantage is quite significant and
the overhead of placing the input vectors in bit-reversed order is very small.
Figure 6.4 shows the binary representation of the indices of the vectors
Reordering of the Input Data 129
Fig. 6.4 Reordering of the input vectors in the 2 x 1 PM DIT DFT algorithm, with
N = 16.
in all the stages. In the last stage, the output vectors are in natural order.
These vectors are formed by butterflies, which require the DFT of even
indexed input vectors at the upper node and the DFT of the odd indexed
input vectors at the lower node. The butterflies are placed in natural order.
Therefore, the DFT of the even and the odd indexed vectors are placed in
natural order as indicated by the two boldface bits on the left side of each
index. To compute the DFT of the even and odd indexed input vectors we
require the DFT of the even of even, even of odd, odd of even, and odd of
odd indexed input vectors in natural order. This is a recursive process that
continues until the input data is split into groups of one, as at the input of
stage 1. The repeated splitting of the input data into even and odd indexed
sets is required. The question is what is the order of the indices we get at
the input due to this process and what is the relation between the input
and the output orders.
If we circularly left shift the naturally ordered binary numbers in the
last stage by one position, the msbs come to the position of the lsbs and we
get the required order for our algorithm at the end of stage 2. Therefore,
130 The u x 1 PM DFT Algorithms
the lsbs of the new order are fixed and again we circularly left shift the
two sets of numbers with two boldface bits to get the proper order at the
end of the stage 1. Now the position of the second bit gets fixed. Only
one bit, shown in boldface, remains to be considered and, as shifting one
bit makes no difference, we get the input order. Circularly left shifting by
one bit repeatedly, the first time we made the msbs of the natural order as
the lsbs of the new order, the second time we moved the bits next to the
right of msbs in the natural order to the left of lsbs in the new order, and
finally we left the lsbs of the natural order in the msb positions of the new
order. The net result is that we have reversed the position of the bits in
the natural order.
To get further insight into the algorithm, let us consider how a specific
coefficient is computed. By highlighting the relevant signal flow paths, we
have shown the grouping of partial results and multiplication by common
factors in the computation of X(13) in Fig. 6.5. By definition,
7
X(13) = ^ ( 5 ) = 5^(-l) n a 1 (n)W 1 8 a n
n=Q
This computation is split over three stages. At the end of the first stage,
we get
= MO) + ^ ( 4 ) 0 - M 2 ) + ai(6)W?6)W?fl
- M l ) + «i(5)^i 4 6 )^i 5 6 + (oi(3) + ai(7)W? e )W7e
A{1)
A(2)
A{3)
A(4)
A(5)
A!(5) = X(13)
A(6)
A(7)
Fig. 6.5 The computation of the coefficient X(13) by the 2 x 1 P M DIT D F T algorithm,
with N = 16.
DFT coefficients. Second stage partial results are used to compute one-
eighth of the DFT coefficients and so on. This sharing of the partial results
contributes to the reduction of the computation compared with the direct
computation since, in that case, no sharing is done.
Seven complex multiplications and fifteen complex additions are re-
quired to compute a single coefficient. The multiplications in the first stage
are trivial. The number of multiplications in the other stages is ^ — 1. In
the second stage, the complex multiplication requires less computational
effort. Compare this with N complex multiplications required in the direct
computation of the DFT. The reduction of the number of multiplications
reduces the round-off errors. The spreading of the computation over several
stages also reduces the errors and makes the scaling problem less severe in
fixed-point implementations.
The DFT algorithms are so efficient that, unless we want to compute
very few coefficients, it is better to use an algorithm to compute all the
coefficients even if all of them are not required. To compute a single DFT
coefficient, we have to use the appropriate computational path in the SFG of
an algorithm. This method is more efficient than using the DFT definition
because the computational effort is reduced by more than half in terms of
arithmetic operations. In addition, we have to compute very few twiddle
factors.
Ap(k)= £ WZnaq(n)WZk+ ]T W ^ a , ( n ) ^ ,
n=0 „=£
The n x l PM DIF DFT Algorithms 133
n=0 n=0
2u'',JV
The even and odd indexed DFT values Ap(k) are readily obtained from
Eq. (6.8) by replacing A; with 2k and k with 2k + 1, respectively.
N--1
r-l
Ap(2k + 1 ) = £ W T ( o , ( n ) + W ^ ^ W ^ i n + — ))W%Wf,
71=0
aqr+1\h) = a$modu(h)+WZa%modu(l)
a™(h) = a%modu(h)-WZa$modu(l)
4"+1)(0 = WhaVmodJh) + WtW}uW^Z\+1)modu(l) {
- }
h = z m o d 2 m - r , i = 0 , 1 , . . . , £. - 1
I = h + 2m~r (6.12)
s = h(2r~1)
As a consequence of splitting the even and the odd indexed output vectors
over the m stages, the output vectors from the last stage are placed in the
bit-reversed order.
a(r)(
2{a«(/),aW(0} o - ^ ^ o °(rf=(?4r+1,(0,«ir+1)(0}
Fig. 6.6 The SFG of the butterfly of the 2 x 1 PM DIF DFT algorithm, where 0 < s <
x - Twiddle factors are represented only by their exponents. The symbol s represents
Example 6.2 Figure 6.8 shows the trace of the algorithm shown in
Fig. 6.7. Vector formation is similar to that in Example 6.1 except that
the vectors, shown in the second column, are placed in natural order. The
third, fourth, and fifth column vectors are obtained after the first, second,
and third stage operations of the algorithm are carried out. The output
vectors have to be swapped to put them in sequential order. I
6.7 C o m p u t a t i o n a l Complexity of t h e 2 x 1 P M D F T
Algorithms
Fig. 6.7 The SFG of the 2 x 1 PM DIF DFT algorithm, with N = 16. Twiddle factors
are represented only by their exponents. For example, the number 4 represents W±6.
One-butterfly implementation
There are m = log2 y stages each with —• butterflies. Each butterfly
requires 8 real multiplications and 12 real additions. Further, 2N real
additions are required in the vector formation stage to compute y 2-point
DFTs. Therefore, the expressions for the number of real multiplications
and real additions are 2Nrn and TV (3m + 2), respectively.
Two-butterfly implementation
In the first butterfly of each group, the twiddle factors are 1 and — j . These
butterflies can be implemented separately. This type of implementation
is called a two-butterfly implementation since one general and one special
butterfly are used. There is one butterfly with twiddle factors of 1 and
-j in the last stage, two in the last but one stage, four in the preceding
stage, and so on. Thus, the saving in real multiplications is 8(2° + 2 1 +
2 2 + ... + 2 m _ 1 ) = 8(2 m - 1) = (47V - 8). Therefore, the total number
Computational Complexity of the 2 x 1 PM DFT Algorithms 137
Three-butterfly implementation
If we set up another special butterfly (a three-butterfly implementation) to
process multiplications by the twiddle factors ± 4 s — J 775, we can further
save some real multiplications. There is one such butterfly in the last
stage, two in the last but one stage, four in the preceding stage, and so on.
Therefore, by separately implementing such butterflies, the saving in real
multiplications is given by
Table 6.1 Figures of Computational Complexity for the 2 x 1 PM DFT Algorithm with
Various Number of Butterflies.
Number of multiplications | Number of additions
N 1-B_fly 2-B_fly 3-B_fly 1-Bjfly 2- fc 3-B_fly
16 96 40 28 176 148
32 256 136 108 448 388
64 640 392 332 1088 964
128 1536 1032 908 2560 2308
256 3584 2568 2316 5888 5380
512 8192 6152 5644 13312 12292
1024 18342 14344 13324 29696 27652
2048 40960 32776 30732 65536 61444
4096 90112 73736 69644 143360 135172
The DFT lengths that are most often used in practice are integral powers
of two. However, for a specific requirement, it is relatively straightforward
The 6 x 1 PM DIT DFT Algorithm 139
to develop efficient algorithms for DFT lengths with a factor such as 3,5,7,
etc. For example, using a vector with six elements, that is u = 6, we can
design algorithms with DFT lengths 12, 24, 48, 96,192, 384, etc. The input
vectors are formed by computing 6-point DFTs of the input data as defined
in Eq. (5.2). The prime-factor algorithm described in Appendix D can be
used to compute the 6-point DFTs efficiently.
terfiy requires 16 real multiplications and 32 real additions while the second
butterfly requires 20 real multiplications and 36 real additions. There are
Y — 1 butterflies of the first type and ^ — 1 of the second type. The six
twiddle factors required for the butterfly operation can be obtained by gen-
erating only three of them. Specifically, if the twiddle factors Wfc, WN 12 ,
8+ &- 8+ ^-+ ^-
6 6 12
and WN are generated, then the remaining twiddle factors WN ,
e B 12
WN , and WN are obtained simply by multiplying, respectively,
the first three twiddle factors with W£ = —j.
Table 6.2 Figures of Computational Complexity for the 6 x 1 PM DFT Algorithm with
Various Number of Butterflies.
Number of multiplications Number of additions
N 1-B_fly 2-B_fly 3-B_fly 1-BJy 2- & 3-B_By
24 128 104 100 288 276
48 352 296 284 720 692
96 896 776 748 1728 1668
192 2176 1928 1868 4032 3908
384 5120 4616 4492 9216 8964
768 11776 10760 10508 20736 20228
1536 26624 24584 24076 46080 45060
3072 59392 55304 54284 101376 99332
6144 131072 122888 120844 221184 217092
(start) (Start)
|call out-put|
£/c(i) = cosfarp
tfs(i) = sin(ar</
( Stop*) ar<7 = org + inc
i = i+ 1
T
6.10(a)
6.10(b)
f Start")
6.10(c) 6.10(f)
Fig. 6.10 The flow chart description of the 2 x 1 P M DIT D F T algorithm, (a) The
main module (b) The twiddle factor module, (c) The input module, (d) The module
for making and swapping vectors, (dl) The swap module, (e) The dit21.31 D F T mod-
ule. (el) The first special butterfly module. (e2) The second special butterfly module.
(e3) The general butterflies module, (f) The output module.
144 The u x l PM DFT Algorithms
(Return J
f Start")
''
N
hbs -= 0, bs = 1,5s = 2, inc =' 4
( Return j
call b-flyl(bs,gs)
call b_fly2(hbs, bs, gs)
call b-fly3(hbs, bs, gs, inc)
brev = brev + bit
hbs = bs,bs — gs,gs = 2 * gs, inc = ^
call swap
6.10(d) 6.10(e)
Fig. 6.10(d). The algorithm actually finds the bit-reversal of the first y
even numbers of a list of y • Therefore, the outer loop is limited to j - as
the sequence counter i is incremented twice in each loop. The bit-reversal
algorithm is described in Appendix C. In the inner loop, the first zero bit
of the previous bit-reversal, brev, is found. Until that time each nonzero
bit of brev is set to zero. The variable bit is used to check each bit and it
is divided by two in each iteration. When bit > brev, the iteration ends
and the bit-reversal of i is found with the operation brev = brev + bit.
Now, the swap module, shown in Fig. 6.10(dl), is called. If the bit-reversal
brev is equal to i, then another vector index in the upper half of the list
is found and 2-point DFTs of each vector is computed. If brev is greater
than i, then the pair of vectors with indices i and brev are swapped and
the 2-point DFTs of each vector is computed. If brev is less than i, then
swapping and the 2-point DFT of a pair of vectors in the upper half of the
Flow Chart Description of the 2 x 1 PM DIT DFT Algorithm 145
f Start J
no
u; = i, q — brev
ifiw > q){w = w+% + l,q = q+% + l}
t l = apr(tu),t2 = api(u;),£3 = amr(tu
£4 = ami(w),£5 = apr(g),£6 = amriq
amriw) = £5 — £6,apr(w) = £5 + £6
£5 = apiiq), *6 = amiiq)
amiiw) = £5 — £6,api(u;) = £5 + £6
amrfg) = £1 — t3,apriq) = £1 + £3
omi(g) = £2 - £4, apiiq) = £2 + £4
3.
i = i + 1, gr = 6rew 4- ^
£1 = ap7-(i),t2 = api(i),t3 = amr(j)
£4 = amz(i),£5 = apr(</),£6 = amriq)
amrii) = £5 — £6,ajw(z) = £5 + £6
£5 = api(g),£6 = amiiq)
amiii) = £5 — £6,api(i) = £5 + £6
amriq) — £1 — £3,apr(g) = t l + t3
ami\q) = t2 — tA, apiiq) = £2 + £4
i =i+ l
I
( Return)
6.10(dl)
146 The u x 1 PM DFT Algorithms
list is carried out. In all the iterations, the vector whose index is the next
higher odd number and the vector whose index is the bit-reversal of the
odd number are swapped and 2-point DFTs computed.
Figure 6.10(e) shows the dit21Sl module. The term dit21 indicates
that the algorithm is the 2 x 1 PM DIT DFT algorithm. This is a three-
butterfly implementation, which is indicated by the number 3. The last
digit 1 indicates that each stage is implemented separately. Two general
and two special types of butterflies are used as presented in Section 6.2.
This flow chart should be followed with the SFG shown in Fig. 6.2. The
variable bs represents the span of a butterfly. The variable gs represents
the span of a group of butterflies. The variable hbs is equal to ^ - Variable
inc represents the difference between two indices of the twiddle factors in
the look-up table for a particular stage. These variables are initialized for
first stage values. The loop steps through various stages. The butterfly
span in the last stage of the algorithm is maximum at ^ , and therefore,
the value ^- 1S u s e d to end the iteration. As the first butterfly in each group
is a special one, module b-flyl is invoked to process this type. This module
processes all the butterfly of this type in a loop as shown in Fig. 6.10(el).
The second special butterfly is required from Stage 2 onwards. The module,
b-fly2, is invoked and it processes all the butterflies of this type in a loop
as shown in Fig. 6.10(e2).
Two general type butterflies are used in the module called b-fly3, shown
in Fig. 6.10(e3). Unlike in the previous cases, the number of butterflies
in each group is more than one. Therefore, two loops are required for
implementation. Two butterflies of the general type are processed at the
same time. This reduces the fetching of the twiddle factors as the twiddle
factors are related in a trivial manner. For each pair of butterflies in the
first group, the indices of the nodes and the twiddle factors are set. The
inner loop steps through all the butterflies with the same twiddle factors in
all groups. The outer loop steps through each butterfly of the first group.
The values are updated and the iteration continues until all the butterflies
in a stage are processed. The ouLput module is shown in Fig. 6.10(f). In
each iteration of the first loop, a pair of values apr(i) and api(i) are printed.
In the second loop, a pair of values amr(i) and ami(i) are printed.
Flow Chart Description of t/ie 2 x 1 PM DIT DFT Algorithm
C Start J
(Return)
6.10(el)
f Start")
I
ft = hbs, I = h + bs,c = £/c(0)
(Return)
£5 = apr(Z),£4 = apiVt)
£1 = c * (£5 + £4), £3 = c * (£4 - 45)
£5 = amr(l),H = ami(l)
t2 = c * (£4 - £5), £4 = c * (£4 + £5)
£5 + £4,api(J) = £ 5 - £ 4
£5 = amr(h),amr(l) = £5 — £2, apr(Z) = £5 + £2
£5 = api(h), api(h) = £5 + £3, ami(h) = £5 — £3
£5 = apr(h),apr(h) = £5 + £l,amr(ft) = £5 - £1
ft = ft + <7S, / = I + gs
6.10(e2)
148 The u x 1 PM DFT Algorithms
(Return)
h = i,l = h + bs,rh = bs — i, rl — rh + bs
c = tfc(J), s = tfs(j)
, . \ U U • • , -i • . -
£5 = apr(rl),t4 = api(rl),tl = s * £5 + c* £4
£3 = s * £4 — c* £5, £5 = amr(rZ),£2 = ami(rl)
tA = s * £5 + c * £2, £2 = s * £2 — c * £5
£5 = ami(rh),ami(rl) = £5 + £4,api(r/) = £5 — £4
£5 = amr^r/i^amr^rZ) = £5 — t2,apr(rl) = £5 + £2
£5 = api(rh), apiOrh) = £5 + £3, ami(rh) = £5 — £3
£5 = apr(rh), apr{rh) = £5 + £1, amr(rh) = £5 — £1
£5 = apr(Z), £4 = api(l), £1 = c * £5 + s * £4
£3 = c * £4 - s * £5, £5 = amr{l), £2 = ami(l)
£4 = c * £5 + s * £2, £2 = c * £2 — s * £5
£5 = ami(h), ami (I) — £5 + £4, api(Z) = £5 - £4
£5 = omr(/i),omr(I) = £5 — £2,opr(Z) = £5 + £2
£5 = api(h), api(h) = £5 + £3, ami(h) = £5 — £3
£5 = opr(ft), apr(/i) = £5 + £1, amr{h) = £5 — £1
h = h + gs,l = I + gs,rh = rh + gs, rl = rl + gs
6.10(e3)
Implementation issues
Factors affecting the execution time of any DFT algorithm are (i) arith-
metic operations, (ii) data movement operations, and (iii) overhead opera-
tions such as bit-reversals, data swapping, and array-index updating. With
the fast execution of arithmetic operations in modern computers, all the
operations contribute significantly to the execution time of an algorithm.
For example, the 2 x 1 PM algorithm requires 4.17iVlog2 N, 4JVlog2./V,
and y log2 N operations, respectively, for the arithmetic, data movement,
Summary 149
and the array-index updating for large values of N. The last two operation
counts can be reduced by a factor of two by implementing the operations of
two consecutive stages together. This involves executing four 2 x 1 PM but-
terflies, two from each stage of a pair of adjacent stages, at the same time.
Modern arithmetic units typically have 16 or more registers. Single-stage
implementation of a 2 x 1 PM algorithm requires 7 registers whereas two-
stage implementation requires about twice as many registers. Therefore,
implementing pairs of consecutive stages concurrently results in efficient
register utilization and thereby reduces the execution time significantly.
The process of implementing the operations of two consecutive stages at a
time is almost a mandatory requirement in order to achieve a fast execution
on modern processors, since the execution is very fast once the operands
are in the registers.
In conclusion, for good performance of the algorithms, the requirements
are the availability of: (i) sufficient number of registers, (ii) a plus-minus
instruction, (iii) a multiply-add instruction, and (iv) efficient generator for
twiddle factors. Further speedup can be achieved by using one or more
hardware butterflies, or parallel processors.
6.10 Summary
References
Exercises
6.1 Derive the 2 x 1 PM DIT DFT algorithm directly from the definition,
with N = 16.
6.2 Derive the 2 x 1 PM DIF DFT algorithm directly from the definition,
with TV = 16.
6.3 Derive the 6 x 1 PM DIT DFT algorithm directly from the definition,
with N = 48.
Programming Exercises
151
152 The 2 x 2 PM DFT Algorithms
Fig. 7.1 The SFG of the butterfly of the 2 x 2 P M DIT D F T algorithm, where 0 < s <
4r. Twiddle factors are represented only by their exponents. The symbol s represents
A(l)
A(2)
A(3)
A(i)
A(5)
A(6)
%*>M7)
Fig. 7.2 The SFG of the 2 x 2 PM DIT D F T algorithm, with N = 16. Twiddle factors
are represented only by their exponents. For example, the number 4 represents W*6.
8 -1
Ap(2k) = £ W 2 p n { M n ) + W*+p*a0(n + ^))
n=0
+ W p * W4*(oo(n + £ ) + W * + p f a 0 (n + ^ ) ) } W £ * , (7.14)
o o 2
A
a
-l
Ap(2k + 1 ) = £ Wr , {(ai(n) + W2*+PTW41oi(n + £ ) )
n=0
N. jfe+p«. , 37V
+ < • WtfWftaiC" + ^ ) + W*+p * +Pi
W4V(r*+^))TOW^,(7.17)
-j)O + W2 Wlai(n+—0 2
f—I
AP(4A: + 1 ) = £ W2p"{(ai(n) + W ^ W ^ n + £ ) )
n=0
+p
+ W* • W2(ai(n +j) + wf* Wlai{n + ™))}WZWf, (7.18)
where k = 0 , 1 , . . . , y - 1.
The 2 x 2 PM DIF DFT Algorithm 157
r)
a{;+1\n) = 4 (U)+a«(/2)
r)
alr+1)(/l) = 4 (n)-aW(/2)
p) p)
4r+1)(<2) = aj (n) + w|a[ (J2)
r) r)
a^+1)(Z2) = 4 (/l)-wlot (Z2)
aW(M)Or ^ h U ^o a(r+2)(hl)
4oa(r+V(l2)
8
Fig. 7.3 The SFG of the butterfly of the 2 x 2 PM DIF DFT algorithm, where 0 < s <
y . Twiddle factors are represented only by their exponents. The symbol s represents
W
7.3 C o m p u t a t i o n a l Complexity of t h e 2 x 2 P M D F T
Algorithms
One-butterfly implementation
M = log2 N, odd: There are j - butterflies in each of the ^-^- combined
stages. Each butterfly requires 24 real multiplications and 44 real additions.
The vector formation stage requires 2N additions. The number of real
additions and multiplications required is, respectively, given as
M even: There are y butterflies in each of the ^f^- combined stages. The
vector formation and first stages require 4N additions. The number of real
additions and multiplications required is, respectively, given as
Fig. 7.4 The SFG of the 2 x 2 PM DIF DFT algorithm, with N = 16. Twiddle factors
are represented only by their exponents. For example, the number 4 represents Wf6.
Two-butterfly implementation
M odd: Each of the first special butterfly saves 20 real multiplications
and 8 real additions. The total number of such butterflies in each pair
of adjacent stages is 4° + 4 X +... +4 a" _ 1 = |(iV - 2). By subtracting
the number of operations saved from the corresponding value for the one-
butterfly implementation, the number of real additions and multiplications
required is, respectively, given as
N 8 N 20
_(33M-25) + - and -(9M-29) + -
Table 7.1 Figures of Computational Complexity for the 2 x 2 PM DFT Algorithm with
Various Number of Butterflies.
Number of multiplications | Number of additions
N 1-B_fly 2-B_fly 3-B_fly 1-B_fly 2- & 3-BJ
16 48 28 24 152 144
32 192 92 88 416 376
64 384 284 264 960 920
128 1152 732 712 2368 2200
256 2304 1884 1800 5248 5080
512 6144 4444 4360 12288 11608
1024 12288 10588 10248 26624 25944
2048 30720 23900 23560 60416 57688
4096 61440 54620 53256 129024 126296
Three-butterfly implementation
M odd: Each of the second special butterfly saves 4 real multiplications.
The total number of such butterflies in each pair of adjacent stages is 4° +
4}+... +4 a 2 = ^j(iV—8). The number of real multiplications required
is given as i V ( | M — 5) + 8. The number of real additions remains the same
as in the case of the 2-butterfly implementation.
M even: The total number of special butterflies is ^(N — 4). The number
of real multiplications is the same as in the case of M odd.
The number of each of the two operations of real multiplication and real
addition required by the 2 x 2 PM algorithms for various values of N and
for various number of butterflies is given in Table 7.1. The implementation
of the 2 x 2 PM DFT algorithms consists of a three-loop construct that is
similar to the implementation of the 2 x 1 PM DFT algorithms.
ward access of all the twiddle factors. The table size can be further reduced
using trigonometric identities to compute some of the twiddle factors. The
access of almost double the number of twiddle factors is a drawback of
this algorithm compared with the 2 x 1 PM DFT algorithms. Therefore,
this algorithm is not recommended when all the twiddle factors are com-
puted. Even when twiddle factors are stored in a table, the reduction in
execution time is not much and it comes only with doubling the size of the
twiddle factor table. Therefore, for software applications, this algorithm
is not of much advantage. The butterfly of this algorithm requires fewer
number of components and this is an advantage when the whole butterfly
is implemented in hardware, in high speed applications.
7.4 Summary
References
P r o g r a m m i n g Exercise
The algorithms for complex data can be used for real data by converting the
real numbers into complex numbers with the value of the imaginary parts
zero. Although this approach requires about double the memory and the
processing compared with more efficient approaches, we recommend this
if the speed and storage requirements are not critical as it is the simplest
approach.
In order to understand the more efficient algorithms for real data, we
have to look at the trace tables of algorithms. Figure 8.1 shows the trace
of the 2 x 1 PM DIT DFT algorithm for real input data with N = 32.
Figure 8.2 shows the trace of the 2 x 1 PM DIF IDFT algorithm for the
transform of real data, shown in Fig. 8.1. The first column values, in
Fig. 8.1, are 32 real input values. The result of vector formation and swap-
ping is shown in column two. The third, fourth, fifth, and sixth column
163
164 DFT Algorithms for Real Data - I
Fig. 8.1 The trace of the 2 x 1 P M DIT D F T algorithm for real input data, with TV = 32,
clearly showing the redundancies.
The Direct Use of an Algorithm for Complex Data 165
Fig. 8.2 The trace of the 2 x 1 P M DIF I D F T algorithm for the transform of real data,
with N = 32, clearly showing the redundancies.
166 DFT Algorithms for Real Data - I
vectors are obtained after the first, second, third, and fourth stage opera-
tions of the algorithm are carried out. The redundancies are evident. The
imaginary parts of the input are all zero. Duplication of values exists in
various stages of the algorithm. For example, the second half of the output
is redundant and, therefore, we need not compute and store these values.
In Fig. 8.2, the result of vector formation is shown in column one. The
second, third, fourth, and fifth column vectors are obtained after the first,
second, third, and fourth stage (including swapping of output vectors) op-
erations of the algorithm are carried out. The output values have to be
divided by the length, N = 32, to get back the input values shown in
Fig. 8.1. Note that the output values are not precise. For example, the
first value is 32.02 instead of 32 because we input the DFT values with
only a precision of 2 digits after the decimal point. The second half of
the input vectors is redundant. The output of the various stages exhibits
symmetry. The imaginary parts of the output values are zero.
The redundancies can be eliminated by: (i) packing the real data to
form complex data or (ii) cutting out the redundancies in each stage of the
algorithm. The first approach is described in this chapter and the second
approach is presented in the next chapter.
Since x(n) and y(n) are real sequences, due to the hermitian-symmetric
Computation of the DFTs of Two Real Data Sets at a Time 167
(start}
Read x(n),y(n), n = 0 , 1 , . . . , N — 1
i
Form c(n) = x(n) + jy{n), n = 0 , 1 , . . . , N — 1
X
Compute C(k) = DFT(c(n))
X
X(0) = R e ( C ( 0 ) ) , X ( £ ) = R e ( C ( f ) )
Y(0) = Im(C(0)),Y(f) = I m ( C ( f ) )
*
Compute
C(k)+C*(N-k) y ^ _ C(k)-C'(N-k) _
X(k) = h
= 1,2,.. • , N2 - 1
X
Write JST(fc),y(fc), A; = 0 , 1 , . . . ,TV
±
( Return)
Fig. 8.3 Theflowchart of the algorithm to compute two RDFTs, each of length N, at
the same time using a DFT algorithm for the same data length.
C(N-k) = X*(k)+jY*(k)
C*(N-k)=X(k)-jY(k)
X(k) = C{k)+C^N-k)
(8.1)
Yft) = g(fc)-C"CAr-fc)
The flow chart of the algorithm to compute RDFT, for an even N, is shown
in Fig. 8.3. Only half of the DFT values are computed since each DFT is
hermitian-symmetric.
168 DFT Algorithms for Real Data - I
(start)
C(0) = X(0)+jY(0),C(f)
± = X(f) + jY(£)
X
Form C(k) = X{k) + jY(k),
C(N -k) = X*(k) + jY* (k), k = 1,2,..., f - 1
X
Compute c(n) = IDFT(C(fc))
±
Form x(n) = Re(c(n)), j/(n) = Im(c(n)), n = 0 , 1 , . . . , iV - 1
Write x(n),y(n),
Xn = 0,l,...,N -1
TReturnJ
Fig. 8.4 The flow chart of the algorithm to compute two RIDFTs, each of length N, at
the same time using an IDFT algorithm for the same data length.
X(0) Re(C(0)) 11
X(l) (-3+jlH(-l-J3) -2-jl
X(2) Re(C(2)) 1
X(3) X*(l) -2+jl
Computation of the DFT of a Single Real Data Set 169
Y(0) = Im(C(0)) = 7
y(i) = (-3+ii)-(-i-J3) = 2 + j l
y(2) = Im(C(2)) = 1
y(3) = y*(i) = 2-ji
To compute the RIDFT, X(fc)+.7 Y(fc) is formed and the IDFT is computed.
The result gives x(n) as the real part and y(n) as the imaginary part. For
this example, X{k)+jY(k) = {11+j7,-3+jl,l+jl,-l+j3}. The IDFT
of this sequence yields x(n) + jy(n) = {2 + j3,3 + jl, 4 + j l , 2 + j 2 } . I
The number of real additions required to separate the two DFTs is
2N — 4. Therefore, for computing an JV-point RDFT, the number of op-
erations required is N — 2 more than one-half of that of the algorithm for
complex data used.
In this method of computing the RDFT, the redundancy is removed by: (i)
computing the DFTs of even and odd indexed input values using a single
DFT algorithm for half data length rather than two, as in the case of the
algorithm for complex data with zero imaginary parts and (ii) computing
only half of the DFT values in combining the two smaller DFTs.
Let x(n) be the data set with N real values whose DFT, X(k), is to be
computed. Leta;( e )(n) = x(2n) anda;(°)(n) = x(2n + l),n = 0 , 1 , . . . , f - 1 .
Let X<e)(fc) and X^ik) be their respective DFTs. Then,
As described in the last section, X^(k) and X^(k) can be computed using
a single DFT algorithm for data length —. The DFTs can be combined
to get X(k) = X^(k) + W#X(°)(fc). The flow chart of the algorithm
to compute RDFT, for N an integral multiple of 8, is shown in Fig. 8.5.
It can be modified for any even N. This flow chart shows how we can
implement this algorithm with minimum arithmetic operations and twiddle
factor access. Note that, in merging the DFTs of the even and odd indexed
data, only half the number of multiplications shown in Fig. 8.5 are actually
required.
In computing the RIDFT, the redundancy is removed by: (i) computing
only half of the input values for the two independent IDFTs computing the
170 DFT Algorithms for Real Data - I
(start)
^r^
Read real x(n), n = 0,1,...,N — 1
•
Form c(n) = x(2n) + jx(2n + 1), n = 0 , 1 , . . . , ^ - 1
I
Compute C{k) = DFT (c(n))
I
XW(0) = Re(C(0)),XW(f) = Re(C(f))
XW(Q) = Im(C(0)),X(°)(g) = Im(C(f))
C
Compute xM(fc) = ^+C;^-*>,
X 0 ( f c ) = g(fc)-^(f-fc) !
( ) fc==i)2,...,f -1
N
X(£ + fc) = X' { 4 - * ) - jW#X* v 4
-k), fc = 1,2,. •• > 8
-1
Write X(k), k =
I 0,l,...,f
(Return)
Fig. 8.5 The flow chart of the algorithm to compute a R D F T of length N using a D F T
algorithm for half data length.
Computation of the DFT of a Single Real Data Set 171
even and odd indexed data values and (ii) computing the two IDFTs in a
single IDFT algorithm for half data length, as described in the last section.
Given X(k), we have
X{k) = X(e\k) + WJt,X(°\k)
X{j + k) = XM(k)-Wkx(°\k)
Since the DFT of real data is hermitian-symmetric, the last equation can
be written as
(start)
ReadX(fc), fc = 0 , l , . . . , f
X(e)(0) =
I
X(0)+X(f))X(o)(0) = X(0)-X(f);
Write x(n), n = 0 , 1 , . . . , AT - 1
( Return)
Fig. 8.6 The flow chart of the algorithm to compute a RIDFT of length AT using an
IDFT algorithm for half data length.
Summary 173
X( e )(0) = iMi = 1 1
X(e)(l) = (0.12-jl.71)+(-4.12-j0.29) _ _2 - j l
XW(2) = Re(i(f)) = 1
lW(3) = X<e\l) = -2 + jl
X(°)(0) = ±t! = 7
X(°)(l) = (0-H-Jl-71?-(-4.12-j0.29)^(1+jl) = g+ ^
XW(2) = -Im(X(f)) = 1
XW(3) = X*(°)(l) = 2 - j l
X^(k) +jX^(k) is formed and the IDFT is computed. The result gives
x^ (n) as the real part and x^ (n) as the imaginary part. For this example,
8.4 Summary
• The second method involves the indirect use of algorithms for com-
plex data. The first type of algorithm is to compute two RDFTs or
RIDFTs at a time using a single algorithm for complex data for the
same data length. The second type of algorithm is to compute a
single RDFT or RIDFT using a single algorithm for complex data
for half the data length.
• By using appropriate PM algorithms for complex data, efficient
algorithms for real data when the number of samples is not an
integral power of 2 can be realized.
• An alternative, which is described in the next chapter, is to deduce
algorithms specifically suited for real data from the algorithms for
complex data by cutting out the redundancies in each stage.
Reference
(1) Brigham, E. 0 . (1988) The Fast Fourier Transform and Its Appli-
cations, Prentice-Hall, New Jersey.
P r o g r a m m i n g Exercises
8.1 Write a program to compute two iV-point RDFTs at a time using the
Appoint 2 x 1 PM DIT DFT algorithm for complex data.
8.2 Write a program to compute two AT-point RIDFTs at a time using the
Appoint 2 x 1 PM DIT DFT algorithm for complex data.
9.1 T h e Storage of D a t a in P M R D F T a n d R I D F T
Algorithms
175
176 DFT Algorithms for Real Data - II
B'(0) = { B ( 0 ) , B ( f ) }
= { ( X ( 0 ) + X ( f ),X(0)-X(f ) ) , ( 2 R e ( X ( f )),2Im(X(£)))} (9.3)
B'(fc) = B(fc) = {(X(k) + X(k + f ) ) , (X(k) - X(k + f ) ) } ,
where k = 1,2,..., f - 1.
b'(n) = {b(n),b(n + ^ ) }
iV AT 37V
= {(x(n),x(n + -)), (x(n + -),x{n + ~^))}, (9.4)
where n = 0 , 1 , . . . , ^ — 1.
The index k runs only from 1 to y — 1, since we need only half of the DFT
values and p = 0,1 (The computation of the output vectors with indices 0,
Y, and ^ is a special case that will be explained later.).
In order to obtain the first half output vectors as defined in Eq. (9.2),
the second quarter vectors are derived from the third quarter vectors using
the conjugate symmetry property as
N N 3N N N N N
-£) = {X(k+j),x(k+^)} = {X(^-C--k)),x(-H--
The 2 x 1 PM DIT RDFT Algorithm 177
TV N SN N N N N
Ap(^-k) = {X(^-k),X(^-k)} = {XQ-Q+k)),X(-+(--k))}
Therefore, Eqs. (9.5) and (9.6), for the vectors defined in Eq. (9.2), can be
expressed as
h = imod2r'2, i = 0,1,..., f - 1
s = 2m~rh
r 1 (9.10)
11 = 2~ - h
1
I = h + T-
The computation and storing of A' (^ — k) in the last stage will erase some
of the input values for the computation of the butterfly indexed ^- — k.
Therefore, two butterflies with indices A; and y — k must be computed at
the same time in the algorithm implementation. The input values for the
computation of the butterfly indexed y — k can be temporarily stored in
the processor registers. A similar procedure is followed in implementing the
other stages.
For example, with N = 32, there are 4 stages specified as r = 1,2,3,
and 4. Four butterflies make up a stage. Indices h, I and 11, and the twiddle
factor exponent s for each group of butterflies are given, respectively, by
(h = i mod 2 r - 2 , {i = 0,1,2,3)), I = h+2r~2,11 = 2r~1-h, and s = 2l'rh.
Fig. 9.2 shows the SFG of the 2 x 1PM DIT RDFT algorithm, with N = 32.
Special butterflies
Unlike in the algorithms for complex data, the data values at one end of an
algorithm for real data is real and it is mostly complex at the other end.
This lack of symmetry of the data forces the use of special butterflies, the
/ - and g-butterflies, those are specific for the algorithms of real data. These
butterflies process data values that may be pure real, pure imaginary, or
complex. The input/output relationship of an /-butterfly is as follows. Let
The 2 x 1 PM DIT RDFT Algorithm 179
Fig. 9.2 The SFG of the 2 x 1 PM DIT R D F T algorithm, with N = 32. Twiddle factors
are represented only by their exponents. For example, the number 4 represents W£2.
Ar^+1\h) = A4rHh)+ArSrHl)
Ar$r){h)-Ar$r){l)
r+1) r+1)
Ar'{ (h)+jAi'} (h) = Atf\h)-jAi$r\l)
r r
4r+1\D = 4 \h)r + Wi4 r\l)
4r+1\i) = A'± \h)-WZA'{ \l)
This butterfly requires 2 operations of real multiplication and 8 operations
of real addition. The g-butterfly carries out the same processing, but with
reduced computation, that is carried out in the first and the middle but-
terflies of each group of butterflies, from the second stage onwards, in the
corresponding algorithm for complex data.
The software implementation of the PM RDFT algorithms is similar to
that of the PM DIT DFT algorithms for complex data with the differences
as explained above. A faster version can be obtained by implementing two
adjacent stages at a time. The number of real multiplications required by
an RDFT algorithm is one-half and that of additions is N — 2 fewer than
one-half of that of the corresponding algorithm for complex data.
Example 9.1 A trace table of the algorithm, shown in Fig. 9.2, is shown
in Fig. 9.3. The first column shows how the 32 real data values are read into
the storage locations of 8 vectors each consisting of two complex elements.
When a value is pure real, it is shown separately with the use of a vertical
line. The second column shows the values after vectors have been formed
and swapped. The third, fourth, fifth, and sixth columns show the values,
respectively, after the first, second, third, and fourth stage operations of the
algorithm are carried out. Compare this table with that given in Fig. 8.1
to find out how redundancy at each stage is eliminated. I
While the DFT of real data is hermitian-symmetric, the data itself is usu-
ally arbitrary. Therefore, it is relatively easier to eliminate the redundancies
starting from the DFT side of the SFG of the algorithm of complex data.
That is the reason we used the DIT approach to derive the RDFT algo-
rithm and we are going to use the DIF approach for deriving the RIDFT
algorithm.
The 2 x 1 PM DIF RIDFT Algorithm
bp(2n + l) = ^^{-l^W^iBiW
fc=0
+ (-l)"+^{j)Bi{k+^)}Wsnk, (9-12)
4 2
N N 37V N 3N
B9Q-k) = {X(j-k) +X(^--k),X(J-k)-X(—-k)}
N N N N
= {X(j-(j + k)) + X(- + (--k)),
N N N N
X(j - (j + *)) - X{- + (-- k))} (9.14)
Thus, from Eqs. (9.13) and (9.14), the relation between the third quarter
and the second quarter input vectors is given by
N N N *
Bq{~J +k) = {B0(- - k), - B i ( T - *)} • (9-15)
' l+k) = {B0C--k),-B1(j-^*
The 2 x 1 PM DIF RIDFT Algorithm 183
-*-T
Fig. 9.4 The SFG of the butterfly of the 2 x 1 PM DIF R I D F T algorithm, where
1 < s < 4r. Twiddle factors are represented only by their exponents. The symbol - s
represents W^'.
b
pi2n) = jj E ("1)Pfc{^o(fc) + ( - l ) " + ^ ( 5 0 ( f - fc))*}WV**(9.16)
*=o
&p(2n + l) = i £ ( - l ) * * W t f { i ? i ( * )
fc=0
h = imod2ro-r-1, i = 0,1,..., f - 1
S T lh
= ~ (9 19)
I = h+ 2m-r-1
For example, with N = 32, there are 4 stages specified as r = 1,2,3, and
4. Four butterflies make up a stage. Indices h, I, and 11, and the twiddle
factor exponent s of each group of butterflies are given, respectively, by
h = i mod 2 3 - r (i = 0,1,2,3), / = h + 23~r, 11 = 24~r - h, and s = 2r~1h.
The SFG of the 2 x 1 PM DIF RIDFT algorithm, with N = 32, is shown
in Fig. 9.5.
Special butterflies
The input/output relationship of a p-butterfly is as follows. LetB'W(/i) =
{(Br$rHh),B4r\h)),(Br'{r)(h),Bi'ir\h))} and B'W(/) = {Br$r\l) +
r) {r) r)
jB4 (1),Br[ (I) + jBif (I)}. Then,
Note that Bi'£r+1\h) and Bi'{r+1'(l) are pure imaginary and the rest of
the values are pure real. The p-butterfly requires 2 operations of real mul-
tiplication and 8 operations of real addition. It should be noted that all
The 2 x 1 PM DIF RIDFT Algorithm 185
Fig. 9.5 The SFG of the 2 x 1 PM DIF RIDFT algorithm, with N = 32. Twiddle
factors are represented only by their exponents. For example, the number —4 represents
Fig. 9.6 The trace of the 2 x 1 PM DIF RIDFT algorithm, with N = 32.
© A'(r+V(l3)
A'(r+2\h2)
Fig. 9.7 The SFG of the butterfly of the 2 x 2 PM DIT RDFT algorithm, where 1 < s <
j ^ . Twiddle factors are represented only by their exponents. The symbol s represents
W*.
butterflies are used to form the second stage (the first stage always consists
of /-butterflies). The expressions for the twiddle factor exponent and the
indices of the nodes of each group of butterflies are given, for the last m — 3
stages for an odd m and for the last m — 2 stages for an even m, as follows
(The butterflies of the first three stages for an odd m and the first two
stages for an even m, and the first butterfly of each group of butterflies of
the other stages are special cases and they will be explained later.).
ftO = imod2r-3, » = 0 , 1 , . . . , ^
s = 2m~rh0
hi = hQ+l(2r'3)
hi = hO + 2(2 r - 3 ) (9.21)
h3 = hO + 3(2 r - 3 )
13 = 2 ' - 1 - hO
11 = 13 - 2(2 r - 3 ),
where r is the stage number of the second of the two adjacent stages com-
bined.
To illustrate the SFG of the algorithm, consider a specific case with
N = 32. There are 4 stages specified as r = 1,2,3, and 4. Two butterflies
make up two adjacent stages. The indices of the nodes of the butterfly and
the twiddle factor exponent s can be readily computed from Eq. (9.21) for
the specific value m = 4. Fig. 9.8 shows the SFG of the 2 x 2 PM DIT
RDFT algorithm, with N = 32.
The 2 x 2 PM DIT RDFT Algorithm 189
a'(4)o •-oA'(l)
a'(2) o - ^ >
a'(6) o - - U
a'(l)o •* » o
a'(5)c
o'(3)o
a'(7)o
Fig. 9.8 The SFG of the 2 x 2 P M DIT R D F T algorithm, with N = 32. Twiddle factors
are represented only by their exponents. For example, the number 4 represents W£2.
Special butterflies
The /-butterfly used in processing the first stage is identical to that in the
2 x 1 PM DIT RDFT algorithm. However, one 5-butterfly, out of a group
of three ^-butterflies and one regular butterfly, is different from that of the
2 x 1 PM DIT RDFT algorithm. The difference in this 5-butterfly is due to
the merging of the twiddle factors of the regular butterfly with its twiddle
factor W£ . This results in the multiplication of the inputs to the lower
output node of this butterfly by Wtf and W^6, respectively. The output
vector at the lower node of this type of ^-butterfly is computed as follows.
A'(r+1)
^0
A'lr+1\l) = Wl,A'{r\h)-W*%A^\l)
190 DFT Algorithms for Real Data - II
j'(r+l)
B'^'ihO) B'o (hO) + (B'^(l3))*
?'(r+l)
B'^'ihO) = p)
B'o ( W ) ) - ( i # ( J 3 ) ) *
r+1
B$ \h2) = B[ (hO)-W-^(B'1ir\l3))*
B'} r+1
\h2) = Bi (hO) + W~f(B'1{r\l3))*
B'Q{r+1)(ll) = B'0 (ll) + (B$r\h2))*
B?r+1\ll) = B'o (U)-(itf p ) (/i2))*
r
B'0(r+1)(l3) = B[ (ll)-W-*(B? \h2))*
B?r+1)(l3) = B[ (Zl) + ^ ^ " ( B ; W ( / i 2 ) ) *
(9.22)
j'(r+2) (
B'^'ihO) B'„ r+l) (hO) + (B'0(r+1\ll))*
J3° (p+2) (W)) = B'Jr+1)(hO)-(B'0{r+1\ll)y
- 2 8 - * Z8 V(r+1)
(r+l,,
< + 2 ) (w) W^'B[(r+1){hO) - W- ~(B[ (ll))
j'(H-2)
(r+i -2s D'(r+1) (ho) + 2s (r+1,
B[ >(hl) = W^'B'i wN -* (B[ (ll)Y
B'0{r+2\h2) W^B$r+1)(h2) + W^+%(B'0{r+1)(l3))
8+ L,
B '(r+2) (h2) = W^B^>(h2) w~ ^(BT m)
B'0{r+2\h3) = s
W^ B'} r+1)
(h2)-W-38-^(B'}r+1)(l3))*
{r+2 3 r+1 -3s-* D'(r+1),
(r+1
B[ >(h3) = Wj 'B? \h2) + W-''--*{B' l >(l3))*,
^ M _ o B^)(/l0)
J * B'(r+2)(W)
B'^ +2 )(/i2)
B'W(ft2)o
Fig. 9.9 The SFG of the butterfly of the 2 x 2 P M DIF R I D F T algorithm, where
1 < s < jg. Twiddle factors are represented only by their exponents. The symbol —s
represents W^3 •
ftO = i mod 2 m - r - 2 , = 0 1 2- - 1
s = 2 r - 1 M)
h\ = M + l(2m-r-2)
Kl = h0 + 2(2 m " r - 2 ) (9.23)
hZ = hO + 3 ( 2 m - r - 2 )
IZ = 2 m ~ r - hO
11 = 13- 2 ( 2 m - ' - 2 ) ,
where r is the stage number of the first of the two adjacent stages combined.
To illustrate the SFG of the algorithm, consider a specific case with
N = 32. There are 4 stages specified as r = 1,2,3, and 4. Two butterflies
make up two adjacent stages. The indices of the nodes of the butterfly and
192 DFT Algorithms for Real Data - //
Fig. 9.10 The SFG of the 2 x 2 PM DIF RIDFT algorithm, with JV = 32. Twiddle
factors are represented only by their exponents. For example, the number —4 represents
the twiddle factor exponent s can be computed readily from Eq. (9.23) for
the specific value m = 4. Figure 9.10 shows the SFG of the 2 x 2 PM DIF
RIDFT algorithm, with JV = 32.
Special butterflies
The /-butterfly used in processing the last stage is identical to that of the
2 x 1 PM DIF RIDFT algorithm. However, one ^-butterfly, out of a group
of three (/-butterflies and one regular butterfly, is different from that of the
2 x 1 PM DIF RIDFT algorithm. The difference in this (/-butterfly is due
to the merging of the twiddle factor of the regular butterfly with its twiddle
factor WN 8 . This results in the multiplication of the inputs to the lower
— M. 31V
input node of this butterfly by WN16 and WN ie
, respectively. The output
Summary and Discussion 193
tr + jti = 2Wrt1{B4r)(l)+jB4r\l))
sr+jsi = >/2Wtf(Br;(r)(/)+j£»i(r)(0)
Then,
References
Programming Exercises
The theory of 2-D signals, for the most part, is a straightforward extension
of the theory of 1-D signals. In this chapter, we refer to the spatial time-
domain 2-D discrete signal as image. In Sec. 10.1, the definitions of 2-D
DFT and IDFT are given. In Sec. 10.2, the physical interpretation of
2-D DFT is presented. The DFT of some simple 2-D signals are derived
analytically. In Sec. 10.3, the row-column approach of computing the 2-D
DFT is described. The properties and theorems of 2-D DFT are presented
in Sec. 10.4. The 2-D PM DFT algorithms are developed in Sec. 10.5.
The 2-D DFT of an iV x JV image (for simplicity, we assume that, unless oth-
erwise stated, the dimensions are the same in the two directions) {x(ni, n 2 ),
n i , n 2 = 0 , 1 , . . . , N — 1} is defined as
JV-l N-l
.. N-l N-l
195
196 Two-Dimensional Discrete Fourier Transform
X(kuk2) = £ E <riun2)W^W^k\
« ! = - « - 712
N N N
-, ,
*(m,n2) = 4 E E ^i-M^"1*1^"2*2,
«1——"2" «2 ——"2"
N N , N n
n1,n2 = - T , - y + l,...,y-l
Getting one format from the other involves the swapping of the quadrants
of the image or the spectrum.
_ 1
* 27T
+ 2 J2 (l*(*i.O)| cos(— mfci + Z(X(fc!,0)))
2
27T
+ 2^ (|X(0,fc 2 )| cos( — n2fc2 + Z(X(0, fe)))
fe2=i
N
y N 2ir N N
+ 2 ^ ( | X ( Y , f c 2 ) | c o s ( - ( n 1 - + n2fc2) + Z(X(-,fe 2 )))
fc2=i
o o
X= 1 and
X(k1,k2)= ^2 53 S(ni,n2)<$l
m=0n 2 =0
Since the impulse signal is zero except with n\ = 0 and n 2 = 0, for all
&i,fc2, the DFT coefficient is unity.
x{ rc,,n2) X(kufa)
1 000 1111
0000 1111
0 0 0 0 t> 1 1 1 1
0000 1111
(a) (b)
X(h 7*2) x(ni,n2) X (* ,fc 2 ) s(ni,n2)
1-H
rH
rH
1000 1 0010 1 -1 1 -1
1-H
0000 11 1 0000 1 -1 1 -1
w
0 0 0 0 *>TS 1 1 1 1 0000 16 1 -1 1 -1
000 0 11 1 0000 1 -1 1 -1
h-i
000 0 0 1 0 1 1 0 -1 0
000 0 1 -1 -1 -1 -1 0 00 0 1 0 -1 0
1 00 0 <$ 16 1 1 1 1 0 00 0 <S> 1 0 -1 0
000 0 -1 -1 -1 -1 0 00 0 1 0 -1 0
(g) (h) (i) (j)
1 1 1 1 -1 -1
1-H
1-H
00 0 0 0 000
1 0 0 0 0 0 0 0 0 000 -1 1 -1 1
W w
00 0 0 8 -1 -1 -1 -1 0 01 0 16 1 -1 1 -1
1 0 0 0 0 0 0 0 0 000 -1 1 -1 1
(k) (1) (m) (n)
0 000 1 0 -1 0 0 000 1 0 -1 0
1 0 -1 1 00
1-H
0 00 1 1 0 0 1 0 -1 0
0 0 0 0 <S> 8 -1 0 1 0 0 0 0 0 <£> 8 -1 0 1 0
0 1 00 0 -1 0 1 0 001 0 1 0 -1
(o) (p) (q) (r)
rH
T
0 000 1 -1 0 000 1 0 -1 0
-1 0 1 0
rH
0 0 0 0 0 0 0 0 000
0 0 0 0 <$ -1 1 -1 1 0 1 0 1 <£> 1 0 -1 0
000 -1 0 1 0
rH
0 0 0 0 0 0 0 0
(s) (t) (u) (v)
Fig. 10.1 (a) The 4 x 4 2-D impulse signal, (b) The DFT of the impulse, (c), (e), (g),
(i), (k), (m), (o), (q), (s) and (u) are DFT coefficients of the impulse and (d), (f), (h),
0)i (')> (n)> (P)> (r)> M a n ^ (v)> respectively, are the corresponding sinusoidal surfaces.
DFT Representation of Some 2-D Signals 199
We can find the real sinusoidal surfaces that constitute the impulse signal
using this equation or Eq. (10.3) with N = 4. Each separate frequency
coefficient or a pair and the corresponding sinusoidal surface are shown in
Figs. 10.1(c) to (v).
Figure 10.1(c) shows X(0,0) = 1 and the corresponding surface is the dc
component having sample value i - at all points, shown in Fig. 10.1(d).
Figure 10.1(e) shows X(0,2) = 1 and the corresponding surface is ^ cos(7rn2),
shown in Fig. 10.1(f). This is a stack, in the vertical direction, of four co-
sine waveforms with frequency index two.
Figure 10.1(k) shows X(1,0) = 1,X(3,0) = 1 and the corresponding sur-
face is | c o s ( f n i ) , shown in Fig. 10.1(1). This is a stack, in the horizontal
direction, of four cosine waveforms with frequency index one.
Figure 10.1(o) shows X ( l , 3 ) = 1,X(3,1) = 1 and the corresponding sur-
face is | c o s ( | ( n i + 3n 2 )), shown in Fig. 10.1(p). This is a stack, in the
horizontal direction, of four cosine waveforms with frequency index one
with a shift of §3n 2 .
Figure 10.1(s) shows X(l, 2) = 1, X(3,2) = 1 and the corresponding surface
is | c o s ( | ( n i + 2n 2 )), shown in Fig. 10.1(t). This is a stack, in the hor-
izontal direction, of four cosine waveforms with frequency index one with
a shift of |2n2- The other sinusoidal surfaces, shown in Fig. 10.1, can be
identified similarly. I
The DFT of z ( m , n 2 ) = e ^ i n i + m " 2 \ n i , n 2 = 0 , 1 , . . . , TV - 1, where I
and m are positive integers, is similar to that of the 1-D complex sinusoids.
ej^(ln1+mn,) ^ ^ 2 ^ _ j ^ _ m )
With 0 = 0,
cos(^(ln1 + mn2))<^^-(d(ki-l,k2-m) + 6{k1-(N-l),k2-(N-m))).
With0 = -f,
sin(^(Zm+mn 2 )) <S> ^-(-jS(k1-l,k2-m)+j6{k1-{N-l),k2-{N-m))).
Example 10.2 Consider the 64x64 sinusoidal surface shown in Fig. 10.2(a)
and its DFT shown in Fig. 10.2(b). The coefficients X(0,1) = O-j'2048 and
X(0,63) = 0+J2048 represent a stack, along the ni direction, of 64 shifted
(with zero shift) sine waveforms with frequency index one and amplitude
one, resulting in the sinusoidal surface, x{n\,n2) = sin(|yn 2 ). An alternate
view of a sinusoidal surface is of a plane wave with frequency \f{u\ + w2)
in the direction 6 = t a n - 1 ^ to the n\ axis. The sinusoidal surface shown
in Fig. 10.2(a) is a plane wave with frequency | f radians per sample in the
direction 90 degrees to the n\ axis.
Consider the sinusoidal surface shown in Fig. 10.2(c) and its DFT shown
in Fig. 10.2(d). The coefficients X ( l , l ) = 0 - j'2048 and X(63,63) =
0 + j'2048 represent a stack, in the n2 direction, of 64 phase shifted sine
waves, s i n ( | j n i ) , (with | f n 2 radians shift) with frequency index one and
amplitude one, resulting in the sinusoidal surface, x(ni,n2) = s i n ( | j n i +
|j7i2). This sinusoidal surface is a plane wave with frequency 2 ^ 2 radians
per sample in the direction 45 degrees to the n\ axis.
Consider the sinusoidal surface shown in Fig. 10.2(e) and its DFT shown
in Fig. 10.2(f). The coefficients X(2,1) = 1448.2-J1448.2 and X(62,63) =
1448.2 + j'1448.2 represent a stack, in the n2 direction, of 64 phase shifted
cosine waves, c o s ( | | 2 n i ) , (with (§fn 2 — j) radians shift) with frequency in-
dex two and amplitude one, resulting in the sinusoidal surface, x(ni,n2) =
cos(|^2ni + | f n2 — \). This sinusoidal surface is a plane wave with fre-
quency 2sxl radians per sample in the direction t a n - 1 \ = 26.565 degrees
to the ni axis. I
63 [ »X(0,63) = 0+/2048
« 0
-1
32 1 f»X(0,l) = 0-;2048
32
", ° 0 60
(a) (b)
1 \ •X(l,l) = 0-;2048
1 63
(c) (d)
63 | X(62,63) = 1448.2+/1448.2
1 f •X(2,l)= 1448.2-;1448.2
62
(•) (f)
Fig. 10.2 (a) The 2-D sinusoid 1(111,712) = s i n ( | | r i 2 ) . (b) The D F T of the signal shown
in (a), (c) The 2-D sinusoid 1(711,712) = s i n ( | | n i + §Jri2). (d) The D F T of the signal
shown in (c). (e) The 2-D sinusoid x ( n i , n 2 ) = c o s ( | f 2ni + | j n 2 - \). (f) The D F T
of the signal shown in (e).
202 Two-Dimensional Discrete Fourier Transform
versa. This method is called the row-column method. Equation (10.1) can
be rewritten in two different forms as
JV-l J V - l
X(kuk2) = X^E^'^TO1*1}^*' (10.4)
n2=0 m = 0
JV-l JV-l
X(h,k2) = J2{T, ^ ^ N2k2}WNkl
x n W
(10-5)
ni=0 712=0
The expression inside the braces is 1-D DFT of each column in Eq. (10.4)
and of each row in Eq. (10.5). The DFT of the N xN matrix x(rii, n2) can
be computed in two stages. One way is to compute the 1-D DFT of each
column of the matrix to get
JV-l
X(h,n2)= ^2 x(ni,n2)W^k\ kltTi2 = 0,l,...,N-l
ni=0
Then, compute the 1-D DFT of each row of the resulting matrix to get
JV-l
X(h,k2)= J2x(kuri2)W^k\ k1,k2 = 0,l,-..,N-l
712=0
Just by decomposing the problem into 2JV 1-D DFTs, the computational
complexity of 2-D DFT has been reduced to 0(N3).
Example 10.3 Compute the 2-D DFT of the following matrix of data
using the row-column method.
n2 ->
2 1 4 3"
1 0 2 2
3 1 0 1
2 0 1 3 .
Compute the IDFT of the transform to get back the original image.
Solution
As the kernel is separable and symmetric, Eq. (10.1) can be written in
Computation of the 2-D DFT 203
ix form as
26 l+j'7 4 1-J'7
5 + jl -6+j4 1-J'l - 4 + jO
4 1-J3 2 1+J3
5-jl -4-jO 1+jl - 6 - j4
The original image can be obtained by computing row and column 1-D
IDFTs of the transform matrix and vice versa. Note that the kernel matri-
ces of the IDFT are the same as those of the DFT with the difference that
each matrix is to be conjugated. However, similar to the case of computing
the 1-D IDFT, the 2-D IDFT can be obtained using the DFT simply by
swapping the real and imaginary parts in reading the input and writing the
output values. The DFT after swapping the real and imaginary parts is
given by
0 + J26 7 + jl 0 + j4 - 7 + j l
1+J5 4-j6 -1+jl 0-j4
O+j/4 -3 + jl 0+j2 3 + jl
-1+J5 0-J4 1 + j l - 4 - j6
204 Two-Dimensional Discrete Fourier Transform
These values divided by iV2 = 16 and swapping the real and imaginary
parts yield the input image.
It can be easily seen that the ratio between the smallest and largest coeffi-
cient has been reduced.
Properties of the 2-D DFT 205
Linearity
The DFT of a linear combination of a set of discrete images is equal to
the same linear combination of the individual DFTs of the images. Let
xi{ni,n2) <$ Xi(ki,k2) and £ 2 (ni,n 2 ) <$ X2(ki,k2). Then,
where a and 6 are real or complex constants. It is assumed that the images
have same dimensions. If it is not so, sufficient zero padding must be done.
Linearity holds in both the spatial time- and frequency-domains.
Example 10.4 Compute the DFT of the first two images. Using the
DFTs obtained, deduce the DFT of the third image by applying the linear-
ity property.
X\ (ni,n 2 ) = x^ (ni,n 2 ) x3(ni,n2) =
1 2 ' " 4 1 ' ' 1 + J 4 2 + jl'
3 4 2 3 1 . 3 + J 2 4 + j'i1
The indiviclual DF I s are
13 - 2 " 10 2 '
X i ( * i J c2) = ,X2(ku k2) =
4 0 0 4
The DFT of X3(ni,n 2 ) = xi(ni,n2) + jx2(ni,n2) is
Periodicity
The 2-D DFT of an N x N image and the IDFT of its spectrum are as-
sumed periodic in both the horizontal and vertical directions with period
N. The right and left edges, and the top and bottom edges of an image
are considered adjacent. This follows from the definition of DFT and IDFT
since the discrete complex exponential is periodic.
3 2 1 4
2 1 0 2
2 j ( 7 i i , n 2 - 1) = <$
1 3 1 0
3 2 0 1
26 7-jl -4 7+ jl
k 5 + jl 4 + j6 - 1 + j'l 0-J4
(-j) *X(kuk2) =
4 -3-jl -2 -3 + j l
5-jl 0+j4 - 1 - j l 4-j6
2 1 + J3 4 1-J3
- 6 - jl 5-jl -4
X(fci-2,*2-2) = +n4 26
1-J7 1+J7
-jl -4 5 + jl -6+>4
Reversal property
Let ar(ni,n 2 ) <3> X(fci, fc2). Then, a r ( i V - n u N - n 2 ) <£> X(N-kuN-k2).
' 2 3 4 1 "
2 3 1 0
n2) - >£>
3 1 0 1
. 1 2 2 0 .
26 i-i7 4 1+J7
5-jl - 6 - j4 l+jl - 4 + jO
•Y(4-fci,4-*2)
4 l+j'3 2 1-J3
5 + jl - 4 - JO 1-jl -6+j4
Symmetry
Similar to the 1-D case, the DFT of a real 2-D data is conjugate-symmetric.
The DFT values at diametrically opposite points form complex conjugate
pairs.
X*{N-k1,N-k2) = X{kuk2)
N N * N
X(-±k1,-±k2) = X*(-Tk1,- ~2 + k2)
Since the spectrum of a real image is conjugate-symmetric, half of the
spectral values are redundant.
Example 10.8 Underline the left half of the non-redundant DFT values
of the example image.
208 Two-Dimensional Discrete Fourier Transform
Solution
*1
26
1 + J7 4 1-J7
1 5 + j l - 6 + j4 i - i i - 4 + jO
4 1-J3 2 1+J3
L 5-jl - 4 - j O 1 + j l - 6 -J4
Complex conjugates
Let x(nun2) •£> X(k1,k2). Then, x*(n1,n2) <& X*(N -ki,N - k2) and
x*(N-m,N- n2) O X*(kuk2).
7V-1 N-l
y(ni,n2) = E ^2 x(mi,m2)h{ni-mi,n2-m2)
m i = 0 7712=0
N-l N-l
= E E h(mi,m2)x(n\ —m\,n2 — m2),
7711=0 7712 = 0
1 N-I N-i
y{nun2) = T ^ E E X{kuk2)H{kuk2)W^W^k*
kl = 0 * 2 = 0
Properties of the 2-D DFT 209
Substituting the corresponding DFT expressions for X(ki, k2) and H(ki, k2),
we get
y(nun2) = ^ £ £ ^ £ E ^ ^ W * 1 ^ * 2 }
fci=0fc2=0 mi=0roj=0
JV-l JV-l
x{j2 E M'i,/2)^ fci t< 2 * 2 }^ nifci w-" 2 * 2
l1=0h=0
-. JV-l JV-l N-1N-1
= w E E E Eaf(mi'maWi'Z2)
m i = 0 m 2 = 0 (i=0 '2=0
jv-i Jv-i
V~* V~~* TT^(ii + mi-ni)*iTi^((2+m2-n 2 )fc2
kl =0*2=0
JV-l JV-l
x m
y(ni,ri2) = £ E i i>m2:)h{ni—mi,n2 — m2)
7711=0 7712=0
JV-l JV-l
x
x(ni,n2)h(ni,n2) <£> j= E ^2 {™1,m2)H{ki - mi,k2 - m2)
7711=0 7712=0
JV-l JV-l
Vxh{ni,n2) = £ y^ ar*(mi,m2)/i(ni+mi,n2+m2)
7711=0 7712=0
•»x*(*i,* 2 )ir(*i,fc2)
N-l JV-1
x(o,o)= J2 E*-' 1 2 )
m = 0 n2—0
With N even,
x
(f'Y)=EE^'^)(- 1 ) ( " 1+ " 2)
n i = 0 ri2=0
1 JV-1 JV-1
fc, = 0 * 2 = 0
With JV even,
fc1=0fc2=0
T/ie difference
Image rotation
When an image is rotated by an angle 9 about the origin, its spectrum is
also rotated by the same angle. A rotation of a multiple of 90 degrees of the
image corresponds to exactly the same amount of rotation of the spectrum
but rotation by other angles requires interpolation. Consider the following
image and its spectrum.
Properties of the 2-D DFT 211
x(m,n2) = X(kuk2) =
10 11 8 9 120 8 - j 8 - 8 8 + J8
14 15 12 13 32 - j32 0 0 0
<3> -32
2 3 0 1 0 0 0
6 7 4 5 L 32+J32 0 0 0
The image and its spectrum rotated by an angle of 90 degrees in t
terclockwise direction are
x{n[,n'2) = X(ki, k2) =
9 13 1 5 8 + j8 0 0 0
8 12 0 4 -8 0 0 0
11 15 3 7 & 8-J8 0 0 0
10 14 2 6 120 32 - J"32 - 32 32 + j32
This rotation is obtained through the transformation a^n'j, n 2 ) = x(ni, n2),
where n\ = —n2 — 1 and n'2 = ni. Remember that the image is periodic.
When an index is negative we add the length N to make it positive.
Separable signals
As the kernel of the 2-D DFT is separable, the DFT of a separable sig-
nal x(ni,n2) — x(ni)x(n2) is also separable. If x(rii,n2) = x(ni)x(n2),
x{ni,n2) & X(ki,k2), x{n,\) <£> X(ki), anda;(n2) <=> X(k2), thenX(fci,fc 2 )
= X(k!)X{h2).
JV-1 N-l
X{kuk2) = J2 E <nun2)W^W^k>
711=0 712=0
80 -8-j8 -32 - 8 + j8
10 + jlO -j2 -4-j4 -2
X(k1,k2) = X(k1)X(k2)
-20 2 + j2 8 2-J2
L 10-jlO -2 - 4 + j4 j2 J
212 Two-Dimensional Discrete Fourier Transform
Parseval's theorem
This theorem implies that the sums of the squared magnitudes of the input
and DFT sequences are related by the constant factor TV2, the number of
samples. That is the signal power can also be computed from the DFT
coefficients of the input sequence.
N-l N-l 1 JV-1 N-l
£ £ \x{nun,)\* = ± £ £ \X(kl,k2)f
ni=0n2=0 ki =0*2=0
fc1=0fe2=0 fci=0fe2=0
The DFT of 2-D data is usually obtained by computing the 1-D DFT of
each row of data followed by the 1-D DFT of each column of the resulting
data and vice versa. The SFG of a 2-D DFT algorithm with the same
The 2-D PM DFT Algorithms 213
o(4) = , Mi) =
x(0,4) ± x(0,12) 1X(0,1),X(0,9)
a(2) =
ar(0,2) ± ar(0,10)
, A{?) =
2X(0,2),X(0,10)
o(6)=o t A(3) =
x(0,6)±x(0,14) '3X(0,3),X(0,11)
o(l) = A(4) =
x(0,l)±x(0,9) X(0,4),X(0,12)
o(5) = A(5) =
x(0,5) ± x(0,13) X(0,5),X(0,13)
o(3) = A(6) =
x(0,3) ± x(0,ll) X(0,6),X(0,14)
o(7)=o A{7) =
x(0,7) ± x(0,15) X(0,7),X(0,15)
Fig. 10.3 The SFG of the 2 x 1 PM DIT DFT algorithm for a 1 X 16 2-D signal. Twiddle
factors are represented only by their exponents. For example, the number 1 represents
number of elements has the same structure as that of the SFG of the 1-D
DFT algorithm. Consider the 1-D data
x{n) = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
x(0, n) = [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15]
o(4) = A(l) =
x(0,4) ± z(l,4) X(1,0),X(1,4)
o(2) = rA(2) =
x(0,2)±a;(l,2) 11(0,1)^(0,5)
a(6)=o A(3) =
x(0,6)±x(l,6) X(1,1),X(1,5)
o(l) = Af4) =
z(0,l)±x(l,l) X(0,2),X(0,6)
a(5) = A(5) =
x(0,5)±x(l,5) X(1,2),X(1,6)
o(3) = Af6) =
z(0,3) ± x(l,3) X(0,3),X(0,7)
o(7)=o *±>A(7) =
6
x(0,7)±x(l,7) X(l,3),X(l,7)
Fig. 10.4 The SFG of the 2 x 1 PM DIT DFT algorithm for a 2 x 8 2-D signal. Twiddle
factors are represented only by their exponents. For example, the number 1 represents
^s'-
the stages 1,2, and 3 of row DFT computation. The DFT values are read
column-by-column. Consider the same data with 2 rows and 8 columns as
shown below.
' 0 1 2 3 4 5 6 7
8 9 10 11 12 13 14 15
The process of 2-D DFT computation is shown in Fig. 10.4. If we read the
data row-by-row and then put it in bit-reversed order, we get the appro-
priate data in each vector locations for computing the column DFTs. In
addition to that, the individual columns of data are placed in bit-reversed
order that is required for computing the row DFTs. There are eight column
DFTs each of size two and are carried out when vectors are formed in the
stage marked C.vector. After computing the column DFTs, the problem
reduces to the computation of two 1-D row DFTs each of size 8. Including
the vector formation stage, we need three stages of computation. After
The 2-D PM DFT Algorithms 215
computing the row vectors in the stage marked R_vector, the upper nodes
of the butterflies contain the vectors in the required order (0, 2, 1, 3) for
the computation of the first row DFT carried out in the next two stages.
The second row DFT is carried out using the vectors at the lower nodes
of the butterflies. It is clearly seen that each set of alternate butterflies
in the last two stages constitutes a row DFT and we get the 2-D DFT
column-by-column in natural order. Consider the same data with 4 rows
and 4 columns as shown below.
"0 1 2 3"
4 5 6 7
8 9 10 11
. 12 13 14 15 .
The SFG, shown in Fig. 10.5, shows the computation of the 4 independent
column DFTs each of size 4 followed by the computation of the 4 indepen-
dent row DFTs each of size 4. While the butterflies of each of the column
DFTs appear together, every fourth butterfly in the last stage computes
each of the 4 independent row DFTs. Note that there are only four butter-
flies in a stage which means one butterfly to each row DFT. Consider the
same data with 8 rows and 2 columns as shown below.
I—>
0
2 3
4 5
6 7
8 9
10 11
12 13
14 15
The SFG, shown in Fig. 10.6, shows the computation of the 2 independent
column DFTs each of size 8 followed by the computation of the 8 indepen-
dent row DFTs each of size 2. The last stage is the vector formation stage
for the row DFTs and no more stages are required since each row has only
two elements.
In summary, we read the data row-by-row (column-by-column), com-
pute the required number of column (row) DFTs, followed by the required
number of row (column) DFTs, and read the DFT values column-by-column
(row-by-row). The vectors for the individual column (row) DFTs are placed
216 Two-Dimensional Discrei le Fourier Transform
o(2) =
ar(0,2) ± ar(2,2) t)X(2,0),X(2,2)
0(6) = » Af3) =
x(l,2) ± ar(3,2) X(3,0),X(3,2)
«(!) = AU) =
z(0,l) ± z(2,l) X(0,1),X(0,3)
o(5) = ii(5) =
a;(l,l)±ar(3,l) X(1,1),X(1,3)
o(3) =
z(0,3) ± x(2,3) X(2,1),X(2,3)
o(7)=c 1
x(l,3)±x(3,3) Z(3,1),X(3,3)
Fig. 10.5 The SFG of the 2 x 1 PM DIT D F T algorithm for a 4 x 4 2-D signal. Twiddle
factors are represented only by their exponents. For example, the number 1 represents
-48.
p p o po to o o o t i ^ ~ q o o c o c o p I5" pa
ui P- CO Its. Ip. b
co co f - i p - * h - » u i b b b b o e.
oo P-* co Cn o M l ^ C D O l O l S H O )
o 1-S
The 2-D PM DFT Algorithms 219
Table 10.3 The D F T of the real data corresponding to the imaginary part of 8 x 8 2-D
data shown in Table 10.1. Real part in the upper half of the table and imaginary part
in the lower half of the table. Origin at upper left-hand corner. Note the conjuagte-
symmetry of the D F T .
240.00 -5.76 4.00 -14.24 -16.00 -14.24 4.00 -5.76
-15.66 8.56 -9.14 -9.51 -9.07 17.49 4.90 16.73
-22.00 -4.76 10.00 11.14 -16.00 -13.24 12.00 -17.14
-4.34 -26.49 -14.90 -22.56 5.07 -8.73 19.14 0.51
28.00 2.00 -10.00 2.00 32.00 2.00 -10.00 2.00
-4.34 0.51 19.14 -8.73 5.07 -22.56 -14.90 -26.49
-22.00 -17.14 12.00 -13.24 -16.00 11.14 10.00 -4.76
-15.66 16.73 4.90 17.49 -9.07 -9.51 -9.14 8.56
0.00 -35.46 18.00 -15.46 0.00 15.46 -18.00 35.46
6.00 17.49 1.93 -2.34 -19.07 13.10 3.83 32.73
2.00 -20.90 2.00 5.83 8.00 -1.10 12.00 0.17
-6.00 13.66 1.83 -0.51 4.93 -7.27 -16.07 -32.90
0.00 19.56 0.00 11.56 0.00 -11.56 0.00 -19.56
6.00 32.90 16.07 7.27 -4.93 0.51 -1.83 -13.66
-2.00 -0.17 -12.00 1.10 -8.00 -5.83 -2.00 20.90
-6.00 -32.73 -3.83 -13.10 19.07 2.34 -1.93 -17.49
the DFT of the complex data in Table 10.2 as follows for two specific cases.
y(o,o)=(210+^-(210-J'240^24o
j2
It is left as an exercise to verify the values in Table 10.3 and derive the
DFT of the real part of the data shown in Table 10.1.
Computational complexity
The computational complexity of an TV x N 2-D DFT of complex data is
2N times that of the 1-D DFT algorithm used. The twiddle factors can be
generated once for all the rows and once for all the columns. This overhead
is, therefore, becomes negligible. Consequently, no table is necessary for the
storage of twiddle factors. Further, the use of one-dimensional indexing and
the 1-D PM DFT algorithms makes the row-column approach of computing
the 2-D DFT practically very efficient. A single algorithm for complex data
is enough for both the DFT and IDFT computation. As in the case of the
1-D IDFT, for the 2-D IDFT computation using DFT, the data is to be
read and written with the imaginary and real parts interchanged.
10.6 Summary
References
Exercises
10.1 Verify that Eqs. (10.1) and (10.2) form a transform pair.
10.3 Describe the sinusoidal surfaces shown in Figs. 10.1(h), (j), (n), (r),
and (v).
10.4 Find the DFT of the N x N 2-D dc signal, x(nun2) = - 3 , from
definition.
10.5 Find the DFT of N x N delayed impulse signal, S(ni - l,n2 - m),
from definition.
10.9 Compute the DFT of the following image using the row-column method.
Then, compute the IDFT of the transform using the DFT and verify that
the original image is obtained.
n2
ni
2 1 3 3
1 0 1 2
4 1 0 1
2 0 1 2
10.10 Compute the DFT of the first two images. Using the resulting trans-
forms, deduce the transform of the third image by applying the linearity
theorem.
-1 -3 2 3 -1-J2 -3-J3
x — 1 4 z = -4-jl
-4 -2 -2-J4
*10.11 For the image of Exercise 10.9, deduce the transform values X(7,21),
X(—4, —3), and X(l, —3), using the periodicity property.
10.12 For the image of Exercise 10.9, deduce the image values x(7,42),
x{—9, —4), and x(2, —7), using the periodicity property.
10.13 For the image of Exercise 10.9, deduce the spectrum of x(ni - 2, n2 -!-
3), using the shift property.
10.14 For the image of Exercise 10.9, deduce the spectrum if the image is
multiplied by 2e~j2^(-3ni~2n^, using the shift property.
Exercises 223
10.15 For the image of Exercise 10.9, deduce the spectrum of x (ni,n2)
*10.16 Underline the upper half of the nonredundant transform values of
the image of Exercise 10.9.
Programming Exercises
10.1 Write a program to directly implement the 2-D DFT using the row-
column method.
10.2 Write a program to directly implement the 2-D ID FT using the row-
column method.
10.3 Write a program for the computation of the 2-D DFT of a complex-
valued image using the 2 x 1 PM DIT DFT algorithm.
Chapter 11
Thus far, we have assumed that signals are periodic and composed of ~ har-
monically related sinusoidal components for N time-domain samples taken
over a period. We made these assumptions in order to develop the discrete
version of the Fourier analysis that is suitable for numerical computation.
However, in practice, signals are mostly continuous and aperiodic. The
accurate representation of these signals may require an infinite number of
samples in the frequency- and time-domains. Therefore, in trying to ap-
proximate arbitrary signals in terms of finite discrete signals, we may end
up with signals having frequency components with frequencies that exceeds
the allowable bandwidth for a given N, the number of samples. In addition,
due to the finite nature of the DFT, the signal may have to be truncated.
In this chapter, we are going to study the effects created by these problems
and the remedies.
The problems are concerned with the selection of appropriate (i) sam-
pling rate, (ii) record length, and (iii) frequency spacing or increment, in the
representation of a signal. These parameters are specified by the theory of
the Fourier analysis. But, due to the discrete and finite nature of the DFT,
we are forced to violate the theory. Therefore, in practice, the problem
usually reduces to the selection of these parameters so that the accuracy of
the frequency-domain representation of a signal is adequate. Consequently,
a good understanding of these problems along with the knowledge of the
characteristics of the signals encountered in a given application will enable
the use of the DFT in an efficient manner. In addition, errors arise in DFT
processing because of the digital representation of the data and coefficients,
and the round off of numbers in arithmetic operations, as in any numer-
225
226 Aliasing and Other Effects
te-VCV;
infinity
(a)
^
*' band-limiled spectrum
infinity
(b)
/ V V w *
infinity
Fig. 11.1 (a) Significant magnitude of frequency components in an infinite range. Alias-
ing is unavoidable, (b) Nonzero value of frequency components only in a finite range.
Aliasing is avoidable by providing a sufficient frequency range, (c) Magnitude of fre-
quency components falls off as frequency increases. Aliasing can be made negligible by
an appropriate choice of the frequency range.
ical computation using digital devices. In Sec. 11.1, the aliasing effect is
described. In Sec. 11.2, the leakage effect is analyzed. In Sec. 11.3, the
picket-fence effect is explained.
The theory of the Fourier analysis is that a periodic signal can be rep-
resented uniquely by a spectrum with an infinite number of harmonically
related sinusoids as shown in Fig. 11.1(a). Since we can deal with only a
finite number of frequency components in the DFT, we are faced with the
following two alternatives: (i) we can represent a signal uniquely with a fi-
nite number of frequency components if the signal is band-limited as shown
in Fig. 11.1(b) or (ii) we give up unique and unambiguous representation of
the signal. The DFT spectral representation of a signal will be in gross er-
ror due to aliasing if its spectrum is as shown in Fig. 11.1(a) (spectrum has
significant values up to infinity). Fortunately, in practice, the spectrum of
Aliasing Effect 227
£ 0 * - 1°
(a)
(c)
4 0
(e) (f)
Fig. 11.2 (a), (c), and (e): Sine waves with frequency indices 0, 1, and 2, respectively,
with 4 samples, (b), (d), and (f): Cosine waves with frequency indices 0, 1, and 2,
respectively, with 4 samples. Waveforms shown in (a), (b), (c), (d), and (f) only have
distinct set of sample values.
2 r os Ima
palginary
it 1 2
(a) (b)
2
it
n
(c) (d)
Fig. 11.3 (a) and (c): Sine waves with frequency indices 1 and 3, respectively, with
4 samples, (b) and (d): The D F T coefficients of the signals shown in (a) and (c), all
located at the same set of frequency samples.
with signs reversed as shown in Fig. 11.3(d). Looking at the set of time-
domain samples or spectra shown in Fig. 11.3, we will assume the presence
of a sine waveform with frequency index 1 whether it is true or not. The
samples or spectra could represent sine waveforms with frequency indices
1,3,5,7,..., or the sum of a set of these waveforms. Figure 11.4 shows
folding of frequencies due to the aliasing effect, for real signals, with N — 16
samples in a period. If we draw an horizontal line starting from a frequency
index in the vertical axis, then we get the indices of frequencies those are
all aliases to it. For example, frequencies with indices 15,17,31,33,...,
have alias representation at index 1. For a complex signal with TV samples,
aliasing occurs when the index of a frequency component exceeds N — 1.
•*. 8 o
•" 7 o o
^ 6 o o A/=16
•2,5 o o
S-4 o o
5
a p .
3 • o o o
» f r o o o
6 1 15 17 —e—e—
". 0 a
31 n 33
16 24 32
Input frequency, k
Fig. 11.4 The folding of frequencies due to aliasing effect, with N = 16. Frequency
components with index 0 to 8 have true representations. Frequency components with an
higher index, shown by unfilled circles, have alias representations.
Leakage Effect 231
? "tM^Hm^lM^
infinity
(a)
#M^V
x(t) time-limited
T NT ' R infinity
(b)
infinity
Fig. 11.5 (a) A signal with significant time-domain values in an infinite range, (b) A
signal with nonzero time-domain values only in a finite range, (c) A signal with time-
domain values falling off rapidly with time.
1
_ 2 • real .
o imaginary
2
n
(a) (b)
=1 -*
X
(c) (d)
1
0
-1
(e) (0
(g) (h)
Fig. 11.6 (a) A sine wave and (b) its spectrum with nonzero coefficients at k = 1 and
k = 3. (c) An ideal rectangular window with all its sample values unity and (d) its
spectrum with just one nonzero coefficient at k = 0. (e) A truncated sine wave and
(f) its spectrum with nonzero coefficients at all k. (g) A rectangular window with a zero
sample at the end and (h) its spectrum with nonzero coefficients at all k.
X{k) = jS^'e-^"*
n=0
JV-1
n=0
I - e-J^-(k-l)N
l-e-i^-(k-i)
= sirnr(fc-Q fa(1_j,K>_n
sin £(*;-/)
1 X ® 9
« » 9 = 32
« 9 x " 9
X L--= 32
9> X 9
X
9 "
8 8
8 " • rectangular * 0
+
o hamming + 5
0.08
o
M ° +
8 $ + Hann
x triangular
n
0
•o 9r +
+ "?,
0
. . + -*• 4 8 12 16 20 24 28 32
n
Windows
Rectangular window
The rectangular window is denned as
. . . f 1 for n — 0 , 1 , . . .,L — 1
rectw(n) = \
[ 0 for n = L,L + 1,...,N - 1
The time-domain representation of this window is shown in Fig. 11.7 with
L = 32 and TV = 32. The DFT of this window, with u = ^ , is given by
The magnitude of the DFT of this window is shown in Fig. 11.8(a) with
L = 16 and N = 64. The magnitude of the largest side lobe is -13.339 dB
(slightly greater than one-fifth of the main lobe magnitude). The response
to complex sinusoids is the same as given in the last subsection, which can
be obtained by replacing k = k — I and N = L in Eq. (11-1). The function
in Eq. (11.1) has a value of L at k = 0. X(k) = 0 for A; = £ , ^ , . . . . Main
lobe width is ^ . Side lobe width is ^ . Apart from k = 0, peaks occur at
k
= 2T' I f ' • • •• Magnitude at peaks is given by s i n ^ ( 2 f c + 1 ^ , f c = 1,2,.. ..
For large values of L, the side lobe peak magnitudes are approximately | ^ ,
2i a + U — 3N_ 5N_
57rv • • a t ft — 2L > 2L '
There are other windows, some of which we present in this section,
apart from the rectangular window which is inherent whenever we truncate
a signal. These windows are smoother and, therefore, their spectra have
Leakage Effect 237
0 "•» triangular
rectangular
N = 64 > N = 64
L= 16 «-lu
T3
\ L=16
- -20 \1
o \ ^-25.913
^-30
J< l\ 1A \ /^A *•*
* _40
-50
\f\ A
II \t \l \
12 18 24 30
(a) (b)
0 Harm 0 '•• hamming
L= 16 *. N = 64
pa - 2 0 pa -10 . L=16
-32.192
£-40 §-20 •
$-30 •
|-60 >3 -40.160
-40 • • • • • • «
-80 « « • • • • • • • • .
16 24 0 4 10 16 22 28
k
(c) (d)
Fig. 11.8 (a), (b), (c), and (d): The magnitude spectrum of the rectangular, triangular,
Harm, and hamming windows, respectively.
wider main lobe and smaller side lobes. The truncated data is modified by
multiplying it with the window samples so that the sample values of the
modified data is smoothly reduced to zero or near zero at both the beginning
and end of the record. The major advantage of these other windows is the
possibility of detecting a weak frequency component that may be masked by
the large side lobes of the rectangular window. Therefore, the rectangular
window is preferred: (i) if there is no leakage, (ii) if the leakage is within
tolerable limits, or (iii) if leakage can be reduced to tolerable limits by using
a more appropriate record length. The other windows when used with no
leakage or very little leakage leads to the undesirable effect of smearing the
spectrum due to a wider main lobe with no advantage. There are several
windows with different characteristics. A choice has to be made depending
on the requirements.
238 Aliasing and Other Effects
Triangular window
One approach to have smaller side lobes is to multiply the DFT of the
rectangular window by itself. This increases the ratio between the main
and side lobe amplitudes at the cost of doubling the main lobe width.
The multiplication of the DFTs results in the convolution of rectangular
windows in the time-domain. The triangular window is defined as
{ \n
triw(L -n)
for n = 0 , 1 , . . . , §
for n = \ + 1, \ + 2 , . . . , L - 1
0 forn = L,L + l,...,N-l
The time-domain representation of this window is shown in Fig. 11.7 with
L — 32 and N = 32. The circular convolution of a rectangular window
l
red (n)-i ^v n = 0,1,. ..,^ - 1
with itself followed by a circular right shift of one position yields the trian-
gular window with a scale factor. For example,
xrectw(n) = {1,1,0,0} e> Xrect„(k) = {2,l-jl,0,l+jl}
L
x (n + 1) = {1,2,1,0}
2 triw
^ X?ectJk) = {4,-j2,0,j2}
%xM„(n) = {0,1,2,1} & Xr2erfJfc)e-^fc = {4,-2,0,-2}
Therefore, the DFT of the triangular window is given in terms of that of
the rectangular window as
The magnitude of the DFT of this window is shown in Fig. 11.8(b) with
L = 16 and N = 64. The magnitude of the largest side lobe is -25.913 dB.
The response to complex sinusoids is obtained, by replacing k by k — I and
N = L in Eq. (11.2), as
2/_sin-V^\ Mk_l}
L\smUk-l)
Leakage Effect 239
Let us consider the reason for the differences in the spectral behavior of the
rectangular and triangular windows. Because of discontinuity, according
to the theory of Fourier analysis, the amplitude of the spectrum of the
rectangular window decreases at the rate which is a function of j , where k is
the frequency index. This is evident from Eq. (11.1) and from Fig. 11.8(a).
With no discontinuity, the amplitude of the spectrum of the triangular
window decreases at the rate which is a function of -^ • This is evident
from Eq. (11.2) and from Fig. 11.8(b). In addition, from Eqs. (11.1) and
(11.2), we find that the main lobe width is ^ for the rectangular window
and ^ for the triangular window. Therefore, the main lobe width is 8 in
Fig. 11.8(a) and it is 16 in Fig. 11.8(b).
Hann window
Another approach to reduce the size of the side lobes of the rectangular
window is to make the frequency response to be the sum of the scaled and
shifted responses of three rectangular windows so that the side lobes tend
to cancel out. This implies the multiplication of the rectangular window
by another function (a linear combination of complex exponentials) in the
time-domain. The multiplication in the time-domain results in the convolu-
tion of the DFTs of the two functions in the frequency-domain. The Hann
window is defined as
cos(—n) = ,
The magnitude of the DFT of this window is shown in Fig. 11.8(c) with
L = 16 and N = 64. The magnitude of the largest side lobe is -32.192 dB.
The main lobe width is 16 samples.
240 Aliasing and Other Effects
Hamming window
The hamming window is defined as
The magnitude of the DFT of this window is shown in Fig. 11.8(d) with
L = 16 and N = 64. The magnitude of the largest side lobe is -40.160 dB.
The main lobe width is 16 samples.
rectangular -6 Hann
W=64 -20 \ W=64
/=1.0 \ /=1.0
-40
-60 Y\n\
3 1 2 3 4 5
k
(a) (b)
-6
-20
^. /=1.3
-40
-60
v\r>
3 1 2 3 4 5
k
(d)
pa " -6
-20 \./=1.5
£-20
-30
2
AAV3
-40
-60
(3 1 2 3
nr
4 5
k k
(e) (f)
Fig. 11.9 (a), (c), and (e): The frequency response of the rectangular window with
the frequency index of the complex exponential signal 1, 1.3, and 1.5, respectively. The
response is relatively sharp with large sidelobes. (b), (d), and (f): The frequency response
of the Hann window is relatively broad with small sidelobes.
•'• •"• -. A • _ 64
"fir • • • • <^*L* • • 3"
• * 0
0 20 40 60 0 79 20 30
n k
(a) (b)
4
£ 0 • A S? 101 • •
"><" o .••'
- 4 •-• 9
0 16 40 60 - 0 79 20 30
n
(c) (d)
_ 64 • •
"?
X
0 20 40 60 0 7 10 20 30
n k
(•> (f)
4 2 T
X
0 f"- . -\^-. —.„ — ST 10
o .« "
•
.". ••
oo i n 0
0 16 40 60 0 7 10 20 30
n
(g) (h)
60
20 40 60 18 30
n
(a) (b)
- 2
r « •"• 5 I
£ 0 • • ' 2
_2L»— t 10° [ • •
• • . " • • • • . - " • •"• ••
16 40 60 0 7 18 30
k
(c) (d)
2r A
°tv>: 16 40 60
*10"
18 30
(e) (0
Fig. 11.11 (a) The signal, 2 c o s ( | | 7 n ) + 0 . 1 c o s ( | j l 8 n ) , and (b) its spectrum, (c) The
truncated signal of (a), and (d) its spectrum, (e) The signal shown in (c) after the
application of the Hann window and (f) its spectrum.
large. As the rectangular window has the smallest main lobe width, it gives
the best response in this respect.
Figures 11.11(a) and (b) show, respectively, the signal,
Reduction of leakage
To reduce leakage, the natural solution is to use an appropriate record
length, if possible. Similar to the case of the aliasing problem, prior knowl-
edge of a signal will enable to fix the record length or a trial and error
procedure can be used, keeping the sampling interval fixed. Otherwise,
leakage can be reduced at the expense of increased smearing of the spec-
trum by the application of windows. As mentioned earlier, if there is no
leakage or negligible leakage then choose the rectangular window. Other-
wise choose any of the other windows that reduces the side lobes to the
desired level. Windows can be applied in the time-domain by multiplying
the data, x(n), with window samples, w(n). That is, instead of comput-
ing the DFT of x(n), we compute the DFT of x(n)w(n). Note that the
window w(n) must be centered on the truncated signal x{n) in the defined
interval of x(n), wherever it may be on the time scale. Windows can also
be applied, in the frequency-domain, in terms of the frequency coefficients
of the rectangular window. Although our discussion concentrated on the
truncation problem in the time-domain, it should be noted that windows
can be used in both the time- and frequency-domains.
16 i
3f
=1 N=16
•
* 0 . 0 . • • • • _j
0 5 10 15 0 2 4 6 8
n k
(a) (b)
_ 1 16 *
e W = 32 5 •
•
K
0 * 0 . •.
0 16 31 0 5 10 15
n k
(c) (d)
_ 1 16 *
e N = 64 } •
0 16 32 48 63 0 10 20 30
n k
<•) (0
Fig. 11.12 (a) A signal and (b) its spectrum, (c) The signal shown in (a) with 16 zeros
appended and (d) its spectrum, (e) The signal shown in (a) with 48 zeros appended and
(f) its spectrum. With more and more zero padding, a denser spectrum is obtained.
limited. Therefore, the spectrum shown in Fig. 11.12(b) is also the correct
frequency-domain representation of the aperiodic signal, but is very coarse.
It seems as though we look at the spectrum through a picket-fence. With
a coarse spectrum, we may miss some of its features. For example, if there
is a peak of the spectrum in between two frequencies it will be missed.
shown since it is symmetric). With more and more zero padding, we get a
denser spectrum as shown in Figs. 11.12(e) and (f). The signal shown in
Fig. 11.12(e) is a more accurate representation of the given aperiodic signal
than that shown in Fig. 11.12(c).
A periodic signal is composed of components with frequencies which are
integral multiples of its frequency and of no other. Therefore, we should set
the record length equal to an integral number of cycles and there should be
no zero padding. If we truncate a periodic signal, we are making an analysis
with a false period. An aperiodic signal is composed of components of all
frequencies. Whether we truncate an aperiodic signal or not, the frequency
coefficients computed by DFT are part of the spectrum. The point is that
the signal processed by the DFT should be sufficiently close to the actual
signal, with the appropriate selection of the record length and the number
of samples so that the aliasing and leakage errors are small enough and the
spectrum is sufficiently denser.
Reference
(1) Brigham, E. O. (1988) The Fast Fourier Transform and Its Appli-
cations, Prentice-Hall, New Jersey.
Exercises
11.2 With JV = 8 and L = 8, list the DFT coefficients of the signal using
the rectangular, triangular, Hann, and hamming windows.
(a) x(n) = c o s ( ^ 2 n )
* (b) x(n) = cos(^2.5n)
* 11.3 The frequency of the significant highest possible frequency com-
ponent of an aperiodic signal of record length 0.1 seconds is 5 kHz. A
minimum frequency increment of 20 Hz is required. Determine the number
of samples required to approximate the spectrum using the DFT. Is zero
248 Aliasing and Other Effects
P r o g r a m m i n g Exercises
11.1 Write a program to apply the Hann window to a signal, with L = JV'.
a finite number of maxima and minima in one period, and (iii) the signal
has a finite number of finite discontinuities in one period. These conditions
are met by most signals of practical interest.
where
1 /Tl-t-i
Xc(0) = TJ x(f)dt,
o ti+T
rti+T
Xc(k) = — I x(t)
{'] cos(fcw
'" 0.*)~dt,
", k' = ~.~.
1,2,...,, o o
T Jti
tl
2 ftl+T
X„(k) = — x(t) sm(kcj0t) dt, k=l,2,...,oo
1
Jh
and ti is arbitrary.
We use the denning equations for Xc(k) and X8(k) to get XC8(k) as
x 1 /-tl+T
cs(k) = = / 2;(i)(cos(fcw0i) - jsin(fcw 0 i))^,
1 /"' 1 + T
= - / x{t)e-jkuot dt, k = - o o , . . . , - 1 , 0 , 1 , . . . , oo (12.3)
Gibbs phenomenon
The failure of the Fourier representation to provide uniform convergence in
the vicinity of a discontinuity of a signal is called the Gibbs phenomenon.
In the vicinity of a discontinuity, the Fourier representation deviates at the
least about 9% from the original signal irrespective of the number of coeffi-
cients used. It is not surprising since it is impossible to provide a pointwise
match in the vicinity of a discontinuity with a set of basis functions each
of those is continuous. Where there is no discontinuity, by increasing the
number of frequency coefficients to represent a signal, the Fourier represen-
tation can be made to correspond to the original signal to any tolerance.
Let us assume that we are approximating a signal using only part of its
spectrum (2JV+1 complex frequency coefficients). The part of the spectrum
used can be considered as obtained by multiplying the original spectrum by
a rectangular window whose value is unity during the part of the spectrum
used and zero otherwise. This multiplication operation in the frequency-
domain is equivalent to convolution of the corresponding signals in the
time-domain. Now, we are going to derive the convolution expression that
252 The Continuous-Time Fourier Series
k=-N
Replacing Xcs(k) by its definition and interchanging the order of summation
and integration, we get
N
*N(t) = i f x(l) J2 ejk»°Wdl
1 Jo
k=-N
Let us evaluate the summation operation separately.
N 2N
y^ ejkuj0{t-i) y^ ej(k-N)w0(t-i)
k=-N k=0
_
l_ e i(2iV+l)wo(t-0 sin( (2N+l)u0{t-l) )
e-jNwQ{t-l)_
I — eJuo(t-l) sin(^i)
Now, the convolution expression characterizing the reconstructed signal
using only 2N + 1 coefficients is given by
sin((2Af+iHft-i?)
(t) = ±j\(l) i rT
XN
8in(i-2^1)
= -1 / x(l)xs(t - l)dl
Jo
The reconstructed signal using 27V + 1 coefficients is the result of the con-
volution of the original signal x(l) and the sine function xs(l). The sine
function, for the specific value of t = 3.14, is shown, with T = 6.28 seconds,
N = 10, and I ranging from 0 to T, in Fig. 12.1(a) and with N = 20 in
Fig. 12.1(b). The sine function has one main lobe (the region between the
(a) (b)
Fig. 12.1 (a) and (b): The sine function is(3.14 — I), respectively, with N = 10 and
AT = 20.
The 1-D Continuous-Time Fourier Series 253
(a) (b)
Fig. 12.2 (a) and (b): The reconstructed square wave with JV = 10 and JV = 20,
respectively.
two adjacent zero crossings about / = 3.14) and large number of side lobes
(the other regions between adjacent zero crossings), which are alternately
positive and negative. The total area of the sine function during a period
is T for any value of JV since
v
T *-> " N N
n=0 n=0
Since x(nTs) represents the nth sample, the equation can be rewritten as
1 JV_1
Xca(k) = -J£x(n)e-i¥nk, k = 0,l,...,N-l
N
71=0
This equation analyzes a waveform in terms of sinusoids. The inverse oper-
ation, that is the synthesis of a waveform from the coefficients, Eq. (12.2),
is approximated as
JV-l
One difference between the DFT equation and the numerical approximation
to the FS is the factor jj. Therefore, by dividing the DFT coefficients by
N, we get an approximation to the complex FS coefficients. Comparing the
approximation of the synthesis equation with the IDFT equation, we find
that there is no constant divisor ^ in the synthesis equation. For N even,
comparing the coefficients of the DFT with that of the FS, we get, for real
signals,
Aliasing effect
Once we represent the signal by N samples, we are able to compute only
N distinct frequency coefficients. If the input signal is bandlimited to
components with frequency indices less than ^ i then there is no problem.
The 1-D Continuous-Time Fourier Series 255
x(t) = Y, Xcs(iwlaot
l=—oo
where u>o = %jr. Let Ts — ]j. To generate only samples of the signal at
intervals of Ts, we get
oo oo
This equation shows how the DFT coefficients are corrupted due to aliasing.
E x a m p l e 12.1 The aliasing effect
Figure 12.3(a) shows the FS magnitude spectrum, which is aperiodic, of
the signal x(t) = 4 + 6 sin(27r£) + 4 sin 2(27ri) + 2 sin 3(27ri). The signal has
frequency components, apart from dc, with frequencies 1 Hz, 2 Hz, and 3
Hz. Therefore, we need a minimum of seven samples in a period to represent
it accurately. Figure 12.3(b) shows the scaled DFT periodic spectrum which
is a superposition sum of the aperiodic spectrum placed at intervals of
nine samples. As the interval of nine samples is more than adequate to
prevent overlap of nonzero values of the spectrum, there is no aliasing effect.
Figure 12.3(c) shows the scaled DFT periodic spectrum with a period of
seven samples and there is no aliasing effect. Figure 12.3(d) shows the
scaled DFT periodic spectrum which is a corrupted periodic version of the
aperiodic spectrum. This is because the period of five samples is inadequate
to prevent the overlap of nonzero values of the aperiodic spectrum. The
magnitude of the spectral value with index 2 is one. We can recover the
original signal from its samples with N = 7 and N = 9 using a lowpass
256 The Continuous-Time Fourier Series
4 4
FS aperiodij spgctrum • • •• • •
"B2 S 2 DFT, pegodic^spejtrurr^ /V= 9
X * 1
Ua l i a s i n g . .
-10 0 10 -10 0 10
k k
(a) (b)
4
^ 3 §.3
DFT periodic spectrum, N = 7 DFT periodic spectrum, N= 5
& 2
No aliasinq Aliasing
1 1
-10 0 10 -10 0 10
k k
(c) (d)
Fig. 12.3 (a) The FS aperiodic spectrum of the signal x(t) = 4 + 6sin(27rt)-f 4 sin(4n-t)+
2sin(67rt). (b) The scaled D F T periodic spectrum, with N = 9, of i ( t ) with no overlap-
ping of nonzero values and hence no aliasing, (c) The scaled D F T periodic spectrum,
with N = 7, of x(t) with no aliasing, (d) The scaled D F T periodic spectrum, with
N = 5, of x(t) with overlapping of nonzero values resulting in a corrupted spectrum.
filter (because the sampling process has not altered the original spectrum,
except for repeating), whereas it is not possible with N = 5. I
The aliasing effect can also be explained in the following way. The
creation of N samples for numerical approximation can be considered as
multiplying one period of the continuous-time signal x(t) with the sampling
signal, a set of unit-impulses. Then, due to the convolution theorem, we get
a periodic spectrum obtained by superposition sum of an infinite number
of shifted aperiodic FS spectrum. Remember that the FS of the sampling
signal is also a set of impulses and the convolution of a spectrum with an
impulse is just translating the origin of the spectrum to the location of the
impulse. The amount of shifting of the spectrum is inversely proportional
to the sampling interval. The sampling interval, in order to avoid aliasing,
must be sufficiently short so that there is no overlap of nonzero values of
the spectra due to the superposition operation.
If the data samples are not taken over an integral number of periods,
then leakage effect also must be accounted for.
The 1-D Continuous-Time Fourier Series 257
Continuous-time frequency
The DFT produces N output values corresponding to N input values and
the DFT computation is independent of the sampling interval Ts. There-
fore, the actual frequency can be found only if Ts or T = NTS is known.
The fundamental frequency /o = ^ is also the frequency increment in Hz.
The DFT frequency index k represents a frequency of A;/0 Hz. The DFT
time index n represents nTs seconds. The folding frequency is y / 0 and the
highest usable frequency is ( y - l)/o.
should be assigned to a sample, where x(t+) and x{t~) are the limiting
values of x(t) as t tends to tn from the right and left, respectively. In order
that the value x(tn) provides minimum least squares error,
(x(tn)-x(tt))2 + (x(tn)-x(t-))2
Solution
The waveform is odd-symmetric and odd half-wave symmetric with a dc
bias. Therefore, we expect only the odd-indexed sine waves as the frequency
components, apart from the dc component.
1 /"= A
Xcs(0) = -Jo Adt=-
258 The Continuous- Time Fourier Series
• I M I M I
•5- _ K , Period, IT =1
•g. 0.5 '/v=4 >
"? n K Period T=1
io.; „' WPeriod,
=16"
r= 1
0 2 4 6 0 4 8 12
(b) (c)
Fig. 12.4 (a), (b), and (c): The continuous-time square wave with period T = 1 second
and its representation by 4, 8, and 16 samples, respectively.
X
X {k)(k) -
cs - - ^r Ae
Ae-f^dt-i -
r
d t
\ Q
~j£ hrkodd
i o l k ever
even and k ^0
A „-2*
x(t) = hj—e J' V ' -|- " j ——< g^ V * j g^ T *
37T 7T 2 7T
2 4 , . 2?r 1 . 2TT . 1 2TT
++ — (l sS mi n — i + - s m 3 — i + - s i n 5 — < + •••)
~ 2 7T r ' ' 3 " ~ T ' ' 5"""T
Assuming that A = 1 and T = 1 second, we get
1 2 1 1
a:(t) = - + -(sin(27rt) + - sin3(27rf) + - sin5(27ri) + • • •) (12.4)
2 7r 3 5
Figure 12.4 shows one cycle of the square wave with 4, 8, and 16 samples.
Note that the sample values at discontinuities are the average values of the
right and left limits. Figure 12.5 shows the coefficients of the constituent
sine waveforms of the signal along with that of the dc component, the ex-
act coefficients marked 'o' and the coefficients computed through the DFT
marked ' x ' . The even harmonic coefficients are zero. The DFT coefficients
corresponding to the samples shown in Fig. 12.4(a) are {2, — j'1,0,,7'1}. Re-
0 0.637 00.604
0.5 > 0.5 W=8 0.5
oFS ^ „ A/=16
»DFT *" 00.212
»0.104 ° 9 o
A/=4 • • • " •
0 1 2 3 4 1 3 5 7
k k
(b) (c)
Fig. 12.5 (a), (b), and (c): The exact and the scaled D F T values of the dc and the
sine components, which constitute the square wave shown in Figs. 12.4(a), (b), and (c),
respectively.
The 1-D Continuous-Time. Fourier Series 259
ferring to Fig. 12.5(a), we see that the dc value is 0.5 for both the FS and
the DFT. The dc value is not affected due to aliasing since the waveform
consists of no other cosine component. However, the magnitude of the har-
monic with k = 1 is \ for the FS and 0.5 for the DFT. This discrepancy
is due to the aliasing effect. With four time-domain samples, we can only
represent frequency components with indices one and two, in addition to
dc value. Therefore, all the odd frequency components, in the case of the
DFT, fold back on to that of the fundamental harmonic and we get
The value of the summation can be obtained from Eq. (12.4) by substituting
t = 0.25.
-, 1 2„ 1 1 1
^S + ^ - a + s - ^ - )
Therefore, we get Xs(l) = 0.5. In Fig. 12.5(b), we have doubled the num-
ber of samples. Therefore, the aliasing effect is reduced. For example,
the frequency component with k = 3 and magnitude ^ folds back on the
frequency component with k = 1 in Fig. 12.5(a). In Fig. 12.5(b), that
frequency component has its independent representation. Frequency com-
ponent with ifc = 1 is mixed up with frequency components starting with
k = 7, whose magnitudes are ^ or smaller, and, therefore, the value com-
puted by the DFT with k = 1 becomes more accurate. The approximation
becomes much better in Fig. 12.5(c) with more number of samples. In a
practical application, sufficient number of samples must be used to satisfy
the accuracy requirements.
Figure 12.6 shows parts of the reconstructed waveforms, using the DFT
coefficients shown in Fig. 12.5. Remember that the magnitudes of the even
N N=a
f =* \ 0,5r \ 0,5f "-is
0 0.5 0 0.5 0 0.5
i t t
(a) (b) (c)
Fig. 12.6 (a), (b), and (c): Parts of the reconstructed square waveforms using frequency
coefficients shown in Figs. 12.5(a), (b), and (c), respectively.
260 The Continuous- Time Fourier Series
S0.5
0
0 0.5 1
t
Fig. 12.7 The reconstructed square waveform, using frequency coefficients shown in
Fig. 12.5(c) modified by the Hann window.
1 2TT 2TT
x(n) = -+ 0.6036 s i n ( - n ) + 0.1036 sin(3—n) (12.5)
2 8 8
1.1002 1.0901
1 1
LH = 13
LH
0.5 0.5
0 0.0753 0.1907 0 0.0382 0.0969 0 0.0192 0.0486
t t
(b)
Fig. 12.8 The initial part of the square wave, its FS reconstruction, and the last har-
monic used (with some offset), (a) Using up to the 3rd harmonic (LH = 3). (b) Using
up to the 7th harmonic (LH = 7). (c) Using up to the 15th harmonic (LH = 15).
To find out the occurrence of the peak values of this waveform, we have to
differentiate the expression with respect to t and equate it to zero and we
get
It is obvious that the first time this expression is equal to zero is when
t = 0.125. For this value of t, we get x(t) = 1.1002. Figure 12.8(a) shows
the initial part of the square wave, the FS reconstructed waveform, and
the last harmonic used (third) in the reconstruction. Note that the third
harmonic is shown with some offset. Remember that the coefficient of the
harmonics are determined with respect to the least squares error criterion.
Therefore, all the reconstructed waveforms are constrained to start from a
value of 0.5 at t = 0, as the FS assumes the average value at a discontinuity.
The waveform still keeps raising even after it reaches the value of 1 as
the sinusoids are continuous signals and cannot suddenly stop. The last
harmonic is the first one to have a negative slope and it starts correcting
the overshoot. However, its amplitude is small and it takes some time to
reach a deep negative slope. After some time, the last but one harmonic
comes into play and so on. Eventually, the overshoot is corrected and an
undershoot occurs.
262 The Continuous-Time Fourier Series
Figures 12.8(b) and (c) show the initial part of the square wave, the FS
reconstructed waveform, and the last harmonic used in the reconstruction,
the last harmonic being 7 and 15, respectively. We can easily calculate, as
shown earlier, that the first peak value occurs for these cases at t = 0.0625
and t = 0.03125, respectively. That is, the value of t for the occurrence
of the first peak value is reduced by a factor of 2 with the doubling of the
number of harmonics used for the reconstruction. The overshoot is also cor-
rected faster by a factor of two. With an infinite number of harmonics used,
the overshoot occurs almost at t = 0 and it exists only for a moment. The
largest overshoot converges to the value of 1.0895 with a relatively small
number of harmonics used. While the overshoot converges to a limit, the
area under the overshoot is reduced and eventually becomes zero confirm-
ing that the FS provides a complete representation for any waveform with
respect to the least squares error criterion. It should be noted that the FS
representation provides uniform convergence when the original waveform is
continuous. It is obvious because when the waveform is continuous the size
of discontinuity between adjacent points is zero and the overshoot=size of
discontinuity x 0.0895=0.
x(h,t2) = Y, E XC8(kx,k2)ejmkltlejuJ2k2t\
Solution
. ,, 27r 2TT .
X{tl,t2) = Bin(lyti+Oyta)
;
j2^
^e.(l,0) = - | , Xcg(-l,0) = |
sin
xc8(kut2) = lj (y*i) e _ j ( ¥ f c l i l ) d i i
Let wi = ?f. Then,
\ g—jkiuiti
Xca(±l,t2) = T^
J\^_ |2
(^7>
i' -J7Tk2 '°
= 0, k2 # 0
X„(±1,0) = ^
264 The Continuous-Time Fourier Series
The DFT coefficients with 4 samples in each direction are given below.
k2 ->•
0 0 0 0
-38 0 0 0
0 0 0 0
j8 0 0 0
The coefficients are the same as the analytically driven FS coefficients with
a scale factor of 16. In this case, there is no aliasing and we are able to get
the exact FS coefficients using the DFT. The DFT representation of the
signal is given by
x(ni,n2) = sin(—ni)
*c.(0,±l) = (i)(^) = TJ
The 4 x 4 samples of the signal are
n2 ->
"1 r
0 0 0 0
I 0 0.25 0 -0.25
0 0.5 0 -0.5
0 0.75 0 -0.75
The 2-D Continuous- Time Fourier Series 265
The DFT coefficients are very inaccurate because we have not put the
average values at discontinuities. The proper sample values of the signal
are
ri2 ->•
Til
" 0 0.5 0 -0.5
1 0 0.25 0 -0.25
0 0.5 0 -0.5
. 0 0.75 0 -0.75
k2 -t
fci
0 - j 4 0 jA
I 0 1 0 -1
0 0 0 0
0 -1 0 1
The coefficients in the first row are exact as there is no aliasing. However,
the other coefficients are not exact due to the aliasing effect. Note that
266 The Continuous-Time Fourier Series
Table 12.1 Comparison of the exact 2-D FS coefficients (second row) of Example 12.4
with those obtained from the DFT coefficients with 4 x 4 (third row), 8 x 8 (fourth row),
and 16 X 16 (fifth row) samples.
0,1 1,1 2,1 3,1 4,1 5,1 6,1 7,1 8,1
-jO.25 0.0796 0.0398 0.0265 0.0199 0.0159 0.0133 0.0114 0.0099
-jO.25 0.0625 0
-jO.25 0.0754 0.0312 0.0129 0
-jO.25 0.0786 0.0377 0.0234 0.0156 0.0104 0.0065 0.0031
(a) (b)
Fig. 12.9 (a) The discrete representation of the 2-D signal x{t\,t2) = ^-sin(^ L t2),
with 32 x 32 samples, (b) The same as in (a) with average values at discontinuities.
The 2-D Continuous-Time Fourier Series 267
(a) (b)
Fig. 12.10 (a) The scaled D F T spectrum of signal in Fig. 12.9(b). Note that X(0,1)
and X(0,31) are not plotted to make the figure more clear, (b) The spectrum in the
center-zero format.
shows the spectrum in the center-zero format. From these figures, we see
that the value of the coefficients is decreasing towards the folding frequency.
The problem of fixing the sampling frequency is the same as that in the
1-D case. In 2-D, we have to keep increasing the sampling frequency in two
directions, rather than one, until the spectral values are sufficiently small
close to the folding frequency.
Figure 12.11(a) shows the reconstructed signal of Fig. 12.9(a) with
32 x 32 DFT coefficients. The signal has ripples in the neighborhood of
the discontinuity due to Gibbs phenomenon. Figure 12.11(b) shows the re-
constructed signal after applying the Hann window to the DFT coefficients.
(a) (b)
As expected, the ripples are reduced at the cost of reducing the rise time.
Note that, for 2-D signals, we apply the 1-D window in each direction. For
this example, we applied the window only in the ki direction as there is no
truncation of the spectrum in the other direction. I
12.3 Summary
References
Exercises
A f <t<T
Exercises 269
x{t) = { ±t 0<t<T
Compute the DFT with 4, 8, and, 16 samples and compare the scaled DFT
and the FS coefficients with A = 1 and T = 1.
Compute the DFT with 4, 8, and, 16 samples and compare the scaled DFT
and the FS coefficients with A — 1 and T = 1.
12.6 Half-wave rectified sine wave
Find the FS representation analytically.
Asin(^i) 0<i<f
*«> = { o J<t<T
Compute the DFT with 4, 8, and, 16 samples and compare the scaled DFT
and the FS coefficients with A = 1 and T = 1.
x(t) = { t2 0<t<T
Compute the DFT with 4, 8, and, 16 samples and compare the scaled DFT
and the FS coefficients with T = 1.
* 12.11 Even symmetric pulse train
Find the FS representation analytically.
A 0<t<w
x{t) = { 0 w <t<T-w
A T-w<t<T
Compute the DFT with 4, 8, and, 16 samples and compare the scaled DFT
and the FS coefficients with A — 1, T = 1, and w — | .
12.12 Pulse train
Find the FS representation analytically.
A 0<t<2w
x(t) = |
0 2w < t < T
Compute the DFT with 4, 8, and, 16 samples and compare the scaled DFT
and the FS coefficients with A = 1,T — 1, and w = | .
<t) = { A-AcosC^-t)
cos(^f)
0<<<£
%<t<T
Exercises 271
Fig. 13.1 (a) Pulse train with period T = 1 second, (b) Pulse train with period T = 2
seconds, (c) Pulse train with period T — 4 seconds.
(a) (b)
(c) (d)
(e) (0
Fig. 13.2 (a), (c), and (e): The FS magnitude spectrum of the waveforms shown in
Figs. 13.1(a), (b), and (c), respectively, (b), (d), and (f): The FS magnitude spectrum,
multiplied by the period T.
The 1-D Continuous-Time Fourier Transform 275
°° u rti+T
jkuol
;(t) = Y e J^ot{ o / x(l)e- dl}
2 n
t™ Jti
The sufficient conditions for the existence of FT are essentially the same as
those for the FS. Gibbs phenomenon is also common to both the FS and
the FT.
E x a m p l e 13.1 Find the FT of the unit impulse signal x(i) — 5{i).
oo
8{t)e-jultdt = 1 and 5{t) & 1
/ •oo
That is, the unit impulse signal is composed of complex sinusoids of all
frequencies from u — — oo to a; = oo in equal proportion. I
E x a m p l e 13.2 Find the inverse FT of the transform Xft(uj) = 8(UJ).
1 f°° 1
x(t) = — 6(oj)ejutdui = — and 1 O 2ir6(u)
2-K J_O0 2n
That is, the dc signal has nonzero spectral component only at u = 0. I
E x a m p l e 13.3 Find the FT of the signal x{t) = ePUot.
This signal can be considered as the product of signals x{t) = 1 and x(t) =
mt
ejwot Therefore, using the shift theorem e^ x(t) <S> Xft(u)—w0) and from
the result of Example 13.2, we get
That is, the spectrum of the complex sinusoid with u = u>o is a single
impulse at u — UIQ. I
Example 13.4 Find the FT of the signal x(t) = COS(CJO^)-
OO I /-OO
/
cos{u0t)e-jutdt =- (e^ot + e-juJot)e-iutdt
-OO 2 ./-oo
— Tr(6(u! - UIQ) + 6(iJ + W0))
The 1-D Continuous-Time Fourier Transform 277
{ 1
0
1
0<t<a
a<t<T-a
T-a<t<T
S l
^ . « =I ^ =^ , M 0 and *»(0) = Yo
5
<nTs) = X
WF ^ Mj£fy¥nk> n = 0,l,...,N-l (13.4)
8 s
fc=o
Therefore, for a direct comparison with the samples of the FT, the DFT
coefficients must be multiplied by the sampling interval Ts. For a direct
comparison with the samples of the inverse FT, the IDFT values must be
multiplied by £-.
E x a m p l e 13.6 Find the FT analytically.
. ,
x(t) = Jf e0 " ' for t > 0
for * < 0
Let the record length T — 8 seconds and the number of samples N = 1024.
Compute the samples of the spectrum of the signal using the DFT. Tabulate
the first 8 scaled DFT coefficients and the corresponding FT coefficients.
Solution
/•OO y-OO -I
Fig. 13.3 The exponential waveform x(t) = e _ t , 0 < t < oo with 16 samples over the
range 0 < t < 1.
signal, we compute the DFT with N = 16, 32, 64, and 128. The scaled
magnitude of the spectra are shown, respectively, in Figs. 13.4(a), (b),
(c), and (d) (focussing on the spectrum close to the folding frequency in
Figs. 13.4(a), (b), and (c)). As the sampling interval is decreased, the
frequency range is increased and the spectrum has reduced aliasing effect
as the spectral values close to the folding frequency tend to become very
small. Remember that if we make the frequency range infinity, then there is
no aliasing effect. From looking at the figures, it is obvious that a sampling
interval of j^g seconds is sufficient. In this case, we have the analytical
result also plotted for comparison. In the case of an arbitrary signal, we
/V = 32
*2 0.03 2 0.015
5 0.02 -FT 5; 0.01
•DFT
&0.01 T=\ S" 0.005
W=16
0
5 10 15
k
(b)
W=128
3 0.009
5- 0.006 .0.5
& 0.003
0
10 20 30
X 20 40 60
k k
(c) (d)
Fig. 13.4 The magnitude of the F T and the scaled D F T spectrum of the waveform in
Fig. 13.3. (a) With T = 1 and N = 16. (b) With T = 1 and N = 32. (c) With T = 1
and N = 64. (d) With T = 1 and N = 128. In (a), (b), and (c), the spectrum close to
the folding frequency is focussed.
280 The Continuous-Time Fourier Transform
have to keep reducing the sampling interval until the spectral values close
to the folding frequency tend to become negligible.
To fix the record length, keeping the sampling interval the same, we keep
increasing the number of samples until two consecutive spectra are essen-
tially the same. The reason for this procedure is as follows. By truncating a
signal, we get the convolution of the true spectrum and the spectrum of the
rectangular window. As we reduce truncation, by sampling the signal over
a longer interval, the spectrum of the rectangular window distorts the true
spectrum of the signal to a lesser extent. Ideally, with no truncation, the
spectrum of the rectangular window is an impulse and it does not distort
the true spectrum of a signal. For the present example, Figs. 13.5(a), (b),
and (c) show, respectively, the spectra with N = 256, 512, and 1024 samples
(focussing on the low frequency part of the spectrum in Figs. 13.5(a) and
(b)). We find that increasing the number of samples beyond 1024 results
in little change in the spectrum from that for N = 1024, as the distortion
of the spectrum due to truncation becomes negligible. Note that the dc
value computed through the DFT is almost 1, the correct value, only for
N = 1024. Therefore, for this signal, we conclude that the sampling inter-
val of j-|g seconds and the record length of eight seconds results in a DFT
spectrum that is very close to the analytically derived spectrum. Table 13.1
-FT
•DFT
T=2 T=4
0.5 N=256 0.5 N = 512
10
(b)
r=8
.0.5 N = 1024
Fig. 13.5 The magnitude of the F T and the scaled D F T spectrum of the waveform in
Fig. 13.3. (a) With T = 2 and N - 256. (b) With T = 4 and TV = 512. (c) With T = 8
and N = 1024. In (a) and (b), the low frequency part of the spectrum is focussed.
The 1-D Continuous-Time Fourier Transform 281
Table 13.1 Comparison of the first 8 exact values (the first two rows) of the spectrum
in Fig. 13.5(c) with the corresponding scaled D F T values (the second two rows).
0.6185-J0.4858 0.2884 - jO.4530 0.1526-jO.3596"
0.0920 - jO.2890 0.0609 - jO.2391 0.0431 - jO.2031 0.0320 -jO.1761
0.9997 0.6183 - jO.4856 0.2883-jO.4529 0.1526 - jO.3595
0.0920 - jO.2889 0.0609 - jO.2390 0.0431 - jO.2030 0.0320 - j'0.1760
shows a comparison of the first eight exact and the scaled DFT values of the
spectrum shown in Fig. 13.5(c). This example demonstrates the fact that
even if a signal is neither time-limited nor band-limited, for all practical
purposes, it can be considered as both time-limited and band-limited by
using appropriate sampling interval and record length. The frequency incre-
ment is ^2- radians per second in the DFT spectrum shown in Fig. 13.5(c).
In this case, the frequency increment is also small enough to represent the
continuous spectrum adequately as the spectrum is very smooth. To obtain
a denser spectrum, we have to increase the record length either by reducing
the level of truncation or zero padding.
Figure 13.6(a) shows the reconstructed signal using the DFT coefficients
computed with T = 1 and N = 16. In this case, the representation is poor.
Note that the reconstructed signal passes through all the sampling points,
as it should be, despite significant aliasing. If the parameters are fixed,
then we can get a better reconstructed signal by applying a window to the
frequency coefficients. Figure 13.6(b) shows the reconstructed signal using
the Hann window. The price we paid for reducing the ripples is a slow
rate of rise. Of course, the best thing to get a good reconstructed signal is
to use the appropriate parameters. Figure 13.6(c) shows the reconstructed
T=\
N=16
0.5
0.5 0 2 4 6 8
t
Fig. 13.6 The reconstructed signal using D F T coefficients computed with T = 1 and
N = 16. The reconstructed signal, using D F T coefficients computed with T = 1 and
N = 16 after applying the Hann window. The reconstructed signal using D F T coefficients
computed with T = 8 and N = 1024.
282 The Continuous-Time Fourier Transform
-I rOO /"OO
x(ti,t3) = T 1 / ^(wi.waJe^V^dwidwa
^™ J—oo J—oo
Let the record length Ti = 12 and T2 = 8 seconds and the number of sam-
ples Ni,N2 = 32. Compute the samples of the spectrum of the signal using
the DFT. Tabulate the first 4 x 4 scaled DFT coefficients and the corre-
sponding FT coefficients. Reconstruct the signal using the DFT coefficients
with and without applying the Hann window.
Solution
As the signal is separable, we use the 1-D FT results to get
(a) (b)
,-0.5 Z-0.5
(c) (d)
Fig. 13.7 (a) A 32 x 32 2-D signal in the center-zero format, (b) Its magnitude spectrum
in the center-zero format, (c) The reconstructed signal using the DFT coefficients.
(d) The reconstructed signal using the 1-D Hann window in the two directions.
Table 13.2 Comparison of the first 4 x 4 exact F T values (the first four rows) and the
corresponding scaled D F T values (the second four rows) of Example 13.7.
6 3.8197-j3.8197 ^/3.8197 -l.2732-jl.2732
3.8197--J3.8197 -jf4.8634 -2.4317-j2.4317 -1.6211
-J3.8197 -2.4317-j2.4317 -2.4317 -0.8106+j0.8106
-1.2732--jl.2732 -1.6211 -O.8106+J0.8106 jO.5404
6 3.8074-J3.8074 ^3.7705 -l.2362-jl.2362
3.8074--J3.8074 -j4.8322 -2.3927-j2.3927 -1.5689
-J3.7705 -2.3927-j2.3927 -2.3695 -0.7769+J0.7769
-1.2362--jl.2362 -1.5689 -0.7769-f-j0.7769 jO.5094
ripples. Figure 13.7(d) shows the reconstructed signal after applying the
1-D Hann window to each row and column of the spectrum. I
13.3 Summary
References
Exercises
Let the record length T — 32 seconds and the number of samples N = 512.
Compute the samples of the spectrum of the signal using the DFT. Tabulate
the first 8 scaled DFT coefficients and the corresponding FT coefficients.
13.3 Find the FT analytically.
x(t) = e~2W
Let the record length T = 8 seconds and the number of samples N = 256.
Compute the samples of the spectrum of the signal using the DFT. Tabulate
the first 8 scaled DFT coefficients and the corresponding FT coefficients.
13.4 Find the FT analytically.
x(t) = e" 4 t 2
Let the record length T = 8 seconds and the number of samples N = 256.
Compute the samples of the spectrum of the signal using the DFT. Tabulate
the first 8 scaled DFT coefficients and the corresponding FT coefficients.
286 The Continuous-Time Fourier Transform
(l-|*i|)(l-M) for|ii|<l,|i2|<l
' ' 0 elsewhere
Let the record length 7 i , T 2 = 4 seconds and the number of samples
Ni,N% = 64. Compute the samples of the spectrum of the signal using
the DFT. Tabulate the first 4 x 4 scaled DFT coefficients and the corre-
sponding FT coefficients.
Chapter 14
Convolution and Correlation
The linear convolution operation, relating the input, output, and the im-
pulse response of an LTI system, is of fundamental importance. The op-
eration of linear correlation is very similar to convolution and is used as a
similarity measure between signals. Use of DFT makes the computation of
these very important operations more efficient than implementing directly.
In Sec. 14.1, the linear convolution operation is presented. In Sec. 14.2,
the computation of convolution using the DFT is described. In Sec. 14.3,
the overlap-save method of convolution of long sequences is explained. In
Sec. 14.4, the convolution of 2-D signals is presented. In Sec. 14.5, the
computation of correlation is described.
287
288 Convolution and Correlation
i 1 0 2 3
m
\ i . i 3 l.l2 1.1 1
1.1 l.l2 l.l3
30C 20C
I
0 0
-i) l.l3 l.l2 1.1 1
h{2 -i) l.l3 l.l2 1.1 1
h(3 -0 l.l3 l.l2 1.1 1
n 0 1 2 3
y(n) 30C 53C 583 641.3
Fig. 14.1 The linear convolution operation.
year after that it will be 1.12$, etc. The savings account is a process and
the rate of growth of money of 1$ is the impulse response. Let us say
we open an account with a deposit of $300 and deposit another $200 at
the beginning of the next year. The deposits are the inputs. Let us try
to find the money, which is the output, in our account for the next three
years assuming that we make no other deposits or withdrawals in this pe-
riod and close the account after three years. At the beginning of this year,
the balance is $300 that we have deposited. At the beginning of the next
year the balance will be $300 x 1.1 + $200. The year after that the bal-
ance will be $300 x l . l 2 + $200 x 1.1. After three years the balance will be
$300 x l . l 3 + $200 x l.l 2 . The problem of finding the balance can be formu-
lated neatly as shown in Fig. 14.1. The impulse response h(i),i = 0,1,2,3
is {1,1.1, l.l 2 , l . l 3 } . The input x(i), i = 0,1,2,3 is {300,200,0,0}. The im-
pulse response when folded about the y-axis, h(0 - i), is { l . l 3 , l.l 2 ,1.1,1}.
To find the response j/(0), we simply find the sum of products of all the
overlapping samples of x{i) and h(0-i). Then, we shift h(0 — i) to the right
by one position to get h(l — i). The sum of products of all the overlapping
samples of x(i) and /i(l - i) yields the output y(l). This process can be
continued to find the other two outputs. Note that the values of x(i) and
h(i) for all values of i not shown in Fig. 14.1 are assumed to be zero. We
get the same result if x(i) is folded rather than h(i).
In summary, given the input sequence x(i) and the impulse response of
a system h(i), there are four steps to find the output of the system through
the convolution operation. 1. Fold one of the sequences about the y-axis.
2. Shift the folded sequence to the point where the output response is to
be determined. 3. Multiply the overlapping samples of the two sequences.
4. Add all the products to find the output at that output point.
The Indirect Convolution 289
It is easy to see that the present output is the sum of products of the two
sequences, each other's index running in opposite directions.
i -3 -2 -1 d 1 2 3
Mi) 3-1 1 2 3-1 1
xli) 1 4 2-1
h{0 - i) r i - i 3 2 1 - 1 3
h{\- W 1 - 1 3 2 1 - 1 3
h{2- i) 1 -1 3 2 1 -1 3
h(3- *) 1 -1 3 2 1 -1 3|
n 0 1 2 3
yip) 1 14 14 1
-6 -5 -4 -3 -2 -1 1 2 3 4 5 6
c
~3| -1 1 0 C c 2 3 -1 1 C C 0
1 4 2-1 C C 0
o c 0 1 -1 3 2 0 C C 1 -1 3
^y c C 0 1-1 3 2 C C C 1-1 3
( 2 - •i) c 0 C 1-1 3 2 c c C 1-1 3
h'(3- • 0 c c 0 1-1 3 2 0 0 C 1-1 3
h'(A- •i) c c C 1 -1 3 2 c c C 1-1 3
h'{5- •i) 0 C 0 1-1 3 2 c C C 1 -1 3
h'(6- •
c c 0 1-1 3 2 c c C 1-1
» )
31
n c 1 2 3 4 5 6
y'(n) 2 11 15 1 - 1 3 - 1
Fig. 14.3 The simulation of the linear convolution operation by the circular convolution
operation with zero padding.
(1) Find the smallest N such that N > P + Q-l and N is an integral
power of two. The second condition enables us to use power of two
DFT algorithms that are the most efficient.
(2) Append both sequences with zeros to get x'(n) and h'{n) of length
N.
(3) Compute the DFTs of x'(n) and h'{n) to obtain X'(k) and H'{k).
(4) Find the term by term product of X'{k) and H'(k) to get Y'(fc).
(5) Find the IDFT of Y'(k) to obtain y'{n).
(6) The first P + Q - l samples of y'(n) are the output of the linear
convolution of the two sequences x(n) and h(n).
292 Convolution and Correlation
Implementation
In practice, signals are real in most applications. To convolve a single real
signal with another real signal, we can use the DFT algorithms described
in Chapters 8 and 9. To convolve two real signals x(ri) and y{n) with a
single real impulse response h(n) (or a single real signal with two impulse
responses), we form a complex signal x'(n) +jy'(n) using the zero padded
signals x'{n) and y'{n). Compute the DFT, X'(k) + jY'(k). Compute the
DFT, H'(k), of the zero padded impulse response h'(n). Form the term by
term product Z(k) = (X'(k) + jY'(k))H'(k). Compute the IDFT of Z(k).
The real part gives the convolution of x(n) and h(n) and the imaginary
part gives the convolution of y(n) and h(n). This process enables the use
of a DFT algorithm for complex data without the necessity of splitting the
two individual DFTs of x'{n) and y'(n).
14.3 Overlap-Save M e t h o d
In general, the input signal is very long and, therefore, it may not be pos-
sible to manipulate the whole signal or we may not be able to wait too
long for the output. In such cases, the convolution operation is carried
out over sections of the input signal. For example, consider the impulse
response, h(n), of length Q = 4 and the input signal, x(n), of length
P = 14 shown in Fig. 14.4. (For illustrative purposes, we use a short
length of P = 14. However, the input sequence should be very long to
take advantage of this method.) The input signal is extended at the front
by Q — 1 = 3 zeros. Remember that the circular convolution without
zero padding yields incorrect values at the beginning. We have to choose
a block length. Let us say we choose a block length of 8. Then, the
h(n) 2 1 4 3
x(n) 7 4 1 3 5 9 1 0 2 4 2 3 8 6
0 0 0 7 4 1 3 5 9 1 0 2 4 2 3 8 61010101010101
2 1 4 3 0 ~o1 0 0
2 1 4 310 0 0 0
2 1 4 3 I00 0 0
2 1 4 3101010|0 1
y{n) 1141151341441291381401521351131161301391381471481181 0 | 0 [ 0
Implementation
The implementation consists of reading blocks of data, two at a time, com-
puting the DFT, multiplying it with the DFT of the impulse response,
computing the IDFT of the product, and storing the valid output. These
operations are repeated until the data is exhausted. As we are finding the
output of two blocks of length N at a time, the computational complexity
for one block is half and it is of computing a complex DFT. The computa-
tion of the DFT of the impulse response is carried out once and is ignored
in the analysis. A single DFT algorithm is sufficient as it can be used for
computing both DFT and IDFT. A table of twiddle factors can be used
repeatedly. The multiplication of two DFTs requires 3iV — 4 operations for
each block. A block produces N — Q + 1 valid output points. For example,
let N = 64. The 2 x 2 PM algorithm for complex data requires 1184 real
multiplications and additions. Multiplying the DFTs requires 188 opera-
tions. For an impulse response of length 12, 64 — 11 = 53 valid output
points are produced. Therefore, the number of operations per output point
i s U84+188 _ 25.9 (approximately 41og2 TV).
As for the choice for block length N, the following considerations must
be taken into account. If the block length is long there are two disadvan-
tages: (i) more memory is required and (ii) the number of DFT operations
per point increases. On the other hand, if the block length is short then
the overlap is more and the number of valid outputs decreases. In general,
for efficient implementation, the following condition is required.
Table 14.1 shows the number of operations for various block and impulse
response lengths. The minimum operation count is shown in boldface. The
other major factor is the data transfers which is about 2 log2 N per output
point. With the complexity order N log2 N for both arithmetic operations
and data transfers, the indirect convolution using fast DFT algorithms is
efficient for most cases than direct convolution. As the block sizes are much
smaller for any data size, the storage requirements are moderate.
Two-Dimensional Convolution 295
Table 14.1 The number of real arithmetic operations per point for various impulse
response and transform block lengths using 2 x 2 PM DFT algorithm for 1-D convolution
by the over-lap save method
N\IR 12 16 24 32 40 48 56 64 72 80 88
32 26.5 32.7 61.8
64 25.9 28.0 33.5 41.6 54.9 80.7
128 28.1 29.1 31.4 33.9 37.0 40.6 45.1 50.7 57.8 67.2 80.3
256 31.2 31.7 32.8 34.0 35.2 36.6 38.0 39.6 41.3 43.2 45.2
512 34.9 35.2 35.8 36.4 37.0 37.6 38.3 39.0 39.7 40.4 41.2
1024 38.8 38.9 39.2 39.5 39.9 40.2 40.5 40.9 41.2 41.6 41.9
n1,n2=0,l,...,P + Q - 2
X r « i , *?)
2 1 4 3 3 h( H,i2) h(ii,- •12) M - * i , - -i 2 )
1 0 2 2 2 1 3 2 2 3 1 3 1 8
3 1 0 1 0 3 5 6 6 5 3 6 5 3
2 0 1 3 5 8 1 3 3 1 8 2 3 1
1 0 4 2 5
(1) The sequence ft(i'i,Z2) is rotated in the (11,12) plane by 180 degrees
about the origin. This operation can be achieved in two steps as
shown in Fig. 14.5. Fold the sequence about i\ axis to get h(i\, - i 2 ) .
Then, we get h(-ii,—i2) by folding the resulting sequence about
12 axis.
(2) Shift the rotated sequence by an amount (711,712) to get the se-
quence h(n\ — »i,ri2 — 12)-
(3) Find the products x(ii,i2)h(ni — n , n 2 - 12) of all the overlapping
samples.
(4) Sum the products to get the convolution output y ( n i , n 2 ) .
For example, with a shift of 0 — i\, 0 —12, there is only one overlapping pair
(1,2). The product of these numbers yields the output y(0,0) = 2. The
overlapping samples with a shift of 2 — ti, 1 — i2 is also shown in Fig. 14.5.
The process is repeated to get the complete convolution output y (711,712)
shown in Fig. 14.5.
JV-l JV-1
y(7ii,n 2 ) = X ] 5 Z x(i2,i2)h(ni -ii,n2 - i2), 7ii,n 2 = 0 , 1 , . . . ,N - 1
i 1= o i2=o
Fig. 14.6 shows the 5 x 5 sequence x(ii,i 2 ) and the 3 x 3 sequence h(ii, 12)
of Fig. 14.5 padded with sufficient zeros so that, by using a power of two
DFT algorithm, the linear convolution is correctly simulated.
Overlap-save method
The 5 x 5 sequence x(i\,i2) and the 3 x 3 sequence h(ii,i2) of Fig. 14.5 are
zero padded as shown in Fig. 14.7. The outputs of two blocks each of size
4 x 4 are produced at a time. Fig. 14.8(a) shows the combined DFT of the
Two-Dimensional Convolution 297
Fig. 14.6 The sequences 1(11,12) and h(h,i2) of Fig. 14.5 padded with zeros in order to
use the circular convolution to simulate the linear convolution. Origin at upper left-hand
corner.
0+jQ 0 + jO 0 + jO 0 + jO
0+jO 0 + jO 0 + jO 0 + jO
0+j2 0 + j'l 2 + j4 l + j3
0+jl 0 + jO 1 + J 2 0 + j2
the real parts in the upper half and the imaginary parts in the lower half.
The DFT of the sequence h'{ii,i2) divided by 16 is shown in Fig. 14.8(b).
The division by 16 eliminates the necessity of the division operation each
time an ID FT is computed. Figure 14.8(c) shows the product of the two
DFTs. The convolution output of the first two blocks is obtained by com-
puting the IDFT (remember the division by 16 required by the IDFT op-
eration has already been done) of the product. The first block output is
the real part and the second block output is the imaginary part shown in
x'(i L , » 2 )
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 2 1 4 3 3 0 0 0 h'(ii,i2)
0 0 1 JL1 20 2 2 0 0 0 1 3 2 0
0 0 3 T0 1 1 0 0 0 0 3 5 6 0
0 0 2 3 5 0 0 0 8 1 3 0
0 0 1 0 4 2 5 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
0 0 0 0 0 0 0 0 0 0
Fig. 14.7 The sequences x ( i i , i 2 ) a n d / i ( n , i 2 ) of Fig. 14.5 padded with zeros to convolve
using the overlap-save method.
298 Convolution and Correlation
Fig. 14.8(d). The valid outputs are shown in boldface. This process is
repeated until all the blocks are processed. The complete output of the
convolution operation is shown in Fig. 14.5. The optimum block size for
various sizes of the sequence h ^ i , ^ ) are given in Table 14.2. The num-
ber of arithmetic operations and data transfers per point are, respectively,
about 8 log2 N and 4 log2 N.
The function of the correlation operation is different from that of the convo-
lution. However, the computation is very similar to that of convolution and
can be considered as the computation of convolution with slight changes in
the procedure. Letar(n), n = 0 , 1 , . . . , P-l and/i(n), n = 0 , 1 , . . . , Q - 1 be
Computation of Correlation 299
Table 14.2 The number of real arithmetic operations per point for various impulse
response and transform block lengths using 2 x 2 PM D F T algorithm for 2-D convolution
by the over-lap save method
NxNMR 3x3 5x5 7x7 9x9 11 x 11 13 x 13 15 x 15
8x8 30.0
16x16 31.3 42.6 61.4
32x32 36.4 41.8 48.5 56.9
64x64 42.6 45.5 48.7 52.2 56.2 60.6 65.5
128 x 128 50.1 51.7 53.4 55.2 57.1 59.1 61.1
i C 1 2 3
h(3 + i)
m
1 21 3 - 1 1
2 a-1 1
1 4 2-1
h(2 + i) | 2 3 -1 1
h(l + i) 2 3 -1 1
h(0 + i) 2 3 -1 1
M-i + ») 2 3 - 1 1
h(-2 + 0 2 3 -1 1
h (-3 + i) 2 3 -1 1
n 3 2 1 C- 1 - 2 - 3
Vxhin) 1 3 1 11 15 1 - 2
two arbitrary sequences. Assume that x(n) = 0, for n < 0 and n > P-1
and h(n) = 0, for n < 0 and n > Q — 1. Then the linear correlation of
the two sequences is given by
Min(Q-n-l,P-l)
Vxhin) = J2 x*(i)h(n + i), n = Q-1,Q-2,... ,-P +1
i=Max(0,—n)
One difference between this operation and the convolution is that there
is no folding operation in computing the correlation operation. Another
difference is that the correlation operation, in general, is not commutative.
A yet another difference is that the first function is conjugated. Otherwise,
the correlation operation is similar to convolution as can be seen from
Fig. 14.9, which shows the computation of the linear correlation of two
sequences { 1 , 4 , 2 , - 1 } and { 2 , 3 , - 1 , 1 } .
300 Convolution and Correlation
5|—4|—3—2|—H q 1] 2|
31 4! 51 6
2 3 - 1
1 C C O
h?(i) = h'(7-i) 2 0 -1 3
0 C
hrs (i) = hr'(i — 3) 2 - 1 3
C 0
x'U) 2-1 0 0
hrs'(0 - i) Q _ C _ C _2 _ 3 ^ 1 C C 0 3-1
firs'(1 -t) C C C 2 3 - 1 1 C 0 3-1
hrs'(2-t) c C 0 2 3-1 1 2 3-1
hrs' (3 -1J 0 0 0 2 3 - 1 C 2 3-1
/irs'(4-l) c 0 C 2 3 - 1 C C 2 3-1
hrs'(b —TJ C C 2 C C 2 3-1
hrs'(6 —1) C C C C O O
B
L(») 1 3 1 11 15 1-2
Fig. 14.10 The linear correlation operation simulated by the circular convolution oper-
ation with zero padding.
{21,40,26,31,36,52,50,23,25,22,24,25,46,57,38,22,12}
Summary 301
Table 14.3 The linear correlation output, yxh(ni,ri2), of the sequences 1(11,12) and
Mil)*z) shown in Fig. 14.5. Origin at upper left-hand corner.
6 5 29 21 44 27 24
15 17 49 49 69 42 25
19 19 53 52 48 36 9
26 26 38 29 43 40 42
21 22 38 36 100 56 55
10 11 31 41 72 49 20
2 3 9 16 20 17 5
Min(Q-m-l,P-l) Min(Q-m-l,P-l)
Vxh(ni,n2)= ^2 Y^, x*(ii,i2)h(ni+ii,n2 + i2),
ii = Max(0,—m) Z2 = Max(0,—n?)
n i , n 2 = Q - 1, Q - 2 , . . . , -P + 1.
The computation of the 2-D correlation is similar to that of the 2-D convo-
lution with the difference mentioned for the computation of 1-D correlation
extended to two dimensions. Table 14.3 shows the linear correlation output
of the sequences x{ii,i2) and h{ii,ii) shown in Fig. 14.5.
14.6 Summary
References
(1) Brigham, E. O. (1988) The Fast Fourier Transform and Its Appli-
cations, Prentice-Hall, New Jersey.
Exercises
14.1 Find the linear convolution of the sequences x(n) = {1,2,3} and
h(n) = {-2,3} using the DFT.
14.2 Find the circular convolution of the sequences x(n) = {1,2,3,4} and
h(n) = {1, - 2 , 1 , 3 } using the DFT.
* 14.3 Using the DFT, find the linear convolution of the sequences
2 1
2 3
x(nx,n2) = 3 4 h(n1,n2) =
1 4
-2 1
14.4 Using the DFT, find the circular convolution of the sequences
3 1 5 - 4 1 4 2 3
2 1 3 - 1 4 5 -2 -3
x(n1,n2) = h{ni,n2)
1-2 3 4 2 3 1 4
2 3 1 3 1 0 1 5
14.5 Find the linear correlation of the sequences x(n) = {1,2,3} and h(n) =
{-2,3} using the DFT.
14.6 Find the circular correlation of the sequences x(n) = {1,2,3,4} and
h{n) = {1, - 2 , 1 , 3 } using the DFT.
* 14.7 Using the DFT, find the linear correlation of the sequences
2 1 5
2 3
x(ni,n2) = 3 4 2 h(ni,n2) =
1 4
-2 1 -3
14.8 Using the DFT, find the circular correlation of the sequences
3 1 5 - 4 1 4 2 3
2 1 3 - 1 4 5 -2 -3
x(ni,n2) = h(ni,n2) =
1 - 2 3 4 2 3 1 4
2 3 1 3 1 0 1 5
Chapter 15
It was stated in Chapter 2 that when the sum of the pointwise products
of two discrete signals is zero over a specified interval, the signals are said
303
304 Discrete Cosine Transform
0.3536
0.4619
* -0.1913
(c) (d)
0.3536 0.4157
; 0.0975
in
-0.3536 -0.2778
-0.4904
(e)
0 4619 0.4157
0.0975
* -0. 1913 -0.2778
-0.4904
(9) (h)
1 N_1
2 ^ ( c O S 2^T ( 2 n + 1)(
' " m) + C S
° 2^(2n + 1)(Z + m))
n=0
c(fc) = t k=
{$I)f) for*
°' = °1,2,..., J V - l
These are the most commonly used definitions. However, it should be noted
that there are other forms also. It is assumed that the data length, N, is
even.
306 Discrete Cosine Transform
Simplifying, we get
X{2n)
xo(n)~S ' »= 0.1.-.f-l
^ W - j x(2JV-2n-l), n = f , f + 1,...,7V-1
and combining the two summations, we get
0.4904 • 4 +
bas s function 3.5 + input data
0.2778
• 3 +
c • 1?2.5 +
V 2 +
"* -0.0975 • +
1.5
• 1 +
-0.4157 • 0.5 +
0 2 4 6 0 2 4 6
n n
(a) (b)
0.4904 • 4 +
+
0.2778 • 3.5
+
3
• •5-2.5 +
1?
+
H
-0.0975 • +
1.5
• 1 +
-0.4157 • 0.5 +
0 2 4 6 0 2 4 6
n n
(c) (d)
Fig. 15.2 (a) The DCT basis function for the computation of Xct{\), with N = 8.
(b) The samples of an arbitrary data, (c) The samples of one cycle of the cosine waveform
giving the same sample values as shown in (a) such that the even-indexed samples appear
first followed by the odd-indexed samples in reverse order, (d) The data samples shown
in (b) rearranged such that the even-indexed samples appear first followed by the odd-
indexed samples in reverse order. Now, either the sum of products of samples shown in
(a) and (b) or those shown in (c) and (d) yields X c t (l).
used with the rearrangement of the input data as shown in Fig. 15.2(d). For
example with n = 1, cos f (1 + \) = cos ^ ( 7 + \). The input data values
shown in Fig. 15.2(b) are rearranged such that the even-indexed values
appear in the first half and the odd-indexed values appear in the second
half in reverse order. The last equation can be, equivalently, expressed as
JV-l
Xct(k) = C{k)Re{Y^xo(n)e~j¥{n+i)k)}
n=0
iV-1
= C(k) Re {W?N(J2 xo(n)W%k)},
Multiplying XO(k), term by term, by W*Q and taking the real parts, we
get {6.0,-0.54,2.83,-1.31}. A more efficient procedure for this step is
as follows. As the DFT is conjugate-symmetric, if XO(k) = a + jb, then
XO(N — k) = a — jb. The twiddle factors are related in the following way.
If W*N = c + jd, then W\N~ = —d — jc. Therefore, the products are
related.
The imaginary part of the product W%NXO(k) in the first half is the nega-
tive of the value of the real part with index N — k. Therefore, multiplication
with the twiddle factors over half the range is sufficient. Now,
These values have been normalized for DCT. For taking the IDFT the first
value must be multiplied by JV = 4 and other values by y = 2 (Note
that the number of multiplication by constants can be minimized in the
implementation of the algorithm.) to get XOik) = {6, - 1 + j , 4 , - 1 — j}.
Computing the IDFT of XOik), we get xoin) = {2,0,3,1}. The first half
The 2-D Discrete Cosine Transform 309
is the even-indexed values of the input data and the second half, in reverse
order, are the odd-indexed values. I
JV-1 JV-1
where C(fci) and C(k2) are as defined in the last section. The 2-D inverse
DCT is defined as
N-l N-l
x(nun2) = Yl Yl C(fci)C(fc2)X ct (fci,fc 2 )cos^r(2ni + l)fci
ki=0k2=0
7T
x c o s — ( 2 n 2 + l)k2, ni,n2 = 0,1,..., N - 1
N-l JV-1
Xct(kuk2) = C(fc2) £ { £ ( * ! ) ^ x ( n 1 , n 2 ) c o s ^ ( 2 n 1 + l)A;1}
ri2=o m=o
x c o s — ( 2 n 2 + l)A;2
Therefore, the algorithm for computing the 2-D DCT is to compute the 1-D
DCT of each row of the image followed by the 1-D DCT of each column of
the resulting data and vice versa.
310 Discrete Cosine Transform
n 2 -*
ni
1 3 1 1
4 0 4 1
3 2 1 0
2 1 4 3
Solution
Computing 1-D DCT of the columns, we get
k2 ->•
7.75 1.09 -0.25 1.98 "
-0.90 0.95 -0.52 1.07
0.25 -2.02 -0.75 1.60
-1.52 1.43 -0.60 2.95 .
The original image can be obtained by computing 1-D inverse DCT of each
row of the transform matrix followed by 1-D inverse DCT of each column
of the resulting matrix and vice versa. I
15.4 Summary
• In this chapter, algorithms for the computation of the 1-D and 2-D
DCT were described. It was pointed out that the DCT is essentially
the DFT of an even-extended real signal. Reordering of the input
data makes the problem of computing the DCT into a problem of
computing the DFT of a real signal with a few additional opera-
tions. This approach provides regular, simple, and very efficient
Exercises 311
References
Exercises
15.1 Compute the DCT, Xct(k), of x(n) = {3,4,5,6} using the DFT.
Compute x(n) back from Xct(k).
* 15.2 Compute the 2-D DCT of the following matrix of data using the
DFT. The origin is at upper left-hand corner.
n 2 -¥
ni
1 4 2 3"
4- 5 6 4 1
2 5 1 3
3 0 4 1
Chapter 16
313
314 Discrete Walsh-Hadamard Transform
where ni is the zth bit in the binary representation of n. The Isb is indicated
by the subscript 0. The transform coefficients, Xw(k), are called sequency
coefficients. Sequency is defined as, for waveforms with an odd number of
zero crossings, 0.5(number of zero crossings+1) and, for waveforms with an
even number of zero crossings, 0.5(number of zero crossings). The matrix
form of the defining equation, with N = 8, is written as
The DWT basis waveforms, with N = 8, are shown in Fig. 16.1. The DWT
basis functions,
Af-l
N-l
Y,WN(0,n)=N
n=0
Since there are equal number of plus ones and minus ones in all other rows,
JV-l
J2WN(k,n) = 0, Jfc = 1 , 2 , . . . , J V - l
n=0
The Discrete Walsh Transform 315
l1r "c 1 • • • •
fe°°oL & 1 • _a_ • . _«.
0 2 4 6 0 2 4 6
n n
(a) (b)
•? 11* • • • "B 1 t* • • •
ci o C 0
fe 1 . • _ _*. a—_*L £ 1 • • • _•_
0 2 4 6 0 2 4 6
n n
(o) (d)
B- 1 • • • • "B 1 • • • •
S. 0 !£ 0
fe 1 _•_ . _•. _•_ _•. B£°° 1 —*_ _• •-. _•
(e) (f)
? 1|« • • • B- 1f
£ 0
OO I cL o -
* -1 L — • — • . • • fe - 1 L — • — • _
4
n
(9) (h)
Example 16.1 Let x(n) = {1,3,5,7}. Compute the DWT of x(n). Get
back x(n) by computing the inverse DWT of the sequency coefficients.
Solution
Xw{0) = 1 + 3 + 5 + 7 = 16
Xw(l) = 1+ 3 - 5 - 7 =-8
Xw(2) = 1-3 + 5 - 7 = - 4
Xw(3) = 1-3-5 + 7= 0
n=0
The Discrete Walsh Transform 317
O
4
__ V^ x(n\^ (™ifci)j^2("o*i+fconi)^l(n0fco)
n=0
3
r l(n 0 fco)
= 5^ar(n)(-l) (no * 1+ * oBl) W4
n=0
This definition is the same as that of the DWT if we set all the twiddle
factors, except those with powers of (—1), to unity. Therefore, by setting
all twiddle factors to unity, except those with powers of ( - 1 ) , we change a
DFT algorithm to a DWT algorithm. The PM DWT algorithm is deduced
from the 2 x 1 PM DIT DFT algorithm as follows. The input vectors a(ri)
are defined as
N N
o.(n) = {o 0 (n),a 1 (n)} = {(x(n) + x(n + -j),x{n) - x(n + y ) ) } ,
N
n = 0,l,...,--l
A[*lHh) = 4 r ) w-4 r ) w
4r+1>(Z) = A[r\h) + A<?\l)
A?+1\l) = A[rHh)-A[rHD
The SFG of the PM DWT algorithm, with N = 16, is shown in Fig. 16.2,
which is the same as that of the 2 x 1 PM DIT DFT algorithm with the
twiddle factors set equal to unity. The number of real addition operations
required by the PM DWT algorithm is N log2 N.
E x a m p l e 16.2 Find the trace of the algorithm shown in Fig. 16.2 for
the following input data.
{1,3,1,1,4,0,4,1,3,2,1,0,2,1,4,3}
Solution
The trace is shown in Fig. 16.3. The sequency coefficients are
318 Discrete Walsh-Hadamard Transform
A(l)
A(2)
A(3)
A(4)
A{5)
A(6)
o(7)o A(7)
{31, - 1 , - 7 , 1 , 1 , 1 , 1 1 , - 5 , 9 , 1 , - 9 , - 9 , - 1 , - 1 , - 3 , - 3 }
n i = 0 I nn 22==00 i=0
M-l
x JJ (-l)^)'^)"-1-1, fci,fc2=0,l,...,iV-l
(=0
Example 16.3 Compute the 2-D DWT of the following matrix of data.
The Discrete Walsh Transform 319
Vector
Formation Stage 1
and Output
Swapping
X(o) m 4 10 20 311 -MO)
-2 -2 0 9j Xw(&)
x(8) |_3j
6 0 0 rri ^ ( i )
*(1) |~3 2 -4 0 LU -M9)
*(2) m
z(10)LU yy ^(io)
*(3) m Xw{3)
a?(ll) I_QJ •Mil)
x{4)
x(12)
x(5)
a 11 X«,(4)
l] ^ ( 1 2 )
rri ^(5)
x(13)
LU XW(U)
x(6) Til Xw{6)
x(14) 31 X„,(14)
*(7) Xw(7)
x(15) -M15)
Fig. 16.3 The trace of the P M D W T algorithm, with N = 16.
n 2 ->
1 3 1 1
4 0 4 1
3 2 1 0
2 1 4 3
Solution
Computing the 1-D DWT of the rows, we get
6 2 -2 -2
9 -1 7 1
6 4 2 0
10 -4 2 0
320 Discrete Walsh-Hadamard Transform
Computing the 1-D DWT of the columns of the resulting matrix, we get
k2 -»•
*1 " 31 1 9 -1
I -1 1 1 -1
-7 11 - 9 -3
1 -5 -9 -3
The original image can be obtained by computing the 1-D row inverse
DWTs of the transform matrix followed by the 1-D column inverse DWTs
of the resulting matrix and vice versa. I
It can be shown that the 2-D computation is the same as that of 1-D
DWT. As such the SFG for computing the 2-D DWT remains the same as
in Fig. 16.2 except that the data length is iV2. If data is read row-by-row
from the input file, the output would be written column-by-column and
vice versa.
Uii
Xnh(k) = Y, *(n)(-l)^-° > fc = 0 , 1 , . . . , iV - 1,
n=0
where ni is the ith bit in the binary representation of n, the lsb is indicated
„., „^„„. - ,..,,,..,.., v -,
Ei=o
Af-l ,
niki
,
n, k = 0 , 1 , . . . , JV - 1 , with N = 8, are shown in Fig. 16.4. The matrix form
of the defining equation, with N = 8, is written as
Xnh(0) " 1 1 1 1 1 1 1 1 " • ar(0) "
Xnh(l) 1 -1 1 - 1 1 - 1 1 -1 x(l)
Xnh(2) 1 1 - 1 - 1 1 1 -1 -1 x(2)
Xnh(3) 1 - 1 - 1 1 1 - 1 -1 1 x(3)
Xnh(4) 1 1 1 1 - 1 - 1 -1 -1 x(4)
Xnh{5) 1 -1 1 - 1 - 1 1 -1 1 x(5)
Xnh(6) 1 1 _1 - 1 _1 _1 1 1 x(6)
L Xnh(7) 1 - 1 - 1 1 - 1 1 1 -1 . «(7) .
The Naturally Ordered Discrete Hadamard Transform 321
I1
Bt"o
"?
d
^ oo
1 [•
o—
1 _a_
•
_a
•
. _•_
•
0 2 4 6 fe i L _ 2
4
6
n 0 n
(a) (b)
"e 1 • • • • "e 1p • • •
^ 00
e o—
£ 1 £ i L __ a _ _ i _ •
0 2 4 6 0 2 4 6
n n
(c) (d)
•? 11* • • • "B 1p • • •
€ o £ 0—
•. 0° I
fe 11 _•_ _• •
~s 1 L_
0 2 4 6 0 2 4 6
n n
(e) (0
"c 1 t* • • • "c 1p • • •
€ 0 £ 0 —
^ o° 1 • •_
—a • a_ fe i L_•_ . t
0 2 4 6 0 2 4 6
n n
(g) (h)
1 1
NDHT2 =
1 -1
NDHTJV NDHTJV
NDHT2)V =
NDHTN -NDHTJV
For example,
1 1 1 1
1 -1 1 -1
NDHT4
1 1 -1 -1
1 -1 -1 1
322 Discrete Walsh-Hadamard Transform
By writing the rows of this kernel in bit-reversed order, we can get the
DWT kernel. The inverse NDHT is given by
4 r + 1 ) w = <4 r) w+4 p) (o
o[ r+1) (ft) = air\h)-a£\l)
a£+1\l) = r
a[ \h) + aP(l)
a[ r+1 )(Z) = a^iV-a^Hl)
The Naturally Ordered Discrete Hadamard Transform 323
A(l)
A(2)
The SFG of the PM NDHT algorithm, with N = 16, is shown in Fig. 16.5,
which is essentially the same as that of the 2 x 1 PM DIF DFT algorithm
with the twiddle factors set equal to unity.
Example 16.5 Find the trace of the algorithm shown in Fig. 16.5 for
the input data shown in Fig. 16.3.
Solution
The trace is shown in Fig. 16.6. The sequency coefficients are
{31,9,1, - 1 , - 7 , - 9 , 1 1 , - 3 , - 1 , 1 , 1 , - 1 , 1 , - 9 , - 5 , - 3 } I
ar(10)LU li 10
-6
-8
4
T l X nh (4)
r9j Xnh(5)
x(3) [ I
x(ll)[_0
x(4)
E H E i
Til Xnft(6)
U X„h(7)
FT] *nft(8)
x(12) LU *nh(9)
x(5)
a
h
0 PH Fl Xnh(W)
x(13) -l 2 i 1 I ^nh(H)
x(6) f T | 8 0 -4 X„ft(12)
x(14)LU 0 0 -4 Xn7l(13)
*(T) m 4 -1 5 Xnh{U)
x(15)liJ -2 3 -1 X„/>(15)
It can be shown that the computation of 2-D NDHT is the same as that of
1-D NDHT. As such the SFG remains the same except that the data length
is N2. If data is read row-by-row from the input file, the output would be
written row-by-row and vice versa.
Example 16.6 Compute the 2-D NDHT of the matrix of data given in
Example 16.3.
Solution
Computing the 1-D NDHT of the rows, we get
6 -2 2 -2
9 7 -1 1
6 2 4 0
0 2 -4 0
The Sequency Ordered Discrete Hadamard Transform 325
Computing the 1-D NDHT of the columns of the resulting matrix, we get
k2 ->•
fcl " 31 9 1 -1
I -7 - 9 11 -3
-1 1 1 -1
1 -9 -5 -3
The original image can be obtained by computing the 1-D row inverse
NDHTs of the transform matrix followed by the 1-D column inverse NDHTs
of the resulting matrix and vice versa. I
where rii is the ith bit in the binary representation of n, the lsb is indicated
by the subscript 0, and
g0(k) = kM-i
9i {k) = {kM-i + kM-2) mod 2
52(k) = (&M-2 + kMs) mod 2
"a 1 "e 1 • • • •
O
fe 0 5° °
& -1
0 2 4 6 0 2 4 6
it n
(a) (b)
B1 1 • • • • "s 1 • • • •
CI 0 C 0
.. 00 • .. 00
& 1 £ 1
0 2 4 6 0 2 4 6
n n
(c) (d)
"a 1 • • • • "a 1 t» • • •
S. 0 !C 0
^ 00 m ^ 00 a
=s 1 fe 1
<•) (f)
"a 1 f 1 M • • •
£ 0 0
& -1
-1 L • . • . • . •.
(g) (h)
are shown in Fig. 16.7, with N — 8. It can be seen that the waveforms
are sequency ordered and are similar to the DFT basis waveforms. This
kernel can be obtained by rearranging the DWT kernel in gray-code order
(0,1,3,2,6,7,5,4, for AT = 8). The inverse SDHT is given by
N _ 1
1 M-l
x
^ = JJ E *.ft(*)(-l) Si -° ni9i{k)
> n = 0 , 1 , . . . , iV - 1
k=0
Example 16.7 Let x{n) = {1,3,5,7}. Compute the SDHT of x(n). Get
back x(n) by computing the inverse SDHT of the sequency coefficients.
The Sequency Ordered Discrete Hadamard Transform 327
Solution
X8h(0) = 1 + 3 + 5 + 7 = 16
X8h(l) = 1+3-5-7=-8
X8h(2) = 1-3-5+7=0
Xsh(3) = 1-3+5-7=-4
The SFG of the PM SDHT algorithm, with N = 16, is shown in Fig. 16.8.
328 Discrete Walsh-Hadamard Transform
o(4) A(l)
o(2) A(2)
«(6) A(3)
o(l) •A(4)
o(5) A(5)
o(3) A(6)
o(7) ^(7)
*.*(*!,to) = £ E x(n1,n2)(-l)(S";1("0^(fc1)+E"o1^)'^^»,
ni=0n2=0
fcl,fc2=0,l,...,JV-l
Example 16.8 Compute the 2-D SDHT of the matrix of data of Exam-
ple 16.3.
Solution
Computing the 1-D SDHT of the rows, we get
6 2 - 2 - 2
9 - 1 1 7
6 4 0 2
10-4 0 2
Summary 329
Computing the 1-D SDHT of the columns of the resulting matrix, we get
fc2 -»•
31 1-1 9"
i -1 1-1 1
1 -5 -3 -9
-7 11 - 3 -9 .
The original image can be obtained by computing the 1-D row inverse
SDHTs of the transform matrix followed by the 1-D column inverse SDHTs
of the resulting matrix and vice versa. I
The SFG of the 1-D SDHT algorithm remains the same for the compu-
tation of the 2-D SDHT with the same number of data values except for a
difference explained below. The vector formation is carried out in the re-
quired manner for the row (column) transforms. However, for the column
(row) transforms, the vector formation stage occurs after the computa-
tion of the row (column) transforms. In this intermediate vector formation
stage, the sum and difference values are stored, respectively, as the first
and second elements of a vector, at both the upper and lower nodes of a
butterfly. If data is read row-by-row from the input file, the output would
be written column-by-column and vice versa.
Example 16.9 Find the trace of the algorithm shown in Fig. 16.8: (i)
for the 1-D input data shown in Fig. 16.3 and (ii) for the 2-D input data of
Example 16.3.
Solution
(i) The trace is shown in Fig. 16.9. The sequency coefficients are
{31, - 1 , 1 , - 7 , 1 1 , - 5 , 1 , 1 , - 1 , - 1 , - 3 , - 3 , - 9 , - 9 , 1 , 9 }
(ii) The trace is shown in Fig. 16.10. The sequency coefficients are the same
as that of Example 16.8. I
16.4 Summary
• In this Chapter, 1-D and 2-D DWT, NDHT, and SDHT and the
PM algorithms to compute them were described. These transforms,
particularly effective for representing waveforms with discontinu-
ities, use a set of orthogonal rectangular waveforms as basis func-
330 Discrete Walsh-Hadamard Transform
Vector
Formation Stage 1 Stage 2 Stage 3
Input
and Output Output Output
Swapping
x{0 3T1 Xsh(0)
x(l _3_
Gn x8h(i)
x(2
x (3 a X8h(2)
X8h(3)
x (4
x(5 a 9
-1
3
1
mn xsh(4)
Lil xsh(5)
x(6
x(7
x(8 3
a 10
-4
-2
8
0
-1
m ^ ft (6)
x(9 2 I -2 -3 n n Jf.fc(8)
z(10)
z(ll)
1
0
1
1
0
0 a X, fc (10)
X8h(U)
*(12)
z(13)
2
1 a a -9
5
-9 X. fc (12)
-9 Jf.h(13)
a;(14)
x(15) a a 0
4
1 X gh (14)
9 X, fc (15)
Fig. 16.9 The trace of the 1-D P M SDHT algorithm, with N = 16.
References
Vector Column
Formation Row
Transform Vector Transform
and Output Formation Output
Swapping
x(0, 0 * 8 fc(0,0
X(0, 1 X8h{\,Q
-
z(0,2
x(0,3
5
1 4
re 16
-4
1 Xsh%Q
-7 Xsh(Z,Q
x(l,0 4 1 nr 1 nn
Xsh{Q,\
x(l,l 4] -i 3 j X8h(l,\
x(l,2
x(l,3
z(2,0
m 10
-4
-2
0
8
-1
[-b\ s h ( 2 , l
X
11 Xsh(3,1
-1 X s / l (0,2
z(2,l -2 -3 -1 X s f t (l,2
x(2,2; 0 -3 -X»fc(2,2
a;(2,3 0 -3 -^»fe(3,2
z(3,0 5 9 * 8 ft(0,3
a;(3,1 -9 1 ^sfe(l,3
z(3,2 4 -9 ^«ft(2,3
z(3,3 0 -9 ^»/j(3,3
Exercises
16.1 List the values at each stage of computing the inverse DWT of the se-
quency coefficients shown in Fig. 16.3 using the algorithm shown in Fig. 16.2.
* 16.2 List the values at each stage of computing the inverse NDHT of
the sequency coefficients shown in Fig. 16.6 using the algorithm shown in
Fig. 16.5.
16.3 List the values at each stage of computing the 1-D inverse SDHT of
the sequency coefficients shown in Fig. 16.9 using the algorithm shown in
Fig. 16.8.
16.4 List the values at each stage of computing the 2-D inverse SDHT of
the sequency coefficients shown in Fig. 16.10 using the algorithm shown in
Fig. 16.8.
332 Discrete Walsh-Hadamard Transform
Programming Exercises
16.7 Write a two stages at a time program to implement the 2-D PM SDHT
algorithm.
Appendix A
333
334 The Complex Numbers
•-1+/J
2+/2
,o+y 1
,-2+yO
0+yO
.-2-yi |
So
2-/2
J
m
- 2 - 1 0 1 2
than using vector algebra or vector diagrams. When the second of the pair
of ordered numbers is zero, it is equivalent to a real number. The set of
real numbers is a subset of the complex numbers.
Rectangular Form
Figure A.l shows some complex numbers in the complex plane. Remember
that the negative symbol '-' is used to represent n radians or 180 degrees
(the angle formed by the positive and the negative real axis). Similarly,
the symbol j is used to indicate an angle of \ radians or 90 degrees. The
rectangular form of a complex number is given by x + jy where x and y are
real numbers and j — y/—l since jj = j 2 = —1, a rotation of 180 degrees.
The number x is called the real part and y is called the imaginary part of
the complex number and j is called the imaginary unit. If the real part of
a complex number is zero (the number 0 + j l ) , it is called a pure imaginary
number (a number on the imaginary axis). If the imaginary part is zero
(the number -2+jO), it is called a pure real number (a number on the real
axis).
Let Zi = xi + jyi and z2 — x2 + J2/2- The complex numbers z\ and z2
are equal if and only if x\ — x2 and y\ =yi-
Addition
Subtraction
Multiplication
Conjugation
The conjugate of a complex number z = x+jy, denoted by z*, is defined
asz* = x—jy, that is the imaginary part is negated. The complex conjugate
pair 2 + j2 and 2 — j2 is shown in Fig. A.l. z + z* = 2x, z — z* — j2y, and
zz* = x2 + y2. The complex conjugate of an expression is equivalent to the
expression with every complex quantity conjugated.
Division
_ zi _ ziz* _ {xxx2 + 2/12/2) + j(x2yi - y2xi)
z
3 — — — T — o~, 9
Z2 Z2Z^ X\ + J/2
Polar Form
A point in the complex plane can also be represented by its distance from
the origin, called the magnitude (the magnitude is always a positive num-
ber), and the angle, called the argument, formed by the line joining the
point and the origin, and the positive real axis. The magnitude A and the
argument 8 can be obtained from the rectangular form x + jy as
A = +x/(a; 2 + 2/2),
9 = tan""1 ^
x
The polar form is written as Aid. As ALQ = AL(Q + 2kir), where k is an
integer, the value of the argument 6 such that — it < 6 < 7T is called its prin-
cipal value. From polar representation, the components of the rectangular
form can be derived as x = ^4cos0 and y = AsinO. Using Euler's identity,
we get
The expression on the left is called the exponential form of the complex
number. The multiplication and division operations are relatively easier to
carry out in the polar or exponential form.
z2 A2e^ A2
Powers and R o o t s
y~z= ^ ( c o s ^ ± f + j s i n ^ ± f ) , fc = 0 , l , . . . , J V - l (A.l)
where %/f is the real positive root. For example, letting r — 1, 6 = TT, and
N = 2, with A; = 0, we get
(cos-+jsin-) =0 + jl
(cos y + j s i n y ) = 0 - j l
Of particular interest to DFT are the N roots of unity, that is the solutions
of the equation xN — 1 = 0. In mathematical literature, the computation
of the DFT is referred to as the evaluation of a polynomial of degree N — 1
at N values of the roots of unity. The usual representation of a polynomial
is with its coefficients. For example, the representation of the polynomial
2 + 3x with its values at the two roots of unity (1, - 1 ) is (5, - 1 ) , obtained
by evaluating the polynomial at 1 and -1. In electrical engineering litera-
ture, the computation of the DFT is referred to as the evaluation of the
^-transform at JV equally spaced points on the unit circle.
The Complex Exponential, and Cosine and Sine Functions 337
Let us express the complex exponential in the series form. The series rep-
resentation is similar to that of a real exponential.
6 1
+ W";+ 2! 3! 4! ' (r)!
The exponent can be any complex number, but our interest is primarily in
the complex exponential with a pure imaginary exponent. One half of the
numbers in the series are pure real and the other half pure imaginary. If
we group the two sets, we get
•»><i-£+S--)+i(#-£+£-->
The two expressions in parenthesis on the right-hand side are series ex-
pansions for cosine and sine functions, respectively. Therefore, we get the
Euler's identity
Figure A.2 shows thirty-two equidistant points of a circle of radius one and
center at origin. By definition, the projection of any point on the real axis
is cos#, where 8 is the angle formed by the line from the origin to the point
and the positive real axis. The line between a point on the circle and the
338 The Complex Numbers
Imaginary axis
k.
fl 0.1951+ J0.9808
* • 0.3827 + j0.9239
• 0.5556+ J0.8315
,f 0.7071 + j'0.7071
,]un\ • 0.8315 + J0.5556
| • 0.9239 + jO.3827
I • 0.9808 + j0.1951
J- .i-oopo + JO.OOOO
cosH t Real axis
I *
I •
I•
1
•I
-J'l
n= 0
i.-'
cos(a;n), LJ = ||
8 *
»•
16
24.
*32
Fig. A.2 The first eight roots of unity, with N = 32. The values not shown can be
obtained by using appropriate signs for various quadrants. The figure also shows the
representation of a cosine waveform as the projection of a rotating vector on the real
axis.
The Representation of a Real Sinusoid 339
Imaginary axis
';'0.5
0.5 ^S(UJn)
2 ' 2
Fig. A.3 The representation of a cosine waveform as the sum of two rotating conjugate
vectors.
341
342 The Measure of Computational Complexity
10 +
+
+
+
+ n
lu
10 A/3* D " o
+ • o
Complex
+
+
° „°
D
+ D
o
O
+ D O NlBSf , " "
D _ • * X
a 0 •
o • X
• • X X
log^V
-m" J1
10" 10' 10' 10J 10' 10°
N
ating the 2-D DFT using the row-column method along with fast 1-D DFT
algorithms is 0(N2 log2 N).
Appendix C
343
344 The Bit-Reversal Algorithm
Table C.l A list of the decimal numbers from 0 to 15 and their bit-reversals.
Decimal Binary Bit-reversed Bit-reversed
ri3n2Tiino noT»lTl2«3 decimal
0 0000 0000 0
1 0001 1000 8
2 0010 0100 4
3 0011 1100 12
4 0100 0010 2
5 0101 1010 10
6 0110 0110 6
7 0111 1110 14
8 1000 0001 1
9 1001 1001 9
10 1010 0101 5
11 1011 1101 13
12 1100 0011 3
13 1101 1011 11
14 1110 0111 7
15 1111 1111 15
weight is greater than the number at any stage, we set the corresponding
bit to zero before we test with the next lower weight. This method will be
used in the bit reversal algorithm to test the bits in various positions.
even number. We can obtain the next even number from an even number
by just adding the binary number 0010. This addition results in the change
of bits from 1 to 0, starting from the second bit from the right, until the
first zero bit is found, which is changed from 0 to 1 leaving the other bits
unchanged. Therefore, given the bit-reversal of a number, we have to start
from the second bit from the left and change all the 1 bits to zeros and the
first zero bit to 1, and leave the rest of the bits unchanged. For example,
the bit-reversal of the number 0100 is 0010. The bit-reversal of 0110 is
0110. In the implementation of the algorithm, we use decimal numbers
and a 1 or 0 is found by comparing the number with appropriate weights.
For the example of finding the bit-reversal of 6, we compare the number 2
(bit-reversal of 4) with 4 and find that the second bit from the left is zero
(number is less than the weight). We change that bit to 1 (by adding the
weight 4) to get the bit-reversal as 6. The flow chart of the algorithm is
shown in Fig. 6.10(d).
Reference
Fig. D.l The prime-factor DFT algorithm, with N = 6, and its trace.
347
348 Prime-Factor DFT Algorithm
{1,3,5,2,4,6} is also given in Fig. D.l. For computing a 3-point DFT, use
the upper half of the SFG without the last stage. The input values x(2)
and a;(4) become, respectively, ar(l) and x(2).
Reference
In this Appendix, we present a variety of test data sets and ways for testing
DFT programs. Once a program is written, it must be tested not only with
a variety of data but also for different data sizes. For example, a program,
written for data lengths of an integral power of 2, must be tested at the
least for N = 16, 32, 64, 128, 256, and 512.
We have derived the 1-D and 2-D DFT of several signals in closed-form
and several problems have been suggested. The closed-form expressions of
these DFTs can be used for testing.
Use of Properties
Certain inputs, which produce known outputs, can be used to test pro-
grams. For example,
(1) Find the DFT of data and compute the IDFT of the transform to
get back the data
(2) Carry out the convolution operation using the DFT and check the
results with that obtained by the direct method. In a similar way,
the correlation operation can also be used.
Number of Operations, Precision, and Execution Time 351
N u m b e r of O p e r a t i o n s , Precision, a n d E x e c u t i o n T i m e
The DFT values must be checked for expected precision. Check always
that the number of operations required for a given data size is correct with
the theoretical values. Check that the execution time is reasonable for the
specific computer.
Appendix F
e±j0 =cos9±jsin9
cos 9 =
. n e»'9-e--»'«
sin 9 = —
sin2 9 + cos2 9 = 1
353
354 Useful Mathematical Formulas
cos(7r ± 9) = — cos#
7T
c o s ( - ±9) = T s i n 0
7T
sin( — ± 0 ) = cos#
c o s ( ^ ± 0 ) = ±sin0
x+y x —y
cos x + cos y = 2 cos —-— cos —-—
A Ad
. x+y . x-y
cos x — cos y = — 2 sin —-— sin —-—
- l ^ • - l
+ + + + +
e - l + (ja;)+ 2! 3! 4! (r)!
X3 X5 , _ X2r+1
sin(x) = x- — + — + v( - l ) r
3! 5! ' (2r + l)!
JV-1
i=0
JJV-1
, _ 1
ci JV\
JV-1
»=0 ^ '
/ udv = uv — I vdu
l'hopital's rule:
d
If lim f(x) = 0 and lim g(x) = 0, then lim ^ = lim /^\/ff
Answers to Selected Exercises
357
358 Answers to Selected Exercises
3.15.5. x( n ) = £ c o 6 ( f j p 5 n - a ? 0 .
5.1.2. The input vectors are {(4 + j 3 , - j l ) , (2 - j 5 , jl)}. The DFT vectors
a r e { ( 6 - j 2 , 2 + j 8 ) , ( l - j l , - l - j l ) } . The DFT X(fc) is { 6 - j 2 , l - j l , 2 +
j8,-l-jl}.
5.5. The input vectors are {(1 + j 5 , - 3 - jl), ( - 5 + j2,1)}. The output
vectors are {(—4 + jl, 6 + j3), (—3 — j2, —3)}. When real and imaginary
parts are swapped, we get x(n) as {7 — j4, —2 — j'3,3 + j6, — j3}/4.
5.9. The swapped input vectors are {(j'4, - 6 - j2), (2 + jA,-4 + j2), ( - 5 +
j4,-l),(j4,-8)}.
The vectors after Stage 1 are {(2 + j 8 , - 2 ) , ( - 4 + j2, - 8 - j6), ( - 5 +
j8,-5),(-l + j8,-l-j8)}.
The output vectors are { ( - 3 + j l 6 , 7 ) , (0.9497 + j'8.364, -8.9497-j'4.364),
( - 2 + j 5 , - 2 - j5), (-12.9497 + jO.364, -3.0503 - J12.364)}. To get the
IDFT, the real and imaginary parts must be swapped and divided by 8.
5.10. The input vectors are {(3 - j 6 , - 1 - j2), (3,1 - j6), (2 - j2,0), (4 -
A-J6)}.
The vectors after Stage 1 are {(5 - j 8 , 1 - ji), (7 - j2, - 1 + j2), ( - 1 -
j2, - 1 - j2), (-7.7782 - jO.7071,0.7071 - J9.1924)}.
The output vectors are {(12 - j'10, - 2 - jQ), (3 - j 3 , - 1 - ;5), (-8.7782 -
J2.7071,6.7782 - jl.2929), (-10.1924 - J2.7071,8.1924 - jl.2929)}. The
output vectors must be swapped to get the DFT values in natural order.
Answers to Selected Exercises 359
10.7(d). X(14,0) = - 6 4 0 ( \ / 3 - j l )
10.7(f). X(8,6) = 512(V5 - j l ) , X(24,26) = 512(V5 + j l )
10.8(f). x{n1,n2) = ^ cos(ff(2m + 3 n 2 ) + f )
10.8(1). x{nun2) = ^ei(?f(2"i+2"=)-f)
10.11. JST(7,21) = X ( 3 , l ) = - 5 + j l , X ( - 4 , - 3 ) = X(0,1) = 4 + j 6 ,
X(l,-3) = X(l,l) = - 5 + j 3
10.16.
-> k2
24 4 + j6 4 4-j6 "
3 + j l - 5 + j3 - 1 + j l -5 - jl
1
^ 6 2-j2 2 2 + j2
. 3-jl -5 + jl -1-jl -5-J3.
10.18.
J V - 1 N-l JV-1 JV-1
4
* E E l*(ni,n2)| = E E |*(*i,fe>)|2 =896
2
ni=0n2=0 fei =0*2=0
must be more than twice the highest frequency, the sampling period Ts
must be less than 2 x g 0 0 0 = 0.0001 seconds. Therefore, the number of sam-
ples, N, in the time-domain data must be more than £- = 0 °p 01 = 1000.
Note that, in practice, typically two times the minimum N is used. In this
case, 2000 samples may be used. In addition, N is usually fixed to the next
largest power of two, so that a power of two DFT algorithm can be used.
The suggested value for N is, therefore, 2048. Note that, with increased
JV from the minimum value, we can decrease the frequency increment, or
increase the sampling frequency, or both as required.
12.4.
, , A A, . 2?r 1 . 2TT 1 . „2TT
x{t) = - - - ( s i n — i + - s i n 2 — i + - s i n 3 — i + •••)
12.11.
2Aw 2A,. ,2ir . ,2-K . 1 . .2TT , ,n27r.
x(t) = — + — (sm(—w) cos(—t) + - sin(—2tu) cos(2—t)
1 . ,27T , , 2 - K .
+-sin(—3w)cos(3—f) + ---)
Answers to Selected Exercises 361
12.18.
X e ,(0,0) = 2.5
13.5.
sin(o; - 10) sin(w + 10)
(u) - 10) (w + 10)
Table 18.4 gives a comparison of the exact FT samples and those computed
by DFT.
13.8.
™=(^y(^)
wi \ 2
362 Answers to Selected Exercises
Table 18.3 Thesecond row ofthe first half of the table shows the exact XC3(ki,0), k\ —
0,1,...,8. The third, fourth, and fifth rows show those computed by the DFT with
4 x 4, 8 x 8, and 16 x 16 samples, respectively. The second half of the table shows
Xc3(0,k2), * 2 = 0 , l , . . . , 8 .
0,0 1,0 2,0 3,0 4,0 5,0 6,0 7,0 8,0
2.5 J0.4775 jO.2387 jO.1592 jO.1194 j'0.0955 jO.0796 j/0.0682 jO.0597
2.5 j'0.375 0
2.5 jO.4527 jO.1875 jO.0777 0
2.5 jO.4713 jO.2263 jO.1403 jO.0937 j'0.0626 J0.0388 jO.0186 0
Table 18.4 The first row shows the first 8 samples of Xft(u) computed by DFT with
T = 16 and N = 1024. The second row shows the corresponding exact values.
-0.1086 -0.0979 -0.0679 -0.0236 0.0271 0.0749 0.1110 0.1277
-0.1088 -0.0982 -0.0680 -0.0237 0.0270 0.0750 0.1111 0.1278
Table 18.5 gives a comparison of the exact FT samples and those computed
by DFT.
Table 18.5 The first half of the table shows the first 4 x 4 samples of Xft(wi,U2)
computed by DFT with Ti,T 2 = 4 and NltN2 = 64. The second half shows the
corresponding exact values.
1 0.8112 0.4066 0.0907
0.8112 0.6581 0.3298 0.0736
0.4066 0.3298 0.1653 0.0369
0.0907 0.0736 0.0369 0.0082
14.3.
4 8 13 15
8 26 25 26
y(ni,n 2 ) =
-1 12 15 -1
-2 -7 1 -12
14.7.
8 6 21 5
18 26 29 12
2/(ni,n 2 ) =
1 20 3 1
-6 -1 -7 -6
15.2.
11.25 1.52 -1.75 -0.90
1.33 0.09 -1.06 -2.55
Xct(ki,k2) —
-2.25 -2.06 0.75 2.21
-1.36 -2.05 0.71 -3.09
365
366 Glossary
369
370 Index
linearity, 61 signal
padding the data with zeros, 86 continuous-time, 7
at the end, 86 digital, 8
in between the samples, 89 discrete, 7, 9
Parseval's theorem, 90 signal representation
periodicity, 62 frequency-domain, 10, 11
signal defined over a finite range, time-domain, 7, 10, 11
80 signal-flow graph, 97
sum and difference of sequences, 85 sine function, 240, 252
symmetry, complex signal, 78 sine function, 8, 12, 47, 200, 337
even, 78 sinusoid, 11
even half-wave, 80 amplitude, 11-13
odd, 80 angular frequency, 12
odd half-wave, 80 complex, 21, 22
symmetry, imaginary signal, 75 cosine, 8, 12
even, 76 cyclic frequency, 12
even half-wave, 76 even function, 15
odd, 76 harmonically related, 19
odd half-wave, 78 harmonics, 19
symmetry, real signal, 72 highest frequency, 18
even, 74 odd function, 15
even half-wave, 75 orthogonality, 24, 26
odd, 74 period, 12
odd half-wave, 75 periodicity, 17, 18
time-reversal, 69 phase shift, 11-13
phase-shifted cosine, 12
rectangular window, 236 phase-shifted sine, 12
roots of unity, 40, 336 polar form, 12
rotating vector, 339 rectangular form, 14
row-column method, 202, 309 representation with a rotating
vector, 337
sampling frequency, 227 representation with two rotating
sampling rate, 227 vectors, 339
sampling theorem, 227 sine, 8, 12
SDHT, see sequency ordered discrete sum of sinusoids, 16, 19, 20, 22
Hadamard transform sinusoidal representation of signals
sequency, 314 advantages, 54
sequency ordered discrete Hadamard sinusoidal surface, 196
transform, 325 spectral density, 275
basis functions, 326 spectral resolution, 241
definition, 325 spectrum, 23
PM SDHT algorithm, 327 amplitude and phase, 23
sequency ordered discrete Hadamard real and imaginary parts, 23
transform, 2-D, 328 symmetry
374 Index
antihermitian, 71
even, 71
even half-wave, 71
hermitian, 71
odd, 71
odd half-wave, 71
windows, 236
Hamming, 240
Hann, 239
rectangular, 236
triangular, 238