You are on page 1of 37

Discrete Fourier Transform (DFT)

Recall the DTFT:


X
X(ω) = x(n)e−jωn.
n=−∞

DTFT is not suitable for DSP applications because

• In DSP, we are able to compute the spectrum only at specific


discrete values of ω,

• Any signal in any DSP application can be measured only in


a finite number of points.

A finite signal measured at N points:



 0, n < 0,
x(n) = y(n), 0 ≤ n ≤ (N − 1),
0, n ≥ N,

where y(n) are the measurements taken at N points.


Sample the spectrum X(ω) in frequency so that


X(k) = X(k∆ω), ∆ω = =⇒
N
N −1
−j2π kn
X
X(k) = x(n)e N DFT.
n=0

The inverse DFT is given by:

N −1
1 X kn
x(n) = X(k)ej2π N .
N
k=0

−1
N
(N −1 )
1 X X
−j2π km j2π kn
x(n) = x(m)e N e N
N m=0
k=0
−1 −1
N
( N
)
X 1 X
−j2π
k(m−n)
= x(m) e N = x(n).
m=0
N
k=0
| {z }
δ(m−n)
The DFT pair:

N −1
X kn
X(k) = x(n)e−j2π N analysis
n=0
N −1
1 X j2π kn
x(n) = X(k)e N synthesis.
N
k=0

Alternative formulation:

N −1
X 2π
X(k) = x(n)W kn ←− W = e−j N
n=0
N −1
1 X
x(n) = X(k)W −kn.
N
k=0
Periodicity of DFT Spectrum

N −1
X (k+N )n
−j2π
X(k + N ) = x(n)e N

n=0
−1
N
!
−j2π kn
X
= x(n)e N e−j2πn
n=0

= X(k)e−j2πn = X(k) =⇒

the DFT spectrum is periodic with period N (which is expected,


since the DTFT spectrum is periodic as well, but with period
2π).

Example: DFT of a rectangular pulse:



1, 0 ≤ n ≤ (N − 1),
x(n) =
0, otherwise.

N −1
X kn
X(k) = e−j2π N = N δ(k) =⇒
n=0
the rectangular pulse is “interpreted” by the DFT as a spectral
line at frequency ω = 0.
DFT and DTFT of a rectangular pulse (N=5)
Zero Padding

What happens with the DFT of this rectangular pulse if we


increase N by zero padding:

{y(n)} = {x(0), . . . , x(M − 1), 0, . . . , 0} },


