Survey
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
* Your assessment is very important for improving the workof artificial intelligence, which forms the content of this project
Basis (linear algebra) wikipedia , lookup
Bra–ket notation wikipedia , lookup
Horner's method wikipedia , lookup
Polynomial greatest common divisor wikipedia , lookup
Matrix calculus wikipedia , lookup
Eisenstein's criterion wikipedia , lookup
Root of unity wikipedia , lookup
Cayley–Hamilton theorem wikipedia , lookup
Factorization wikipedia , lookup
Oscillator representation wikipedia , lookup
Fundamental theorem of algebra wikipedia , lookup
Factorization of polynomials over finite fields wikipedia , lookup
The Fourier series A large class of phenomena can be described as periodic in nature: waves, sounds, light, radio, water waves etc. It is natural to attempt to describe these phenomena by means of expansions in periodic functions. The Fourier series is an expansion of a function in terms of trigonometric sines and cosines: Suppose f(x) is defined over a finite range –L x L, i.e. f(x) is periodic with period 2L. The trigonometric functions are periodic with period 2L = 2 , so it is natural to expand these functions in terms of trigonometric functions with an argument [(x / 2L) 2 n], n : 1 n n f ( x) a0 am cos( x) bm sin( x) 2 L L m 1 m 1 1 L n 1 L n an f x cos( x)dx bn f x sin( x)dx L L L L L L Example for Fourier series Let’s take the following function: f(x) = { |x| ; - 8 <= x <= 8 f(x 16n) , n ; otherwise - f(x) is even in x while sin(x) is odd => bn’s must be zero. 2 L n 2L 4L an x cos( x)dx 2 2 [cos( n ) 1] 2 2 L 0 L n n ; if n is odd 2 L n 2L an x cos( x)dx 2 2 [cos( n ) 1] 0 0 L L n ; if n is even => the expansion is : L 8 f ( x) (1 2 2 1 n cos( x)) 2 L n odd n Example for Fourier series(2) source: f(x) =|x|, -8 <= x <= 8 n= 1 L 8 f ( x) (1 2 2 n= 5 1 n cos( x)) 2 L n odd n n= 3 y Successive approximations of f(x) f(x) x Complex version of the Fourier expansion ei cos i sin The Euler identity: The inverse equations: sin 1 2i ( e i e i ) , cos 12 (ei e i ) Using the formulas above and some properties of exponential function, the Fourier series can also be written as an expansion in terms of complex exponentials as: 1 f ( x) c e n n ( in / L ) x 1 L i ( n / L ) x c f ( x ) e dx , n 2 L L Note: you can read the full explanation here. The Fourier transform n Let’s define w = L => dw L . The Fourier transform is a generalization of the complex Fourier series in the limit as L on the formula we got on the previous slide: 1 f ( x) c e n 2 ( in / L ) x n 1 f ( x) 2 ^ 1 L i ( n / L ) x c f ( x ) e dx n , 2L L f ( x)e iwx dx The inverse Fourier transform By placing the formula transform formula: 1 f ( x) c e n 3 2 in the formula 1 L i ( n / L ) x c f ( x ) e dx , n 2 L L ( in / L ) x n 1 f ( x) 2 1 we get the inverse Fourier ^ f ( x)eiwx dw Note: you can read the full explanation here The discrete Fourier transform Motivation: computer applications of the Fourier transform require that all of the definitions and properties of Fourier transforms be translated into analogous statements appropriate to functions represented by a discrete set of sampling points rather than by continuous functions. Let f(x) be a function. Let {fk = f(xk)} be a set of N function values, xk kx k = 0, 1, …, N-1. Let x be the separation of the equidistant sampling points. Assumption: N is even. The discrete Fourier transform is: ^ N f n (e k 0 2i / N nk ) f k , n 0,1,..., N 1 The inverse discrete transform is: 1 N 2i / N nk ^ fk (e ) f n , k 0,1,..., N 1 N 1 n 0 The discrete Fourier transform(2) Let’s examine more closely the formula of the discrete Fourier transform: ^ N f n (e 2i / N ) nk f k , n 0,1,..., N 1 k 0 wN 2i N (it’s called n-th root of unity), so the We know that formula above can be rewritten as: ^ N f n wn f k , n 0,1,..., N 1 k 0 k ^ ^ f n f n ( wn ) Usage of the Fast Fourier Transform - motivation Let n 1 n 1 k 0 k 0 A( x) ak x k , B( x) bk x k be two polynomials. We want to multiply them: C(x) = A(x)*B(x). Two ways to do this: 1. C ( x) 2 n2 j j where c c x ak b j k j j , j 0 k 0 - takes time ( n 2 ) 2. (a) calculate A(x) and B(x) values in 2n-1 distinct points x0, …, x2n-2; we get two vectors {(x0, y0),…,(x2n-2, y2n-2)}, {(x0,z0),…,(x2n-2, z 2n-2)}; (b) multiply these vectors: {(x0, y0 z0),…,(x2n-2, y2n-2 z 2n-2)} (c) calculate the polynomial C(x) that passes through the result vector (interpolation) - takes time ( n log n) if use FFT Uniqueness of C(x) Theorem1: for any set {(x0, y0),…,(xn-\, yn-1)} on n distinct points there is a unique polynomial C(x) with degree less than n such that yi = C(xi) for i = 0,1,…, n-1. n 1 Proof: we can write yi = C(xi) = ck xi for i = 0,1,…, n-1 as matrices multiplication: k k 0 c0 y0 c1 y1 * ... = ... cn-1 yn-1 The matrix V(x0 ,..., xn-\ ) is called a Vandermonde matrix. Since all x0 ,..., xn-\ are distinct, a discriminate of V isn’t zero, so it is reversible. => we can calculate ci = V (x0 ,..., xn-\ ) -1 yi . Discrete FFT and FFTinverse We will use FFT to execute step (a) and FFTinv to execute step (c). Let C ( x) n 1 c x k 0 k k be a polynomial. We want to execute a step (a): calculate C(x) in n distinct points x0, …, xn-1. FFT uses special n points – wn0, wn1 , wn2 , …, wnn-1. wn is called the n-th (complex) root of unity. That means that wnn = 1. Properties of n-th root of unity Let’s examine some properties of wn : 1. There are exactly n n-th roots of unity: wn0, wn1 , wn2 , …, wnn-1. 2i / n Each one of them can be presented as e wn is called the principal n-th root of unity. . 2. The inverse of wn is wn-1 = wnn-1: wn * wn-1 = wn0 = 1; wn * wnn-1 = wnn = 1. 3. wdndk = wnk : wdndk = (e 2i / dn ) dk= (e 2i / n ) k = wnk . 4. wnn/2 = w2 = -1 : wnn/2 = w(n/2)*2n/2 = (by property 3) w2 = e 2i / 2 = -1. Properties of n-th root of unity(2) 5. If n > 0 and n is even => (wnk ) 2 = wn/2k , k = 0, 1, …, n–1: . (wnk ) 2 = (e 2i / n ) 2 k = (e 2i / n / 2 ) k = wn/2k . . (wnk+n/2 ) 2 = wn2k+n = wn2k wnn = wn2k = (wnk ) 2 = wn/2k . 6. : . geometry series formula DFFT preview Let pc ( x) n 1 c x k 0 k k be a polynomial. We want to execute a step (a): calculate pc(x) in wn0, wn1 , wn2 , …, wnn-1. Observation: Let c (c0 , c1 ,..., cn1 ) be an n-tuple of the coefficients of pc(x). Assume that n is power of 2 (if it isn’t, we force it to be by adding 0’s). Let a (c0 , c2 ,..., cn 2 ) and b (c1 , c3 ,..., cn1 ) => pc ( x) p a ( x 2 ) xpb ( x 2 ) , where p a is the polynomial that is defined by the vector a, and p b is the polynomial that is defined by the vector b. => pc ( wni ) p a ( wn2i ) wni p b ( wn2i ) Let t = n/2 => wnt = wnn/2 = -1 . => for i < n/2: pc ( wni ) p a ( wn2i ) wni p b ( wn2i ) for i >= n/2: pc ( wni ) p a ( wn2i ) wnj t p b ( wn2i ) p a ( wn2i ) wnj p b ( wn2i ) DFFT algorithm DFFT ( c (c0 , c1 ,..., cn1 ) , wn) : // n is a power of 2 and wnn/2 = -1 // array C[0, …, n – 1] // for the answer if n = = 1 then C[0] c[0] else t n/2 arrays a, b, A, B [0,…,t – 1] // intermediate arrays for i 0 to t – 1 do: a[i] c[2i] b[i] c[2i + 1] // recursive Fourier transform computation A DFFT (a, wn2 ) B DFFT (b, wn2 ) // Fourier transform computation of the vector c for i 0 to t – 1 do: temp = wni C[i] A[i] + temp * B[i] C[t + i] A[i] – temp * B[i] temp temp * wn return C // return the answer DFFT algorithm - example Let n = 8 and c = (255, 8, 0, 226, 37, 240, 3, 0). Let F257 be a finite field => w8 = 4 (48 mod 257 = 1). 1) a = (255, 0, 37, 3), b = (8, 226, 240, 0) 2) recursive call with t = 8 / 2 = 4 and w82 = 42 = 16: A = [38, 170, 32, 9], B = [217, 43, 22, 7] 3) C[0] 38 + 217 = 255 C[1] 170 + 43* w8 = 85 C[2] 32 + 22 * w82= 127 C[3] 9 + 7 * w83 = 200 C[4] 38 – 217 C[5] 170 – 43* w8 = 255 C[6] 32 – 22 * w82= 194 C[7] 9 – 7 * w83 = 75 4) The final result is: C = (255, 85, 127, 200, 78, 255, 194, 75). DFFT algorithm – execution time We have log(n) recursive calls. For each call: - n multiplications w8i+1 w8i * w8 - n multiplications of const * w8i , i = 0, 1, …, n / 2 - 1 - n / 2 additions, n / 2 subtractions => (n) arithmetical instructions, each costs => DFFT algorithm execution time is (1) (n log n) DFFTinv algorithm - preview We want to execute a step (c) calculate the polynomial C(x) that passes through the result vector (interpolation) n 1 We can write yi = C(wni) = ck wn for i = 0,1,…, n-1 as matrices multiplication: ik k 0 c0 y0 c1 y1 * ... = ... cn-1 yn-1 The matrix Vij(x0 ,..., xn-\ ) is called a Vandermonde matrix. Since all x0 ,..., xn-\ are distinct, a discriminate of Vij isn’t zero, so it is reversible. => we can calculate ci = Vij (x0 ,..., xn-\ ) -1 yi . DFFTinv algorithm – preview(2) Theorem: let Vij (x0 ,..., xn-\ ) be the matrix as above. Then the inverse matrix of Vij is Vij-1 = n-1 wn-ij . Proof: we already saw that Vij-1 exists. n 1 Vij * Vij-1 = V V k 0 n 1 ik kj n 1 wn(i j ) k k 0 i. if i = j, then wn(i - j)k = wn0 = 1, and so n n 1 ii. else, then => 1 n 1 1 n * n 1 k 0 n 1 wn(i j ) k n 1 * 0 0 (by property 6) k 0 So we get that Vij * Vij-1 = In . DFFTinv algorithm DFFTinv (C[0, …, n – 1] , wn) : // n is a power of 2 and wnn/2 = -1 // array c[0, …, n – 1] // for the answer c DFFT (C[0, …, n – 1] , wnn-1 ) // remember that wn-1 = wnn-1 for i 0 to n – 1 do: c[i] n-1* c[i] return c // return the answer DFFTinv algorithm - example Let n = 8 and C = (255, 85, 127, 200, 78, 255, 194, 75). Let F257 be a finite field => w8 = 4 (48 mod 257 = 1). 1) w8-1 = w87 = 193. 2) calculate DFFT(C, 193): c = [241, 64, 0, 9, 39, 121, 24, 0] 3) multiply c by n-1 = 225 (225 * 8 mod 257 = 1) 4) The final result is: c = (255, 8, 0, 226, 37, 240, 3, 0). DFFTinv algorithm – execution time DFFT takes (n log n) time . n multiplications c[i] n-1 * c[i] => (n) arithmetical instructions, each costs => DFFTinv algorithm execution time is (1) (n log n)