Introduction to the FFT 1 Introduction Assume that we have a “signal” f(x) where x denotes “time”. We would like to represent f(x) as a linear combination of functions e2πiax (or, equivalently, sin(2πax) and cos(2πax)) of frequency a. Note that a˜ = 2πa is often called circular frequency. The frequency is the number of periods per unit interval, the circular frequency is the number of periods per interval of length 2π. Here we will always use frequencies and have 2π in all exponents. The resulting coefficients fˆ(a) describe “how strong frequency a is present in the signal” and are interesting in many applications. Often one wants to apply certain “filters” which are easier to apply in the “frequency domain”. So one first applies the Fourier transformation, then applies some other transformation, and then performs an inverse Fourier transformation. This approach is attractive since there exists a Fast Fourier Algorithm which takes only O(N log(N)) operations. This is in particular useful for convolution operations. We will always assume that the function f(x) is complex valued. In fact, the Fourier data fˆ will be complex valued even for a real valued function f(x). 2 Different cases of “Fourier transforms” There are four basic cases, depending on whether one has periodic or nonperodic data, or continuous or discrete data. In each case the correspondence of f and fˆ is stated for the case where f, fˆ are square integrable or summable. Note that Fourier transforms can also be defined for more general functions and even distributions. 2.1 Different conventions for definition of “Fourier transform” We will always put 2π in the exponent for consistency. Often Fourier transforms are defined without 2π in the exponent, giving factors involving 2π in the definition of the Fourier transform, its inverse, or 1 both. Also, often i is replaced with −i in the definitions. Furthermore, for discrete data factors of N or h occur which can be split up in different ways in the definition of the Fourier transform and its inverse. These different definitions are trivially related to each other. But one has to carefully check what the definition of “Fourier transform” is in a specific book or software package to make sure that one obtains correct results. 2.2 Periodic functions Let f : R → C be a 1-periodic function, i.e., f(x) = f(x + 1) for all x ∈ R. We want to represent this P ˆ 2πikx ˆ R 1 2 function in the form f(x) = fke using coefficients fk, k ∈ . If |f(x)| dx < ∞ there are k∈Z Z 0 ˆ P ˆ 2 unique coefficients (fk)k∈ with fk < ∞ and we have the following relations: Z k∈Z 1 Z ˆ −2πikx X ˆ 2πikx fk = f(x)e dx ⇐⇒ f(x) = fke Inversion (1) 0 k∈Z 1 Z 2 X ˆ 2 |f(x)| dx = fk Parseval (2) 0 k∈Z 1 1 Z ˆ q(x) = f(t)g(x − t) dt ⇐⇒ qˆk = fkgˆk Convolution (3) 0 ˆ P ˆ 2πikx Proof: Assume first that only finitely many fk are nonzero, and that f(x) = fke . Then the k∈Z result follows since 1 ( Z 1 if j = k e2πijxe−2πikxdx = (4) 2πi(j−k)x 2π c[e ]0 = 0 if j 6= k 0 This also implies Parseval’s identity (2). By using a density argument one can conclude that (1), (2) R 1 2 hold for all f with 0 |f(x)| dx < ∞. For the convolution formula we have 1 1 1 1−t Z Z Z Z −2πikx −2πiky −2πikt ˆ qˆk = f(t)g(x − t) dt e dx = f(t)g(y)e e dy dt = fkgˆk x=0 t=0 t=0 y=−t by changing the order of integration and a change of variables from x to y = x − t. 2 2.3 Discrete data of periodic functions j We consider the values f of a 1-periodic function at the points for j ∈ , i.e., we have f = f . j N Z j j+N We want to find a function f˜(x) of the form N−1 ˜ X ˆ 2πikx f(x) = fke (5) k=0 ˜ j which passes through the given points, i.e., f( n ) = fj, j = 0,...,N − 1. For given values (f0, . , fN−1) ˆ ˆ there exists a unique solution (f0,..., fN−1) and we have the following relations: N−1 N−1 1 X X fˆ = f e−2πikj/N ⇐⇒ f = fˆ e2πikj/N Inversion (6) k N j j k j=0 k=0 N−1 N−1 1 X 2 X ˆ 2 |fj| = fk Parseval (7) N j=0 k=0 N−1 1 X q = f g ⇐⇒ qˆ = fˆ gˆ Convolution (8) j N ` j−` k k k `=0 Proof of (6): Assume that the right equation in (6) holds. Then N−1 N−1 N−1 1 X X 1 X f e−2πikj/N = fˆ e2πi(`−k)j/N N j ` N j=0 `=0 j=0 1 PN−1 2πi(k−`)j/N PN−1 2πi(k−`)j/N 1 N If ` = k we have N j=0 fje = 1. If ` 6= k we have j=0 e = N (q − 1)/(q − 1) with q = e2πi(`−k)/N , hence qN = 1 and the sum is zero. 2 The function f˜(x) in (5) uses values of k in the range 0,...,N − 1. Usually one prefers to have k values in a symmetric range about zero since the frequency of eikx is |k|, and we would like to include all frequencies below a certain bound. It turns out that we can construct a different interpolating function ˆ ˆ 2πiNx j p˜(x) using (f0,..., fN−1). The key observation is that e = 1 at all points x = N . Hence we can divide some terms in (5) by e2πiNx and still have an interpolating function. 2 N−1 2πiNx N is odd: Here we divide the terms in (5) with k = 2 ,...,N − 1 by e and obtain (N−1)/2 N−1 (N−1)/2 X ˆ 2πikx X ˆ 2πi(k−N)x X ˆ 2πikx p˜(x) = fke + fke = fke (9) k=0 k=(N−1)/2+1 k=−(N−1)/2 ˆ ˆ if we define fk := fk+N for k < 0. In other words, we use the coefficients N−1 N−1 − 2 ... −1 0 1 ... 2 ˆ ˆ ˆ ˆ ˆ f(N−1)/2+1 ... fN−1 f0 f1 ... f(N−1)/2 Using eit = cos t + i sin t we can rewritep ˜(x) in the form (N−1)/2 X p˜(x) = a0 + ak cos(2πkx) + bk sin(2πkx) . k=1 If all fj are real, then ak, bk are real. N 2πiNx N is even: Here we divide the terms in (5) with k = 2 + 1,...,N − 1 by e , and for k = N/2 we ˆ 2πi(N/2)x 1 ˆ 2πi(N/2)x 1 ˆ 2πi(N/2)x −2πiNx replace fN/2e with 2 fN/2e + 2 fN/2e e yielding N/2−1 X ˆ 2πikx 1 ˆ −2πi(N/2)x −2πi(−N/2)x p˜(x) = fke + 2 fN/2 e + e (10) k=−N/2+1 ˆ ˆ if we define fk := fk+N for k < 0. In other words, we use the coefficients N N N N − 2 − 2 + 1 ... −1 0 1 ... 2 − 1 2 1 ˆ ˆ ˆ ˆ ˆ ˆ 1 ˆ 2 fN/2 fN/2+1 ... fN−1 f0 f1 ... fN/2−1 2 fN/2 Using eit = cos t + i sin t we can rewritep ˜(x) in the form N/2−1 X N p˜(x) = a0 + ak cos(2πkx) + bk sin(2πkx) + aN/2 cos(2π 2 x). (11) k=1 If all fj are real, then ak, bk are real. ˆ ˆ We can use (5) to define the Fourier coefficients (f0,..., fN−1), but we should use (9), (10) to interprete ˆ them in terms of frequencies: The coefficients fj with j close to 0 or N −1 correspond to “low frequency” ˆ components of f, the coefficients fj with j close to N/2 correspond to high frequency components. We 1 N 1 also see that given data with a spacing d = N allows us to determine frequencies up to 2 = 2d . This 1 frequency 2d is called the Nyquist frequency. −1 Matlab: The function fft in Matlab implements NFN and the function fft implements N FN . Assume we have the Matlab vectors f and fhat with ˆ ˆ f = [f0, . , fN−1], fhat = [f0,..., fN−1] then ˆ ˆ −1 fft(f) = N[f0,..., fN−1], ifft(fhat) = N [f0, . , fN−1]. Note that Matlab vectors of length N are indexed by 1,...,N (instead of 0,...,N − 1). 3 2.4 Manipulating the Fourier vector ˆ ˆ Recall that we should interprete the Fourier vector (f0,..., fN−1) as follows: For odd N = 2n + 1 the vector contains the coefficients of the functions ˆ ˆ ˆ ˆ ˆ f0 f1 ... fn fN−n ... fN−1 1 e2πix . e2πinx e−2πinx . e−2πix For even N = 2n the vector contains the coefficients of the functions ˆ ˆ ˆ ˆ ˆ ˆ f0 f1 ... fn−1 fn fN−(n−1) ... fN−1 2πix 2πi(n−1)x e2πinx+e−2πinx −2πi(n−1)x −2πix 1 e . e 2 e . e ˆ ˆ Extending the Fourier vector by zeros: The Fourier vector (f0,..., fN−1) corresponds to a function cos p˜ ∈ Tn for N = 2n + 1, andp ˜ ∈ Tn for N = 2n.
Details
-
File Typepdf
-
Upload Time-
-
Content LanguagesEnglish
-
Upload UserAnonymous/Not logged-in
-
File Pages8 Page
-
File Size-