| 0,{z
N −M positions

where x(0) = · · · = x(M − 1) = 1. Hence, DFT is

N −1 M −1
−j2π kn −j2π kn
X X
Y (k) = y(n)e N = y(n)e N

n=0 n=0

sin(π kM
N ) −jπ
k(M −1)
= e N .
sin(π Nk )
DFT and DTFT of a Rectangular Pulse with
Zero Padding (N = 10, M = 5)

Remarks:

• Zero padding of analyzed sequence results in


“approximating” its DTFT better,

• Zero padding cannot improve the resolution of spectral


components, because the resolution is “proportional” to
1/M rather than 1/N ,

• Zero padding is very important for fast DFT implementation


(FFT).
Matrix Formulation of DFT

Introduce the N × 1 vectors


   
x(0) X(0)
 x(1)   X(1) 
x=
 .. ,
 X=
 .. .

x(N − 1) X(N − 1)

and the N × N matrix


 
0 0 0 0
W W W ··· W

 W0 W1 W2 · · · W N −1 

W=
 W0 W2 W4 · · · W 2(N −1) .

 .. .. .. .. .. 
 
(N −1)2
W 0 W N −1 W 2(N −1) ··· W

DFT in a matrix form:

X = Wx.

Result: Inverse DFT is given by

1 H
x= W X,
N
which follows easily by checking W H W = WW H = N I, where
I denotes the identity matrix. Hermitian transpose:

xH = (xT )∗ = [x(1)∗, x(2)∗, . . . , x(N )∗].

Also, “∗” denotes complex conjugation.

Frequency Interval/Resolution: DFT’s frequency resolution

1
Fres ∼ [Hz]
NT

and covered frequency interval

1
∆F = N ∆Fres = = Fs [Hz].
T

Frequency resolution is determined only by the length of


the observation interval, whereas the frequency interval is
determined by the length of sampling interval. Thus

• Increase sampling rate =⇒ expand frequency interval,

• Increase observation time =⇒ improve frequency resolution.

Question: Does zero padding alter the frequency resolution?


Answer: No, because resolution is determined by the length of
observation interval, and zero padding does not increase this
length.

Example (DFT Resolution): Two complex exponentials with


two close frequencies F1 = 10 Hz and F2 = 12 Hz sampled
with the sampling interval T = 0.02 seconds. Consider various
data lengths N = 10, 15, 30, 100 with zero padding to 512
points.

DFT with N = 10 and zero padding to 512 points.


Not resolved: F2 − F1 = 2 Hz < 1/(N T ) = 5 Hz.
DFT with N = 15 and zero padding to 512 points.
Not resolved: F2 − F1 = 2 Hz < 1/(N T ) ≈
3.3 Hz.

DFT with N = 30 and zero padding to 512 points.


Resolved: F2 − F1 = 2 Hz > 1/(N T ) ≈ 1.7 Hz.
DFT with N = 100 and zero padding to 512
points. Resolved: F2 − F1 = 2 Hz > 1/(N T ) =
0.5 Hz.
DFT Interpretation Using
Discrete Fourier Series

Construct a periodic sequence by periodic repetition of x(n)


every N samples:

{e
x(n)} = {. . . , x(0), . . . , x(N − 1), x(0), . . . , x(N − 1), . . .}
| {z } | {z }
{x(n)} {x(n)}

The discrete version of the Fourier Series can be written as


X
j2π kn 1 X e j2π kn 1 X e
x
e(n) = Xk e N = X(k)e N = X(k)W −kn,
N N
k k k

where X(k)
e = N Xk . Note that, for integer values of m, we
have
(k+mN )n
−kn j2π kn
W =e N =e j2π N = W −(k+mN )n.

As a result, the summation in the Discrete Fourier Series (DFS)


should contain only N terms:

N −1
1 X e j2π kn
x
e(n) = X(k)e N DFS.
N
k=0
Inverse DFS

The DFS coefficients are given by

N −1
X kn
X(k)
e = e(n)e−j2π N
x inverse DFS.
n=0

Proof.
 
N −1 N −1  N −1
X
−j2π kn
X 1 X e j2π pn

−j2π kn
x
e(n)e N = X(p)e N e N
N 
n=0 n=0 p=0

−1 −1
N
( N
)
X 1 X
j2π
(p−k)n
= X(p)
e e N = X(k).
e
p=0
N n=0
| {z }
δ(p−k)

The DFS coefficients are given by

N −1
X kn
X(k)
e = e(n)e−j2π N
x analysis,
n=0
N −1
1 X e j2π kn
x
e(n) = X(k)e N synthesis.
N
k=0
• DFS and DFT pairs are identical, except that
− DFT is applied to finite sequence x(n),
− DFS is applied to periodic sequence x
e(n).

• Conventional (continuous-time) FS vs. DFS


− CFS represents a continuous periodic signal using an
infinite number of complex exponentials,
whereas
− DFS represents a discrete periodic signal using a finite
number of complex exponentials.
DFT: Properties

Linearity

Circular shift of a sequence: if X(k) = DFT {x(n)} then

km
X(k)e−j2π N = DFT {x((n − m) mod N )}

Also if x(n) = DFT −1{X(k)} then

km
x((n − m) mod N ) = DFT −1{X(k)e−j2π N }

where the operation mod N denotes the periodic extension


x
e(n) of the signal x(n):

x
e(n) = x(n mod N ).
DFT: Circular Shift

N
X −1
x((n − m)modN )W kn
n=0
N
X −1
= W km x((n − m)modN )W k(n−m)
n=0
N
X −1
= W km x((n − m)modN )W k(n−m)modN
n=0

= W kmX(k),

where we use the facts that W k(lmodN ) = W kl and that the


order of summation in DFT does not change its result.

Similarly, if X(k) = DFT {x(n)}, then

j2π mn
X((k − m)modN ) = DFT {x(n)e N }.

DFT: Parseval’s Theorem

N −1 N −1
X 1 X
x(n)y ∗(n) = X(k)Y∗(k)
n=0
N
k=0

Using the matrix formulation of the DFT, we obtain

 H  
1 H 1 H
yH x = W Y W Y
N N
1 H H 1 H
= Y W W } X = Y X.
N2 | {z
NI
N
DFT: Circular Convolution

If X(k) = DFT {x(n)} and Y (k) = DFT {y(n)}, then

X(k)Y (k) = DFT {{x(n)} ~ {y(n)}}

Here, ~ stands for circular convolution defined by

N
X −1
{x(n)} ~ {y(n)} = x(m)y((n − m) mod N ).
m=0

DFT {{x(n)} ~ {y(n)}}


N −1 h i
X PN −1 kn
= m=0 x(m)y((n − m) mod N ) W
n=0 | {z }
{x(n)}~{y(n)}
N −1 h i
X PN −1
= n=0 y((n − m) mod N )W kn x(m)
m=0 | {z }
Y (k)W km
N
X −1
= Y (k) x(m)W km = X(k)Y (k).
|m=0 {z }
X(k)
Discrete Fourier Transform
 What is Discrete Fourier Transform (DFT)?
(Note: It’s not DTFT – discrete-time Fourier transform)
 A linear transformation (matrix)
 Samples of the Fourier transform (DTFT) of an aperiodic (with finite duration) sequence
 Extension of Discrete Fourier Series (DFS)

 Review: FT, DTFT, FS, DFS


Time signal Transform Coeffs. Coeffs. (con-
(periodic/aperiodic) ti./discrete)
Analog aperiodic FT Aperiodic Continuous
Analog periodic FT Aperiodic Continuous (impulse)
FS Aperiodic Discrete
Discrete aperiodic DTFT Periodic Continuous
Discrete periodic DFS Periodic Discrete
Discrete finite-duration DFT

 The Discrete Fourier Series


 Properties of WN

2
 j 2 j k
WN  e N , thus W  e k
N
N

-- WN is periodic with period N. (It is essentially cos and sin) : W Nk  W Nk  N  W Nk  2 N  

N 1
N , if l  mN 
--
W N 
lk

k 0 0, if l  mN 

(Pf) (i) If l  m  N , WNlk  WNmk N  WN0  1

N 1 N 1
 WNlk   1  N
k 0 k 0

(ii) If l  m  N , WNl  1

N 1
1  WNlN 11
WNlk  
1  WN 1  WNl
l
0
k 0

N 1 
-- Y l   1
W N   l  mN 
lk

N k 0 m  
 DFS for periodic sequences
~
x [n]

x n   ~
~ x n  rN , period N

Its DFS representation is defined as follows:


N 1 2 N 1
Synthesis equation: ~x n   1 X k e N 
1
 X k WN
~ j kn ~

 kn

N k o N k 0
N 1
Analysis equation: X~ k  
 ~x nWn
kn

n 0

Note: The tilde in ~


x indicates a periodic signal.
~
X [k ] is periodic of period N.
N 1
Pf) ~x n   1
 X k WN
