You are on page 1of 23

Finite Length Discrete Fourier

Transform

Discrete Fourier Transform (DFT)


Usually, we do not have an infinite amount of data which is required by the
DTFT. Instead, we have 1 image, a segment of speech, etc. Also, most real-
world data are not of the convenient form an u[n].
Finally, on a computer, we can not calculate an uncountably infinite
(continuum) of frequencies as required by the DTFT.
ACTUAL DATA ANALYSIS on a computer- Use a DFT to look at a
finite segment of data.
In our development in the previous section of x[n] periodic with x0 [n] the
part of the signal that was repeated, we could have assumed that our finite
segment of data came from “windowing” an infinite length sequence x[n]

x0 [n] = x[n]wR [n]

where wR [n] is a rectangular window:

1
!
1, n = 0, 1, · · · , N − 1
wR [n] =
0, otherwise
x0 [n] = x[n]wR [n] is just the samples of x[n] between n = 0 and n = N − 1.
x0 [n] is 0 everywhere else. Therefore, it is defined ∀n, and we can take its
DTFT:

" ∞
" N
" −1
−jΩn −jΩn
X0 (Ω) = DTFT(x0 [n]) = x0 [n]e = x[n]wR [n]e = x[n]e−jΩn
n=−∞ n=−∞ n=0

So,
N
" −1 N
" −1
X0 (Ω) = x[n]e−jΩn = x0 [n]e−jΩn
n=0 n=0

as we saw before.

Let’s say now that we want to sample X0 (Ω) (which is continuous and
periodic with period 2π) so we store it on a computer.
Sample X0 (Ω):
Assume we want 8 points in frequency – then sample X0 (Ω) at 8 uniformly
spaced points on the unit circle:

Values of frequency are 0, π/4, π/2, · · · , 7π/4 or 2πk/8, k = 0, 1, · · · , 7.

2
If we let k = N, what happens? If k = N, we get repetition of the points
we sampled so only N samples are unique.
Define Discrete Fourier Transform (DFT) as
2πk
X[k] = X0 ( )
N
for Ω = 2πk
N
, k = 0, 1, . . . , N − 1, i.e. only look at the N distinct sampled
frequencies of X0 (Ω).

Significant Observations
1. The resolution of the samples of the frequency spectrum is 2π
N
since we
sample the spectrum at points that are spaced 2π N
apart in frequency,
that is, ∆Ω = 2π
N
.
2. If we looked at the samples of X0 (Ω) for all k = −∞ to ∞ for frequen-
cies 2πk
N
, we would get the closely related Discrete Fourier Series (DFS)
which is of course periodic with period N since X0 (Ω) is periodic.
3. If x is a periodic signal with period N, as we saw that DFS was suf-
ficient to construct the DTFT of the signal. In other words, the DFT
procedure approximates a signal with a periodic approximation of itself.
Now
2πk
X[k] = X0 (Ω)|Ω = , k = 0, 1, · · · , N − 1
N
N
" −1
= x[n]e−jΩn |Ω= 2πk ,k=0,1,···,N −1
N
n=0
N
" −1
2πkn
= x[n]e−j N , k = 0, 1, · · · , N − 1
n=0

Shorthand Notation for the DFT:



Let WN = e−j N ⇒ N th root of unity (WNN = 1) since WNN = e−j2π = 1.
You may also write WN simply as W .
Then
N
" −1
X[k] = x[n]WNkn , k = 0, 1, · · · , N − 1
n=0
is the DFT of your windowed sequence x0 [n].

3
Ex.
Find
N
" −1 N
" −1
−j2πk
(e N )n = W kn
n=0 n=0

This is just the DFT of x[n] = 1, n = 0, 1, · · · , 7.

4
Ex.
!
1, n=0
x[n] =
0, n = 1, . . . , 7

Find X[k], k = 0, 1, . . . , 7.

5
Given y[n] = δ[n − 2] and N = 8, find Y [k].

6
Ex. x[n] = cWN−pn , n = 0, 1, . . . , N − 1,

p is an integer with p ∈ [0, 1, . . . , N − 1] and WN = e−j N (as usual), find
its DFT.

7
Synthesis: INVERSE DFT
How can we recover x[n] from X[k]?
Synthesis formula is
−1
1 N"
x[n] = X[k]WN−kn , n = 0, 1, . . . , N − 1
N k=0

Prove this gives back x[n]:

−1 N −1
1 N" "
x[n] = x[l]WNkl WN−kn
N k=0 l=0
−1 −1
1 N" N
" k(l−n)
= x[l] WN
N l=0 k=0

Ex.
N
" −1
k(l−n)
WN =?
k=0

8
ORTHOGONALITY OF EXPONENTIALS AGAIN!
So,
N −1
!
" k(l−n) N, l = n
WN =
k=0
̸ n
0, l =

and

−1 −1 −1
1 N" N
" k(l−n) 1 N"
x[n] = x[l] WN = x[l]Nδ[n − l]
N l=0 k=0
N l=0
1
= (Nx[n]) = x[n]
N
Ex. Find the IDFT of X[k] = 1, k = 0, 1, . . . , 7.

9
Ex. Given x[n] = δ[n] + 2δ[n − 1] + 3δ[n − 2] + δ[n − 3] and N = 4, find
X[k].

10
Ex. Given X[k] = 2δ[k] + 2δ[k − 2] and N = 4, find x[n].

11
Selected DFT Properties
1. Linearity.

ax1 [n] + bx2 [n] ↔ aX1 [k] + bX2 [k]

