8.1 Introduction 8.2 Goertzel Algorithm 8.3 Fast Fourier Transform (FFT) 8.4 Inverse FFT (IFFT)

31
1 8.1 Introduction 8.2 Goertzel Algorithm 8.3 Fast Fourier Transform (FFT) 8.4 Inverse FFT (IFFT) 8.5 Signal Analysis using DFT Chapter 8 Fast Fourier Transform (FFT) Section 9.1-9.4, 10.1

description

Chapter 8 Fast Fourier Transform (FFT) Section 9.1-9.4, 10.1. 8.1 Introduction 8.2 Goertzel Algorithm 8.3 Fast Fourier Transform (FFT) 8.4 Inverse FFT (IFFT) 8.5 Signal Analysis using DFT. 8.1.1 DFT Expression. Consider how complicated this is when x [ n ] is complex. - PowerPoint PPT Presentation

Transcript of 8.1 Introduction 8.2 Goertzel Algorithm 8.3 Fast Fourier Transform (FFT) 8.4 Inverse FFT (IFFT)

Page 1: 8.1 Introduction 8.2 Goertzel Algorithm 8.3 Fast Fourier Transform (FFT)  8.4 Inverse FFT (IFFT)

1

• 8.1 Introduction

• 8.2 Goertzel Algorithm

• 8.3 Fast Fourier Transform (FFT)

• 8.4 Inverse FFT (IFFT)

• 8.5 Signal Analysis using DFT

Chapter 8 Fast Fourier Transform (FFT)

Section 9.1-9.4, 10.1

Page 2: 8.1 Introduction 8.2 Goertzel Algorithm 8.3 Fast Fourier Transform (FFT)  8.4 Inverse FFT (IFFT)

2

• Consider how complicated this is when x[n] is complex.

• Represent x[n]=Re{x[n]}+j Im{x[n]}.

• We have the expression:

