DFT and FFT - 2021
DFT and FFT - 2021
However, in some applications, signal frequency content is more useful than the
digital signal samples.
Sample number k
Let x(t) be a periodic function of time having a time period T0, then
the fundamental frequency of x(t) is
2
0 …….(1)
T0
Fourier series for a periodic signal
Let x(t) be a periodic function of time having a time period T0, then
the fundamental frequency of x(t) is
2
0 …….(1)
T0
The signal x(t) may be expressed in terms of the Fourier series as
x(t ) a0 an cos n0t bn sin n0t …….(2)
n1
Fourier series for a periodic signal
x(t ) a0 an cos n0t bn sin n0t …….(2)
n1
where 2 T0
1 1
a0 x(t)d (0 t) x(t)dt , the average value
2 0 T0 0
2 T0
1 2
an x(t) cosn0td(0 t) x(t) cosn0tdt
0 T0 0 for n = 1, 2, 3, …
2 T0
1 2
bn x(t ) sin n0td (0 t ) x(t ) sin n0tdt
0 T0 0 for n = 1, 2, 3, …
an’s are known as cosine coefficients and bn’s are known as sine coefficients.
Fourier series for a periodic signal
Relation (2) may be rewritten as
2 an 2 bn
x(t) a0 an bn ( 2 2 cosn0t 2 2 sinn0t)
n1 an bn an bn
or x(t ) C0 Cn cos(n0t n ) …….(3)
n1
an an
an jbn an jbn
where F0 a0 , Fn ( ) and Fn ( )
2 2
x(t ) F0 Fn e jn 0t Fn e jn 0t
n 1 n 1
Fourier series for a periodic signal
Now x (t ) F0 Fn e jn 0t F n e jn 0t
n 1 n 1
x (t ) F0 Fn e jn 0 t n
F e jn 0 t
n 1 n 1
Hence, we can write, x (t ) F n e jn 0 t …….(5)
n
n 1 n 1
Hence, we can write, x (t ) F n e jn 0 t …….(5)
n
F n Fˆn
F n Fˆn
j Fn Fn
1
and n tan
Fn Fn
the phase of the nth harmonic.
Fourier series for a periodic signal
From relation (4), Fn may be expressed as
an jbn
Fn ( )
2
Substituting expressions of an and bn from relation (2)
T0
1 jn 0 t
Fn x ( t ) e dt …….(7)
T0 0
For aperiodic signals, the time period T0 becomes infinite, and the Fourier
transform of an aperiodic signal x(t) is defined as
j t
X ( ) x ( t ) e dt …….(8)
Fourier series for a periodic discrete sequence
Using rectangular rule for integration, the Fourier coefficients may be obtained as
N 1
1
a0
T0
x
k 0
k
N 1 N 1
1 1
or a0
N
k 0
x k
N
x
k 0
k …….(10)
Fourier series for a periodic discrete sequence
Using rectangular rule for integration, the Fourier coefficients may be obtained as
Similarly,
From relation (2)
T0
2
an
T0 x (t ) cos n tdt
0
0
N 1
2 2
an
N
x k cos n N k
k 0
2 N 1 2 kn
or an x k cos …….(11)
N k 0
N
2 2
(using the substitutions: 0 and T0 N and t k in relation (2))
T0 N
Fourier series for a periodic discrete sequence
Using rectangular rule for integration, the Fourier coefficients may be obtained as
and
From relation (2)
T0
2
bn
T0 x (t ) sin n tdt
0
0
N 1
2 2
bn
N
x k sin n N k
k 0
2 N 1 2 kn
or bn x k sin …….(12)
N k 0
N
2 2
(using the substitutions: 0 and T0 N and t k in relation (2))
T0 N
Fourier series for a periodic discrete sequence
Now from relations (11) and (12),
N 1
a n jb n 1 2 kn 2 kn
N
x k cos j sin
2 k 0 N N
N 1 2k
1 jn
N
xk e
N k 0
Hence, the Fourier series coefficients for the periodic discrete sequence are:
F0 a0 and
N 1 2k
an jbn 1 jn
N
Fn xk e , n 1,2,3, …….(12a)
2 N k 0
Since the coefficients Fn are obtained from the Fourier series expansion in
the complex form, the resultant spectrum Fn will have two sides.
Fourier series for a periodic discrete sequence
Now from relations (11) and (12),
N 1
a n jb n 1 2 kn 2 kn
N
x k cos j sin
2 k 0 N N
N 1 2k
1 jn
N
xk e
N k 0
Hence, the Fourier series coefficients for the periodic discrete sequence are:
F0 a0 and
N 1 2k
an jbn 1 jn
N
Fn xk e , n 1,2,3, …….(12a)
2 N k 0
It can be shown that Fn+N = Fn. Hence the Fourier series coefficients Fn are
periodic having a periodicity of N.
Fourier series for a periodic discrete sequence
Fn
For the kth harmonic, the frequency is f=kf0. The frequency spacing between
the consecutive spectral lines, called the frequency resolution, is f0 Hz.
As Fn+N = Fn, the two-sided line amplitude spectrum Fn is periodic.
Fourier series for a periodic discrete sequence
Fn
OBSERVATIONS:
• Only the line spectral portion between the frequency –fs/2 and frequency
fs/2 (folding frequency) represents the frequency information of the
periodic signal.
Fn
OBSERVATIONS:
xk
x1
x3
Fourier series for a periodic discrete sequence
Problem 1
Let us consider a periodic signal x(t) = sin(2t), sampled using a sampling rate of fs = 4 Hz.
(i) Compute the Fourier coefficients or spectrum Fn using the samples in one period.
(ii) Plot the two-sided amplitude spectrum Fn over the range from -2 to 2 Hz.
Solution (contd.)
For a duration of one period, N = 4. The sample values are: x0=0, x1=1, x2=0, x3=-1.
From the expression of Fn in relation (12a), we can compute:
1 3 1 1
F0 xk x0 x1 x2 x3 0 1 0 1 0
4 k 0 4 4
1 3 j 2 1k 1 j j 3
F1 xk e 4
x0 x1e 2 x2e x3e 2
j
4 k 0 4
1 1
x0 jx1 x2 jx3 0 j1 0 j 1 j 0.5
4 4
Fourier series for a periodic discrete sequence
Problem 1
Let us consider a periodic signal x(t) = sin(2t), sampled using a sampling rate of fs = 4 Hz.
(i) Compute the Fourier coefficients or spectrum Fn using the samples in one period.
(ii) Plot the two-sided amplitude spectrum Fn over the range from -2 to 2 Hz.
Solution (contd.)
Similarly we get:
1 3 j 2 2 k 1 3 j 2 3k
F2 xk e 4
0 and F3 xk e 4
j 0.5
4 k 0 4 k 0
Using periodicity, it follows that:
Fn
N 1 2k
N jn
a n jbn xk e N
2 k 0
N
Substituting Na0 X 0 and an jbn X n , for n = 1, 2, 3, …
2
N 1 2k
jn
N
X n NFn xk e for n = 0, 1, 2, … …….(13)
k 0
Fourier series for a periodic discrete sequence
N 1 2k
jn
N
From relation (13) X n NFn xk e for n = 0, 1, 2, …
k 0
2k
N 1 j N m
N
X n xk e
k 0
N 1 2k
jm
or X mN xk e j 2k .e N
k 0
N 1 2k
jm
N
or X mN xk e Xm …….(14)
k 0
N 1 2k
jn
N
X n xk e , for n = 0, 1, 2, …., N-1 …….(15)
k 0
N 1 2k
jn
N
X n xk e , for n = 0, 1, 2, …., N-1 …….(15)
k 0
1
C0 X 0 , the average value
N
2
and Cn X n , for n = 1, 2, 3, … …….(16)
N
Discrete Fourier Transform
T0 = N
xk xN+1=x1
x1
The development of
the DFT formula
x0
k
xN=x0
xk
x1 xk Xn=NFn
x0 xN-1 t = k f = nf
k f = fs/N
Inverse Discrete Fourier Transform
Relation (15):
2 l N 1 2k
jn
By multiplying 1 jn
N
X n xk e N
e , for n = 0, 1, 2, …., N-1
N k 0
2 l 2 k 2 l
1 N 1 jn
N
1 N 1 N 1 jn
N
jn
N
X ne xk e .e
N n 0 N n0 k 0
1 N 1 N 1 jn l k
2
xk e N
N n0 k 0
Now, changing the order of summation,
2 l 2 l k
1 N 1 jn
N
1
N 1 N 1 jn
N
X n e xk e N
…….(17)
n 0 k 0 N n 0
Inverse Discrete Fourier Transform
N 1 2 ( l k )
jn
Now, in e
n 0
N , when (l k ) pN
N 1
jn 2 p
where p is a positive integer, the expression becomes
n0
e
N 1 N 1
j 2 np
As np is another integer, it becomes
e
n 0
1 N
n 0
In the present case, as l and k are limited within 0 and (N – 1), the possible
value of p is zero, i.e. when (l - k) = 0 or l = k, the summation becomes N.
Inverse Discrete Fourier Transform
N 1 2 ( l k )
jn
2 l k
Now, in e
n 0
N , let
N
N 1 2 l k N 1
jn
jn
Then the summation becomes e
n 0
N =
e
n0
It may be expressed as
N 1 N
jn j m1
e
n0
e
m1
, where m = n + 1
N
e jm .e j
m 1
Inverse Discrete Fourier Transform
N 1 N
jn jm j
or
e
n0
.e
e
m1
N
e cos m j sin m
j
m1
N N
sin sin
j 2 N 1 2 N 1
e cos j sin
2 2
sin sin
2 2
N
sin N 1
j
j
e 2 e 2
sin
2
Inverse Discrete Fourier Transform
N
N 1 sin N 1
j
j
jn 2
or e e
e 2
n0 sin
2
N
sin j
N 1
2 e 2
sin
2
jN2 jN
e e 2
jN
2j e 2
e jN 1
j j
. j j
2 e 1
e 2
e 2 e
2j
Inverse Discrete Fourier Transform
N 1
jn e jN 1
or e
n0
j
e 1
Putting the value of ,
l k j 2 ( l k )
N 1 jn2 e 1
e
n0
N
j 2
( l k )
e N
1
Now for l k, the summation is zero.
0, for l k
considering 0 l, k N
Thus all terms on the right hand side of relation (17) vanishes except
when l = k.
2 l 2 l k
1 N 1 jn
N
N 1 1 N 1 jn
N
X n e xk e N
…….(17)
n 0 k 0 N n 0
Inverse Discrete Fourier Transform
N 1 jn2
l k
Thus,
e
n0
N
N, for l k
0, for l k
considering 0 l, k N
Thus all terms on the right hand side of relation (17) vanishes except
when l = k.
2 l
1 N 1 jn
N
N 1 1 N 1 jn 2 Nl k
Therefore, X ne
N n 0
xk e
N
…….(17)
k 0 n 0
N 1 2l
1 jn
N
N
N
X
n0
n e xl xl , for l = 0,1,2,…,N-1
N
Inverse Discrete Fourier Transform
N 1 2l
1 jn
N
N
N
X
n 0
n e xl xl , for l = 0,1,2,…,N-1
N
N 1 2k
1 jn
N
xk X n e , for k = 0,1,2,…,N-1 …….(18)
N n 0
N-point IDFT:
N 1 2 k
1 jn
N
xk
N
X
n 0
n e , for k = 0,1,2,…,N-1 …….(18)
2
j
N
Replacing the expression e
by the term WN, the DFT pair takes the form
N 1
X n x kW Nnk , for n = 0,1,2,…, N-1 …….(19)
k 0
N 1
1 nk …….(20)
xk
N n 0
X n N , for k = 0,1,2,…,N-1
W
N-point DFT pair
N 1
X n x kW Nnk , for n = 0,1,2,…, N-1 …….(19)
k 0
N 1
1 nk …….(20)
xk
N n 0
X n N , for k = 0,1,2,…,N-1
W
2
j
N
where WN e
a complex operator (twiddle factor), which rotates any vector through
2 N Radians.
Solution 2
j
j
4 2
Here N = 4. Hence WN W4 e e
3 3 nk
j
Therefore, X n x kW4nk x k e 2
k 0 k 0
3
For n = 0, X 0 x k e j 0 x0 e j 0 x1e j 0 x2 e j 0 x3 e j 0
k 0
x0 x1 x 2 x3 1 2 3 4 10
3 k 3
j j j
For n = 1, X 1 xk e 2
x0 e j 0 x1e 2
x 2 e j x3 e 2
k 0
x0 jx1 x 2 jx 3 1 j 2 3 j 4 2 j 2
DFT and IDFT
Problem 2
A sequence xk, for k = 0,1,2,3, is given as: x0 = 1, x1 = 2, x2 = 3, and x3 = 4.
Evaluate its DFT Xn.
Solution (contd.) 2
j
j
4 2
Here N = 4. Hence WN W4 e e
3 3 nk
j
Therefore, X n x kW4nk x k e 2
k 0 k 0
3 2 k
j
For n = 2, X 2 xk e 2
x0 e j 0 x1e j x 2 e j 2 x3 e j 3
k 0
x0 x1 x 2 x3 1 2 3 4 2
3 3 k 3 9
j j j
For n = 3, X 3 xk e 2
x0 e j 0 x1e 2
x 2 e j 3 x 3 e 2
k 0
x0 jx1 x 2 jx 3 1 j 2 3 j 4 2 j 2
DFT and IDFT
Problem 2
A sequence xk, for k = 0,1,2,3, is given as: x0 = 1, x1 = 2, x2 = 3, and x3 = 4.
Evaluate its DFT Xn.
Solution (contd.)
Solution 2
j
j
Here N = 4. Hence WN1 W41 e 4
e 2
nk
1 3 1 3 j
Therefore, x k X nW4 nk X n e 2
4 n 0 4 n 0
For k = 0,
1 3 1
4 n 0
j0
4
x 0 X n e X 0 e j 0 X 1e j 0 X 2 e j 0 X 3 e j 0
1
X 0 X 1 X 2 X 3
4
1
10 2 j 2 2 2 j 2 1
4
DFT and IDFT
Problem 3
Using the DFT coefficients Xn, for n = 0,1,2,3, computed in the previous problem,
evaluate its inverse DFT to determine the time domain sequence xk.
Solution (contd.) 2
j
j
1 1 4 2
Here N = 4. Hence WN W4 e e
nk
1 3 1 3 j
Therefore, x k X nW4 nk X n e 2
4 n 0 4 n 0
For k = 1,
n 3
1 3 j 1 j j
x1 X n e 2 X 0 e j 0 X 1e 2 X 2 e j X 3 e 2
4 n 0 4
1
X 0 jX 1 X 2 jX 3
4
1
10 j 2 j 2 2 j 2 j 2 2
4
DFT and IDFT
Problem 3
Using the DFT coefficients Xn, for n = 0,1,2,3, computed in the previous problem,
evaluate its inverse DFT to determine the time domain sequence xk.
Solution (contd.) 2
j
j
1 1 4 2
Here N = 4. Hence WN W4 e e
nk
1 3 1 3 j
Therefore, x k X nW4 nk X n e 2
4 n 0 4 n 0
For k = 2,
1 3 1
x 2 X n e jn X 0 e j 0 X 1e j X 2 e j 2 X 3 e j 3
4 n0 4
1
X 0 X 1 X 2 X 3
4
1
10 2 j 2 2 2 j 2 3
4
DFT and IDFT
Problem 3
Using the DFT coefficients Xn, for n = 0,1,2,3, computed in the previous problem,
evaluate its inverse DFT to determine the time domain sequence xk.
Solution (contd.) 2
j
j
1 1 4 2
Here N = 4. Hence WN W4 e e
nk
1 3 1 3 j
Therefore, x k X nW4 nk X n e 2
4 n 0 4 n 0
For k = 3,
3 n 3 9
1 3 j 1 j j
x3 X n e 2 X 0 e j 0 X 1e 2 X 2 e j 3 X 3 e 2
4 n 0 4
1
X 0 jX 1 X 2 jX 3
4
1
10 j 2 j 2 2 j 2 j 2 4
4
DFT and IDFT
Problem 3
Using the DFT coefficients Xn, for n = 0,1,2,3, computed in the previous problem,
evaluate its inverse DFT to determine the time domain sequence xk.
Solution (contd.)
This result can be verified in MATLAB as:
Important Properties of DFT
Periodicity
N 1
Then,
X n pN x k W N n pN k
for p 0 , 1, 2 , ….
k 0
N 1
x k W Nnk , as W NpNk W NN pk 1
k 0
X n
Thus Xn is periodic with a period N, i.e. the pNth harmonic or at the p times
sampling frequency, the DFT repeats.
Important Properties of DFT
Linearity
DFT DFT
If x1k X 1n and x 2 k X 2 n
N N
DFT ….
a1 x1k a 2 x 2 k a1 X 1n a 2 X 2 n
N
This property follows immediately from the definition of DFT given in (19).
Important Properties of DFT
Circular symmetries of a sequence
Let us assume that the periodic sequence xpk is shifted by m units to the right. Thus
we obtain another periodic sequence, given as:
x pk x p k m x
l
k m lN …….(21b)
x k xk 2 4
This implies that
x0 x 2 4 x 2
x1 x1 4 x3
x 2 x0 4 x0
x3 x14 x1
Hence x k is simply xk shifted circularly by two units in time, where counterclockwise
direction has been arbitrarily selected as the positive direction.
Important Properties of DFT
Circular symmetries of a sequence
Hence we can conclude that a circular shift of an N-point sequence is equivalent
to a linear shift of its periodic extension, and vice versa.
The inherent periodicity resulting from the arrangement of the N-point sequence on
the circumference of a circle dictates a different definition of even and odd symmetry,
and time reversal of a sequence.
x N k xk 1 k N 1 …….(21e)
x N k xk 1 k N 1 …….(21f)
An equivalent definition of even and odd sequences for the associated periodic
sequence xpk is given as:
even : x pk x p k x p N k
odd : x pk x p k x p N k …….(21h)
conjugate even : x pk x *p N k
conjugate odd : x pk x *p N k …….(21i)
Important Properties of DFT
Circular symmetries of a sequence
x pk x pe k x po k …….(21j)
where
1
x pe k x pk x *p N k
2
1
x po k x pk x *p N k
2
…….(21k)
Important Properties of DFT
Symmetry
Then, N 1
X pN n xW
k 0
k N
pN n k
for p 0 , 1, 2 , ….
N 1
x k W N nk , as W NpNk W NN pk 1
k 0
If these two DFTs are multiplied together, the resultant will be a DFT X3n
of a sequence x3k of length N.
Now our objective is to determine the relationship between x3k and sequences x1k and x2k .
Now, we have:
X 3 n X 1n X 2 n n 0,1, , N 1 …….(22c)
l 0
1 N 1 N 1 N 1 j 2n Nm k l
N
x1k x 2 l e …….(22e)
k 0 l 0 n0
N 1 N, a 1
n N
a 1 a
n 0 1 a , a 1 …….(22f)
N 1
n N , l m k pN m k N
a …….(22h)
n 0 0, otherwise
If we substitute this result in (22e), we obtain the desired expression of x3m as:
N 1
x3 m x1k x 2 m k N , m 0,1, , N 1 …….(22i)
k 0
However it is not the ordinary linear convolution. Instead, the convolution sum in (22i)
Involves the index (m-k)N and is called circular convolution.
DFT DFT
If x1k X 1n and x 2 k X 2 n
N N
then
x1k N x 2 k
DFT
X 1n X 2 n
N
where x1k N x 2 k denotes the circular convolution of the sequences x1k and x2k.
Computation of DFT
From relation (19),
N 1 2
j
X n x kW Nnk , for n = 0,1,2,…, N-1, where WN e N
k 0
X0 x0
X x
1 1
Here, Xn , X k
X N1 xN 1
W N0 W N0 … W N0
0 N 1
W N W N1 … WN
and W nk
N W N0 W N2 … W N2 N 1
…
…
W 0 W N N 1 … W N N 1 N 1
N
Computation of DFT
X n W Nnk X k …….(23)
k 0 N
k
2
N N
1 1 N
2 2 n k
xkWNnk x NW N
2
k 0 k k 0
2
N N
1 nN 1
2 2
xkWNnk W x NWNnk N
2
k 0 k k 0
2
Fast Fourier Transform (FFT)
N N
1 nN 1
2 2
or Xn xkWNnk W x NWNnk N
2
k 0 k k 0
2
nN 2 N
jn
1
N 2 jn n
Now, W e2
e
N
N
1
2
X n xkWNnk 1 x N WNnk
n
Then,
k 0 k
2
N
1
2
nk
X n xk 1 x N WN
n
or …….(24)
k 0
2
k
Fast Fourier Transform (FFT)
N
1
2
nk
X n xk 1 x N WN
n
or …….(24)
k 0
2
k
as WN2 pk W Npk
2
Fast Fourier Transform (FFT)
N
1
2
pk
Now, X2p xk xk N W N
k 0
2 2
N
1
2
k 2 pk
xk x N WN WN
k 0
2
k
N
1
2
k pk
xk x N WN WN as WN2 pk WNpk
k 0
k
2 2 2
Let, gk/ xk x N WNk for k = 0,1,2,…,(N/2-1)
k
2
Fast Fourier Transform (FFT)
N
1
2
Then, X 2 p 1 g k/ W Npk …….(26)
k 0
2
Then for p 0,
1 1
0
X 0 g kW2 gk g0 g1 …….(28)
k 0 k 0
and for p 1,
1
X 2 g kW2k g 0W20 g 1W21
k 0
g 0 1g 1 g 0 g1 …….(29)
4-point FFT
N
1
2
Now from relation (26), X 2 p 1 g k/W Npk …….(26)
k 0
2
N
1
2
X 2 p1 g k/WNpk , for p = 0,1,2,…,(N/2-1)
k 0
2
/ k
where g k xk x N WN , for k = 0,1,2,…,(N/2-1)
k
2
1
or, X 2 p1 g k/W2 pk , for p 0,1
k 0
Then for p 0,
1
X 1 g k/W20 g 0/ g1/ …….(31)
k 0
and for p 1,
1
X 3 gk/W2k g0/ g1/W21
k 0
g0 x0 x2
g1 x1 x3
g 0/ x0 x2 W40 x0 x2 x0 x2W42
X 0 g 0 g1
X 2 g 0 g1
X 1 g 0/ g1/
X 3 g 0/ g1/
Then in matrix form,
X 0 1 1 0 0 g0
X 1 1 0 0 g1
2 …….(34)
X 1 0 0 1 1 g 0/
X 3 0 0 1 1 g 1/
4-point FFT
From relations (33) and (34),
g 0 1 0 1 0 x0 Time
g 0 1 0 1 x1
history
1
g 0/ 1 0 W 42 0 x2
/ 1
g
1 0 W 4
0 W 43 x 3
Frequency X 0 1 1 0 0 g0
X 1 1 0 0 g1
2
X 1 0 0 1 1 g 0/
X 3 0 0 1 1 g 1/
Bit reversed order
4-point FFT
Frequency X 0 1 1 0 0 g0
X 1 1 0 0 g1
2
X 1 0 0 1 1 g 0/
X 3 0 0 1 1 g 1/
Bit reversed order
since,
X 0 X 00
X 2 X10
in terms of binary bits
X1 X 01
X 3 X11
Signal Flow Graph for N = 4
From relations (33) and (34),
g 0 1 0 1 0 x0 X 0 1 1 0 0 g0
g 0 1 0 1 x1 X 1 1 0 0 g1
1
2
/ 2
g 0 1 0 W4 0 x2 X 1 0 0 1 1 g 0/
/ 1
g1 0 W4 0 W43 x3 X 3 0 0 1 1 g 1/
x1 g1 x1 g1
j w43
computation w42 w40
w41 butterfly -1 1
x3 g1/
x3 g1/ -j w41
w43 = - w41
Signal Flow Graph for N = 4
x1 g1 x1 g1 j w43
w42 w40
w41 -1 1
w4 1
x3 g1/ g 1/ -j w41
x3
w43 = - w41
-1
This involves two complex additions and one complex multiplication.
This is true for all butterflies.
Signal Flow Graph for N = 4
A A A
T A B
Butterfly A A B
B B
B T B T W
-1
The above algorithm for the computation of FFT of sequence xk, k = 0,1,2,….,(N-1)
may be called radix-2 decimation-in-frequency in-place FFT algorithm.
Here, N should be a power of 2.
DFT FFT
N complex complex complex complex
additions multiplications additions multiplications
4 16 16 8 4
8 64 64 24 12
16 256 256 64 32
32 1024 1024 160 80
8-point FFT
Relations (25) and (26) may be split further (i.e. decimated) into N/2-point
DFTs as follows:
N
1
2
X 2 p gkWNpk …….(25)
k 0 2
N
1
2
X 2 p1 gk/WNpk …….(26)
k 0 2
8-point FFT
Relations (25) and (26) may be split further (i.e. decimated) into N/2-point
DFTs as follows:
N
1
In relation (25), splitting N/2-point sequence 2
X 2 p gkWNpk …….(25)
g k into two N/4-point sequences, k 0 2
N N
1 1
4 2
X 2 p g kW Npk g kW Npk
k 0 N
2 k 2
4
N N
1 1 N
4 4 p k
g kW Npk g N W N
4
k 0 k
k 0
2 4 2
N N
1 1 pN
4 4
g kW Npk g N W Npk W N
4
k 0 k
k 0
2 4 2 2
8-point FFT
N N
1 1 pN
4 4
Now, X 2 p g kW Npk g N W pk
N W N
4
k
k 0 2 k 0 4 2 2
pN
p
Here, W N
4
1
2
N
1
4
g k 1 g N W Npk
p
Therefore, X 2p …….(35)
k 0
4
k
2
N
1
4
g k g N W N2 kW Nrk
k 0
4
k
4
/ 2k
Let h g k g N
k
WN ,
for k = 0,1,2,…,(N/4-1)
k
4
N
1
4
Then, X 4 r 2 hk/W Nrk , for r = 0,1,2,…,(N/4-1) …….(37)
k 0
4
/ / / 2k
lk g k g N WN , for k = 0,1,2,…,(N/4-1)
k
4
8-point FFT
N
Let N = 8 (= 23) for 8-point FFT. 2
1
X 2 p gkWNpk …….(25)
k 0 2
In relation (25),
g k xk x N , for k = 0,1,2,…,(N/2-1)
k
2
Then, g0 x0 x 4
g1 x1 x5
…….(40)
g2 x 2 x6
g3 x3 x7
8-point FFT
N
1
2
X 2 p 1 g k/ WNpk …….(26)
Now in relation (26), k 0 2
/ k
gk xk x N WN , for k = 0,1,2,…,(N/2-1)
k
2
Then, g 0/ x0 x4 W80
g 1/ x1 x5 W81
…….(41)
2
g 2 x2 x6 W8
/
g 3/ x3 x7 W83
8-point FFT
g0 x0 x4 g 0/ x 0
x 4 W 8
0
x 5 g 1/ x x 5 W 1
g1 x1 1 8 …….(41)
…….(40)
g2 x2 x6 g /
2
x 2
x 6 W 8
2
g3 x3 x 7 g /
3
x 3
x 7 W 8
3
From relations (40) and (41), signal flow graph for computations of
g03 and g0/ 3 may be represented as:
8-point FFT
Now from relation (36),
hk gk g N , for k = 0,1,2,…,(N/4-1)
k
4
Then, h0 g 0 g 2
…….(42)
h1 g1 g3
8-point FFT
And from relation (37),
/ 2k
hk g k g N WN , for k = 0,1,2,…,(N/4-1)
k
4
/ / / 2k , for k = 0,1,2,…,(N/4-1)
lk gk g N WN
k
4
Then,
l 0/ g 0/ g 2/ W 8 0 …….(45)
2
l1 g 1 g 3 W 8
/ / /
8-point FFT
h0 g 0 g 2 h0/ g 0 g 2 W80 l0 g 0/ g 2/ l 0/ g 0/ g 2/ W 80
…….(42) …….(43) …….(44) …….(45)
h1 g 1 g 3 h1/ g1 g 3 W82 l1 g 1/ g 3/ l1/ g 1/ g 3/ W 8 2
From relations (42), (43), (44) and (45), signal flow graph for computation of
/ /
h01 , h01 , l 0 1
and l 0 1
may be represented as:
8-point FFT
Now, from relation (36), N
4
1
Then,
X 0 h0W 20 h1W 20 h0 h1
…….(46)
0 1
X 4 h0W 2 h1W 2 h0 h1
And, from relation (37), N
4
1
Then,
Then,
X 1 l0W20 l1W20 l0 l1
…….(48)
0 1
X 5 l0W2 l1W2 l0 l1
And, from relation (39), N
4
1
Then,
Time Frequency
history
FORTRAN subroutine to compute radix-2 FFT
C ***Subroutine to compute radix-2 FFT***
C Decimation-in-frequency in-place algorithm
SUBROUTINE FFT(A,N,INV)
C N: Dimension of Array (must be a power of 2)
C A: Complex array containing data sequence
C DFT coefficients are returned in the array
C INV = 0 for forward FFT
C INV = 1 for inverse FFT
DIMENSION A(N)
COMPLEX T,W,A
IF (INV.EQ.0) GO TO 8
C Divide sequence by N for inverse FFT
DO 7 I=1,N
7 A(I)=A(I)/CMPLX(FLOAT(N),0.0)
8 S=-1.0
IF (INV.EQ.1) S=1.0
FORTRAN subroutine to compute radix-2 FFT
C Calculate number of iterations
C M: Number of iterations (log(N) to the base 2)
M=1
K=N
2 K=K/2
IF (K.EQ.1) GO TO 1
M=M+1
GO TO 2
C Compute for each iteration
C NP: Number of points in each partition
1 NB=N
DO 3 I=1,M
NP=NB
NB=NP/2
PHI=3.14159265/FLOAT(NB)
FORTRAN subroutine to compute radix-2 FFT
C Compute for each iteration
C NP: Number of points in each partition
1 NB=N
DO 3 I=1,M
NP=NB
NB=NP/2
PHI=3.14159265/FLOAT(NB)
C Calculate the twiddle factor W for each butterfly
C NB: Number of butterflies for each partition
DO 3 J=1,NB
ARG=FLOAT(J-1)*PHI
W=CMPLX(COS(ARG),S*SIN(ARG)) Nested DO loop
C Compute butterfly for each partition
DO 3 K=NP,N,NP
J1=K-NP+J
J2=J1+NB
T=A(J1)-A(J2)
A(J1)=A(J1)+A(J2)
A(J2)=T*W
3 CONTINUE
FORTRAN subroutine to compute radix-2 FFT
C Bit reversal operation
N2=N/2
N1=N-1
J=1
DO 4 I=1,N1
IF (I.GE.J) GO TO 5
T=A(J)
A(J)=A(I)
A(I)=T
5 K=N2
6 IF (K.GE.J) GO TO 4
J=J-K
K=K/2
GO TO 6
4 J=J+K
RETURN
END
During the bit-reversal operation, N/2 DFT coefficients remain unchanged and
the remaining N/2 coefficients are exchanged in place as required.
Applications of FFT
Computation of amplitude spectrum of a finite real data sequence
(N must be a
power of 2)
1
C0 X0 , the average value
N
2
and Cn X n , for n = 1,2,…,(N/2-1), the nth harmonic amplitude.
N
Applications of FFT
Computation of amplitude spectrum of a finite real data sequence
DO 15 I=1,10
IF(N-2**I)24,25,15
15 CONTINUE
24 WRITE(*,5)
5 FORMAT(1X,'Incorrect size - it must be a power of 2')
STOP
25 DO 30 I=1,N
30 A(I)=CMPLX(B(I),0.0)/CMPLX(FLOAT(N),0.0)
WRITE(*,300)
300 FORMAT(1X,'FFT analysis in progress')
CALL FFT(A,N,0)
Applications of FFT
FORTRAN program for computation of amplitude spectrum
NA=N/2
C(1)=CABS(A(1))
DO 40 I=2,NA
40 C(I)=CABS(A(I))*2.0
D=180.0/3.141592654
DO 80 I=2,NA
R=REAL(A(I))
X=AIMAG(A(I))
ALPHA=ATAN2(X,R)
80 PHASE(I)=D*ALPHA
Applications of FFT
FORTRAN program for computation of amplitude spectrum
WRITE(*,60)
60 FORMAT('0','Harmonic no.',7X,'Amplitude',12X,'Phase (deg)')
WRITE(*,70)
70 FORMAT(1X,'------------',7X,'---------',12X,'-----------'//)
NB=0
WRITE(*,75)NB,C(1)
75 FORMAT(5X,I3,9X,1P,E13.6)
DO 85 I=2,NA
NB=I-1
85 WRITE(*,90)NB,C(I),PHASE(I)
90 FORMAT(5X,I3,9X,1P,E13.6,9X,E13.6)
END
Applications of FFT
FFT-based digital filtering of a finite real data sequence
convolution
xk Digital yk
input output
sequence Filter sequence
xk Digital yk
yk = hk * xk
input output
sequence Filter sequence
multiplication
FFT IFFT
xk Xn Hn Yn yk
FFT IF F T
xk Xn H Yn yk
n Yn = Hn . Xn
N -p oin t R eal C om p u te
d ata seq u en ce F orm N -p oin t Xn
com p lex N - p oin t
x k , k= 0, 1, … ,
array
(N -1) FFT
ou tp u t
inp u t C om p u te
Yn seq u en ce
seq u en ce m ultip lier N - p oin t y k,
k= 0, 1,… ,
IF F T
(N -1)
((N /2)+1)-p oin t F orm com p lex
array (H n ) of
gain an d p h ase len gth N u sin g
ch aracteristic com p lex Hn
con ju gates
Hn Hn
OPEN(1,FILE=FNAME1)
READ(1,*,END=50)(X(I),I=1,1024)
GOTO 60
50 I=I-1
60 N=I
WRITE(*,70)N
70 FORMAT(1X,'Data points = ',I4)
DO 375 I=1,10
IF(N-2**I)380,390,375
375 CONTINUE
380 WRITE(*,400)
400 FORMAT(1X,'Incorrect size of data')
STOP
Applications of FFT
FORTRAN program for FFT-based digital filtering
390 WRITE(*,100)N/2+1
100 FORMAT(1X,'Enter filter gain (',I3,' points)')
READ(*,*)(A(I),I=1,N/2+1)
PH(1)=0.0
WRITE(*,110)N/2
110 FORMAT(1X,'Enter filter phase (',I3,' points)')
READ(*,*)(PH(I),I=2,N/2+1)
C Form complex filter gain array
H(1)=CMPLX(A(1)*N,0.0)
DO 200 I=2,N/2+1
200 H(I)=CMPLX(A(I)*N*COS(PH(I))/2.0,A(I)*N*SIN(PH(I))/2.0)
H n
N /2 n
Applications of FFT
FORTRAN program for FFT-based digital filtering
390 WRITE(*,100)N/2+1
100 FORMAT(1X,'Enter filter gain (',I3,' points)')
READ(*,*)(A(I),I=1,N/2+1)
PH(1)=0.0
WRITE(*,110)N/2
110 FORMAT(1X,'Enter filter phase (',I3,' points)')
READ(*,*)(PH(I),I=2,N/2+1)
C Form complex filter gain array
H(1)=CMPLX(A(1)*N,0.0)
DO 200 I=2,N/2+1
200 H(I)=CMPLX(A(I)*N*COS(PH(I))/2.0,A(I)*N*SIN(PH(I))/2.0)
C Form rest of the gain array by complex conjugate
DO 340 I=2,N/2
J=N+2-I
340 H(J)=CONJG(H(I))
H n
N /2 N -1 n
Applications of FFT
FORTRAN program for FFT-based digital filtering
Multiplication
FFT IFFT
xk Xn Hn Yn yk
Applications of FFT
FORTRAN program for FFT-based digital filtering
C Save output
IF(FNAME1.EQ.FNAME2)CLOSE(1)
OPEN(2,FILE=FNAME2,STATUS='NEW')
WRITE(2,*)(X(I),I=1,N)
END