2. Time shift.

x[n − n0 ]mod N
↔ WNkn0 X[k]

3. Frequency shift.

WN−nk0 x[n] ↔ X[k − k0 ]mod N

4. Multiplication.

1
x1 [n]x2 [n] ↔ X1 [k] ⊗ X2 [k]
N
5. Circular convolution.

x1 [n] ⊗ x2 [n] ↔ X1 [k]X2 [k]

6. Real/Even.

x[n] = xe [n] + xo [n] ↔ X[k] = A[k] + jB[k]

xe [n] ↔ A[k]

xo [n] ↔ jB[k]

If x[n] is real, then


X[−k]mod N
= X ∗ [k].

If x[n] is even, then X[k] is real. (For a finite length function to be


even, x[n] = x[−n]mod N )

12
Fast Fourier Transform
The work of Cooley and Tukey showed how to calculate the DFT with com-
plexity N log N (called the Fast Fourier Transform) instead of complexity
N 2 using the direct algorithm. The fft command that you use in MATLAB
implements a Fast Fourier Transform.

Examine:
N
" −1
X[k] = x[n]W kn
n=0

There are approximately N 2 complex multiplications and additions re-


quired to implement this (N for each value of X[k]).

If N = 210 = 1024, then N 2 = 220 = 106 , a very large number!

However, the FFT would only require about 5000, a substantial savings
in complexity (the actual calculation is N2 log2 N).

There are a number of different FFT algorithms that exist including


decimation-in-time and decimation-in-frequency.

N
The primary idea is to split up the size-N DFT into 2
DFTs of length 2
each.

You split the sum into 2 subsequences of length N2 and continue all the
way down until you have N2 subsequences of length 2.

13
First break x[n] into even and odd subsequences:

" "
X[k] = x[n]W kn + x[n]W kn
neven nodd

Now let n = 2m for even numbers and n = 2m + 1 for odd numbers:

N N
−1 −1
"
2 "
2
2mk
X[k] = x[2m]W + x[2m + 1]W k(2m+1) =
m=0 m=0

N N
−1 −1
"
2 "
2
2 mk k
x[2m](W ) +W x[2m + 1](W 2 )mk =
m=0 m=0

Xe [k] + W k Xo [k]
N
Xe [k] and Xo [k] are both the DFT of a 2
point sequence.

W k is often referred to as the “twiddle factor.”

N
Now break up the size 2
subsequences in half by letting m = 2p:

N N
−1 −1
"
4 "
4
4 kp 2k
Xe [k] = x[4p](W ) +W x[4p + 2](W 4 )kp =
p=0 p=0

The first subsequence here is the terms x[0], x[4], . . . and the second is
x[2], x[6], . . . .

14
Also, we have that:
N
WN2 = −1

1
"
Y [k] = y[n]W2kn = y[0] + W2k y[1]
n=0

j2π
W2 = e− 2 = e−jπ = −1

So we get,

Y [k] = y[0] + (−1)k y[1]


and:

Y [0] = y[0] + y[1]

Y [1] = y[0] − y[1]

15
Ex.
This was a problem I had on a DSP final exam in 1984:
Express the DFT of the 9-point sequence {x[0], x[1], . . . , x[8]} in terms of
the DFTs of 3-point sequences {x[0], x[3], x[6]}, {x[1], x[4], x[7]}, and {x[2], x[5], x[8]}

We start with:

2
" 2
" 2
"
(3m+1)k (3m+2)k
X[k] = x[3m]W93mk + x[3m + 1]W9 + x[3m + 2]W9
m=0 m=0 m=0

16
Applications of the DFT
Linear Convolution
You can use an FFT in MATLAB to compute linear convolution. If you
don’t use a sufficient number of points in the DFT, you will get overlap.

CIRCULAR CONVOLUTION
Since DFTs are a limited length sequence, convolution is done mod N ⇒
circular convolution.
N
" −1
x1 [n] ⊗ x2 [n] = x1 [p]x2 [n − p]mod N
p=0

That is, when we flip and shift the sequence x2 [n], we do it mod N.

Also, note that:

x1 [n] ⊗ x2 [n] ↔ X1 [k]X2 [k]

17
Ex. Find x1 [n] ⊗ x2 [n] = z[n].

18
Ex. N = 8, find x1 [n] ⊗ x2 [n] = y[n].

19
Ex. Find y[n] = x[n] ⊗ x[n].

20
Overview of Chapters 3, 4, and 5
Fourier Analysis for Discrete-Time Signals
1. DTFT for infinite length sequences:
continuous frequency, periodic with period 2π,
"
X(Ω) = x[n]e−jΩn
n

Important: DT convolution ↔ multiplication of DTFTs.


Inverse system:

h[n] ∗ hi [n] = δ[n] ↔ H(Ω)Hi (Ω) = 1

2. DTFT of a periodic DT sequence by allowing impulses in frequency:


" "
x[n] = ak ejΩk n ↔ 2π ak δ(Ω − Ωk )
k k

where
2πk
ak = X0 ( )
N
3. DFT for a finite length data
discrete frequency
Take DTFT of windowed infinite length sequence and then sample at
discrete frequencies,
2πk
Ω= , k = 0, 1, . . . , N − 1
N
N discrete frequencies since exponential is periodic.
N
" −1 N
" −1
2πkn
X[k] = x[n]e−j N = x[n]WNkn
n=0 n=0

Orthogonality of Exponentials:
N
" −1
WNkn = Nδ[k]
n=0

21

You might also like