ln 3.2 polynomials and fft

Upload: buggub

Post on 05-Apr-2018

221 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/2/2019 LN 3.2 Polynomials and FFT

    1/22

    FFT(Fast Fourier Transform)

  • 8/2/2019 LN 3.2 Polynomials and FFT

    2/22

    p2.

    Polynoms

  • 8/2/2019 LN 3.2 Polynomials and FFT

    3/22

    p3.

    Polynomial addit ion and mult iplicat ion1

    0 1 1

    1

    0 1 1

    2 2 3 2 2

    0 1 2 2 3 2 2

    0

    ( ) .....

    ( ) .....

    ( ) ( ) ( )

    = c .....

    n

    n

    n

    n

    n n

    n n

    j

    j k j k

    k

    A x a a x a x

    B x b b x b x

    C x A x B x

    c x c x c x c x

    c a b

    Coefficient representat ion:

    How to evaluat e A(x0)?

  • 8/2/2019 LN 3.2 Polynomials and FFT

    4/22

    p4.

    Different Representations

    Coefficient representation & Horners rule:

    Root & Scale representation:

    Point-value representation:

    0 0 0 1 0 2 0 2 0 1( ) ( ( ..... ( )...))

    (n)

    n nA x a x a x a x a x a

    0 0

    1 1 n-1 1 k

    A point-value representation of a polynomial A(x) of

    degree-bound n is a set of n point-value pairs {(x , ),

    (x , ),.....(x , )}, where y ( )n k

    y

    y y A x

    0 0 1 1 2n-1 2 1

    ' ' '

    0 0 1 1 2n-1 2 1

    ' ' '

    0 0 0 1 1 1 2n-1 2 1 2 1

    :{(x , ), (x , ),.....(x , )}

    :{(x , ), (x , ),.....(x , )}

    :{(x , ), (x , ),.....(x , )}

    n

    n

    n n

    A y y y

    B y y y

    C y y y y y y

  • 8/2/2019 LN 3.2 Polynomials and FFT

    5/22

    p5.

    Thm1

    0 0 1 1 n-1 1

    k

    For any set {(x , ), (x , ),.....(x , )} of n point-value

    pairs, there is a unique poly A(x) of degree n-1, such that

    y ( ) for k=0, 1,...., n-1

    n

    k

    y y y

    A x

    Pf:2 1

    0 0 0

    2 1

    1 1 1

    2 1

    1 1 1

    0 0

    1 1

    1 1

    1

    1if X = then

    1

    yy

    n

    n

    n

    n n n

    n n

    x x x

    x x x

    x x x

    aa

    X

    a y

    Vandermonde Matrix

  • 8/2/2019 LN 3.2 Polynomials and FFT

    6/22

    p6.

    n-point interpolation:

    Lagranges formula:

    0 0

    1 11

    1 1

    det( ) ( ) 0 if 's are distinct

    Thus, 's can be solved uniquely.

    y

    y

    k j

    k

    n

    k

    j

    j

    n

    a

    aX

    X x x x

    a

    a y

    1

    0

    ( )( )

    ( )

    jnj k

    k

    k k j

    j k

    x xA x y

    x x

  • 8/2/2019 LN 3.2 Polynomials and FFT

    7/22

    p7.

    Complexity Analysis in 3 representation

  • 8/2/2019 LN 3.2 Polynomials and FFT

    8/22

    p8.

    0 1 1

    0 1 1

    , ,....,

    , ,....,

    n

    n

    a a a

    b b b

    0 0

    2 2

    0 0

    2 2

    2 1 2 1

    2 2

    ( ), ( )

    ( ), ( )

    ,

    ( ), ( )

    n n

    n n

    n n

    n n

    A B

    A B

    A B

    0

    2

    0

    2

    2 1

    2

    ( )

    ( )

    ( )

    n

    n

    n

    n

    C

    C

    C

    0 1 2 2, ,...., nc c c

    Evalation

    ( log )n n

    2

    Ordinary Mult

    ( )n

    Pointwise Mult

    ( )n

    Interpolation

    ( log )n n

    Point-valuerep.

    Cof.rep.

  • 8/2/2019 LN 3.2 Polynomials and FFT

    9/22

    p9.

    Thm2

    The product of 2 polynomials of deg-bound n can

    be computed in time (nlog n), with both the input

    and output representation in coefficient form

    0

    ( )mod

    n 2 ik/n iu

    2 i/n

    0 1 2 1

    Complex roots of unity:

    1, e for k=0, 1, ..., n-1 e cos sin

    e , the principal n-th root of unity

    , , ,..

    =?, =

    .,

    1

    =

    n

    n

    n

    n n

    j k j k n

    n n

    n

    n

    n n

    n

    n

    u i u

    1 1nn

  • 8/2/2019 LN 3.2 Polynomials and FFT

    10/22

    p10.

    Lemm a 3 (Cancellat ion Lemma)

    n, k, d: non-negat ive int egers,

    Cor. 4 n: even posit ive integer

    dk k

    dn n

    Pf:

    2 / 2 / ( ) ( )dk i dn dk i n k k dn ne e

    / 2

    2 1n

    n

  • 8/2/2019 LN 3.2 Polynomials and FFT

    11/22

    p11.

    Lemma 5 (Halving lemma)

    n: even positive integer

    The squares of the n complex n-th roots of unity are n/2

    complex (n/2)th roots of unity.

    2 2

    / 2,

    / 2 2 2 2

    / 2

    / 2

    ( ) where {0}

    ( )

    and have the same squre

    k k k

    n n n

    k n k n k k

    n n n n

    k k n

    n n

    k Z

    Pf:

    Lemma 6 (Summat ion lemma)n-1 k

    n

    j=0

    , {0}, | , ( ) 0jn Z k Z n k Pf:

    k nn-1k n nn k k

    j=0 n n

    ( ) 1 ( ) 1( ) 0

    1 1

    n kj

  • 8/2/2019 LN 3.2 Polynomials and FFT

    12/22

    p12.

    DFT-1

    0 1 -1

    0

    -1

    0 1 -1

    0

    0 1 -1

    0 1 n-1

    Evaluate ( ) , ,....., ,

    Assume n is a power of 2

    Let , ,...., , and ( )

    , ,...., is the DFT of the coefficient

    vector a=

  • 8/2/2019 LN 3.2 Polynomials and FFT

    13/22

    p13.

    Interpolation at the complex roots of unity:

    02 1

    1

    2 4 2( 1)

    2

    1 2( 1)1

    1 1 1 1y

    1y

    y = 1

    1

    n

    n n n

    n

    n n n

    n nn n n n

    y

    0

    1

    2

    ( 1)( 1)1

    ,

    1

    , ( )

    n nn

    kj

    n n k j n

    n

    aa

    a

    a

    y V a V

    a V y

  • 8/2/2019 LN 3.2 Polynomials and FFT

    14/22

    p14.

    Thm 71

    ,, 0,1,....., 1, ( ) / kj

    n j k nj k n V n

    11 1 1

    , ' , , '

    0

    1'

    0

    1( ' )

    0

    , ( ) ( ) ( )

    1=

    1= -------(*)

    if j=j', then (*)=1, if j

    n

    n n n n n j j n j k n k j

    k

    nkj kj

    n n

    k

    nk j j

    n

    k

    V V I V V V V

    n

    n

    j', then by lemma 6, (*)=0

    -(n-1) < j'-j

  • 8/2/2019 LN 3.2 Polynomials and FFT

    15/22

    p15.

    FFT[0] 2 / 2 1

    0 2 4 2

    [1] 2 / 2 1

    1 3 5 1

    [0] [12 2]

    ( ) .....

    ( ) .....

    (*) ( ) ( ) ( )

    n

    n

    n

    n

    A x a a x a x a x

    A x a a x a x a x

    A x x A xA x

    [0] [1]

    0 2

    0 1

    1 2 1 2

    1

    1. evaluating ( ) and ( ) at

    Thus ev

    ( ) , ( ) ,....., (

    aluating A(x) at , ,....., reduce

    )

    2. combining the results according to (*)

    to

    n

    n n n

    n

    n n n

    A x A x

  • 8/2/2019 LN 3.2 Polynomials and FFT

    16/22

    p16.

  • 8/2/2019 LN 3.2 Polynomials and FFT

    17/22

    2 /

    n

    [0]

    0 2 2

    [1]

    1 3 1

    [0] [0]

    [1]

    Recursive-FFT(a)

    { n=length[a]; /* n: power of 2 */if n=1 the return a;

    ;

    =1

    a ( , ,....., );

    a ( , ,....., );

    y Recursive-FFT(a );

    y Recurs

    i n

    n

    n

    e

    a a a

    a a a

    [1]

    [0] [1]

    k k k

    [0] [1]

    k+n/2 k k

    n

    ive-FFT(a );

    for k=0 to (n/2 - 1) do

    {

    y y y ;y y y ;

    = ; }

    }

    ( ) 2 ( / 2) ( )

    = (nlog n)

    T n T n n

  • 8/2/2019 LN 3.2 Polynomials and FFT

    18/22

    p18.

  • 8/2/2019 LN 3.2 Polynomials and FFT

    19/22

    p19.

  • 8/2/2019 LN 3.2 Polynomials and FFT

    20/22

    Eff icient FFT im plement[0]

    ky

    [1]

    ky

    k

    n

    [0] [1]k

    k n k

    y y

    [0] [1]k

    k n k

    y y

    0 1 2 3 4 5 6 7( , , , , , , , )a a a a a a a a

    0 2 4 6( , , , )a a a a 1 3 5 7( , , , )a a a a

    2 6( , )a a 1 5( , )a a 3 7( , )a a0 4( , )a a

    3

    011

    a7

    111

    a5

    101

    a1

    001

    a6

    110

    a2

    010

    a4

    100

    a0

    000

    a

    s

    s-1

    s-1 s-1 s-1

    :

    for s=1 to (lg n) do

    for k=0 to n-1 by 2

    do combine the two 2 element DFT's in

    A[k..k+2 1] and A[k+2 ..k+2 1]

    Idea

    s sinto one 2 element DFT in A[k..k+2 1]

    [0 ]y

    [1]y

    Butterfly operation

  • 8/2/2019 LN 3.2 Polynomials and FFT

    21/22

    p21.

    s 2 /

    Iterative-FFT(a)

    { Bit-Reverse-Copy(a, A);

    n=length[a];

    for s=1 to (lg n) do

    { m=2 ; ; 1;

    for j=0 to (m/2 -1) do

    { for k=j to n-1 by m do

    i m

    m e

    { t = [ / 2];

    u = A[k];

    A[k]=u+t;

    A[k+m/2]=u-t; }

    }

    }

    }

    m

    A k m

    k

    Bit-Reverse-Copy(a,A)

    { n=length[a];

    for k=0 to n-1 do

    eg

    rev(011

    A[rev(k

    )=110, rev(00

    )] = a

    }

    1)=100

  • 8/2/2019 LN 3.2 Polynomials and FFT

    22/22

    0a

    1a

    2a

    4a

    3a

    5a

    6a

    7a

    0

    2

    0

    2

    0

    2

    0

    2

    0

    4

    1

    4

    0

    4

    1

    4

    0

    8

    1

    8

    3

    8

    2

    8

    0y

    1y

    2y

    4y

    3y

    5y

    6y

    7y

    FFT circuit

    8

    In general, depth: (lg n)

    size : (nlg n)

    n

    S= 1 S= 2 S= 3