8.1.1 DFT Expression

)Re(])[Im()Im(])[Re(

)Im(])[Im()Re(])[Re(][1

0

knN

knN

N

n

knN

knN

WnxWnxj

WnxWnxkX

1

0

][][N

n

knNWnxkX N

j

N

N

k

knN

N

n

knN

eW

NnWkXN

nx

NkWnxkX

2

1

0

1

0

)10(][1

][

)10(][][

Page 3: 8.1 Introduction 8.2 Goertzel Algorithm 8.3 Fast Fourier Transform (FFT)  8.4 Inverse FFT (IFFT)

3

• For each K we have 4N real multiplications, 4N-2 real adds.

• For all N of X[k] we have

– N(4N) = 4N2 real multiplication

– N(4N-2) = 4N2 -2N real adds

• Example. N=1000

– # multiplications = 4,000,000 !

– # additions 4,000,000

• The computational complexity is O(N2). As N increase, the order becomes huge!

• Storage Requirements (memory): x[n] -N values (complex), WN - N values (complex), which can be reduced due to periodicity and symmetry.

8.1.2 DFT Computational Complexity

Page 4: 8.1 Introduction 8.2 Goertzel Algorithm 8.3 Fast Fourier Transform (FFT)  8.4 Inverse FFT (IFFT)

4

• Symmetry and Periodicity

• Periodic in both k and n with period N

*)( knN

knN

nNkN WWW

nNkN

NnkN

knN WWW )()(

98

18 ,WW

158

78 ,WW

148

68 ,WW

128

48 ,WW

Example N=8

8.1.3 DFT Symmetry and Periodicity Properties

Page 5: 8.1 Introduction 8.2 Goertzel Algorithm 8.3 Fast Fourier Transform (FFT)  8.4 Inverse FFT (IFFT)

5

• Based on the symmetry, we can write for real part:

Re{x[n]}Re{WNkn

}+ Re{x[N-n]}Re{WNk(N-n) }

Group terms, drop one multiplication we get:

(Re{x[n]}+ Re{x[N-n]})Re{WNkn}

Since Re{WNkn

}= Re{WNk(N-n)

}

• Similarly for other three terms, and this results in a reduction

by 50% of real multiplications without really doing anything.

• However, the overall complexity is still O(N2)

• The periodicity property is better that leads to the Fast

Fourier Transform (FFT) with O(Nlog(N))

8.1.4 Symmetry and Periodicity Properties

Page 6: 8.1 Introduction 8.2 Goertzel Algorithm 8.3 Fast Fourier Transform (FFT)  8.4 Inverse FFT (IFFT)

6

• Known for many years

– Gauss 1805

– Runge 1905

– Danielson and Lanczos (1942)

• Hand calculation of the DFT

• Relatively short sequence

• Cooly & Tukey – 1965

– Modern algorithm that could decompose a DFT into a

sum of shorter DTFs

– When N is a composite number, i.e., the product of two or

more integers.

8.1.5 FFT History

Page 7: 8.1 Introduction 8.2 Goertzel Algorithm 8.3 Fast Fourier Transform (FFT)  8.4 Inverse FFT (IFFT)

7

• Decompose a sequence into successively smaller sequence to

reduce overall computation .

• Example:

– Consider N=100

– Brute Force O(N2)=10000

– If we can break this into 2 (50 point) DFTs, then: O(502) + O(502)

=5000<10000 !

– Decompose further, gaining each time.

• Two basic classes

– Decimation in time (DIT)

– Decimation in frequency (DIF)

8.1.6 FFT Principles

Page 8: 8.1 Introduction 8.2 Goertzel Algorithm 8.3 Fast Fourier Transform (FFT)  8.4 Inverse FFT (IFFT)

8

• The Goertel algorithm is an example of how the periodicity of the sequence can be used to reduce computation.

• To suggest the final result, let us define the sequence

• It can be interpreted as a discrete convolution of the finite duration sequence with the sequence

• Consequentially, can be viewed as the response of a system with impulse response to a finite-length input x[n]. In particular, X[k] is the value of the output when n=N.

12)/2( kjNkNjkNN eeW

8.2.1 Goertel Algorithm: Periodicity

knNW

1

0

)(1

0

][][][N

r

rNkN

N

r

krN

kNN WlxWlxWkX

].[][][ )( rnuWrxnyr

rNkNk

Nnk nykX

][][

10],[ Nnnx ].[nuW knN

][nyk

].[nuW knN

Page 9: 8.1 Introduction 8.2 Goertzel Algorithm 8.3 Fast Fourier Transform (FFT)  8.4 Inverse FFT (IFFT)

9

8.2.2 Goertel Algorithm: Complexity

Z-1

kNW

0][

][

Nx

nx

e

e

0]1[

][

k

k

y

ny

• For a particular value of k, we need 4N real multiplications and 4N real additions to compute X[k].

• This procedure is slightly less efficient than the direct method.

• It avoids the computation or storage of the coefficient , since these quantities are implicitly computed by the recursion.

knNW

Page 10: 8.1 Introduction 8.2 Goertzel Algorithm 8.3 Fast Fourier Transform (FFT)  8.4 Inverse FFT (IFFT)

10

10

1

1

1)()(

zW

zWzHk

Nn

nkNk

8.2.3 Goertel Algorithm: Complexity Reduction

21

1

11

1

)/2cos(21

)1(

)1)(1(

)1()(

zzNk

zW

zWzW

zWzH

kN

kN

kN

kN

k

• 2(N+2) real multiplications

• 4(N+1) real additions

Page 11: 8.1 Introduction 8.2 Goertzel Algorithm 8.3 Fast Fourier Transform (FFT)  8.4 Inverse FFT (IFFT)

11

• In either the direct method or the Goertzel method, we do not need to evaluate X[k] at all N values.

• We can evaluate X[k] for any M values of k, with each DFT value being computed by a recursive system.

• This is slightly less efficient than DFT performed directly.

• But, WNkn does not need to be computed and stored in

advance due to recursive nature of the algorithm.

• Advantage: Goertzel’s algorithm can be used to compute efficiently a small number of DFT coefficients.

• Next – the real FFT

8.2.4 Goertel Algorithm: Comments

Page 12: 8.1 Introduction 8.2 Goertzel Algorithm 8.3 Fast Fourier Transform (FFT)  8.4 Inverse FFT (IFFT)

12

knN

evenn

knN

oddn

knN

N

n

oddeven

WnxWnxkX

WnxkX

nxnxnx

][][][

][][

][][][1

0

• Decimation in Time (DIT) FFT – Classical approach:– Based on decomposing x[n] into small sequences

– Exploits both periodicity and symmetry of W

– Usually consider N=2v so that we can successively subdivide by factor of 2 (v times) all the way down to length – 2 subsequences.

• Divide into even and odd indexed points

Let N=2v

8.3.1 DIT-FFT: Concepts

Page 13: 8.1 Introduction 8.2 Goertzel Algorithm 8.3 Fast Fourier Transform (FFT)  8.4 Inverse FFT (IFFT)

13

)12(12

0

)2(12

0

]12[]2[][

nk

N

N

n

nkN

N

n

WnxWnxkX

Want to write this as a sum of N/2 points DFT

So we can write

222

212

0

212

0

212

0

212

0

2/2422

)(]12[)(]2[][

)(]12[)(]2[][

Njjj

Nj

N

knN

N

n

kN

knN

N

n

kN

nkN

N

n

knN

N

n

WeeeWeW

WnxWWnxkX

WWnxWnxkX

NNNN

8.3.2 DIT-FFT: Formulas

Page 14: 8.1 Introduction 8.2 Goertzel Algorithm 8.3 Fast Fourier Transform (FFT)  8.4 Inverse FFT (IFFT)

14

• Where G[k] and H[k] are N/2 point DFT

• G[k] and H[k] are both periodic with period N/2

• So, must be computed over only N/2 points (not N)

• X(k) is still N points long.

• Lets check the flow diagram

• Rewrite

10][][][

][][][

]12[]2[][22

12

0

12

0

NkkHWkGkX

kHkGkX

WnxWWnxkX

kN

knN

n

kN

knN

n

NN

8.3.2 DIT-FFT: Formulas (Cont’d)

Page 15: 8.1 Introduction 8.2 Goertzel Algorithm 8.3 Fast Fourier Transform (FFT)  8.4 Inverse FFT (IFFT)

15

]3[]3[]7[

]1[]1[]5[

]0[]0[]4[

]1[]1[]1[

]0[]0[]0[

][][][

78

58

48

18

08

HWGX

HWGX

HWGX

HWGX

HWGX

kHWkGkX kN

8.3.3 DIT-FFT: Flow Graph

Because of periodicity

G[4]=G[0] H[4]=H[0]

G[5]=G[1] H[5]=H[1]

G[6]=G[2] H[6]=H[2] ….

Page 16: 8.1 Introduction 8.2 Goertzel Algorithm 8.3 Fast Fourier Transform (FFT)  8.4 Inverse FFT (IFFT)

16

• Consider computation:– Recall that DFT is O(N2)

– Now length is N/2, not N, but there are two N/2 point DFTs

– At first (Complex)

– N2 multiplications and adds (each)

– Now, 2*(N/2)2 = N2/2 multiplications and additions (each)

– Plus N complex multiplications for W

– Plus N complex additions

• Total = N+N2/2 complex multiplications and adds.

• Since N+N2/2 < N2 ! A savings for N=2v.

• We can continue this decomposition process and get more savings, if N/2 is even and greater than 2.

8.3.4 DIT-FFT: Reduced Complexity

Page 17: 8.1 Introduction 8.2 Goertzel Algorithm 8.3 Fast Fourier Transform (FFT)  8.4 Inverse FFT (IFFT)

17

14

042

14

04

14

042

14

04

14

0

)12(2

14

0

22

12

02

]12[]2[][

]12[]2[][

]12[]2[][

]2[][with][][

N

l

lkN

kN

N

l

lkN

N

l

lkN

kN

N

l

lkN

N

l

klN

N

l

lkN

N

n

knN

WlhWWlhkH

WlgWWlgkG

WlgWlgkG

nxngWngkG

• Assume N=8– Stage I : Form two 4 point DFTs, plus combining algebra

– Stage II: Split 4-point DFTs into four 2-point DFTs, plus combining algebra

– Would continue if N>8

• Consider the two 4-point DFTs

8.3.5 DIT-FFT: Procedure

Page 18: 8.1 Introduction 8.2 Goertzel Algorithm 8.3 Fast Fourier Transform (FFT)  8.4 Inverse FFT (IFFT)

18

]12[][ nxnh• Where

• This represents the 4-point DFTs as four 2-point DFTs plus 2 stages of combining algebra

• If N=2v, it will take v stages to do this completely.

• log2N decomposition to get down to 2-point DFTs, now require 4(N/4)2+2(N/2)+N=N2/4+N+N<N2

• A 2-point DFT – what is the simplest stage like?

]1[]0[]1[]0[]1[

]1[]0[]1[]0[]0[

10][][

12

12

02

12

02

1

02

pWpWpWpP

ppWpWpP

kWnpkPn

nk

8.3.5 DIT-FFT: Procedure (Cont’d)

p[0]

p[1]

P[0]=p[0]+p[1]

P[1]=p[0]+W21p[1]

112 W

Page 19: 8.1 Introduction 8.2 Goertzel Algorithm 8.3 Fast Fourier Transform (FFT)  8.4 Inverse FFT (IFFT)

19

8.3.5 DIT-FFT: Procedure (Cont’d)

Page 20: 8.1 Introduction 8.2 Goertzel Algorithm 8.3 Fast Fourier Transform (FFT)  8.4 Inverse FFT (IFFT)

20

In general

Xm+1 [p]=Xm [p]+WrNXm [q]

Xm+1 [q]=Xm [p]+WN(r+N/2)Xm [q]

• With this decomposition, each stage requires N complex mults and ~N complex adds

• There are log2N stages

• Thus Nlog2N complex mults and adds, not N2

• Further reduction results in each stage of Butterflies of form as

8.3.6 DIT-FFT: Complexity

xm[p]

xm[q])2( Nr

NW

Xm+1[p]

Xm+1[q]

rNW

Page 21: 8.1 Introduction 8.2 Goertzel Algorithm 8.3 Fast Fourier Transform (FFT)  8.4 Inverse FFT (IFFT)

21

1

)1(

2

22

22

N

NjN

N

rN

rN

NN

rN

NrN

eW

WWWWW

Then the general Butterfly can be written as

But

xm[p]

xm[q]

Xm+1[p]

Xm+1[q]r

NW -1

So

][][][

][][][

1

1

qWpXqX

qWpXpXr

Nmm

rNmm

8.3.6 DIT-FFT: Complexity (Cont’d)

Page 22: 8.1 Introduction 8.2 Goertzel Algorithm 8.3 Fast Fourier Transform (FFT)  8.4 Inverse FFT (IFFT)

22

• This signal flow graph saves one complex multiply per butterfly – which cuts the total by half

# complex mults = N/2 log2N

# complex adds = Nlog2N

• As opposed to N2 of the DFT direct computation.

• Consider reductions:

N DFT FFT Ratio

256 2562=65536 256*8=2048 32:1

512 5122=262144 512*9=4608 57:1

1024 10242=1048576 1024*10=10240 102:1

2048

8.3.6 DIT-FFT: Complexity (Cont’d)

Page 23: 8.1 Introduction 8.2 Goertzel Algorithm 8.3 Fast Fourier Transform (FFT)  8.4 Inverse FFT (IFFT)

23

• Due to “flow of calculation” from left to right, 2-point calculations in each Butterfly – only a single complex storage array is needed in the computation

• Bit reward ordering: data is stored in “bit-reversed” order due to the even/odd splits on the data.

Index Binary Bit Rev Order

0 000 000 0 Even

1 001 100 4

2 010 010 2

3 011 110 6

4 100 001 1 Odd

5 101 101 5

6 110 011 3

7 111 111 7

8.3.7 DIT-FFT: In-Place Computations

Page 24: 8.1 Introduction 8.2 Goertzel Algorithm 8.3 Fast Fourier Transform (FFT)  8.4 Inverse FFT (IFFT)

24

• Subdivide X[k] into successively smaller subsequences

• Let N=2v

• These are 2 N/2 point DFTs

8.3.8 Decimation-In-Frequency (DIF)

nN

nrN

N

N

n

rnN

NrN

n

WWnxnxrX

WnxnxrX

22

12

0

22

212

0

])[][(]12[Odd

])[)1(][(]2[Even

nrN

nN

N

n

rnN

N

n

N

N

WWnhrX

WngrX

nxnxnh

nxnxng

2

12

0

2

12

0

2

2

)][(]12[

])[(]2[

][][][and

][][][Let

Page 25: 8.1 Introduction 8.2 Goertzel Algorithm 8.3 Fast Fourier Transform (FFT)  8.4 Inverse FFT (IFFT)

25

8.3.9 DIF-FFT: Signal Flow Graph

Page 26: 8.1 Introduction 8.2 Goertzel Algorithm 8.3 Fast Fourier Transform (FFT)  8.4 Inverse FFT (IFFT)

26

which is the DFT of X*[k]

1

0

*

*1

0

**

][

][][])[(

N

k

nkN

N

k

nkN

WkX

WkXnNxnNx2. Take the complex conjugate

3. Take the conjugate again*1

0

* ][][

N

k

nkNWkXnNx

Want to compute IDFT using FFT

1. Multiply IDFT by N

1

0

][1

][N

k

nkNWkX

NNnNx

8.4.1 Inverse FFT: Ideas

*1

0

* ][1

][

N

k

nkNWkX

Nnx

4. Divided by N

IDFT ][1

][1

0

N

k

nkNWkX

Nnx

Page 27: 8.1 Introduction 8.2 Goertzel Algorithm 8.3 Fast Fourier Transform (FFT)  8.4 Inverse FFT (IFFT)

27

1. Get X*[k];

2. Compute FFT(X*[k]);

3. Compute conjugate to get Nx[n];

4. Divide result by N.

8.4.2 Inverse FFT: Procedure and Example

Original Image A FFT(A) Sine Wave B FFT(B)

A+B FFT(A+B) FFT(A+B)-FFT(B) IFFT[FFT(A+B)-FFT(B)]

Page 28: 8.1 Introduction 8.2 Goertzel Algorithm 8.3 Fast Fourier Transform (FFT)  8.4 Inverse FFT (IFFT)

28

8.5.1 Signal Analysis using DFT

• Anti-aliasing filter is to incorporated to eliminate or minimize the effect of aliasing when the continuous-time is converted to a sequence.

• The need for multiplication of x[n] by w[n] is a consequence of the finite-length requirement.

• A finite-duration window w[n] is applied to x[n] prior to computation of the DFT in order to smooth sharp peaks and discontinuities in .

• The C/D conversion is represented in the frequency-domain as

)( jeX

T

rj

TjX

TeX

rc

j 21)(

Page 29: 8.1 Introduction 8.2 Goertzel Algorithm 8.3 Fast Fourier Transform (FFT)  8.4 Inverse FFT (IFFT)

29

(a) Fourier transform of continuous-time input signal.

(b) Frequency response of anti-aliasing filter.

(c) Fourier transform of output of anti-aliasing filter.

(d) Fourier transform of sampled signal.

(e) Fourier transform of window sequence.

(f) Fourier transform of windowed segment and frequency samples obtained using DFT samples.

Illustration of the Fourier transforms:

)( jS

)( jHaa

)()()( jHjSjX aacc

T

rj

TjX

TeX

rc

j 21)(

)(*)()( jjj eXeWeV

1

0/2

)/2( )(][][N

nNk

jknNj eVenvkV

frequency) lfundamenta(2

,2

,2

NN

k

NT

kNkk

Page 30: 8.1 Introduction 8.2 Goertzel Algorithm 8.3 Fast Fourier Transform (FFT)  8.4 Inverse FFT (IFFT)

30

8.5.2 Signal Analysis using DFT: Example-1

Page 31: 8.1 Introduction 8.2 Goertzel Algorithm 8.3 Fast Fourier Transform (FFT)  8.4 Inverse FFT (IFFT)

31

8.5.3 Signal Analysis using DFT: Example-2