Chapter 10 The Discrete Fourier Transform and

advertisement
EE 422G Notes: Chapter 10
Instructor: Zhang
Chapter 10 The Discrete Fourier Transform and
Fast Fourier Transform Algorithms
10-1 Introduction
1. x(t) --- Continuous-time signal
X(f) --- Fourier Transform, frequency characteristics

Can we find X ( f ) 
 x(t )e
 j 2ft
dt

if we don’t have a mathematical equation for x(t) ? No!
2. What can we do?
(1) Sample x(t) =>
x0, x1, … , xN-1 over T (for example 1000 seconds)
Sampling period (interval) t
N (samples) over T => t  T / N
Can we have infinite T and N? Impossible!

(2) Discrete Fourier Transform (DFT):
N 1
 j 2kn / N
=> X k   x n e
k  1, 2,..., N
n 0
for the line spectrum at frequency  k  ( 2 )
k
T
3. Limited N and T =>
1
T
limited frequency band (from   to  in Fourier transform to):
0    2N / T
N 1
1
X k e j 2kn / N
4. xn 
---- periodic function (period N)

N k 0
limited frequency resolution 2
x(t) --- general function
 sampling and inverse transform
xn --- periodic function
Page 10-1
EE 422G Notes: Chapter 10
( k  2
5. X k
Xk 
Instructor: Zhang
k
line spectrum)
T
N 1
 xn e  j 2kn / N
period function (period N)
n0
10-2 Error Sources in the DFT
1. Preparations
(1) Ideal sampling waveform y s (t ) 

  (t  mTs ) :
m  

y s (t )  f s   ( f  nf s )
 
n

( fs 
1
)
Ts
Fourier
Transform
Pair
in DFT Ts  t  T / N
(2) Rectangular Pulse (window)
sin x
sin cX 
t  t0
(
)  T sin c(Tf )e  j 2t0 f
x
T
 sin c(Tf ) 

width
of
the
window
when t0 = 0
Center of the
window
sin Tf
Tf
t
 ( )  T sin c(Tf )
T
(3) x1 (t ) * x2 (t )  X1 ( f ) X 2 ( f )
(4) x1 (t ) x2 (t )  X1 ( f ) * X 2 ( f )
Page 10-2
EE 422G Notes: Chapter 10
Instructor: Zhang
2. Illustration of Error Sources
Example 10-1: Continuous – time signal: two-sided exponential signal
x(t )  e

|t |

Its Fourier transform
2
1  (2f ) 2
(1) If we sample x(t) in
(,)



X( f ) 
with sampling frequency fs :
not lim ited as in DFT
sampled signal xs (t )  ys (t )e

|t |

its Fourier transform:
X s ( f )  Ys ( f ) * F (e
 X s ( f )  fs


|t |

)  Ys ( f ) * X ( f )
 X ( f  nf s )  2f s
n  

1
 1  (2 ( f  nf
n  
s
)) 2
sampling => (1) possible overlapping if f s  2 f h is not held.
(2) periodic function, introduce frequencies beyond fs .
(2) Limited T (over which x(t) is sampled to collect data for DFT)
t
T
window  ( )
t
 xsw (t )  xs (t ) ( )
T
 X sw ( f )  (2f s

{1  2 ( f  nf
n  
s
) 2 }1 ) * (T sin c(Tf ))
Fourier transform given by sampled data in limited window (T)
 X sw ( f ) is a worse estimate of X(f) than Xs(f) due to the introduction of
( Tsinc( Tf ) ) for convolution!
Effect of limited T
Page 10-3
EE 422G Notes: Chapter 10
Instructor: Zhang
(3) Dose DFT give X s ( f ) for every f ?
No! only discrete frequencies.
DFT as an estimate for X(f): even worse than X s ( f ) due to the limited
frequency resolution.
3. Effect of sampling frequency (or number of points) on accuracy when T is
given: Example
t
use  ( )
4

for e
|t |

4. Effect of T (window size)
t
t
Compare  ( ) and  ( )
4
8

for e
|t |

