You are on page 1of 31

Chapter 5

The Discrete Fourier Transform


Contents
Overview . . . . . . . . . . . . . . . . . . . . . . . .
Definition(s) . . . . . . . . . . . . . . . . . . . . . . .
Frequency domain sampling: Properties and applications
Time-limited signals . . . . . . . . . . . . . . . . . . .
The discrete Fourier transform (DFT) . . . . . . . . . .
The DFT, IDFT - computational perspective . . . . . .
Properties of the DFT, IDFT . . . . . . . . . . . . . . .
Multiplication of two DFTs and circular convolution . .
Related DFT properties . . . . . . . . . . . . . . . . .
Linear filtering methods based on the DFT . . . . . . .
Filtering of long data sequences . . . . . . . . . . . . .
Frequency analysis of signals using the DFT . . . . . .
Interpolation / upsampling revisited . . . . . . . . . . .
Summary . . . . . . . . . . . . . . . . . . . . . . . .
DFT-based real-time filtering . . . . . . . . . . . . .

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

5.1

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

.
.
.
.
.
.
.
.
.
.
.
.
.
.
.

5.3
5.4
5.9
5.12
5.12
5.14
5.15
5.19
5.23
5.24
5.25
5.27
5.29
5.31
5.31

c J. Fessler, May 27, 2004, 13:14 (student version)


5.2

Sum of shifted replicates

x[n] = xa (nTs )

Sampling
xa (t)

x[n]

xps [n]

Bandlimited:

Time-limited:

Sinc interpolation

Rectangular window

FT

DTFT

Sum shifted scaled replicates

DFT

DTFS

X[k] = X ()|= 2 k
N

Sampling
Bandlimited:

PSfrag replacements

X ()

X[k]
Time-limited:

Rectangular window

Dirichlet interpolation

Sa

pl

le

rc

ni

Ci

tC

it

irc

Un

The FT Family Relationships


FT
R
Xa (F ) = xa (t) e2F t dt
R
xa (t) = Xa (F ) e2F t dF
DTFT
P
X () = n= x[n] en = X(z)|z=ej
R
1
x[n] = 2
X () en d

X(z)
Uniform Time-Domain Sampling
x[n] = xa (nTs )


P
X () = T1s k= Xa /(2)k
(sum of shifted scaled replicates of Xa ())
Ts
Recovering xa (t) from
 x[n]
 for bandlimited xa (t), where Xa (F ) = 0 for |F | Fs /2
F
Xa (F ) = Ts rect Fs X (2F Ts ) (rectangular window to pick out center replicate)


P
s
xa (t) = n= x[n] sinc tnT
, where sinc(x) = sin(x) /(x). (sinc interpolation)
Ts

le

Xa (F )

DTFS
ck =

1
N

PN 1

2
N kn =
n=0 xps [n] e
PN 1
2
N kn
, k =
k=0 ck e

1
2
N X(z)|z=e N k
2
N k

xps [n] =
Uniform Frequency-Domain
Sampling


X[k] = X () 2 , k = 0, . . . , N 1
=

X[k] = N ck
PN 1
1
2
N kn
xps [n] = P
k=0 X[k] e
N

xps [n] = l= x[n lN ] (sum of shifted replicates of x[n])


Recovering x[n] from X[k] for time-limited x[n], where x[n] = 0 except for n = 0, 1, . . . , L 1 with L N
x[n] = xps [n], n = 0, . . . , L 1, 0 otherwise. (discrete-time rectangular window)
PN 1
PN 1
X () related to X[k] by Dirichlet interpolation: X () = k=0 X[k] P ( 2k/N ), where P () = N1 k=0 en .

c J. Fessler, May 27, 2004, 13:14 (student version)


5.3

Overview
Why yet another transform? After all, we now have FT tools for periodic and aperiodic signals in both CT and DT! What is left?
DTFT

One of the most important properties of the DTFT is the convolution property: y[n] = h[n] x[n] Y() = H() X (). This
property is useful for analyzing linear systems (and for filter design), and also useful for on paper convolutions of two sequences
h[n] and x[n], since if the sequences are simple ones whose DTFTs are known or are easily determined, we can simply multiply
the two transforms and then look up the inverse transform to get the convolution.
What if we want to automate this procedure using a computer? Right away there is a problem since is a continuous variable that
runs from to , so it looks like we need an (uncountably) infinite number of s which cannot be done on a computer.
For example, we cannot implement the ideal lowpass filter digitally.

This chapter exploit what happens if we do not use all the s, but rather just a finite set (which can be stored digitally). In general
this will entail irrecoverable information loss. Fortunately, not always though! (Otherwise DSP would be a more academic subject.)
Any signal that is stored in a computer must be a finite length sequence, say x[0], x[1], . . . , x[L 1] . Since there are only L signal
time samples, it stands to reason that we should not need an infinite number of frequencies to adequately represent the signal. In
fact, exactly N L frequencies should be enough information.
(We will see when we discuss zero-padding that for some purposes N 2L is an appropriate number of frequencies.)

Main points
By the end of Chapter 5, we will know (among other things) how to use the DFT to convolve two generic sampled signals stored
in a computer. By the end of Ch. 6, we will know that by using the FFT, this approach to convolution is generally much faster
than using direct convolution, such as M ATLABs conv command.
Using the DFT via the FFT lets us do a FT (of a finite length signal) to examine signal frequency content. (This is how digital
spectrum analyzers work.)
Chapter 3 and 4 especially focussed on DT systems. Now we focus on DT signals for a while.
The discrete Fourier transform or DFT is the transform that deals with a finite discrete-time signal and a finite or discrete number
of frequencies.
Which frequencies?
k =

2
k,
N

k = 0, 1, . . . , N 1.

For a signal that is time-limited to 0, 1, . . . , L 1, the above N L frequencies contain all the information in the signal, i.e., we
 N 1

can recover x[n] from X 2
.
N k
k=0

However, it is also useful to see what happens if we throw away all but those N frequencies even for general aperiodic signals.
Discrete-time Fourier transform (DTFT) review
Recall that for a general aperiodic signal x[n], the DTFT and its inverse is
X () =

x[n] en ,

x[n] =

n=

1
2

X () en d .

Discrete-time Fourier series (DTFS) review


Recall that for a N -periodic signal x[n],
x[n] =

N
1
X
k=0

ck e N kn where ck =

N 1
2
1 X
x[n] e N kn .
N n=0

c J. Fessler, May 27, 2004, 13:14 (student version)


5.4

Definition(s)
The N -point DFT of any signal x[n] is defined as follows:
 PN 1
2
N kn ,
4
k = 0, . . . , N 1
n=0 x[n] e
X[k] =
??
otherwise.

Almost all books agree on the top part of this definition. (An exception is the 206 textbook (DSP First), which includes a
front to make the DFT match the DTFS.)
But there are several possible choices for the ?? part of this definition.

1
N

out

1. Treat X[k] as an N -periodic function that is defined for all integer arguments k Z.
This is reasonable mathematically since
X[n + N ] =

N
1
X

x[n] e

2
N (k+N )n

N
1
X

n=0

x[n] e

( 2
N kn+2kn)

n=0

N
1
X

x[n] e N kn = X[k] .

n=0

2. Treat X[k] as undefined for k


/ {0, . . . , N 1}.

This is reasonable from a practical perspective since in a computer we have subroutines that take an N -point signal x[n]
and return only the N values X[0], . . . , X[N 1], so trying to evaluate an expression like X[k] will cause an error in a
computer.

3. Treat X[k] as being zero for k


/ {0, . . . , N 1}.
This is a variation on the previous option.

The book seems to waver somewhat between the first two conventions.
These lecture notes are based on the middle convention: that the N -point DFT is undefined except for k {0, . . . , N 1}. This
choice is made because it helps prevent computer programming errors.
Given X[k] for k {0, . . . , N 1}, the N -point inverse DFT is defined as follows:
 1 PN 1
2
N kn ,
n = 0, . . . , N 1
k=0 X[k] e
N
x
[n] =
??,
otherwise.
Here the natural choice for the ?? part depends on the type of signal is under consideration.
If x[n] is a finite length signal, supported on 0, . . . , L 1, where L N , then we interpret the inverse DFT as
 1 PN 1