~  kn

N k 0

Pick an r ( 0 rN)
N 1
x n WNrn   X k WN
~ 1 ~  kn
W rn
N
  W Nrn
N k 0

N 1 N 1 N 1
 ~x nWNrn  N   X k WN
1 ~  kn
 WNrn
n 0 n 0 k 0
N 1
 
N 1
~ N 1 ( r k ) n
  ( X k  WN
1
)
n 0 N k 0 n 0

 X 0  0  X 1  0    X k  r   1  
~ ~ ~

 X r 
~

N 1
~
That is, X r    ~x n WNrn . QED
n 0
Example: Periodic Rectangular Pulse Train

 k 
4k sin 
4
1  W105k j
 2 
X k    W10Kn 
~
 e 10
n 0 1  W10k  k 
sin 
 10 

 Sampling the Fourier Transform


Compare two cases:

x n  X [k ]
(1) Periodic sequence ~
~

(2) Finite duration sequence xn  = one period of ~


x n 
An aperiodic sequence:

xn   FT   
X e j x t   FT  X  j 
Compare:
?  samples  samples ?
x n   IDFS  X k   X e j |
~ ~
  2
 
xn   DTFT  X e j
 k
N
1, r10  n  4  r10
Example: xn   1, 0  n  4 x n   
~
 0, 5  r10  n  9  r10
