EC533: Digital Signal Processing
  5          l      l

           Lecture 10
       DFT and FFT
10.1 - Frequency Domain Vs. Time Domain



        CTFS              DTFS




        CTFT              DTFT
10.2 - Discrete Fourier Transform (DFT)

• A finite or periodic sequence has only N unique values,
    f              d             h    l             l
  x[n] for 0 ≤ n p N
• S t
  Spectrum is completely defined by N distinct frequency
             i       l t l d fi d b     di ti t f
  samples
• Divide 0..2π into N equal steps {ω(k)} = 2πk/N
           0 2π               steps,
• Uniform sampling of DTFT spectrum:
10.2 – DFT – contd.
Hence,




    Where,                        i.e, 1/Nth of a revolution


                         Twiddle Factor

Properties of the Twiddle Factor:
             k+N              k                                     j
         W   N
                     =
                         W    N
                                             periodicity
                  N
             k+                   k
         W   N
                  2 = −
                          W       N
                                                               -1
                                                                         1
             2
         W   N
                 =
                     W    N
                          2
                                                                    -j
                                                                         N=4
DFT Example
Find the DFT for the 4 points time sequence {1 0 0 1}, fs=8KHz
                            3                           3
                 X (0) = ∑ x(nT ) e − j 0 = ∑ x(nT )
   at k=0,

                           n =0                        n =0

                        = x(0) + x(T ) + x(2T ) + x(3T )
                        = 1+ 0 + 0 +1 = 2
                            3
    at k 1,
       k=1,       X (1) = ∑ x(nT ) e − jΩnT , Ω = 2π
                           n =0
                                                              NT
                            3
                                         − j 2πn
                  X (1) = ∑ x(nT ) e               N

                           n =0
                        = 1 + 0 + 0 + 1e − j 2π 3 4 = 1 + e − j 3π   4


                                 ⎛ 3π     ⎞         ⎛ 3π      ⎞
                        = 1 + cos⎜        ⎟ − j sin ⎜         ⎟ = 1+ j
                                 ⎝ 2      ⎠         ⎝ 2       ⎠
DFT Example – contd.
                  3                               3
                                                            − j 2π 2 n
at k=2,   X (2) = ∑ x(nT ) e   − j 2 ΩnT
                                             = ∑ x(nT ) e                N

                 n =0                            n =0
                 3
                             − j 4πn
              = ∑ x(nT ) e             N

                n =0

              = 1 + 0 + 0 + 1e − j 4π 3 4 = 1 + e − j 3π = 1 − 1 = 0
                       3
                                − j 2π 3 n
at k=3,    X (3) = ∑ x(nT ) e                N

                  n =0

               = 1 + 0 + 0 + 1e − j 9π 2 = 1 − j


           X (k ) = {2, 1 + j , 0, 1 − j}
DFT Example – contd.
x(nT)                                  |X(k)|
    1                                          2
                                                    √2

            x     x                                           x
        0   125   250   375   t(µs)             0    12.57   25.14   37.71   50.28
                                                                                     kΩ(X 103 rad/s)
                                      φ(k)(⁰)
  x(n) ={ , 0, 0,1
         1        }                       +45                                 Phase Angle 
                                                                             indeterminate
                                                                     37.71
                                           0    x                             x
                                                     12.57   25.14           50.28
                                                                                     kΩ(X 103 rad/s)

                                           ‐45




                                                 X(k) ={2,1+ j, 0,1− j}
10.3 - Inverse Discrete Fourier Transform
                  (
                  (IDFT))

  •


  • Ch k
    Check
10.4 - DFT Computational Complexity
The DFT
has:
• (N complex multiplies + N-1 complex adds per point) x N points (k = 0..N-1)
            N2 complex multiplies and N(N 1) complex additions
                                      N(N-1)
where
      cpx mult: (a+jb)(c+jd) = ac - bd + j(ad+bc)= 4 real mults + 2 real adds

       cpx add = 2 real adds

• Total: 4N2 real mults, 4N2-2N real adds

•Looking at DFT Matrix,
 lots of repeated structure are found;
 means opportunities for efficient
                t iti f      ffi i t
 algorithm to be used to reduce
  the DFT complexity
10.5 – Fast Fourier Transform (FFT)