Page 10-4
EE 422G Notes: Chapter 10
Instructor: Zhang
Page 10-5
EE 422G Notes: Chapter 10
Instructor: Zhang
5. DFT Errors
(1) Aliasing
X s ( f )  fs

 X(f
n  
superposition of the analog signal
spectrum X(f) and its translates (X(f-nfs)
n0)
 nf s )
Caused by sampling
Overlapping of X(f) and its translates: aliasing (sampling effect)
(2) Leakage Effect
t
limited window size T (  ( ) )
T
t
X s ( f )  X s ( f ) * F ( ( ))
T
t
 ( f )  F ( ( ))
T
worse than Xs(f) as approximation of X(f).
X s ( f ) : contribution of X s ( f  f ) to X s ( f ) : determined by
weight  (f )
frequency energy “leaks” from one frequency to another!
(3) Picket – Fence Effect:
As an estimation of X(f), does X s ( f ) have picket fence effect? No!
DFT: discrete frequencies (not blocked by the fence).
6. Minimization of DFT Error Effects.
 Major ways: increase T and fs
Problem: DFT for large N.
Page 10-6
EE 422G Notes: Chapter 10
Instructor: Zhang
10-3 Examples Illustrating the computation of the DFT
(Preparation for Mathematical Derivation of FFT)
1. DFT Algorithm
N 1
X ( k )   x ( n )e
 j 2kn / N
n 0
  x(n)e  j 2 / N 
N 1
nk
n 0
Denote WN  e  j 2 / N , then
X (k ) 
N 1
 x(n)WN nk
n0
WN m :
0
 j 2 / N 0
Properties of
(1) WN  (e
(2) WN
N m
 WN
WN N  e  j 2  1
)  e0  1,
m
WN N  m  (e  j 2 / N ) N  m
 (e  j 2 / N ) N (e  j 2 / N ) m
 1  (e  j 2 / N ) m  WN m
(3) WN
N /2
 e  j 2 /( N / 2) / N  e  j  1
WN N / 4  e  j 2 /( N / 4) / N  e  j / 2   j
WN
3N / 4
 e j 2 /(3 N / 4) / N  e j 3 / 2  j
2. Examples
Example 10-3: Two-Point DFT
x(0), x(1): X (k ) 
1
 x(n)W2 nk
k  0,1
n0
X (0) 
1
 x(n)W2 n0 
n0
1
X (1)   x(n)W2
n 0
n1
1
 x(n)  x(0)  x(1)
n0
1
  x(n)W2
n 0
 x(0)W2  x(1)W2
0
 x(0)  x(1)W2
n
1
(1 / 2 ) 2
 x(0)  x(1)( 1)
 x(0)  x(1)
Page 10-7
EE 422G Notes: Chapter 10
Instructor: Zhang
Example 10-4: Generalization of derivation in example 10-3 to a four-point DFT
x(0), x(1), x(2), x(3)
3
 x(n)W4 nk
X (k ) 
X (0) 
n0
3
 x(n)W4
n0
n0
3
k  0,1,2,3,

3
 x(n)  x(0)  x(1)  x(2)  x(3)
n0
X (1)   x(n)W4  x(0)W4  x(1)W4  x(2)W4  x(3)W4
n
0
1
2
3
n 0
 x(0)  jx(1)  x(2)  jx(3)
3
X (2)   x(n)W4
2n
n 0
 x(0)W4  x(1)W4  x(2)W4  x(3)W4
0
2
 x(0)  x(1)( 1)  x(2)(1)  x(3)W4
4
6
2
 x(0)  x(1)  x(2)  x(3)
3
X (3)   x(n)W4
n 0
3n
 x(0)W4  x(1)W4  x(2)W4  x(3)W4
0
3
 x(0)  x(1)W4  x(2)(1)W4  x(3)W4
3
2
6
9
1
 x(0)  jx(1)  (1) x(2)  ( j ) x(3)
 x(0)  jx(1)  x(2)  jx(3)
X (0)  [ x(0)  x(2)]  [ x(1)  x(3)]

