DFT & FFT Computation. Why DFT ? The two reasons : – It allows us to determine the frequency...

32
DFT & FFT Computation

Transcript of DFT & FFT Computation. Why DFT ? The two reasons : – It allows us to determine the frequency...

Page 1: DFT & FFT Computation. Why DFT ? The two reasons : – It allows us to determine the frequency content of a signal (Spectral Analysis) – Perform frequency.

DFT & FFT Computation

Page 2: DFT & FFT Computation. Why DFT ? The two reasons : – It allows us to determine the frequency content of a signal (Spectral Analysis) – Perform frequency.

Why DFT ?

The two reasons :

– It allows us to determine the frequency content of a signal (Spectral Analysis)

– Perform frequency analysis on a digital computer.

Page 3: DFT & FFT Computation. Why DFT ? The two reasons : – It allows us to determine the frequency content of a signal (Spectral Analysis) – Perform frequency.

Fourier Transform Vs Discrete Fourier Transform :

Fourier Transform – Continuous function of ω and so cannot be processed by digital system.

DFT – Converts the continuous function of ω to a discrete function of ω

DFT – obtained by sampling one period of the Fourier Transform X(ω) at a finite number of frequency points.

Sampling – performed at N equally spaced points in the period 0 < ω < 2 π

(or) at ωk = 2 π k / N; 0 < k < N – 1.

Page 4: DFT & FFT Computation. Why DFT ? The two reasons : – It allows us to determine the frequency content of a signal (Spectral Analysis) – Perform frequency.

Discrete Fourier Transform :

The Discrete Fourier Transform (DFT) converts time domain data to frequency domain data.

where the Twiddle Factor is

The Inverse DFT (IDFT) coverts frequency domain data to the time domain

The DFT/IDFT requires N2 complex multiplies and N(N-1) complex additions

1,1,0)()()(1

0

1

0

2

NkWnxenxkX

N

n

nkN

N

n

N

knj

1

0

1

0

2

1,1,0)(1

)(1

)(N

n

nkN

N

n

N

nkj

NnWkXN

ekXN

nx

)2

sin()2