• Reduce complexity of DFT from O(N2) to O(N log2N)
                                         O(N·log

• Grows more slowly with larger N

• Works by decomposing large DFT into several stages of
  smaller DFTs

• Often provided as a highly optimized library
10.6 - Decimation in Time (DIT) FFT

• Can rearrange DFT formula in 2 halves:
10.6 - Decimation in Time (DIT) FFT - contd.



  • We can evaluate an N-pt DFT as two N/2-pt DFTs
                    (plus a few mults/adds)

  • But if DFTN{•} ~ O(N2)
    then DFTN/2{•} ~ O((N/2)2) = 1/4 O(N2)

  • Total computation ~ 2 * 1/4 O(N2)
    = 1/2 the computation (+ε) of direct DFT
10.6.1 - One-Stage DIT Flowgraph
10.6.2 - Multiple DIT Stages
• If decomposing one DFTN into two smaller DFTN/2’s speeds things
  up...
    p
• Why not further divide into DFTN/4’s ?

• ie
  i.e.

• so have




• Similarly,
10.6.2 - Multiple DIT Stages – contd.
Two-Stage DIT Flowgraph
10.6.2 - Multi-stage DIT FFT – contd.

• Can keep doing this until we get down to 2-pt DFTs:




      x(0)
      x(1)
10.7 - FFT Implementation Details
• Basic Butterfly at any stage




• Can be simplified to
10. 8 - 8-pt DIT FFT Flowgraph

000
001
0 0
010
                                            2
011                                        W
                                             8
100
101
110
111                                           2
                                             W
                                              8

      • -1’s absorbed into summation nodes
         0
      • WN disappears

      • Twiddle factor step=N/2 j   (stage order),   j≠1
10.9 - FFT Complexity

                                    N
• Total no. of butterflies = 
  Total no. of butterflies            log 2 N
                                        g
                                    2                  No of stages
                                                           f t


• As each butterfly gives one complex multiplication and 2
  As each butterfly gives one complex multiplication and 2 
  complex addition
• So, FFT has complex multiplications of
  So, FFT has complex multiplications of 
                 N
            Ο(     log 2 N) instead of Ο(N 2 ) in case of DFT
                 2

  and complex additions  of
          Ο(Nl 2 N) i
           (Nlog    instead of Ο(N(N - 1)) i case of DFT
                          d f              in      f
10.10 - Inverse FFT

•


• Thus



                                    Steps f calculating IFFT:
                                    St    for l l ti IFFT
                                    1. Take the conjugate of the freq.
•Hence, Use FFT to calculate IFFT      Samples
                                    2. Calculate FFT of these samples
                                    3. Divide the output by N
                                    4.
                                    4 Take the conjugate of the output

Dsp U Lec10 DFT And FFT

  • 1.
    EC533: Digital Signal Processing 5 l l Lecture 10 DFT and FFT
  • 2.
    10.1 - FrequencyDomain Vs. Time Domain CTFS DTFS CTFT DTFT
  • 3.
    10.2 - DiscreteFourier Transform (DFT) • A finite or periodic sequence has only N unique values, f d h l l x[n] for 0 ≤ n p N • S t Spectrum is completely defined by N distinct frequency i l t l d fi d b di ti t f samples • Divide 0..2π into N equal steps {ω(k)} = 2πk/N 0 2π steps, • Uniform sampling of DTFT spectrum:
  • 4.
    10.2 – DFT– contd. Hence, Where, i.e, 1/Nth of a revolution Twiddle Factor Properties of the Twiddle Factor: k+N k j W N = W N periodicity N k+ k W N 2 = − W N -1 1 2 W N = W N 2 -j N=4
  • 5.
    DFT Example Find theDFT for the 4 points time sequence {1 0 0 1}, fs=8KHz 3 3 X (0) = ∑ x(nT ) e − j 0 = ∑ x(nT ) at k=0, n =0 n =0 = x(0) + x(T ) + x(2T ) + x(3T ) = 1+ 0 + 0 +1 = 2 3 at k 1, k=1, X (1) = ∑ x(nT ) e − jΩnT , Ω = 2π n =0 NT 3 − j 2πn X (1) = ∑ x(nT ) e N n =0 = 1 + 0 + 0 + 1e − j 2π 3 4 = 1 + e − j 3π 4 ⎛ 3π ⎞ ⎛ 3π ⎞ = 1 + cos⎜ ⎟ − j sin ⎜ ⎟ = 1+ j ⎝ 2 ⎠ ⎝ 2 ⎠
  • 6.
    DFT Example –contd. 3 3 − j 2π 2 n at k=2, X (2) = ∑ x(nT ) e − j 2 ΩnT = ∑ x(nT ) e N n =0 n =0 3 − j 4πn = ∑ x(nT ) e N n =0 = 1 + 0 + 0 + 1e − j 4π 3 4 = 1 + e − j 3π = 1 − 1 = 0 3 − j 2π 3 n at k=3, X (3) = ∑ x(nT ) e N n =0 = 1 + 0 + 0 + 1e − j 9π 2 = 1 − j X (k ) = {2, 1 + j , 0, 1 − j}
  • 7.
    DFT Example –contd. x(nT) |X(k)| 1 2 √2 x x x 0 125 250 375 t(µs) 0 12.57 25.14 37.71 50.28 kΩ(X 103 rad/s) φ(k)(⁰) x(n) ={ , 0, 0,1 1 } +45 Phase Angle  indeterminate 37.71 0 x x 12.57 25.14 50.28 kΩ(X 103 rad/s) ‐45 X(k) ={2,1+ j, 0,1− j}
  • 8.
    10.3 - InverseDiscrete Fourier Transform ( (IDFT)) • • Ch k Check
  • 9.
    10.4 - DFTComputational Complexity The DFT has: • (N complex multiplies + N-1 complex adds per point) x N points (k = 0..N-1) N2 complex multiplies and N(N 1) complex additions N(N-1) where cpx mult: (a+jb)(c+jd) = ac - bd + j(ad+bc)= 4 real mults + 2 real adds cpx add = 2 real adds • Total: 4N2 real mults, 4N2-2N real adds •Looking at DFT Matrix, lots of repeated structure are found; means opportunities for efficient t iti f ffi i t algorithm to be used to reduce the DFT complexity
  • 10.
    10.5 – FastFourier Transform (FFT) • Reduce complexity of DFT from O(N2) to O(N log2N) O(N·log • Grows more slowly with larger N • Works by decomposing large DFT into several stages of smaller DFTs • Often provided as a highly optimized library
  • 11.
    10.6 - Decimationin Time (DIT) FFT • Can rearrange DFT formula in 2 halves:
  • 12.
    10.6 - Decimationin Time (DIT) FFT - contd. • We can evaluate an N-pt DFT as two N/2-pt DFTs (plus a few mults/adds) • But if DFTN{•} ~ O(N2) then DFTN/2{•} ~ O((N/2)2) = 1/4 O(N2) • Total computation ~ 2 * 1/4 O(N2) = 1/2 the computation (+ε) of direct DFT
  • 13.
    10.6.1 - One-StageDIT Flowgraph
  • 14.
    10.6.2 - MultipleDIT Stages • If decomposing one DFTN into two smaller DFTN/2’s speeds things up... p • Why not further divide into DFTN/4’s ? • ie i.e. • so have • Similarly,
  • 15.
    10.6.2 - MultipleDIT Stages – contd. Two-Stage DIT Flowgraph
  • 16.
    10.6.2 - Multi-stageDIT FFT – contd. • Can keep doing this until we get down to 2-pt DFTs: x(0) x(1)
  • 17.
    10.7 - FFTImplementation Details • Basic Butterfly at any stage • Can be simplified to
  • 18.
    10. 8 -8-pt DIT FFT Flowgraph 000 001 0 0 010 2 011 W 8 100 101 110 111 2 W 8 • -1’s absorbed into summation nodes 0 • WN disappears • Twiddle factor step=N/2 j (stage order), j≠1
  • 19.
    10.9 - FFTComplexity N • Total no. of butterflies =  Total no. of butterflies  log 2 N g 2 No of stages f t • As each butterfly gives one complex multiplication and 2 As each butterfly gives one complex multiplication and 2  complex addition • So, FFT has complex multiplications of So, FFT has complex multiplications of  N Ο( log 2 N) instead of Ο(N 2 ) in case of DFT 2 and complex additions  of Ο(Nl 2 N) i (Nlog instead of Ο(N(N - 1)) i case of DFT d f in f
  • 20.
    10.10 - InverseFFT • • Thus Steps f calculating IFFT: St for l l ti IFFT 1. Take the conjugate of the freq. •Hence, Use FFT to calculate IFFT Samples 2. Calculate FFT of these samples 3. Divide the output by N 4. 4 Take the conjugate of the output