Discrete Fourier Transform.rtf

Embed Size (px)

Citation preview

  • 7/30/2019 Discrete Fourier Transform.rtf

    1/15

    Discrete Fourier Transform of

    Real Sequence

    Motivation:

    Consider a finite duration

    signal )(tg of duration T

    sampled at a uniform

    rate st

    such that

    sNtT =

    where N is an integer 0>NThen the Fourier transform of signal is given by

    =T

    ftj dtetgfG0

    2)()(

    If we now evaluate the above integral by trapezoidalrule of integration after padding two zeros at the

    extremity on either side [signal is zero there infact], we

    obtain the following expressions.

    =

    =1

    0

    2)()(

    N

    n

    fntj

    sssentgtfG

    (1)

    The inverse DFT (IDFT) which is used to reconstruct the signal is given by:

    Fig (1)

    = dfefGtg ftj 2)()((2)

    If, from equation (1) we could compute complete frequency spectrum i.e. ffG ),( then (2) would imply that we can obtain Tttg 0)( . The fallacy

    in the above statement is quite obvious as we have only finite samples and the curveconnecting any 2-samples can be defined plausibly in infinitely many ways (see fig (2)).

    This suggests that from (1), we should be able to derive only limited amount of frequency

    domain information.

    Since, we have N-data points [real] and)( fG a complex number contains both

    magnitude and phase angle information in thefrequency domain (2-units of information), it is

    reasonable to expect that we should be in a

    position to predict atmost 2

    N

    transforms )( fG

    for original signal.

  • 7/30/2019 Discrete Fourier Transform.rtf

    2/15

    Now, letN

    f

    NtTf s

    s

    ===11

    0

    andN

    mf

    Nt

    mmff s

    s

    === 0(3)

    then substituting (3) in (1), we getFig (2)3- different fits to the curve

    =

    =1

    0

    2

    )()(N

    n

    ntNt

    mj

    sss

    ssentgt

    N

    mfG

    =

    =1

    0

    2

    )(N

    n

    N

    mnj

    ss entgt

    Note that our choice of frequency is such that the exponential term in (1) is

    independent of st . The intuition for choosing such f is that, basically we are attemptinga transform on discrete samples which may (or) may not have a corresponding analogparent signal. This suggests to us the following discrete version of Fourier transform for

    a discrete sequence{ }110 ,......,, Nxxx

    =

    =1

    0

    2

    )()(N

    n

    N

    mnj

    enxmX

    (4)Our next job should be to come up with inverse transformation. Assuming for N-samples

    110 .,........., Nxxx that (4) would be a transformation and if (2) defines IFT in continuous

    domain, in the discrete domain, we can hypothesize following inverse transform.

    =

    =1

    0

    2)(1)(

    N

    m

    Nmnj

    emXK

    nx

    (5)

    Where K is a suitable scaling factor.

    Our next job is to verify that (4) and (5) indeed define a transformation pair

    Substituting (4) in (5), we get following expression for right hand side of (5)

    Right hand side

    N

    mnjN

    m

    N

    k

    N

    mkj

    eekxK

    21

    0

    1

    0

    2

    )(1

    =

    =

    =

    (6)

    [Note the use of dummy subscript k]

    Let us work this expression out in a long hand fashion; for compactness we use notation)(nxxn =

  • 7/30/2019 Discrete Fourier Transform.rtf

    3/15

    2

    0 1 1

    2 2 2 2 ( 1) 2

    0 1 1

    2 ( 1) 2 ( 1) 2 ( 1) 2 ( 1) 2 ( 1)

    0 1 1

    0

    11

    1

    N

    j n j j n j N j n

    N N N N NN

    j N n j N j N n j N j N n

    N N N N NN

    x x x m

    x e x e e x e e mRHS

    K

    x e x e e x e e m N

    + + + = + + + + ==+ +

    + + + + =

    In the above expression, for the first row m is set to zero, for the second row it is set to

    one and for the last row 1= Nm

    Now, grouping terms column wise, we get

    ++++

    +++++++=

    )1(

    )1()1(1

    )1()1(2

    )1(2

    1

    )1)(1(2)1(2

    1

    )1(22

    0

    NnN

    NjNn

    N

    j

    N

    N

    nNj

    N

    nj

    N

    nNj

    N

    nj

    eex

    eexeex

    KRHS

    =

    =

    =

    1

    0

    1

    0

    )(2

    1 N

    k

    N

    m

    knN

    mj

    k exK

    Note that this jugglery shows that we can interchange the summation order. One order

    indicates row wise and another column wise summation

    i.e.

    =

    =

    =

    1

    0

    1

    0

    )(2

    1 N

    k

    N

    m

    knN

    mj

    kex

    KRHS

    (7)

    Our primary task now is to evaluate the expression.

    =

    1

    0

    )(2N

    m

    knN

    mj

    e

    We now claim that

    ;

    ;

    0

    1

    0

    )(2

    nkif

    nkifNe

    N

    m

    mknN

    j

    =

    ==

    =

    =

    Proof: - for nk = meemj

    mkn

    N

    j

    ==

    1.0.

    )(2

    Hence, the first case is obvious.

    Now, if nk , let1

    knk = )1)((

    21)(

    20)(

    21

    0

    )(2

    =

    +++=

    NknN

    jkn

    N

    jkn

    N

    jN

    m

    knN

    mj

    eeee

  • 7/30/2019 Discrete Fourier Transform.rtf

    4/15

    Now,

    ( )mkm

    kN

    jmk

    N

    j

    aee1

    11 22

    =

    =

    whereN

    j

    ea

    2

    =1

    11

    1 1

    22 2 21 1( )

    2 20 0

    1 10

    1 1

    j k Nmj m j kNN Nn k j k

    N Nj j

    k km m N N

    e ee e

    e e

    = =

    = = = =

    if1k is integer, then 1

    12 =kje

    Note that we have used the following geometric series expression

    r

    raarara

    nn

    =+++ 1

    )1(........ 1

    Thus, RHS in (6) is equal to

    nx

    K

    N

    We see that equation (6) defines the inverse transformation if we choose K N= ;

    Thus, N-point DFT and IDFT for samples[ ]110 ,....., Nxxx are defined as follows.

    N

    mnjN

    m

    N

    n

    N

    nmj

    n

    emXN

    nx

    exmX

    21

    0

    1

    0

    2

    )(1

    )(

    )(

    =

    =

    =

    =

    Note that in general DFT and inverse DFT can be defined in many ways, each only

    differing in choice of constant 1C and 2CDFT IDFT

    i.e.

    =

    =1

    0

    2

    1)(N

    n

    N

    nmj

    nexCmX

    =

    =1

    0

    2

    2 )(N

    m

    N

    nmj

    n emXCx

    The constraint in choosing the constraints is that product NCC 121 =

    For Example, when

    NCC

    1,1 21 ==

    2

    1221 == CNC

    NC

    NC

    1121 ==

    Choice of NC

    21 =

    is commonly used in relaying because it simplifies phasor estimation.

    Phasor estimation will be discussed later.

  • 7/30/2019 Discrete Fourier Transform.rtf

    5/15

    We now discuss some important properties of DFT.

    Important Properties of DFT (Lecture 7)

    (1) Linearity: Let{ }

    110

    ,......,N

    xxxand

    { }110

    ,......,N

    yyybe two sets of discrete

    samples with corresponding DFTs given by )(mX and )(mY . Then DFT of

    sample set{ }111100 ..,,........., +++ NN yxyxyx is given by )()( mYmX +

    Proof:

    =

    =1

    0

    2

    )(N

    n

    N

    nmj

    n exmX

    ;

    =

    =1

    0

    2

    )(N

    n

    N

    nmj

    neymY

    =

    +=+1

    0

    2

    )()()(N

    n

    N

    mnj

    nn eyxmYmX

    (2) Periodicity : We have evaluated DFT at 1,........,1,0 = Nm . There after,

    ( )m N it shows periodicity. For example

    )()2()()2()()( mkNXmNXmNXmNXmNXmX +=+=+=+=+=

    Where k is an integer

    Proof:

    =

    +

    =+

    1

    0

    )(2

    )(

    N

    n

    mkN

    N

    nj

    nexmkNX

    =

    =1

    0

    2

    2N

    n

    knjN

    nmj

    n eex

    (8)

    Both k and n are integers. Hence 12 = knje ; Therefore from (8) we set

    )()(1

    0

    2

    mXexmkNxN

    n

    N

    nmj

    n ==+

    =

    (3) DFT symmetry: If the samples nx are real, then extracting in frequency domain

    )1()........0( NXX seems counter intuitive; because, from N bits of information

    in one domain (time), we are deriving 2N bits of information in frequency

    domain. This suggests that there is some redundancy in computation of

  • 7/30/2019 Discrete Fourier Transform.rtf

    6/15

    )1(....).........0( NXX . As per DFT symmetry property, following relationship

    holds.

    )()(* mXmNX = 1,.....,1,0 = Nm

    Proof:

    =

    =

    1

    0

    2

    )(N

    n

    Nnmj

    n exmX

    =

    =1

    0

    )(2

    )(N

    n

    mNN

    nj

    nexmNX

    =

    njN

    n

    N

    nmj

    n eex

    21

    0

    2

    =

    Since2

    1,j n

    e = integer follows that

    =

    =1

    0

    2

    )(N

    n

    N

    nmj

    n exmNX

    =

    =1

    0

    *

    2

    )(N

    n

    N

    nmj

    nex

    *1

    0

    2

    =

    =

    N

    n

    N

    nmj

    nex

    * *( ( )) ( )X m X m= =

    If the samples nx

    are real; then they contain atmost N bits of information. On

    the other hand, )(mX is a complex number and hence contains 2 bits of

    information. Thus, from sequence{ }110 ,.....,, Nxxx , if we derive

    { })1(),.......,1(),0( NXXX , it implies that from N-bit of information, we are

    derivingN2

    bits of information. This is counter intuitive. We should expect

    some relationship in the sequence { })1(),.......,1(),0( NXXX

    Thus, we conclude that

    )()( mXmNX =[Symmetry]

  • 7/30/2019 Discrete Fourier Transform.rtf

    7/15

    and )()( mXmNX = [Anti-symmetry]

    Thus, a typical DFT magnitude and phase plots appear as follows. ( )X m

    Fig (3)

    Fig (4)

    DFT phase shifting:-

    DFT shifting property states that, for a periodic sequence with periodicity N i.e.

    )()( lNmxmx += , l an integer, an offset in sequence manifests itself as a phase shift in

    the frequency domain. In other words, if we decide to sample x(n) starting at n equal to

    some integer K, as opposed to n=0, the DFT of those time shifted samples. )(mXshifted

    2

    shifted ( ) ( )j Km

    NX m e X m

    =

    Starting DFT with say

    this sample will lead

    to offset of 2

    Fig (5)

    +

    =

    =1 2

    )()(nk

    kn

    N

    nmj

    shifted ekxmX

  • 7/30/2019 Discrete Fourier Transform.rtf

    8/15

    Proof: By periodicity of samples, we have

    )0()( xNx =

    )1()1( xNx =+

    )1()1( =+ KxKNx

    =

    =1

    0

    2

    )(N

    n

    mN

    nj

    n exmX

    =

    =

    +=1 21

    0

    2 N

    Kn

    N

    nmj

    n

    K

    n

    N

    nmj

    n exex

    =

    =

    + +=1 21

    0

    2 N

    Kn

    N

    nmj

    n

    K

    n

    N

    nmj

    nN exex

    =+=

    =

    =

    +

    + 121

    21

    0

    )(2

    N

    NmjN

    Kn

    N

    nmj

    n

    K

    n

    N

    nNmj

    Nn eexex

    =

    +

    =

    +=1 21 2 N

    Kn

    N

    nmj

    n

    KN

    Nn

    N

    nmj

    n exex

    +

    =

    =1 2

    )(KN

    Kn

    mN

    nj

    nexmX

    (8)

    Now to compute shiftedX , let us map the samples 11 ,........,, ++ KNKK xxx to

    110 .........,, Nyyy .

    Apply DFT to sequence y

    =

    =1

    0

    2

    )(N

    n

    N

    nmj

    nshifted eymX

    =

    +=1

    0

    2N

    n

    mN

    nj

    nK ex

    =

    +

    +=1

    0

    )(22 N

    n

    KnN

    mj

    nKN

    mKj

    exe

    +

    =

    =1 22 KN

    Kn

    NN

    nj

    nN

    nKj

    exe

  • 7/30/2019 Discrete Fourier Transform.rtf

    9/15

    )(

    2

    mXe nN

    nKj

    =(from (8))

    Review Questions:

    1. Compute 8 pt DFT ( 0, 7)m = of the following sequence. (0) 0.35x =

    (1) 0.33x = (2) 0.68x = (3) 1.07x = (4) 0.40x = (5) 1.12x = (6) 1.35x =

    (7) 0.35x = Hence, illustrate the various DFT properties discussed in this

    lecture.

    2. By using inverse DFT, show that discrete samples can be recovered with

    knowledge of (0), ........ (7)x x

    3. Calculate the N pt DFT of rectangular function given by, 0 1 1.......... 1Nx x x = = = .

    Verify the various DFT properties for this signal.

    Computation of Phasor from DFT: (Lecture 8)

    Consider a sinusoidal input signal of frequency 0

    , given by

    )sin(2)( 0 += tXtx (9)

    This signal is conveniently represented by a phasorX

    (cos sin )jX Xe X j = = + (10)

    Assuming that ( )tx is sampled N times per cycle s.t 0 sT Nt= of the 50Hz waveform,

    0 50f = to produce the sample set { kx }, Then,

    )

    2sin(2

    += k

    NXxk

    (11)

    Hence, An integer m, in the transform domain corresponds to frequency mF 0. Thus,

    choice m=1 corresponds to extract the fundamental frequency component. The discrete

    Fourier Transform of kx

    contains a fundamental frequency component given by sF N

    =

    =

    1

    0

    2

    1

    2 N

    k

    kN

    j

    kexN

    X

    (12)

  • 7/30/2019 Discrete Fourier Transform.rtf

    10/15

    =

    =

    =1

    0

    1

    0

    )2

    sin(2

    )2

    cos(2 N

    k

    N

    k

    kk kN

    xN

    jkN

    xN

    scjXX =

    (13)

    where

    ==

    1

    0

    )2cos(2N

    k

    kc kN

    xN

    X

    (14)

    =

    =1

    0

    )2

    sin(2 N

    k

    ks kN

    xN

    X

    (15)

    Substituting for kx

    from (11) in (12) and (13) it can be shown that for a sinusoidal input

    signal given by (9)

    cos2sin2 XXXX sc == (16)

    From equation (10), (13) and (14) it follows that

    ( )1

    1 1

    2 2s cX jX X jX= = +

    (17)

    When the input signal contains other frequency components as well, the phasor

    calculated by equation (17) is a filtered fundamental frequency phasor. It is presumed

    here that the input signal must be band-limited to satisfy the Nyquist Criterion, to avoid

    errors due to aliasing affects.

    Effect on phasor computation

    In relaying applications during steady state we will be working with moving

    window, such that each window having most recent N-samples. Letw

    cX andw

    sX indicate

    cX and sX

    component of DFT forthw window (window no. bery equal to 1st sample

    no.). Then, by DFT define

    1

    0

    2 2cosNw

    c k w

    k

    X x kN N

    +

    =

    = 1

    0

    2 2 22 sin cos

    N

    k

    X k w kN N N

    =

    = + +

  • 7/30/2019 Discrete Fourier Transform.rtf

    11/15

    1

    0

    2 4 2 2sin sin

    N

    k

    Xk w w

    N N N N

    =

    = + + + +

    2 20 sin

    XN w

    N N

    = + +

    22 sinX w

    N

    = +

    Similarly,

    1

    0

    2 2sin

    Nw

    k w

    k

    sX x kN N

    +=

    = 1

    0

    2 2 22 sin sin

    N

    k

    X k w kN N N

    =

    = + +

    1

    0

    2 2 4 2cos cos

    N

    k

    Xw k w

    N N N N

    =

    = + + +

    2 2cos

    XNw

    N N

    = +

    22 cosX w

    N

    = +

    Hence, DFT estimated atth

    w window for (m = 1) is given by

    2 2(1) 2 sin cos

    w w w

    c sX X jX X w j wN N

    = = + +

    Hence, phasor estimate atth

    w window

    ( )1 2 2

    cos sin2

    w w w

    s cX X jX X w j wN N

    = + = + + +

    2j w

    NX e

    + =

    2j w

    j NX e e

    =

    Thus, we see that with moving window, the phasor estimate rotates at a speed of

    2j

    Ne

    per

    window. This rotate in phasor during computation can be directing derived from DFT phase shifting properties.

    This suggests that

    N

    j

    K ejXN

    KX

    2

    1 )1(2

    )(

    =

    phasor estimated forthn window rotates at

    speed N2

    per sample.

  • 7/30/2019 Discrete Fourier Transform.rtf

    12/15

    In the computation of phasor, we would not like this phasor shift to occur due to DFT

    phase shifting. This can be avoided if we use equation (8) for computing DFT. Replace k

    by w , the window number, we get

    21

    2( )

    j kmk w

    Nk c s

    k w

    X m x e X jXN

    +

    == =

    Where

    1 2( ) cos

    N ww

    c k

    k w

    kmX m x

    N

    +

    =

    = (9)

    12 2( ) sin

    N ww

    s k

    k w

    kmX m x

    N N

    +

    =

    = (10)

    Example: let )sin( tx =

    With sampling rate of N-samples per cycle we have N

    Tts

    0=;

    )2

    sin()2

    sin( 0

    0 N

    n

    N

    Tn

    Txn

    ==

    Substituting kx

    in equation (9), we get

    12 2 1 2 22sin cos

    2

    N ww

    c

    k w

    X k kmX

    N N N

    +

    =

    = +

    12 2 1 2 2sin (1 ) sin (1 )

    2

    N w

    k w

    X k km m

    N N N

    +

    =

    = + + + +

    2 sinX =

    12 2 1 2 22sin sin

    2

    N ww

    k w

    s

    X k kmX

    N N N

    +

    =

    = +

    12 2 1 2 2cos( (1 ) ) cos( (1 ) ) 2 cos

    2

    N w

    k w

    X k km m X

    N N N

    +

    =

    = + + + =

    sin( )x t = +

    ( )1

    2

    ww w

    s sX X jX X= + =

    a

  • 7/30/2019 Discrete Fourier Transform.rtf

    13/15

    From equation (10) and (11), we have

    12 2( ) cos

    N ww

    c k

    k w

    kmX m x

    N N

    +

    =

    = and

    12 2( ) sin

    k N ww

    s k

    k w

    kmX m x

    N N

    = +

    =

    =

    . The computation forw

    cX can be visualized from the

    following pair wise multiplication and add sequence show in red in the figure -

    Now, to compute1( )wcX m

    +

    , we get one new sample. w Nx + and computation of

    1( )WcX m+

    is( )wcX m shown by pairing in green boundary. It is now obvious, that

    ( )12 2

    ( ) ( ) cos cosw w

    c c w N wX m X m x N w m x wmN N

    ++

    = + + . Since,

    ( )2 2 2

    cos cos 2 cosN w m m wm wmN N N

    + = + = for m an integer, we get

    ( )12

    ( ) ( ) cosw w

    c c w N wX m X m x x wmN

    ++

    = + -------- (12)

    Similarly, for sine component, we have

    1 2

    ( ) ( ) [ ]sin

    w w

    w N ws sX m X m x x wmN

    ++

    = + ----(13)

    Eqns. 12 and 13 provide a recursive update for DFT computation. The advantage of

    recursive form is that it reduces computation from 2-N multiply- add operation in normal

    DFT into additions and 2 multiplication is respectively.

    To begin with we will get( ) ( ) 0w ws sX m X m= = . When the first window is full populated

    with N-samples, we will correct values of( )cX m and

    ( )mX m . Afterwards, for a

    stationary phasor w N wx x+ = and hence, the DFT latches in the appropriate phasor.

    wx

    2 ( 2)cos

    w m

    N

    +

    2wx + 1w N

    x +

    2cos ( 1)N w m

    N

    +

    w Nx +

    2cos ( )N w m

    N

    +

    1( )wcX m+

    ( )wcX m

  • 7/30/2019 Discrete Fourier Transform.rtf

    14/15

    Half Cycle DFT Form for Phasor Estimation

    If our primary interest is to extract fundamental phasor component in the signal then, it

    can be verified that, restricting moving window to half a cycle does not alter the end

    result of eqn. (5) and (6) provided that N-now represents, number of samples per half-

    cycle. Now, the sample kx

    is given by

    2 sinkx kN

    = + . Thus, half cycle form of

    DFT phasor estimation is given by the following eqns.

    12cos

    N ww

    c k

    k w

    X x kN N

    +

    =

    = ----(14)

    1

    2 sinN w

    wk

    k w

    sX x kN N

    +

    ==

    ----(15)

    Advantage of half cycle algorithm is that the moving window latches on to the post fault

    signal in1

    2 a cycle. Thus, compared to full cycle version, it is twice as fast. A keen

    observer would have noticed that DFT based on moving window phasor estimation

    equations are identical to the full cycle and cycle fourier algorithms derived in lecture-x.

    Thus, the frequency response of fourier algorithms developed in lecture x applies to the

    DFT version. In particular, it is not surprising to see that harmonic rejection property of

    half cycle algorithm is inferior to its full cycle avatar. This is consistent with the Speed

    vs accuracy conflict, we have discussed earlier.

    Half Cycle Recursive DFT

    Recursive form of half cycle DFT can be derived in an analogous manner to full cycle

    DFT. Realizing that

    ( )cos cosN w m m mwN N

    + = +

    cos mod dmwN

    =

    ( )sin sinN w m m mwN N

    + = +

  • 7/30/2019 Discrete Fourier Transform.rtf

    15/15

    sin mod dmwN

    =

    we get following recursive update forms for fundamental phasor computation

    1 ( ) cosw wc c w N w

    X X x x wN

    +

    += +1 ( ) sinw w w N ws sX X x x w

    N

    ++= +

    Review Questions

    1. Consider, the following signal

    ( ) 10sin(2 50 30 )tx t= +

    a) Generate samples on this waveform using sampling frequency of samples

    per cycle.b) Apply full cycle and half cycle algorithms to estimate phasor from

    generalized DFT approach.

    c) Repeat (b) using recursive forms.

    2. Now consider the following signal.

    10( ) 10sin(2 50 30 ) 5sin(4 50 17.5 ) cos(6 50 75 )

    3x t t t t = + + + + +

    Repeat (2) and comment on the accuracy of full cycle and half cycle estimation

    methods.