cos(2

N

knj

N

kneW N

knj

nkN

Page 5: DFT & FFT Computation. Why DFT ? The two reasons : – It allows us to determine the frequency content of a signal (Spectral Analysis) – Perform frequency.

Problem :

Compute 4 – point DFT of casual three sample sequence given by

x[n] = 1/3 ; 0 < n < 2

= 0; else.

Solution : |X(k)| = {1, 1/3, 1/3, 1/3}

Angle of X(k) = {0, -П/2, 0, П/2}

Page 6: DFT & FFT Computation. Why DFT ? The two reasons : – It allows us to determine the frequency content of a signal (Spectral Analysis) – Perform frequency.

Properties of DFT :

Linearity :

If DFT{x1[n]} = X1(k) and DFT{x2[n]} = X2(k) Then DFT{ax1[n] + bx2[n]} = a X1(k) + b X2(k)

Periodicity :

If x[n] and x(k) are an N point DFT pair, then

x[n + N] = x[n]; for all N

X(k + N) = X(k); for all N

Page 7: DFT & FFT Computation. Why DFT ? The two reasons : – It allows us to determine the frequency content of a signal (Spectral Analysis) – Perform frequency.

Properties of DFT :

Time Reversal :

If DFT{x[n]} = X(k)

Then DFT{x[N - n]} = X(N - k)

Shifting :

If DFT{x[n]} = X(k)

Then DFT{x[n – n0]} = X(k) e-j2Пkn0

/N.

Page 8: DFT & FFT Computation. Why DFT ? The two reasons : – It allows us to determine the frequency content of a signal (Spectral Analysis) – Perform frequency.

Properties of DFT :

Circular convolution :

If DFT{x1[n]} = X1(k) and DFT{x2[n]} = X2(k)

Then DFT{x1[n] x1[n]} = X1(k) X2(k)

Multiplication of two sequence :

If DFT{x1[n] x x2[n]} = 1/N {X1(k) X2(k)}

(Dual of Circular convolution)

*

*

Page 9: DFT & FFT Computation. Why DFT ? The two reasons : – It allows us to determine the frequency content of a signal (Spectral Analysis) – Perform frequency.

Relation between DFT with Z and Fourier Transform:

Z transform of x[n] is

Relation : X(k) = X(z) | z = ej2Пk/N

Fourier Transform of x[n] is

Relation : X(k) = X(ω) | ω = 2Пk/N

n

nznxzX )()(

n

njj enxeX ][)(

Page 10: DFT & FFT Computation. Why DFT ? The two reasons : – It allows us to determine the frequency content of a signal (Spectral Analysis) – Perform frequency.

Divide and Conquer

Page 11: DFT & FFT Computation. Why DFT ? The two reasons : – It allows us to determine the frequency content of a signal (Spectral Analysis) – Perform frequency.

Divide and Conquer

Page 12: DFT & FFT Computation. Why DFT ? The two reasons : – It allows us to determine the frequency content of a signal (Spectral Analysis) – Perform frequency.

Fast Fourier Transform (FFT):

It is a method (or algorithm) for computing the DFT with reduced number of calculations.

The computational efficiency is achieved – divide and conquer approach.

In an N point sequence, N = rm, where r – radix.

For radix – 2 FFT, N = 2m, for radix – 4 FFT, N = 4m and so on…

Page 13: DFT & FFT Computation. Why DFT ? The two reasons : – It allows us to determine the frequency content of a signal (Spectral Analysis) – Perform frequency.

Fast Fourier Transform (FFT):

In radix – 2 FFT, the N point sequence is decimated into 2 point sequence – 2 point DFT is computed.

From the result of 2 point DFTs – 4 point DFTs can be computed.

From the result of 4 point DFTs – 8 point DFTs can be computed and so on until we get N point DFT.

For N point sequence (DFT : FFT) :

Total number of addition – N(N-1) : N log2N.

Total number of multiplication – N2 : (N/2) log2N.

Page 14: DFT & FFT Computation. Why DFT ? The two reasons : – It allows us to determine the frequency content of a signal (Spectral Analysis) – Perform frequency.

Comparison of number of computation in direct DFT and FFT:

Number of

points N

Direct computation Radix – 2 FFT

Complex additions

N(N – 1)

Complex Multiplication

N2

Complex additions

Nlog2N

Complex Multiplication

(N/2)log2N

4

8

16

32

64

128

12

56

240

992

4032

16,256

16

64

256

1,024

4,096

16,384

8

24

64

160

384

896

4

12

32

80

192

448

Page 15: DFT & FFT Computation. Why DFT ? The two reasons : – It allows us to determine the frequency content of a signal (Spectral Analysis) – Perform frequency.

The decimation-in-frequency (DIF) FFT algorithm

Introduction: Decimation in frequency is an alternate way of developing the FFT algorithm

It is different from decimation in time in its development, although it leads to a very similar structure

Page 16: DFT & FFT Computation. Why DFT ? The two reasons : – It allows us to determine the frequency content of a signal (Spectral Analysis) – Perform frequency.

The decimation in frequency FFT (continued)

Consider the original DFT equation ….

Separate the first half and the second half of time samples:

X[k] n0

N 1

x[n]WNnk

X[k] n0

(N / 2) 1

x[n]WNnk

nN / 2

N 1

x[n]WNnk

n0

(N / 2) 1

x[n]WNnk WN

(N / 2)k

n0

(N / 2) 1

x[n (N / 2)]WNnk

n0

(N / 2) 1

x[n] ( 1)k x[n (N / 2)] WNnk

Page 17: DFT & FFT Computation. Why DFT ? The two reasons : – It allows us to determine the frequency content of a signal (Spectral Analysis) – Perform frequency.

Continuing with decimation in frequency ...

For k even, let

For k odd, let

These expressions are the N/2-point DFTs of

X[k] n0

(N / 2) 1

x[n] ( 1)k x[n (N / 2)] WNnkk 2r

X[k] n0

(N / 2) 1

x[n] ( 1)2r x[n (N / 2)] WNn2r n0

(N / 2) 1

x[n] x[n (N / 2)] WN /2nr

k 2r 1

X[k] n0

(N / 2) 1

x[n] ( 1)2r ( 1)x[n (N / 2)] WNn(2r1)

n0

(N / 2) 1

x[n] x[n (N / 2)] WNnWN / 2

nr

x[n] x[n (N / 2)] and [x[n] x[n (N / 2)]]WNn

Page 18: DFT & FFT Computation. Why DFT ? The two reasons : – It allows us to determine the frequency content of a signal (Spectral Analysis) – Perform frequency.

These equations describe the following structure:

Page 19: DFT & FFT Computation. Why DFT ? The two reasons : – It allows us to determine the frequency content of a signal (Spectral Analysis) – Perform frequency.

Continuing by decomposing the odd and even output points we obtain …

Page 20: DFT & FFT Computation. Why DFT ? The two reasons : – It allows us to determine the frequency content of a signal (Spectral Analysis) – Perform frequency.

… and replacing the N/4-point DFTs by butterflys we obtain

Page 21: DFT & FFT Computation. Why DFT ? The two reasons : – It allows us to determine the frequency content of a signal (Spectral Analysis) – Perform frequency.

The DIF FFT is the transpose of the DIT FFT

To obtain flowgraph transposes:

– Reverse direction of flowgraph arrows

– Interchange input(s) and output(s)

DIT butterfly: DIF butterfly:

Comment:

– We will revisit transposed forms again in our discussion of filter implementation

Page 22: DFT & FFT Computation. Why DFT ? The two reasons : – It allows us to determine the frequency content of a signal (Spectral Analysis) – Perform frequency.

The DIF FFT is the transpose of the DIT FFT

Comparing DIT and DIF structures:

DIT FFT structure: DIF FFT structure:

Alternate forms for DIF FFTs are similar to those of DIT FFTs

Page 23: DFT & FFT Computation. Why DFT ? The two reasons : – It allows us to determine the frequency content of a signal (Spectral Analysis) – Perform frequency.

Comparison of DIT and DIF:

Difference between DIT and DIF:

– In DIT, the input is bit–reversed while the output is in natural order. For DIF, the reverse is time, i.e., input is normal order, while output is bit–reversed. However, both DIT and DIF can go from the normal to shuffled data or vice–versa.

– Considering the butterfly diagram, in DIF, the complex multiplication takes place after the add–subtract operation.

Similarities:

– Both algorithm requires same number of operations to compute DFT.

– Both algorithms require bit–reversed at same place during computation.

Page 24: DFT & FFT Computation. Why DFT ? The two reasons : – It allows us to determine the frequency content of a signal (Spectral Analysis) – Perform frequency.

Computation of IDFT through FFT:

Take conjugate of X(k) [say X*(k)].

Compute the N–point DFT of X*(k) using radix–2 FFT.

Take conjugate of the output sequence of FFT.

Divide the sequence obtained in step–3 by N. the resultant sequence is x[n].

Note : Thus a single FFT algorithm serves the evaluation of both direct and inverse DFTs.

Page 25: DFT & FFT Computation. Why DFT ? The two reasons : – It allows us to determine the frequency content of a signal (Spectral Analysis) – Perform frequency.

Problem:

In an LTI system the input x[n] = { 1, 1, 1 } and the impulse response h[n] = { -1, -1 }. Determine the response of LTI system by radix–2 DIT and DIF FFT.

Solution : y[n] = { -1, -2, -2, -1 }.

Page 26: DFT & FFT Computation. Why DFT ? The two reasons : – It allows us to determine the frequency content of a signal (Spectral Analysis) – Perform frequency.

Convolution:

The output or response of an LTI system is given by

X[n] – N1 samples.

h[n] – N2 samples.

Y[n] – N1 + N2 – 1 samples.

kknhkxny ][][][

Page 27: DFT & FFT Computation. Why DFT ? The two reasons : – It allows us to determine the frequency content of a signal (Spectral Analysis) – Perform frequency.

Sectioned convolution :

If one of the sequence (either the input sequence or impulse response sequence) is very much larger than the other, then it is very difficult to compute the linear convolution using DFT for the following reasons :

– The entire sequence should be available before convolution can be carried out. This makes long delay in getting the output.

– Large amounts of money is required to store the sequence.

The larger sequence is sectioned into size of the smaller sequence.

Linear convolution of each section of longer sequence and the smaller sequence is performed.

The output sequence obtained from the convolutions of all the section are combined to get the overall output sequence.

Page 28: DFT & FFT Computation. Why DFT ? The two reasons : – It allows us to determine the frequency content of a signal (Spectral Analysis) – Perform frequency.

Overall add method:

Let N1 – length of longer sequence, N2 – length of smaller sequence.

The longer sequence be divided into sections of size N3 (same as N2) samples.

The linear convolution of each divided section with smaller sequence will produce an output sequence of size N3+N2 -1.

The last N2 - 1 samples of each output sequence overlaps with the first N2 – 1 samples of next section

While combining the output sequences of the various sectioned convolutions, the corresponding samples of overlapped regions are added and the samples of non – overlapped regions are retained as such.

Page 29: DFT & FFT Computation. Why DFT ? The two reasons : – It allows us to determine the frequency content of a signal (Spectral Analysis) – Perform frequency.

Overall add method:

Page 30: DFT & FFT Computation. Why DFT ? The two reasons : – It allows us to determine the frequency content of a signal (Spectral Analysis) – Perform frequency.

Overall save method:

Let N1 – length of longer sequence, N2 – length of smaller sequence.

The longer sequence be divided into sections of size N3 (same as N2) samples.

The smaller and the sectioned longer sequence (N3) are converted into the size of the output sequence (N3 + N2 – 1) by appending with zeros.

The convolution between N2 with the sections of N3 is carried by means circular convolution.

Page 31: DFT & FFT Computation. Why DFT ? The two reasons : – It allows us to determine the frequency content of a signal (Spectral Analysis) – Perform frequency.

Overall save method:

Page 32: DFT & FFT Computation. Why DFT ? The two reasons : – It allows us to determine the frequency content of a signal (Spectral Analysis) – Perform frequency.

Problem:

Perform the linear convolution of the following sequence by (i) overlap add method and (ii) overlap save method.

x[n] = {1, -1, 2, -2, 3, -3} and h[n] = {-1, 1}.

Also sketch the output sequence.

Solution : (i) y[n] = {-1, 2, -3, 4, -5, 6, -7, 8, -4}

(ii) y[n] = { *, 2, -3, 4, -5, 6, -7, 8, -4}

y[n] = {-1, 2, -3, 4, -5, 6, -7, 8, -4, *}