2
N kn ,
n = 0, . . . , N 1
k=0 X[k] e
N
x[n] =
0,
otherwise.

This definition is the most important one since our primary use of the DFT is for length L signals with L N .
N 1
In this case the inverse is named appropriately, since we really do recover x[n] exactly from {X[k]} k=0 . The proof of this is
essentially identical to the proof given for the self-consistency of the DTFS.
If x[n] is a N -periodic signal, then we really should use the DTFS instead of the DFT, but they are so incredibly similar that
sometimes we will use the DFT, in which case we should interpret the inverse DFT as follows
x[n] =

N 1
2
1 X
X[k] e N kn .
N
k=0

This is indeed a N -periodic expression.


If x[n] is a signal whose length exceeds N , e.g., if x[n] is a aperiodic infinitely long signal, then the inverse DFT is best expressed
xps [n] =

N 1
2
1 X
X[k] e N kn ,
N
k=0

where xps [n] 6= x[n] in this case. (Nevertheless, it may be that xps [n] x[n] for n = 0, . . . , N 1 so the DFT can be useful
even in this case.

c J. Fessler, May 27, 2004, 13:14 (student version)


5.5

Examples
Example. x[n] = [n] +0.9 [n 6]. What is L? L = 7. Let us use N = 8. (Powers of 2 are handy later for FFTs.)
X[k] =

N
1
X

x[n] e N kn =

7
X

x[n] e

2
8 kn

n=0

n=0

7
X

n=0

([n] +0.9 [n 6]) ej2kn/8 = 1 + 0.9 e

2
8 k6

DFT Example
1
0.8
x[n]

0.6
0.4
0.2
0
0.2

3
n

|X[k]|

1.5

0.5

X[k]

0.5

0.5

Alternative approach to finding X[k]. First find X(z), then sample around unit circle. X(z) = 1 + 0.9z 6 , so

2

X[k] = X(z) 2 k = 1 + 0.9 e 8 k .
z=e

Example. Find N -point inverse DFT of

Picture .

N 1
{X[k]}k=0

x[n] =

where X[k] =

1,
0,

k = k0
otherwise

= [k k0 ], for k0 {0, . . . , N 1}.

N 1
2
1 2 k0 n
1 X
e N
.
X[k] e N kn =
N
N
k=0

Thus we have the following important DFT pair.

If k0 {0, . . . , N 1} , then

1 2 k0 n DFT
[k k0 ] .
e N
N
N

N 1

Example. Find N -point inverse DFT of {X[k]}k=0 where



k = k0
e ,
e , k = N k0 = e [k k0 ] + e [k (N k0 ])
X[k] =

0,
otherwise,

for k0 {1, . . . , N/2 1, N/2 + 1, . . . , N 1}. Picture .


x[n] =



N 1
2
1 X
1 2 k0 n
1 2 (N k0 )n
2
2
X[k] e N kn =
e e N
+
e
e N
=
cos
k0 n + .
N
N
N
N
N
k=0

c J. Fessler, May 27, 2004, 13:14 (student version)


5.6


Example. Find the 8-point DFT of the signal x[n] = 6 cos2 4 n .
h
i

2
2
2
2
Expanding: x[n] = 3 + 3 cos 2 n = 3 + 23 e 8 2n + 23 e 8 2n = 81 24 + 12 e 8 2n + 12 e 8 (82)n .
So by coefficient matching, we see that X[k] = {24, 0, 12, 0, 0, 0, 12, 0} .
Example. Complex exponential signal with frequency that is an integer multiple of 2
N .
2
k0 n
0 n
2
N
=e
for n = 0, . . . , N 1, where 0 = N k0 and k0 is an integer.
Suppose x[n] = e
Find the N -point DFT of x[n].
X[k] =

N
1
X

x[n] e N kn =

n=0

N
1
X

e N k0 n e N kn =

n=0

N
1
X

e N (kk0 )n =

n=0

N,
0,

k = k0 + lN, l Z
otherwise.

Thus
DFT

x[n] = e N k0 n X[k] = N
N

where N [n] =

l=

[k k0 lN ] = N N [k k0 ],

l=

[n lN ].

Example. Complex exponential signal with frequency that is not an integer multiple of 2/N .
Suppose x[n] = e0 n for n = 0, . . . , N 1, where 0 6= 2
N k0 for any integer k.
Find the N -point DFT of x[n].

X[k] =

N
1
X

e0 n e

2
N kn

n=0

N
1 
X

(0 2
N k)

n=0

n

N

2
1 e(0 N k)
1e

(0 2
N k)

1 e0 N

1 e(0 N k)

Thus we have the following curious DFT pair.


DFT

0 n
X[k] =
If 0 / 2
N is non-integer, then e
N

1 e0 N

1 e(0 N k)

What is going on in these examples?


Let s[n] = e0 n be an eternal complex exponential signal, and define the following rectangular window

1, n = 0, . . . , N 1
rN [n] =
0, otherwise,
which has the following DTFT:
R() =
Then we have

N
1
X
n=0

en

sin(N/2)
 
, 6= 0
N sinc N
.
= = e(N 1)/2 Rr (), where Rr () =
sin(/2)

2
N,
=0

x[n] = s[n] rN [n] = X () = S() RN () = 2 ( 0 ) R() = 2 R( 0 ),

where the above is a Dirac impulse. Thus



X[k] = X ()

= 2
N k


2
k 0 .
= 2 R
N


When 0 = 2
N k0 , then the sinc is sampled only at the peak and the nulls, which gives the Dirac impulse form above.
Otherwise the sinc is sampled at many nonzero values, which gives the messy form above.

c J. Fessler, May 27, 2004, 13:14 (student version)


5.7

DTFT sampling preview


The DTFT formula is X () =

x[n] en whereas the DFT analysis formula is X[k] =

PN 1

x[n] e N kn .
PL1
If x[n] is a L-point signal, i.e., it is nonzero only for n = 0, 1, . . . , L1, then the DTFT simplifies to X () = n=0 x[n] en .
n=

n=0

Comparing these two formulas leads to the following conclusion.

If x[n] is a L-point signal with L N , then the N -point


DFT values are samples of the DTFT:


X[k] = X () 2 .
=

If we are given a DTFT X (), and


x[n], then the usual approach would be to apply the inverse DTFT, i.e., the DTFT
R wish to find
1
X () en d .
synthesis formula: x[n] = 2

However, performing this integral can be inconvenient.


The above relationship between the DFT and the DTFT suggests the following easier approach.
First sample the DTFT X () to get DFT values X[k], k = 0, . . . , N 1.
Then take the inverse DFT of X[k] (using the inverse FFT) to get (hopefully) the signal x[n].
Does this approach always work? No!
Why not? Because the DFT/DTFT relationship holds only if x[n] is an L-point signal with L N .

Example. Find the signal x[n] that has the following spectrum, with 0 = /2.


2
1

3

0 2

4
0







1 3 2
3
1

<
,


0 2
2 2
0
2
It seems it would be painful to find x[n] via the inverse DTFT integral!
X () =

2 < 0 0
0,

periodic
otherwise.
Simpler (approximate!) approach: sample X (), then compute inverse DFT (using FFT).
Challenging DTFT H()

Exact Inverse DTFT

0.8
0.25

0.2

0.4

x[n]

0.2
x[n]

H()

0.6

0.15

0.1
0

0.1

0.05

0.2
0
2

0.8

0.75

0.05

Samples, N=16

xps[n] via ifft

0
15

Inverse DFT of X[k]

0.1
0

ps

0.4
0.2

0.2

0.15

0.05

0.75

0.05

2
0

0
0

8
4
x 10

0.1

Error

x [n] via ifft

0.6
H(2/N k)

0.2

0.25

0
2

0
After "fftshift", for N=16

In fact in this case there is an analytical solution: x[n] =

15

1
4

sinc3

1
4n

, so we can compare x[n] and xps [n].

c J. Fessler, May 27, 2004, 13:14 (student version)


5.8

The modulo function


If m = m0 + lN with m0 {0, 1, . . . , N 1} and l Z then m mod N = m0 .
You can also think of m mod N as the remainder when dividing m by N .
Example. 1 mod 4 = 1; 7 mod 4 = 3; 1 mod 4 = 3; 8 mod 4 = 0.
For any signal x[n], be it time-limited or not, we define the N -point periodic superposition of x[n] as follows:
4

xps [n] =

l=

x[n lN ] .

Note that all the values of x[n] affect xps [n].


The book uses the terms periodic extension (p396) and periodic repetition (p395) to describe x ps [n], but these terms are less
descriptive. The term superposition always implies a summation in signal processing.
For any signal x[n], be it time-limited or not, we define the N -point circular extension of a signal x[n] as follows:
4

x((n))N = x[n mod N ] .


Note that only the values of x[n] for n {0, . . . , N 1} affect x[n mod N ]. So this is truly an extension.
Both xps [n] and x[n mod N ] are N -periodic signals. They are both defined for all values of n Z.
In general, xps [n] and x[n mod N ] are different signals.
If x[n] is a time-limited signal over 0, . . . , L1, also called a finite-length sequence, with L N , then x ps [n] = x[n mod N ],
and they consist of of shifted replicates of x[n]. Otherwise xps [n] and x[n mod N ] differ!
x[n]
4 6
2
Example. x[n] = {4, 3, 2, 1} =
N -point periodic superposition:

4 n,
0,

0n3
so L = 4.
otherwise,

-2

x [n], N = 6
6 ps

xps [n], N = 3
5 6

3
2

2
-6

-1

N -point circular extension:


6x[n mod N ], N = 6

x[n mod N ], N = 3
6

4
3
2

2
-6

Why is this important? Because the following two processes are equivalent only if L N .
 N 1

N -point inv DFT xps [n]
x[n] DTFT X () sample X 2
N k
k=0
x[n]

N -point DFT

N -point inv DFT x[n] or x[n mod N ]

c J. Fessler, May 27, 2004, 13:14 (student version)


5.9

5.1
Frequency domain sampling: Properties and applications
Recall that the DTFT X () is periodic, and that this periodicity arose because of the time-domain sampling.

5.1.1 Frequency-domain sampling and reconstruction of DT signals

Now suppose we sample the DTFT at the N particular frequencies given above (think: to store digitally):




X
2
2

x[n] e N kn , k = 0, 1, . . . , N 1.
k = X () 2 =
X
N
= N k
n=

Picture of [0, 2) with sample locations and values, and around unit circle too.
Questions arise:

I. How is X

 N 1

N 1

related to DTFS (both involve unit circle) and to DFT {X[k]}k=0 .


 N 1

N 1
II. When (if ever) can we recover x[n] from X 2
or from DFT {X[k]}k=0 ?
N k
k=0
Probably not always since loss of information; after all inverse DTFT requires an integral over .
 N 1

N 1
or from DFT {X[k]}k=0 ?
III. How can we recover x[n] from X 2
N k
k=0
2
N k

k=0

Before doing math, think about duality. Earlier we considered sampling a CT signal, which led to replication in frequency domain,
and recovery possible if signal bandlimited (finite support in replicated domain). Now we are sampling in the frequency domain.

We explore this by manipulating and re-interpreting the formula for X 2
N k .

First break up the infinite summation into the intervals . . . (2N.. N 1) (N.. 1) (0..N 1) (N..2N 1) (2N..3N 1) . . .

2
k
X
N



= X ()

l0 NX
+N 1
X

l0 =

=
=
=

= 2
N k

x[n] e N kn

n=
2

x[n0 ] e N kn

(split up sum)

n0 =l0 N

N
1
X
X

l0 = n=0
N
1
X
X

x[n + l0 N ] e N k(n+l N ) (n = n0 l0 N 0 )
2

x[n + l0 N ] e N kn (simplify exponent, let l = l 0 )

l0 = n=0
N
1

X
X
n=0

l=
0

x[n lN ] e N kn (exchange sums)

where n = n0 l0 N and l = l . Thus


 N

1

X
2
4 X
2
kn
xps [n] e N
x[n lN ] .
k =
where xps [n] =
X
N
n=0
l=

The above relationship holds for any aperiodic DT signal whose DTFT exists. It is true N N and k Z.
I call xps [n] the N -point periodic superposition of x[n].
The signal xps [n] is N -periodic, i.e., clearly xps [n + N ] = xps [n] .

DFT

In summary: xps [n] Xps [k] = X


N

2
N k

c J. Fessler, May 27, 2004, 13:14 (student version)


5.10

What tool do we use to represent periodic discrete-time signals?


Since xps [n] is N -periodic, we know from Ch. 4 that we can expand it using a discrete-time Fourier series (DTFS):
xps [n] =

N
1
X

ck e N kn where ck =

k=0

Result I. Comparing the DTFS coefficients with the DTFT samples X


ck =

1
X
N

N 1
2
1 X
xps [n] e N kn .
N n=0

2
N k


2
k .
N


Thus, we can recover the periodic signal xps [n] from the DTFT samples X
xps [n] =

, we see that

2
N k

 N 1
k=0

via the DTFS synthesis equation:


N 1 
2
2
1 X
X
k e N kn .
N
N
k=0


However, recovery of xps [n] from X

 N 1
DTFT samples X 2
.
N k
k=0

2
N k

 N 1
k=0

does not alone ensure that we can recover the original signal x[n] from the

To address this, we must further study how xps [n] relates to x[n].
Recall from Ch. 4 that time-domain sampling yields a DT frequency spectrum that is a sum of shifted replicates of the CT frequency
spectrum of xa (t).
Similarly, here we are considering frequency-domain sampling, and the result is that the periodic
signal x ps [n] consists of a sum
P
of shifted replicates of the discrete-time signal x[n], as described by the relationship x ps [n] = l= x[n lN ] .

c J. Fessler, May 27, 2004, 13:14 (student version)


5.11

1
Example. Suppose x[n] = an u[n] where |a| < 1, for which X () =
. This is not a time-limited signal.
1

a
e



Now suppose we take N samples of this DTFT at X 2
(equally spaced around the unit circle).
N k = X ()
2
=

Then we synthesize xps [n] from those samples via inverse DFT. What will xps [n] look like?
From the above equation, for n = 0, . . . , N 1:
xps [n] =

l=

x[n lN ] =

l=

anlN u[n lN ] = an

More generally, for any n Z: xps [n] =

an mod N
1aN

l=

bn/N c

alN u[n lN ] = an

alN = an

l=

l=

x[n]

0.5

12

12

12

12

x[nN]

0.5

x[n2N]

0.5

x[n+N]

0.5

xps[n]

0.5

alN =

an
.
1 aN

. Does xps [n] = x[n]? No, but as N , xps [n] x[n] for any fixed n 0.

The problem is time-domain aliasing; the time-domain replicates overlap before summing.

0
X

10

15

20

This time aliasing arises from our attempt to form a signal from a finite number of values of .
For this aperiodic non time-limited signal, no finite set of k s will allow perfect reconstruction of x[n].

c J. Fessler, May 27, 2004, 13:14 (student version)


5.12

Time-limited signals
There is an important special case where the time-domain replicates do not overlap. That case is time-limited signals.
By convention, we say x[n] is time-limited with duration L if x[n] is nonzero only in the interval 0, 1, . . . , L 1.
Result II.
If x[n] is time-limited to duration L, then if N L, then there is no overlap in the replicates when forming x ps [n] from
 2  N 1
X N k k=0 .

Result III. Thus, if x[n] is time-limited with duration L N , (called adequate frequency sampling) then we can recover x[n]
from xps [n] by simply extracting the appropriate values:
x[n] =

0nL1
otherwise.

xps [n],
0,

From the recovered x[n] we could use the DTFT formula to find X () for any , meaning we have gone from the samples
 2  N 1
X N k k=0 back to the continuous X () (in the time-limited case). It is also possible to recover X () directly from the
samples using the Dirichlet interpolation formula - see text.

Review FT family tree.

5.1.2
The discrete Fourier transform (DFT)
For the rest of this chapter, our primary focus will be time-limited signals x[n], which are nonzero only for n = 0, . . . , L 1.
For such signals, the DTFT simplifies to

X () =

L1
X

x[n] en .

n=0

We pick any N L and sample the DTFT uniformly over [0, 2)




X[k] = X ()

or for convenience

X[k] =

N
1
X

= 2
N k

x[n] e N kn ,

n=0

L1
X

x[n] e N kn

n=0

k = 0, . . . , N 1,

where the upper limit is changed to N with no effect since x[n] = 0 for n = L, . . . , N 1.
The above expression is called the discrete Fourier transform or (DFT).
The DFT is always defined, since it is a finite sum!
Since x[n] is time-limited, we can recover it from xps [n], which in turn can be recovered from the DTFS synthesis equation.
Thus we have the inverse DFT or (IDFT):
x[n] =

1
N

0,

PN 1
k=0

X[k] e N kn ,

n = 0, . . . , N 1
otherwise.

The above pair of equations can be implemented easily on a computer since there is just a finite sum. Fortunately, we can implement
the sums cleverly using the fast-Fourier transform (FFT), as discussed in Ch. 6.
Although the ranges of the indices only run from 0 to N 1, the expressions are defined for any integer k and n.

c J. Fessler, May 27, 2004, 13:14 (student version)


5.13

skim

5.1.3 The DFT as a linear transformation


Define
4

WN = e N
then we can rewrite the DFT and IDFT formulas as:
X[k] =

N
1
X

x[n] WNkn , x[n] =

n=0

N 1
1 X
X[k] WNkn ,
N
k=0

which we can also write in matrix-vector form X = W x and x =

1
0
NW X

(see text).

Graduate students should study the matrix-vector form, since it is very useful for theoretical analysis of many SP methods.
5.1.4 Relationship of the DFT to other transforms
DTFS Suppose we take any signal x[n] and form its N -point circular extension, i.e., x[n mod N ]. Since x[n mod N ] is N periodic, it has a DTFS representation with some coefficients ck . Those coefficients are related to the N -point DFT of x[n] as
follows:
1
ck =
X[k] .
N
DTFS
P
Suppose we take any signal x[n] and form its N -point periodic superposition, i.e., x ps [n] = l= x[n lN ] . Since xps [n]
is N -periodic, it has a DTFS representation with some coefficients ck . Those coefficients are related to the DTFT of x[n] as
follows:


2
1
X
k .
x[k] =
N
N
If in addition x[n] has length L N , then the DTFS coefficients are related to the N -point DFT of x[n] as follows: c k =
1
N X[k] .
DTFT


If x[n] is an L-point signal with L N then X[k] = X () 2 .
=

z-transform



If x[n] is an L-point signal with L N then X[k] = X(z)

2 k

z=e N

If x[n] is an L-point signal with L N , then we can express X(z) in terms of X[k] (see text):
X(z) =

N 1
1 z N X
X[k]
.
2
N
1 e N k z 1
k=0

If x[n] is an L-point signal with L N , then we can express X () in terms of X[k]. (Left to reader.)
Fourier series of continuous time periodic signal
see text. DFT values X[k] related to aliased version of the CT Fourier coefficients.

c J. Fessler, May 27, 2004, 13:14 (student version)


5.14

The DFT, IDFT - computational perspective


In the above description we have introduced the DFT from the point of view of sampling the DTFT. In this section we take a more
computational perspective, which may be simpler.
Given a DT signal x[n], we define the N -point DFT of x[n] to be
4

X[k] =

N
1
X

x[n] e N kn ,

n=0

k = 0, . . . , N 1.

Since this is a finite sum, it is well defined for any signal x[n], be it time-limited, periodic, or aperiodic.
The expression for X[k] is certainly mathematically well defined for any integer k, and on paper it is sometimes useful to think
about all integers k. However, the DFT is periodic with period N :
k.

X[k + N ] = X[k],

Thus, in a computer we will only bother to compute X[k] for k = 0, 1, . . . , N 1.


N 1
N 1
Input: N time values {x[n]}n=0 , output: N DFT values {X[k]}k=0 .
N 1

Given {X[k]}k=0 , the N -point inverse DFT is given by


N 1
2
1 X
X[k] e N kn ,
xi [n] =
N
4

n = 0, . . . , N 1.

k=0

This expression is also mathematically well defined for any integer n, but on paper it is also sometimes useful to think about all
integers n. However, the IDFT is also periodic with period N :
xi [n + N ] = xi [n],

n.

Thus, again, in a computer we would only bother to compute this sum for n = 0, . . . , N 1. Again an N -point input and N -point
output.
Now we discuss the properties of the DFT and the IDFT for various types of DT signals x[n].
1. For any DT signal x[n], we have
x[n] = xi [n], for n = 0, . . . , N 1,

so the inverse DFT is aptly named. If you take the DFT of any DT signal, be it time-limited, not time-limited, periodic, or
aperiodic, and then compute the IDFT, the IDFT xi [n] will agree with the original signal x[n] over the interval n = 0, . . . , N 1.
N 1
2. If x[n] is a periodic signal with period N , then it has a DTFS representation with some coefficients {c k }k=0 where
X[k] = N ck .
In this case x[n] = xi [n] for all n.
3. If x[n] is time-limited to 0, . . . , L 1 where L N , then in addition to Property 1, we have


X[k] = X () 2 .
=

If x[n] is not time-limited, then there is still a relationship between X[k] and X (), but it is fairly complicated and not easily
interpreted. Most of the time we do want to be able to directly interpret the DFT values X[k]s as frequency components, so we
focus on time-limited signals.
In the time-limited case, we can recover the original signal from xi [n] by simply taking

xi [n], n = 0, . . . , N 1,
x[n] =
0,
otherwise.

Since we will focus mainly on time-limited signals in the context of the DFT, for simplicity we will replace the x i [n] in the IDFT
N 1
with just x[n]. But one should keep in mind that the IDFT formula really gives a periodic extension of {x[n]} n=0 , and to truly
recover x[n] using the IDFT you would set to zero all the values other than n = 0, 1, . . . , N 1.

c J. Fessler, May 27, 2004, 13:14 (student version)


5.15

5.2
Properties of the DFT, IDFT

X[k] =

N
1
X
n=0

x[n] e N kn ,

k = 0, . . . , N 1.

x[n] =

N 1
2
1 X
X[k] e N kn ,
N
k=0

n = 0, . . . , N 1.

5.2.1 Periodicity, linearity, and symmetry properties


Periodicity
X[k + N ] = X[k] k

The above formula is easy to see by plugging in to the DFT definition and simplifying the complex exponential.
xi [n + N ] = xi [n] n
This formula may seem surprising, since supposedly we are dealing with time-limited signals! Frequency-domain sampling leads
to periodic replication in the time domain. To recover the original time-limited signal from the above formulas, we would just
use n = 0, . . . , N 1 and zero the rest. In a computer we essentially only care about 0 to N 1 anyway, so the signal periodicity
is mainly a theoretical property, except as it impacts convolution below.
So mathematically we are dealing with N -periodic sequences, even though practically we are thinking of it as finite-length.
Another way of thinking about it: suppose you give me two finite-length sequences and ask me to convolve them. All you really
care is that I give you back the correct answer (and quickly); it does not matter to you as the client that the convolution algorithm
that I use may be based on ideas involving periodic signals, as long I as return to you the correct answer.
Remember, one of our goals here is to develop a (much) faster convolution method than the brute-force conv approach. It so
happens that periodic signals play an important role in the derivation and analysis, but by using the final results appropriately, we
will also end up with a very practical method that works even for non-periodic time-limited signals.
Linearity
DFT

a x[n] +b y[n] a X[k] +b Y [k]


N

Post for properties


Most of the properties of the DTFT have analogous relationships for the DFT. However, our previous definitions of signal properties
and operations like symmetries, time-reversal, time-shifts, etc. do not quite work directly for time-limited signals over 0, . . . , N 1.
Time-limited signals are never symmetric in the sense used previously. And ordinary time-reversal or time-shifting would move
some or many of the sample values outside of the interval 0, . . . , N 1. What we need is a new concept of termsymmetry, timereversal, and time-shift in the context of time-limited signals. The appropriate definitions (meaning the ones that work with the
DFT) are defined in terms of the periodic extension of a signal.
(Do convolution last, after familiar with circular properties.)

c J. Fessler, May 27, 2004, 13:14 (student version)


5.16

Symmetries
The next set of properties of the DFT describes what happens when the signal x[n] has certain symmetries. Hence we first need to
appropriately define symmetries in the context of periodic sequences.
A signal x[n] is called N -point circularly even iff its N -point circular extension, x[n mod N ], is even.
Equivalently, a signal x[n] is N -point circularly even iff x[n mod N ] = x[n mod N ] .
Example. x[n] = {4, 3, 2, 1}.

Is this signal 4-point circularly even? No, since x[n mod N ] is not even.

Example. x[n] = {4, 3, 2, 1, 2, 3}

Is this signal 6-point circularly even? Yes, as the following figure illustrates.
Is it 8-point circularly even? No, for N = 8 it is not circularly even, since x[n mod N ] is not even for N = 8.
Timelimited signal x(n)

Timelimited signal x(n)

L=6

L=6

x(n)

x(n)

1
0
15

10

0
n

10

15

0
15

Periodic extension x((n))N with N=6

0
n

10

15

10

15

3
x((n))N

x((n))

Periodic extension x((n))N with N=8

2
1
0
15

10

3
2
1

10
2N

5
N

0
n

10
N

15
2N

0
15
2N

10

5
N

0
n

5
N

2N

c J. Fessler, May 27, 2004, 13:14 (student version)


5.17

A simple test for whether a sequence is N -point circularly even is to draw it around a circle (in N evenly spaced points).
3

n=1

n=0

n=N-1

If the sequence is the same whether you read it out CW or CCW, then it is circularly even.
By considering the points around the circle, we conclude the following.
An signal is N -point circularly even iff x[N n] = x[n], n = 1, . . . , N 1, where x[0] is arbitrary.
An signal is N -point circularly odd iff x[N n] = x[n], n = 1, . . . , N 1, with x[0] = 0.

Example. A 6-point circularly odd sequence: x[n] = {0, 3, 2, 0, 2, 3}.

Decomposing an N -point sequence into circularly even and circularly odd components:

xce [n] =

1
2

(x[n] + x[N n]) ,


x[0],

x[n]
n = 1, . . . , N 1
n=0

xce [n] + xco [n]


 1
2 (x[n] x[N n]) ,
xco [n] =
0,

n = 1, . . . , N 1
n=0

Example. x[n] = {4, 3, 2, 1} with N = 4 = xce [n] = {4, 2, 2, 2}, xco [n] = {0, 1, 0, 1} circle pictures

Now we are finally ready to return to the properties of the DFT.


Symmetry properties

If x[n] is real, then (cf. Hermitian symmetry of DTFT) its DFT has circular Hermitian symmetry:
X[k] = X [k mod N ] .
Proof. It follows by the following periodicity argument, since k mod N = k + lN for some l Z:
"N 1
# "N 1
# N 1
X
X
X
2

2
(k mod N )n
2
(k)n
N
N
X [k mod N ] =
x[n] e
x[n] e N kn = X[k] .
=
x[n] e
=
n=0

n=0

n=0

If x[n] is circularly even, then X[k] is circularly even.


Proof (using n0 = N n)
X[k] =

N
1
X

x[n] e N kn = x[0] +

N
1
X

x[n] e N kn = x[0] +

n=1

n=0

N
1
X

N
1
X

n0 =1
2

x[n0 ] e N (k)n = X[k mod N ] .

n0 =0

Combining the above:

If x[n] is real and circularly even, then X[k] is also real and circularly even.
There are many such relationships, as summarized in the following diagram.
x[n]

X[k]

xce
R [n]
l
ce
XR
[k]

+
+

xce
I [n]
l
XIce [k]

+
+

+ xco
I [n]
.
&
%
co
XR
[k] + XIco [k]
xco
R [n]

Note: (5.2.31) looks different than (4.3.37) only because the order of terms differs.

x[N n0 ] e N k(N n )

c J. Fessler, May 27, 2004, 13:14 (student version)


5.18

5.2.3 Additional DFT properties


Circular time-reversal
Again we must be careful, since ordinary time-reversal a time-limited sequence would yield a sequence that is not limited to 0 to
N 1. Instead, we first take the N -point circular extension of the signal, time-reverse that, and then pick out the values from 0 to
N 1. This is called circular time-reversal. It is equivalent to writing the sequence CCW around a circle, and then reading the
values CW.
Example. If x[n] = {10, 11, 12, 13, 14} and N = 6, then x[n mod N ] = {10, 0, 14, 13, 12, 11}. Picture of circle

We will use x[n mod N ] to denote circular time-reversal. Like the textbook, we may sometimes
use the convenient shorthand

= x[0] rather than x[N ].
x[n mod N ] = x[N n]. But note that this shorthand is imprecise since x[n mod N ]
n=0

Specifically:

x[0],
x[N n],
x[n mod N ] =

(periodic),

n=0
n = 1, . . . , N 1
otherwise.

DTFT

The DFT property is (cf. DTFT property: x[n] X ()):

DFT

x[n mod N ] X[k mod N ] .


N

Circular time-shift
Again we must be careful, since time-shifting a time-limited sequence would yield a sequence that is not limited to 0 to N 1.
Instead, we first take the periodic extension of the signal, time-shift that, and then pick out the values from 0 to N 1. This is
called a N -point circular time-shift. It is equivalent to writing the sequence CCW around a circle, and then reading the values
CCW starting from point l.
Example. If x[n] = {10, 11, 12, 13, 14} and N = 6 and l = 2, then x[n l mod N ] = {14, 0, 10, 11, 12, 13}. Picture of circle
DFT

x[n n0 mod N ] e N kn0 X[k]


N

Circular frequency-shift / complex modulation


2

DFT

x[n] e N k0 n X[k k0 mod N ]


N

Complex conjugate
DFT

x [n] X [k mod N ]
N

DFT

x [n mod N ] X [k]
N

Parsevals theorem
N
1
X
n=0

x[n] y [n] =

N 1
1 X
X[k] Y [k]
N
k=0

N
1
X
n=0

|x[n]| =

N 1
1 X
2
|X[k]|
N
k=0

Expresses signal time-domain energy in terms of average energy in frequency components.


Duality
Exercise.

c J. Fessler, May 27, 2004, 13:14 (student version)


5.19

Recall that one of the most important DTFT properties is that if Y() = H() X () then y[n] = x[n] h[n], so convolution in the
time domain becomes simply multiplication in the transform domain. What about for the DFT?
5.2.2
Multiplication of two DFTs and circular convolution
DFT

DFT

(This is one of the most important topics in this chapter.)

Suppose h[n] H[k] and x[n] X[k], where h[n] is time-limited with M N and x[n] is time-limited with L N .

(The N s must be same!)

(For now think of x[n] and h[n] as two generic signals; they need not be an input and a filter.)
Suppose we multiply the two sets of DFT coefficients:
4

S[k] = H[k] X[k],


N 1

k = 0, . . . , N 1,
N 1

and then take the N -point inverse DFT of {S[k]}k=0 to get {s[n]}k=0 . How does s[n] relate to h[n] and x[n]?

The resulting s[n] is not the ordinary convolution of h[n] and x[n], but rather the N -point circular convolution of h[n] and x[n],
denoted s[n] = h[n]
N x[n].

(The derivation is given on the next page.)


We can interpret the N -point circular convolution expression
s[n] = x[n]
N h[n] =

N
1
X
m=0

x[m] h[n m mod N ]

in words as follows.
Take one of the two sequences, e.g., h[n], and form its N -point circular extension h[n mod N ].
Perform ordinary convolution of that extended signal h[n mod N ] with the time-limited signal x[n].
We need only bother to compute the results for n = 0, . . . , N 1.
Example. Circular convolution (using DFT): x[n] = {2, 0, 3, 1}, h[n] = {10, 20, 30, 40}.
Find s[n] = h[n]
4 x[n], i.e., N = 4.

Circular convolution, the fast way (in frequency domain):


s = ifft(fft([2 0 3 -1]) .* fft([10 20 30 40]))
yields
s[n] = h[n]
4 x[n] = {90, 130, 50, 130} .

Note that since s[n] is the IDFT of S[k] = H[k] X[k], it is periodic with period N = 4.

Recipe for finding h[n]


4 x[n] manually in time domain:
Draw one sequence x[n] CCW around a circle.
Fold (time reverse) the other sequence h[n] by drawing it CW around a circle. See illustration on subsequent page.
s[0] is the sum of the element-by-element product of the two sequences around the circle.
For the above example, s[0] = x[0] h[0] + x[1] h[3] + x[2] h[2] + x[3] h[1] = 2 10 + 0 40 + 3 30 + (1) 20 = 90.
Shift the folded sequence by rotating CCW around the circle, then multiply and sum.
For the above example: s[1] = x[0] h[3] + x[1] h[2] + x[2] h[1] + x[3] h[0] = 2 40 + 0 30 + 3 20 + (1) 10 = 130.
Repeat N times. Thankfully we can do this with FFTs painlessly.

Illustrated on subsequent page.

If asked to do it manually, one can either use the above time domain recipe, or manually compute X[k] and H[k] and multiply, and
then manually compute inverse DFT.

c J. Fessler, May 27, 2004, 13:14 (student version)


5.20

Circular Convolution Derivation

Input information:
H[k] =

N
1
X

h[n] e

2
N kn

X[k] =

n=0

S[k] = H[k] X[k], k = 0, . . . , N 1

s[n] =

N
1
X

n=0
N
1
X

1
N

Goal: relate s[n] to h[n] and x[n].

x[n] e N kn
2

S[k] e N kn .

k=0

Recall that we previously showed (4.2.2) the following useful equality:



N 1

X
1 X 2 km
1,
m
=
0,
N,
2N,
.
.
.
=
e N
[m lN ] = [n mod N ] .
=
0, otherwise
N
k=0

l=

Another useful fact: h[n0 mod N ] =

PN 1

m0 =0

h[m0 ]

l= [n

m0 lN ] .

N 1
N 1
2
1 X
1 X
2
kn
s[n] =
S[k] e N =
H[k] X[k] e N kn (IDFT and S[k] defn)
N
N
k=0
k=0
" N 1
#
# "N 1
N
1
X
2
2
2
1 X X
0
h[m0 ] e N km
=
x[m] e N km e N kn (DFT defn)
N
m=0
k=0 m0 =0
"
#
N
1
N
1
N
1
X
X
X
2
1
0
h[m0 ]
e N k(nmm ) (exch. sums)
x[m]
=
N
m=0
m0 =0
k=0
"
#
N
1

N
1
X
X
X
h[m0 ]
[n m m0 lN ] (exp. sum prop.)
x[m]
=
m=0

N
1
X
m=0

m0 =0

l=

x[m] h[n m mod N ] (modulo fact)

= h[n]
N x[n] = x[n]
N h[n] defn of
N
In summary, if s[n] = IDFTN (DFTN (x[n]) .* DFTN (h[n])), then
DFT

s[n] = h[n]
N x[n] S[k] = H[k] X[k] .
N

c J. Fessler, May 27, 2004, 13:14 (student version)


5.21

Reversed Signal 2

Product

40

30

h((0-m))

10

90

20

x(m)

-20

40

h((1-m))

n=1

10

0
3

20

s(0) = 20 + 90 - 20 = 90

x(n) = {2, 0, 3, -1}


h(n) = {10, 20, 30, 40}

Signal 1

n=0

20

120

30

40
-30

s(1) = 40 + 120 - 30 = 130

-1
10

h((2-m))

n=2

20

30

30

40

60
-40

s(2) = 60 + 30 - 40 = 50
30
20

h((3-m))
10

40

60

n=3
80

-10
s(3) = 80 + 60 - 10 = 130

c J. Fessler, May 27, 2004, 13:14 (student version)


5.22

Remember we set out to find a faster way to do convolution. Did it work? Ordinary linear convolution for the above signals can
be computed using:
y = conv([2 0 3 -1], [10 20 30 40]) which yields
y[n] = h[n] x[n] = {20, 40, 90, 130, 70, 90, 40} .

The result has L + M 1 = 4 + 4 1 = 7 nonzero values. All other values are zero.

Note that y[n] 6= s[n], i.e., 4-point circular convolution of x[n] and h[n], which can be computed rapidly by FFTs, did not result
in the linear convolution of x[n] and h[n]. Fortunately this can be fixed using zero-padding.
How are s[n] and y[n] related? s[n] is a time-domain aliased version of y[n]; a sum of 4-point shifted replicates of y[n]:
s[n] =

l=

y[n lN ] =

l=

(x h)[n lN ].


If N L and N M (which is true in above example), then x[n] and h[n] are sampled adequately, so H[k] = H 2
N k and
X[k] = X 2
= Y()|= 2 k , and hence s[n] will be the N -point periodic superposition of
N k . So S[k] = H() X ()|= 2
N k
N
the inverse DTFT of Y() = H() X (), i.e., the N -point periodic superposition of y[n] = h[n] x[n].
-4
...
20 40 90 130

70 90 -40
20 40 90 130

... 90 130 50 130

70 90 -40
20 40 90 130

y[n+4]
y[n]
y[n-4]

70 90 -40
...

...

s[n] (sum of above)


5

4
x((n))

x(n)

3
2

0
6

10

s(n) = x(n) (5) h(n)

h(n)

10

10

10

2
n

10

20

1
0.8
0.6
0.4
0.2
0
6

2
1

1
0
6

15
10
5
0
6

10

20

4
x((n))

y(n)

15
10
5
0
6

0
6

10

20
s(n) = x(n) (8) h(n)

h(n)

2
1

0.8
0.6
0.4
0.2
0
6

2
n

10

15
10
5
0
6

Exercise. Review the properties of


 linear convolution and generalize each property to the case of N -point circular convolution.
x[n n0 mod N ], n0 {0, . . . , N 1}
Example. x[n]
N [n n0 ] =
0,
otherwise.

c J. Fessler, May 27, 2004, 13:14 (student version)


5.23

Related DFT properties


If s[n] = x[n]
N h[n] then

N
1
X

s[n] = S[0] = H[0] X[0] =

"N 1
X

x[n]

h[n] ,

n=0

n=0

n=0

# "N 1
X

which is a similar property to that for ordinary linear convolution, except here the sums are finite.
Circular correlation
DFT

rxy (l) = x[l]


N y [l mod N ] X[k] Y [k]
N

Circular autocorrelation
DFT

2
rxx (l) = x[l]
N x [l mod N ] |X[k]|
N

Time-domain multiplication
DFT

x[n] y[n]
N

Properties of circular correlation



rxy (l) = x[n]
N y [n mod N ]

1
X[k]
N Y [k]
N

Read
n=l

rxy (l) = ryx


(l) (conjugate symmetry)
DFT

DFT

Proof: ryx (l) Y [k] X [k] = (X[k] Y [k]) rxy


(l) by complex conjugate property above.
N

(l).
rxy

Thus ryx (l) =


rxy (l) is periodic with period N
p
PN 1
2
|
rxy (l)| Ex Ey where Ex = n=0 |x[n]| is the signal energy in one period.

Proof for real signals:


0

=
=

Thus

N
1
X
n=0

"

y[n l mod N ]
x[n]

Ex
Ey

#2

N 1
N 1
1 X
2
1 X
2
2
[x[n]] +
[y[n l mod N ]] p
Ex n=0
Ey n=0
E x Ey

rxy [l]
.
2 2p
Ex Ey

"N 1
X
n=0

x[n] y[n l mod N ]

p
p
Ex Ey rxy [l] Ex Ey .

Summary

We have now covered all the most important transforms:


continuous time: Laplace, Fourier, Fourier Series,
discrete time: Z, DTFT, DTFS, DFT/FFT
The first six are for pencil and paper analysis/intuition/understanding. The DFT/FFT is for doing.
Example: time delay estimation, such as the radar example on HW.
2

If y[n] = x[n n0 ] x[n n0 mod N ] then DFT gives Y [k] = X[k] e N kn0 . Multiplying: X[k] Y [k] = |X[k]| e N kn0 ,
taking phase gives 2
0 = slope/ 2
N kn0 which (after unwrapping) is a line in k, so find slope and n
N . Multiply by Ts to estimate
delay (related to distance to target).
Note periodic ambiguity (tracking).

c J. Fessler, May 27, 2004, 13:14 (student version)


5.24

5.3
Linear filtering methods based on the DFT
5.3.1 Use of the DFT in linear filtering
DFT-based filtering always performs a circular convolution. This is a property of the math; usually it is not our desired operation.
But by zero-padding adequately, circular convolution and linear convolution can yield the same result.
Goal: find y[n] when:
x[n] h[n] y[n] = h[n] x[n]
x[n] time limited to 0, . . . , L 1
h[n] time limited to 0, . . . , M 1 (FIR)

PL1
Brute force approach (about LM multiplies required): y[n] = k=0 x[k] h[n k] .
What range of n? y[n] is time limited to n = 0, . . . , (L + M 1) 1.

Since y[n] is a L + M 1 point signal, we can reconstruct y[n] from N L + M 1 samples of its DTFT, i.e.,
N 1

2
1 X

y[n] =
Y [k] e N kn , where Y [k] = Y() 2 .
N
= N k
k=0

But since Y() = H() X (), then


Does



Y [k] = Y()



X[k] = X ()

= 2
N k

= 2
N k



= H() X ()

= 2
N k



and H[k] = H()

= 2
N k

where X[k] is the N -point DFT of x[n]? Yes, because x[n] is time-limited to L N , and h[n] is time-limited to M N . Thus
Y [k] = H[k] X[k],
and we have the following simple recipe for performing linear convolution using DFTs.
Convolution via DFT
zero pad x[n] to N L + M 1 elements
zero pad h[n] to N L + M 1 elements
compute N -point DFT X[k] of x[n]
compute N -point DFT H[k] of h[n]
multiply: Y [k] = X[k] H[k], k = 0, . . . , N 1
compute inverse DFT of Y [k] to get y[n]
In M ATLAB:

x
h
X
H
Y
y

=
=
=
=
=
=

[2 0 3 -1]
[10 20 30 40]
fft(x,8) % tells to compute an 8-point DFT
fft(x,8)
H .* X
ifft(y)

Brief way:
y = ifft(fft([2 0 3 -1], 8) .* fft([10 20 30 40], 8))
This returns 8 values. What is the last value? 0 because L + M 1 = 7

Key point: with zero-padding the general time-domain aliasing phenomena is still present, but the signal values that are timealiased are all zero, so they cause no detrimental effect! We have thus tricked a circular convolution into performing something
that gives the same answer as linear convolution.

c J. Fessler, May 27, 2004, 13:14 (student version)


5.25

5.3.2
Filtering of long data sequences
We have mentioned that signals stored in a computer must have finite length. But finite can still be very large.
sec
Example: music CD: L = 44.1kHz 70 min 60 min
2channels 400 106 samples!

How can we digitally filter such signals if RAM smaller than signal data? Goal: linear convolution.

Options for filtering in M ATLAB. Each has a role. Which option is best depends on L and on form of system description (h[n] or
H(z) or H()).
1. Direct convolution y[n] =

Pn

k=0

x[n k] h[k]

y = conv(x,h)
Given FIR h[n] (length M )
x[n] can be arbitrarily large - read sequentially from storage.
LM multiplies
appropriate if M  log2 L

2. Recursion based on constant-coefficient linear difference equation


y[n] =

N
X

k=1

ak y[n k] +

M
X

k=0

bk x[n k],

y = filter(b,a,x)
Given H(z) rational (or pole-zero etc.)
Usually N, M small relative to L
L(N + M ) multiplies

Fairly simple recursion to implement.

3. Zero-padded DFT/FFT from impulse response y[n] = x[n]


N h[n] where N L + M 1.
y = ifft(fft(x,N) .* fft(h,N))
Given FIR h[n] length M
O(N log2 N ) multiplies
Appropriate when M L N/2, i.e., signal and impulse response have similar lengths. (Often not the case, consider a
CD with 400 106 samples; rarely would we need to use a filter so long. Even an IIR filter could be truncated to far fewer
samples.
Caution: check imaginary part of ifft if both x[n] and h[n] are real!
4. Overlap-add method for very long sequences but short filters.
Recipe:
FFT signal a block at a time
multiply X[k]s by H[k]s with h[n] zero padded if necessary
stitch together results from each block.
see text for details.
y

= fftfilt(h,x)
Given h[n] or H[k]
L
N log2 N ) = O(L log2 N ) multiplies
O( N
appropriate when h[n] much shorter than x[n]

Is there an overlap-save method in M ATLAB?

c J. Fessler, May 27, 2004, 13:14 (student version)


5.26

5. Zero-padded DFT/FFT from frequency response H(), using the fact that Y() = H() X ()
Hv = ?
y = ifft(fft(x,N) .* Hv)
Given H() but finding h[n] is painful
Exact only if h[n] is FIR and N L + M 1, but for sufficiently large N , often a reasonable approximation.
How large of N ? Need N L + M0 1, where M0 is approximate length of significant nonzero part of h[n].
O(N log2 N ) multiplies
What should Hv be? It should be H(k ), k = 0, . . . , N 1, where k =

2
N k.

Example. Suppose we have a signal x[n] and we wish to apply the following filter:
H() =

e16 ,
0,

|| /4
/4 < || .

On paper no problem: take DTFT of x[n], multiply by H(), take inverse DTFT, gives exact y[n] if no math errors.

Suppose N = 16, what does abs(Hv) look like?


om = (0:15)*2*pi/15
Hv = (om <= pi/4) || (om >= 3*pi/4) \% ignoring phase here
which is [1 1 1 0 0 00 0 0 0 0 0 0 0 1 1]
..., ...

1,
|| /4

0,
/4 < ||
Because |H()| =
0,
< || < 7/4

1,
7/4 || 9/4

..., ....

What is the catch? y[n] is not exact. Why not? IDFT of H[k] has length N , so N + L 1 > N so y[n] always
undersampled, no matter what N is, so always time-domain aliasing in y[n]. But if N is large enough relative to the effective
length of y[n], then time-domain aliasing can be made minimal. Again need N > L + M 0 1, where M0 is the approximate
length of h[n].
Desired magnitude response

0.4
0.2

0.1

0.1

Samples of frequency response

20

30
40
50
60
Filtering by DFT using sampled H()

70

80

90

3
N=80

2
1
0
0

0.3

N=32

0.2

0.2

ifft(fft(x,N) .* Hk)

h[n lN]

|H[k]| = |H(k)|

31

Periodic superpostion of h[n]

0.8

0.1
0

0
0

16
n

ifft(fft(x) .* Hk)

0.4

10

0.6

2
1

0.2

0.6

h[n]

|H()|

y[n]

0.3

0.8

Ordinary linear convolution

Ideal impulse response

0.1

16
n

31

10

20

30

40

50

60

70

80

90

3
N=128

2
1
0
0

10

20

30

40

50

60

70

80

90

c J. Fessler, May 27, 2004, 13:14 (student version)


5.27

5.4
Frequency analysis of signals using the DFT
Suppose you are working with an analog device (such as a microphone, or a pressure sensor in an automobile, etc.) that produces
a signal xa (t), and you would like to examine its frequency spectrum Xa (F ).
Three options: analytical, analog, digital
Analytical.
2
If xa (t) has a simple analytical form, such as xa (t) = et , then one can use integration or tables and FT properties to find Xa (F ).
Analog spectrum analyzer
xa (t)

lowpass filter integrator:

cos(F0 t)

| |2 dt energy in band

Or bank of bandpass filters. picture of overlapping responses Hk (F )


For a filter bank, resolution is limited by the number of channels. (Sinusoids within the passband produce same response.)
For mixer approach, spectral resolution limited by lowpass bandwidth.
Narrow lowpass means higher resolution, but then longer transient response so longer delay before integrating, so slower readout.
Digital spectrum analyzer
The following diagram illustrates the digital approach to exploring Xa (F ).
PSfrag replacements Arbitrary
Analog
Signal

x
a (t)

Bandlimited
Signal
Sampler

Anti-Alias
Filter

DTFT

X ()

DFT/FFT

X[k]

x[n]

xa (t)

Consider first the hypothetical top path, i.e., imagine that we could really compute X ().

From sampling theorem (4.2.85),




1 X
/(2) k
X () =
.
Xa
Ts
Ts
k=

For an ideal anti-alias filter, there is no overlap of the replicates in the above sum, so


 
F
F
Xa (F ) = Ts X 2
rect
.
Fs
Fs

Thus if we could compute X (), then we could display X () with an appropriate horizontal axis as X a (F )!

In practice we cannot compute X () for all .

However, let us suppose that x[n] is time-limited to 0, . . . , L 1, and then suppose we compute a N -point DFT of x[n] for N L.
Since x[n] is time-limited:


2
k ,
k = 0, . . . , N 1.
X[k] = X
N

However, we have seen above that X () is related to Xa (F ) for |F | Fs /2. So X[k] is also related to Xa (F ).

k related to k by k = 2
N k
related to F by = 2F/Fs for |F | Fs /2, or F =

2 Fs

Combining:

Fk =

k
N Fs ,
kN
N Fs ,

for [, ]
k = 0, . . . , N/2 1
k = N/2, . . . , N 1

c J. Fessler, May 27, 2004, 13:14 (student version)


5.28

fftshift
X ()

Xa (F )
1

1/T

After sampling

Fs/2

N=10
0 1 2 3 4 5 6 7 8 9 k
k-N:

PSfrag replacements

-5 -4 -3 -2 -1

-N/2

(N-1)/2

N-1

Main point: display vs Fk most natural.


Spectral resolution
In principle one could choose to plot as many frequency values (N ) as one would like of the DTFT, so the spectral resolution could
be made arbitrarily fine. However, large N means more storage, longer sampling time, longer computation, etc.
 N 1

. How good is our
In practice, we store L samples of x[n], and then compute an N -point FFT of x[n] to get X 2
N k
k=0
frequency resolution as a function of N ?
Analysis method. Realize that x[n] is not exactly time limited since it is bandlimited by assumption after passing through the ideal
anti-alias filter. (A signal cannot be both bandlimited and time limited.)

1, n = 0, . . . , L 1
. How do Y() and X () relate? Y() = X () W()
Consider y[n] = x[n] w[n] where w[n] =
0, otherwise,
(L1)/2
where W() = sin(L/2)
(periodic version of a sinc function). So Y() is a blurred out version of X (), smeared
sin(/2) e
by the FT of the rectangular window x[n]. This is called spectral leakage.
4

The width of W() is approximately 2/L = = k k1 for a L-point DFT.

We would like to express this width in terms of the analog signal spectrum.

=
= 2u/Fs so F = Fs 2

Fs
L

1
LTs .

F =

1
LTs

so spectral width is the inverse of the total sampling time! longer time means finer spectral resolution.
Example: audio, suppose we would like 22Hz resolution. Then 22 = 1/(LTs ) so L = Fs /22Hz = 44kHz/22Hz = 2000 samples
needed.

c J. Fessler, May 27, 2004, 13:14 (student version)


5.29

Interpolation / upsampling revisited


Suppose we are given the (stored) samples x[n] of a band-limited analog signal x a (t). Suppose we wish we could have M 1
samples in between each sample, i.e., we would like to find a signal y[n] such that

x[n/M ],
n = 0, M, 2M,
y[n] =
intermediate values, otherwise.
Time-domain approach
We could recover xa (t) from x[n] using the sinc-interpolation formula:
xa (t) =

l=


t lTs
,
x[l] sinc
Ts


and then evaluate x[n] at intermediate points:


y[n] = xa

n 
X
x[l] sinc(n/M l) .
Ts =
M
l=

This is the ultimate upsampling method, but it requires excessive amounts of computation.
How do the spectra of x[n] and y[n] relate to xa (t)?
Xa (F )
1 6
Fs /2

Fs /2 F

X ()
Fs 6

Y()
MFs 6

FFT-based approach

/M 0 /M

A more efficient way is to take an N-point DFT, and zero-pad in the frequency domain! Why zero pad? Because of the pictures of
X () and Y() above!
Y [k] =


1
1
X[0] X[1], . . . , X[N/2 1], X[N/2], [(M 1)N 1 zeros], X[N/2], X[N/2 + 1], . . . , X[N 1] .
2
2

Take M N -point IDFT of Y [k] and scale by M . Yields sinc-like interpolation of x[n], where y[nM ] = x[n].
In M ATLAB this is performed using the interpft command as follows:
signal length, e.g., N = 3 * length(x) for upsampling by 3.

y = interpft(x, N); where N is desired

c J. Fessler, May 27, 2004, 13:14 (student version)


5.30

Example.
% fig_interp.m
% illustrate FFT-based interpolation
N = 8;
n=0:N-1;
x = 0.5 + (n > N/4 & n < 3*N/4); % simply boxcar signal
clf, subplot(211)
stem(n, x, filled), stem_fix
xlabel n, ylabel x[n]
axis([0 N 0 2])
M = 4;
X = fft(x);
middle = X(N/2+1)/2;
Y = M * [X(1:N/2) middle zeros(1, (M-1)*N-1) middle X(N/2+2:end)];
y = reale(ifft(Y));
t = linspace(0, N, N*2*M);
xt = 0.5 + sinc(t-3) + sinc(t-4) + sinc(t-5);
subplot(212)
plot(0:length(y)-1, y, o, t*M, xt, --)
legend(y[n], x(t))
xlabel n, ylabel y[n]
axis([0 M*N 0 2])
title FFT-based interpolation of x[n]
hold on
stem(n*M, x, filled), stem_fix
hold off
% savefig fig_interp
2

x[n]

1.5
1
0.5
0

4
n

FFTbased interpolation of x[n]

y[n]
x(t)

y[n]

1.5
1
0.5
0

10

15

20

25

30

c J. Fessler, May 27, 2004, 13:14 (student version)


5.31

5.5
Summary
For a time-limited signal x[n] with L samples, the N -point DFT is an invertible transform that computes samples of the DTFT
X () of x[n].
The DFT can be used for filtering, via zero-padding and multiplication of DFT coefficients. This approach is particularly useful
because of the FFT.
x[n]

X
DTFS analysis
N -point periodic superposition
N 1 DTFS synthesis
x[n lN ]

{ck }k=0

xps [n]

xps [n] =
l=

 
N 1
2
IDFT
X
k
xps [n]
N
k=0
 
N 1
2
DFT
IDFT
x[n] X
k
x[n mod N ]
N
k=0

Sample
DTFT
x[n] X ()

In time-limited case with L N ,

X[k] = X

and

2
k
N

= N ck

xps [n] = x[n mod N ], n.

FT family tree diagram

DFT-based real-time filtering skip


Application: DFT-based removal of low-frequency hum.
Analog approach: x
a (t) Ha (F ) ya (t)
with Ha (F ) = 1 for |F | 100Hz picture

Analog design inflexible. Can we do it digitally?

System:
x
a (t) anti-alias xa (t) sampler x[n] N -point DFT

IDFT y[n] D/A ya (t)

H[k]
Want x[n] = h[n] x[n] but get y[n] = x[n]
N h[n]
Design issues
anti-alias cutoff
sampling frequency (relates to bandwidth of x
a (t)
N (larger causes more lag)
H[k]s (filter)

Suppose Fs = 1600Hz, so Fs /2 = 800Hz.

Is is real time? Not exactly due to lag to buffer in N samples, compute DFT/Multiply/IDFT.

You might also like