X (1)  [ x(0)  x(2)]  ( j )[ x(1)  x(3)]
X (2)  [ x(0)  x(2)]  [ x(1)  x(3)]
X (3)  [ x(0)  x(2)]  j[ x(1)  x(3)]
Page 10-8
EE 422G Notes: Chapter 10
Instructor: Zhang
Two – point DFT
If we denote z(0) = x(0), z(1) = x(2) => Z(0) = z(0) + z(1) = x(0) + x(2)
Z(1) = z(0) - z(1) = x(0) - x(2)
v(0) = x(1), v(1) = x(3) => V(0) = v(0) + v(1) = x(1) + x(3)
V(1) = v(0) - v(1) = x(1) - x(3)
Four – point DFT
Two-point DFT
 X(0) = Z(0) + V(0)
X(1) = Z(1) + (-j)V(1)
X(2) = Z(0) - V(0)
X(3) = Z(1) + jV(1)
 One Four – point DFT
Two Two – point DFT
10-4 Mathematical Derivation of the FFT
10-4A Decimation-in-Time FFT Algorithm
x(0), x(1), … , x(N-1)
N  2m
Page 10-9
EE 422G Notes: Chapter 10
Instructor: Zhang
N

g
(
0
),
g
(
1
),

,
g
(
 1)

2