0, otherwiase
r  integer

N 1
x n   X k W
~ 1 ~  Kn
N (IDFS)
N k 0

   kn

1
  X e j
N k 
  2
 k
WN (Sampling)
N 
  
  xme  jm 
1
 
N k  m     k
2 
WN kn (FT)
N
2
N 1     kn
   xme
1 j km
 N WN
N 
k 0  m   

 N 1 
 xmW
1
 WN kn 
km
N (Interchange  )
N m   k 0 
 
 xn     n  rN    xn  rN 
r   r  
If x[n] has finite length and we take a sufficient number of equally spaced samples of its
Fourier Transform ( a number greater than or equal to the length of x[n]), then x[n] is re-
coverable from ~ x[n] .

 Two ways (equivalently) to define DFT:


(1) N samples of the DTFT of a finite duration sequence xn 

(2) Make the periodic replica of x n 


xn   ~
x n 
Take the DFS of ~
~
Pick up one segment of X [k ]

xn   DFT  X [k ]
 periodic  one segment
x n   DFS  X k 
~ ~
 Properties of the Discrete Fourier Series
-- Similar to those of FT and z-transform

 Linearity

x1 n   X 1 k  
~ ~
x1 n   b~
x2 n   aX 1 k   bX 2 k 
~ ~
  a~
x 2 n   X 2 k 
~ ~

 Shift

~ ==> ~
x n  X k 
~ x n  m   W N X k 
km ~

x n   X k  l 
~
WNnl ~

 Duality