(( x (0), x ( 2),, x ( N  2))
=> 
h(0), h(1),, h( N  1)

2
(( x (1), x (3),, x ( N  1))

N 1
X (k )   x(n)WN
N
po int s
2
( g ( r )  x ( 2r ))
 enen
N
po int s
2
( h( r )  x ( 2 r  1))
 odd
kn
n 0

N / 2 1
 g (r )W
r 0

2 kr
N
N / 2 1
 g (r )W
r 0
WN
k (2r )

N / 2 1
 h(r )W
r 0
2 kr
N
 WN
k
k ( 2 r 1)
(k  0,1,..., N  1)
N
N / 2 1
 h(r )W
r 0
2 kr
N
 (e  j 2 . / N ) 2 kr  (e  j 2 /(.N / 2) ) kr  W N
kr
2
 X (k ) 
N / 2 1
 g (r )W
r 0
kr
N /2
 WN
k
N / 2 1
 h(r )W
r 0
kr
N /2
 G (k )  W N H (k )
( G(k): N/2 point DFT output (even indexed), H(k) : N/2 point DFT
output (odd indexed))
k
X ( k )  G ( k )  WN k H ( k )
G(k ) 
N / 2 1

r 0
H (k ) 
g ( r )WN / 2 kr 
N / 2 1

r 0
h( r )WN / 2 
kr
k  0,1,..., N  1
N / 2 1

r 0
N / 2 1

r 0
x ( 2 r )WN / 2 kr
x ( 2 r  1)WN / 2 kr
Question: X(k) needs G(k), H(k), k=… N-1
How do we obtain G(k), H(k), for k > N/2-1 ?
G(k) = G(N/2+k)
k <= N/2-1
H(k) = H(N/2+k)
k <= N/2-1
Page 10-10
EE 422G Notes: Chapter 10
Future Decimation
g(0), g(1), …, g(N/2-1)
h(0), h(1), …, h(N/2-1)
N
 2)
2
N
ge(0), ge(1),...ge(  1)
4
N
g (1), g (3), , g (  1)
2
N
go(0), go(1),... go(  1)
4
Instructor: Zhang
G(k)
H(k)
G (k ) 
N / 2 1
g (0), g (2), , g (
 g (r )W
r 0

N / 4 1
 ge(m)W
km
( N / 4)
m 0
 W( N / 2)
kr
( N / 2)
k
N / 4 1
 go(m)W
km
( N / 4)
m 0
 GE(k )  W( N / 2) Go(k )
k
even indexed g odd indexed g
(N/4 point)
(N/4 point)
Page 10-11
EE 422G Notes: Chapter 10
Instructor: Zhang
WN / 2 k  WN 2 k ?
WN / 2 k  ( e  j 2 /( N / 2 ) ) k
 ( e  j 2 2 / N ) k  ( e  j 2 / N ) 2 k
 WN 2 k
=> G(k )  GE (k )  WN Go(k )
2k
Similarly,
H (k )  HE (k )  WN 2k Ho(k )
even indexed
h (N/4 point)
odd indexed
h (N/4 point)
For 8 – point
g ( 0)

g (1)

g ( 2)

g (3)

h ( 0)

h(1)

h ( 2)

h(3)

x ( 0)

ge(0)
x ( 2)
x ( 4)

ge(1)
x ( 6)
x (1)

he(0)
x (3)
x (5)

he(1)
x (7)

go(0)

go(1)

ho(0)

ho(1)
Page 10-12
EE 422G Notes: Chapter 10
Instructor: Zhang
10-4B Decimation-in-Frequency FFT Algorithm
N  2m
x(0), x(1), … , x(N-1)
N 1
X (k )   x(n)W N
nk
n 0

N / 2 1
 x(n)WN
n 0
nk

N 1
 x(n)W
n N / 2
nk
N
Page 10-13
EE 422G Notes: Chapter 10
Instructor: Zhang
let m = n-N/2 (n = N/2+m)
 X (k ) 
N / 2 1

n 0

N / 2 1

n 0
n = N/2 => m = N/2-N/2 = 0
n = N-1 => m = N-1-N/2 = N/2-1
x ( n )WN
x ( n )WN nk 
N
nk

N / 2 1

m 0
N / 2 1

m 0
x ( N / 2  m )WN ( N / 2  m ) k
N
x ( N / 2  m )WN mk WN 2 k
N
WN 2  1  WN 2 k  ( 1) k
X (k ) 
N / 2 1

n 0

N / 2 1

n 0
x ( n )WN nk 
N / 2 1

m 0
( 1) k x ( N / 2  m )WN mk
[ x ( n )  ( 1) k x ( N / 2  n )]WN nk
k : even (k  2r )  X (k )  X (2r ) 
N / 2 1
[ x(n)  x( N / 2  n)]W
n 0
WN
N/2 point DFT
2 rn
 (e
 j 2 / N
 X ( k )  X ( 2r ) 
) 2 rn  (e  j 2 /( N / 2) ) rn  WN / 2
N / 2 1
x(n)  x( N / 2  n)]W
[



n 0
Y (r) 
N / 2 1
k : odd  k  2r  1
 X (k )  X (2r  1)


n 0

n)  x( N / 2  n)]W W
 [x(


n
N
 z (n)W
2 rn
N
N / 2 1
 z (n)W
n 0
2 rn
N
z (n)
N / 2 1
n 0

n ( 2 r 1)
N
N / 2 1
n 0
rn
N /2
Z (r )
N / 2 1
 [ x(n)  x( N / 2  n)]W
rn
y (n)
y ( n )WN / 2 rn
n 0

2 rn
N
rn
N /2
Page 10-14
EE 422G Notes: Chapter 10
Z (r ) 
Instructor: Zhang
N / 2 1
 z (n)W
n 0
rn
N /2

N
po int
2
DFT
of
z (0), , z (
N
 1)
2
X(k) : N-point DFT of x(0), …, x(N)  two N/2 point DFT
One N/2 point DFT => two N/4 point DFT
… two point DFTs
Consider N/2 point DFT
y(0), y(1), …, y(N/2-1)
Y (k ) 
N / 2 1

n 0

N / 4 1

n 0
y ( n )WN / 2 rn
[ y ( n )  ( 1) k y ( N / 4  n )]WN / 2 nk
Page 10-15
EE 422G Notes: Chapter 10
Instructor: Zhang
k : even  k  2r
Y (k )  Y (2r ) 
N / 4 1

n 0
Y 1( r ) 
N / 4 1

n 0
[ y ( n )  y ( N / 4  n )]WN / 2 nk

y1( n )
y1( n )WN / 4 nk  N / 4
po int
DFt
k : odd  k  2r  1
Y ( k )  Y ( 2r  1) 
N / 4 1

n 0
Y 2( r ) 
N / 4 1

n 0
[ y ( n )  x ( N / 4  n )]WN / 2 n WN / 2 2 rn

y 2( n )WN / 4 rn  N / 4
y 2( n )
po int
DFT
Page 10-16
EE 422G Notes: Chapter 10
Instructor: Zhang
10-4 C Computation
N – point DFT : 4N(N-1) real multiplications
4N(N-1) real additions
N – point FFT : 2Nlog2N real multiplications
(N = 2m)
3Nlog2N real additions
Computation ration
FFT ' s computations 5 log2 N

DFT ' s computations 8( N  1)
N  212  4096

5  12
 0.18%
8  4095
10-5 Properties of the DFT
Assumptions
(1)
x ( n ) and y ( n )


X (k )
Y (k )
(n  0,..., N  1)
(k  0,..., N  1)
(2) A, B: arbitrary constants
(3) Subscript e:
Subscript o:
Page 10-17
EE 422G Notes: Chapter 10
Instructor: Zhang
N 1
if N even
 2
xe(n) : even about 
N
if N odd
 2
N 1
if N even
 2
xo(n) : odd about 
N
if N odd
 2
N = 10, xe(n)
 x ( 4)  x (5)
 x (3)  x (6)

N 1

 4.5   x ( 2)  x (7)
2
 x (1)  x (8)

 x (0)  x (9)
N = 9, xe(n)
 x ( 4)  x (5)
 x (3)  x (6)

N
  4 .5   x ( 2 )  x ( 7 )
2
 x (1)  x (8)

 x (0)  x (9)
(4) Any real sequence can be expressed in terms of its even and odd parts
according to
x( n )  xe ( n )  xo (n )
1
1
 [ x( n )  x ( N  n )]  [ x( n )  x( N  n )]
2
2
even
odd
Question 1: x(n) = 1/2[ ] +1/2 [ ] ?
Question 2: x(n) + x(N-n) even ?
x(n) - x(N-n) odd ?
Yes!
Page 10-18
EE 422G Notes: Chapter 10
Instructor: Zhang
Example: N = 9 => N/2 = 4.5
Consider n = 2
x(2) + x(9-2) = x(2) + x(7)
is x(2) + x(7) = x(4.5+(4.5-2)) +x(4.5-(7-4.5))?
4.5 + (4.5-2) = 9-2 = 7
4.5 - (7-4.5) = 9-7 = 2
x(2) + x(7) = x(7) + x(2) ?
Yes! => x(n) + x(N-n) even
Is x(2) - x(7) = - [x(7) + x(2)] ?
Yes! => x(n) - x(N-n) odd
(5) subscript r : xr(n)
a real sequence
subscript i : xi(n)
Imaginary part of a complex sequence
(6) x ( n )  X ( k )
left
right side:
side:
DFT
sequence
(7) sequences are assumed periodically repeated if necessary
Properties
1. Linearity :
2. Time Shift:
Ax ( n )  By ( n )  AX ( k )  BX ( k )
x(n  m)  X (k )e  j 2km / N  X (k )WN k  m
3. Frequency Shift:
4. Duality :
why?
x(n)e j 2km / N  X (k  m)
N 1 x(n)  X (k )
X (k ) 
DFT ( X ( n )) 
N 1
 x(m)e  j 2mk / N
m 0
N 1
 X (n)e j 2nk / N
n 0
DFT of x(m)
Page 10-19
EE 422G Notes: Chapter 10
Instructor: Zhang
x( n )  x( N  n )
1

N
N 1
 X (k )e j 2k ( N  n ) / N
k 0
e j 2k ( N  n ) / N  e j 2kN / N e  j 2kn / N
1
x( n ) 
N
N 1
 X (k )e  j 2kn / N
k 0
 DFT ( N 1 X ( n )) 
1
N
N 1
 X (n)e j 2nk / N  x( k )
n 0
5. Circular convolution
N 1
 x(m) y(n  m)  x(n)y(n)  X (k )Y (k )
circular convolution
m0
6. Multiplication
x ( n) y ( n)  N



1
N 1
 X (m)Y (k  m)  N 1 X (k )Y (k )
m0
new sequence
z (n)  x(n) y (n)
7. Parseval’s Theorem
N 1
 | x ( n) |
n 0
2
N
1
N 1
 | X (k ) |
2
k 0
8. Transforms of even real functions:
xer (n)  X er (k )
(the DFT of an even real sequence is even and real )
9. Transform of odd real functions:
xor (n)  jX oi (k )
(the DFT of an odd real sequence is odd and imaginary )
10. z(n) = x(n) + jy(n)
z(n)  Z(k) = X(k) + jY(k)
Page 10-20
EE 422G Notes: Chapter 10
Instructor: Zhang
Example 10-7
z (n)  x(n)  jy(n)  e jn  / 2
 cos(n / 2)  j sin( n / 2)
n  0,1,2,3
Four – point DFT for x(0), x(1), x(2), x(3):
X(0) = [x(0) + x(2)] + [x(1) + x(3)]
X(1) = [x(0) - x(2)] + (-j)[x(1) - x(3)]
X(2) = [x(0) + x(2)] - [x(1) + x(3)]
X(3) = [x(0) - x(2)] + j[x(1) - x(3)]
For x(n)  cos(n / 2) =>
x(0)  1 x(1)  0 x(2)  1 x(3)  0


X (0)  1 X (1)  2
X (2)  0
X (3)  2
For y (n)  sin( n / 2) =>
y (0)  0 y (1)  1 y (2)  0 y (3)  1


Y (0)  1 Y (1)   j 2 Y (2)  0 Y (3)  j 2
Z ( 0)  0
Z (1)  2  j 2

Z ( 2)  0
Z (3)  2  j 2
Example 10-8
DFT of x(n)   (n) :
N 1
X (k )    (n)W N
nk
 1 k  0,1,..., N  1
n 0
Time-shift property
N 1
DFT [ x(n  n0 )]    (n  n0 )W N
nk
n 0
 WN
n0 k
 e  j 2kn0 / N
Page 10-21
EE 422G Notes: Chapter 10
Instructor: Zhang
Example 10-9: Circular Convolution
x1 (n)  1 x2 (n)  1 0  n  N  1
N 1
Define x3c (n)  x1 (n)x2 (n)   x1 (m) x2 (n  m)
m 0
X 1 (k )  X 2 (k ) 

N 1
N 1
n0
n0
 x1 (n)WN nk 
k 0
N 1
N
nk
W

 N 0

n0
k0
N 2
 X 3 (k )  X 1 (k ) X 2 (k )  
0
1 N 1
x3c (n)   x3 (k )e j 2nk / N
N k 0

1
N
 x2 (n)WN nk
k 0
k 0
N 1
 N 2 (k )e j 2nk / N
k 0
N 1
 N  e j 2nk / N  Ne j 2nk / N  N
k 0
 x3c (n)  N
10-6 Applications of FFT
1. Filtering
x(0), …, x(N-1) FFT (DFT) =>
X(0), … , X(1), … , X(N-1)
X(k): Line spectrum at  k 
2kt 2k

T
N
(1 
2
T
t 
T
)
N
(Over T: x(0), …, x(N-1) are sampled.)
Inverse DFT:
N 1
x(n)   X (k )e j 2nk / N
k 0
^
N0
x(n)   X (k )e j 2nk / N
k 0
Frequencies with  
2N 0
have been filtered!
N
Page 10-22
EE 422G Notes: Chapter 10
Example 10-10
x(n)  cos
Instructor: Zhang

1 

 cos
n
4

2 2
( )
8 N
0n7
n
2

 2 (
2
4 
)2 

N
8 2
x(0), x(1), …, x(7)

X (0),

X (1),

X (2),

 X (7 )


non  zero non  zero 0

How to filter frequency higher than ?
4
0
0
2. Spectrum Analyzers
Analog oscilloscopes => time-domain display
Spectrum Analyzers: Data Storage, FFT
3. Energy Spectral Density
x(0), …, x(N-1): its energy definition
E
N 1
 | x ( n) |2
n0
Parseval’s Theorem
N 1
| x ( k ) |2
E
N
k 0
Page 10-23
Download