~ 1 N 1 ~
Def:  x n    X k WNkn (*)
N k 0
 N 1
 X~ k    ~ x n WNnk (# )
 n 0

x n   X k 
~
~
~
 X k   Nx  k 
~

x n  X k 
 Symmetry ~ ~

Re~
~  1 ~
 ~ 
x n   X e k   X k   X *  k   
 2 

j Im~
~  1 ~
 ~ 
x n   X o k   X k   X *  k   
 2 

~ 1
2

xe n   ~x n   ~ 
x *  n   ReX k 
~

xo n   ~
~ 1
2

x n   ~ 
x *  n   j ImX k 
~

 X~ k   X~  k 
 ~
x n  is real, X k   X *  k  .
~ ~
If ~ X k   X~  k 
 ReX k   ReX  k 
~ ~

ImX k    ImX  k 
~ ~
 Periodic Convolution
x1 n , ~
~ x 2 n  are periodic sequences with period N
N 1
 ~x1 m~x2 n  m  X 1 k X 2 k 
~ ~
m 0
N 1
x3 n   ~
x1 n ~
x2 n    X 1 l X 2 k  l 
~ 1 ~ ~
N l 0

 Discrete Fourier Transform


 Definition
xn  : length N, 0  n  N  1
Making the periodic replica:

x n  
~
 xn  rN 
r  

 xn modulo N 
 xn N 
N 1
X k    ~ x n WNkn
~
n 0

Keep one segment (finite duration)


 X k , 0  k  N  1 That is, X
~
X k   
~
k   X [(( k )) N ]
 0, otherwise

This finite duration sequence X [k ] is the discrete Fourier transform (DFT) of xn 
N 1
Analysis eqn : X k    xnWNkn , 0  k  N 1
n 0
N 1
Synthesis eqn : xn    X k WNkn ,
1
0  n  N 1
N k 0
Remark: DFT formula is the same as DFS formula. Indeed, many properties of DFT are de-
rived from those of DFS.
 Properties of Discrete Fourier Transform
 Linearity

x1 n  X 1 k  
  ax1 n   bx2 n  aX 1 k   bX 2 k 
x2 n   X 2 k 
length  maxN1 , N 2 

 Circular Shift

xn  m N   WNkm X k 


xn   X k  ==>
WNln xn   X k  l N 
(Pf) From the right side of the 2nd eqn.
2 2
WNKm X k   e X k   e X k 
j
N
km j
N
km ~
QED
 DFT  IDFS
xn  m N   xn  m N   x n  m
~

Remark: This is circular shift not linear shift. (Linear shift of a periodic sequence = circular
shift of a finite sequence.)
 Duality

xn   X k 
X n   Nx k N , 0  k  N - 1

 Symmetry Properties
x ep n   periodic conjugate - symmetric
~
e x n 

 
 xn N   x * n N  , 0  n  N-1
1
2
1
 
 xn   x N  n  , 1  n  N-1
 2
*

 Rex0, n0
xop n   periodic conjugate - antisymmetric
1
 
 xn   x N  n  , 1  n  N-1
 2
*

Imx0, n0
xep n   ReX k  xop n   j ImX k 

If xn  real, X k   X *  k N , 0  k  N  1


 X k   X  k N   ReX k   ReX  k N 
 
X k   X  k N  ImX k    ImX  k N 



Rexn   X ep k  
1
2
 
X k  N   X *  k  N 

Imxn   X op k  

1
2
 
X k  N   X *  k  N 

 Circular Convolution
x 3 n   x1 n x 2 n 
N 1 N-point circular convolution
  xmxn  m  N 
m 0

x1 n x 2 n   X 1 k X 2 k 
Example: N-point circular convolution of two constant sequences of length N

2L-point circular convolution of two constant sequences of length L


 Linear Convolution Using DFT
 Why using DFT? There are fast DFT algorithms (FFT)

 How to do it?

(1) Compute the N-point DFT of x1 n  and x 2 n  separately

 X 1 k  and X 2 k 

(2) Compute the product X 3 k   X 1 k X 2 k 

(3) Compute the N-point IDFT of X 3 k   x3 n 

 Problems: (a) Aliasing


(b) Very long sequence
 Aliasing

x1 n , length L (nonzero values)


x2 n , length P
In order to avoid aliasing, N  L  P  1
(What do we mean avoid aliasing? The preceding procedure is circular convolution but we

want linear convolution. That is, x3 n equals to the linear convolution of x1 n  and x2 n )
x1 n  pad with zeros  length N
x2 n  pad with zeros  length N

Interpretation: (Why call it aliasing?)

X 3 k  has a (time domain) bandwidth of size L  P 1

(That is, the nonzero values of x3 n  can be at most L  P  1 )

Therefore, X 3 k  should have at least L  P  1 samples. If the sampling rate is insuf-

ficient, aliasing occurs on x3 n  .


 Very long sequence (FIR filtering)
 Block convolution
 Method 1 – overlap and add
Partition the long sequence into sections of shorter length.
For example, the filter impulse response hn  has finite length P and the input data xn 
is nearly “infinite”.

 xn  rL, 0  n  L-1
Let xn    x r n  rL where x r n   
r 0 0, otherwise
The system (filter) output is a linear convolution:

yn   xn   hn    y r n  rL where y r n   x r n   hn 
r 0

Remark: The convolution length is L  P  1 . That is, the L  P  1 point DFT is used.
y r n  has L  P  1 data points; among them, (P-1) points should be added
to the next section.

This is called overlap-add method.


(Key: The input data are partitioned into nonoverlapping sections  the section outputs
are overlapped and added together.)
 Method 2 – overlap and save
Partition the long sequence into overlapping sections.
After computing DFT and IDFT, throw away some (incorrect) outputs.
For each section (length L, which is also the DFT size), we want to retain the correct
data of length ( L  ( P  1)) points

Let hn , length P


xr n , length L (L>P)
Then, y r n  contains (P-1) incorrect points at the beginning.
Therefore, we divide into sections of length L but each section overlaps the preceding
section by (P-1) points.
x r n   xn  r L  P  1  P  1, 0  n  L - 1
This is called overlap-save method.

You might also like