3.5 Lecture 15: Fourier Series and Transforms

3.5 Lecture 15: Fourier Series and Transforms

3.5 Lecture 15: Fourier series and transforms Fourier transforms are useful for signal analysis, and are also an important tool for solving differential equations. First let’s recall what Fourier series can do: any periodic function f(x) defined on a finite interval 0 x L ≤ ≤ can be written as a Fourier series. If f(x) is symmetric about the midpoint at L/2, then we can write ∞ 2πkx f(x)= α cos , k L !k=0 " # where α is the set of coefficients. If f(x) is antisymmetric about the { k} midpoint, then we have ∞ 2πkx f(x)= β sin k L !k=1 " # So we can write a function with no symmetry as ∞ 2πkx ∞ 2πkx f(x)= α cos + β sin k L k L !k=0 " # !k=1 " # and then making using of cos θ =(eiθ + e iθ)/2 and sin θ =(eiθ eiθ)/2i to − − write ∞ 2πkx 2πkx f(x)= α exp i +exp i k L − L !k=0 $ " # " #% i ∞ 2πkx 2πkx + β exp i exp i 2 k − L − L !k=1 $ " # " #% From which point we can collect terms and write it as ∞ 2πkx f(x)= γ exp i k L k= " # !−∞ where 1 (α k + iβ k),k<0 2 − − γk = ⎧α0,k=0 ⎪ 1 ⎨ (α k iβ k),k>0. 2 − − − ⎩⎪ 76 Fourier series can only be used for periodic functions! To extend to non- periodic ones, just pick out an interval of a function and repeat it infinitely so that it becomes periodic. i 2πkx How do we calculate the coefficients, γ ? Just use the fact that e− L k { }k constitutes an orthonormal basis for the space [0,L]. That is, consider that L L 2πkx ∞ 2π(k′ k)x f(x)exp i = γk′ exp i − dx. 0 − L 0 L * " # k′= * " # !−∞ If k = k,then ′ ̸ L 2π(k k)x L 2π(k k)x L exp i ′ − dx = exp i ′ − L i2π(k k) L *0 " # ′ − $ " #%0 L = exp(i2π(k′ k)) 1 i2π(k′ k) − − −2πin =0sincee +=1 n Z , ∀ ∈ However, if k′ = k, then the integral is equal to L. In this case, L 2πkx f(x)exp i dx = Lγ − L k *0 " # or 1 L 2πkx γ = f(x)exp i dx. k L − L *0 " # 3.5.1 Discrete Fourier transforms There are many cases in which it isn’t possible to calculate the coefficients γk analytically. So we can use numerical methods. It turns out that ap- proximations with the trapezoidal rule is equivalent to the discrete Fourier transform. Consider N slices of width h = L/N. Applying the trapezoidal rule gives N 1 1 L 1 1 − 2πkx γ = f(0) + f(L)+ f(x )exp i n k L N 2 2 n − L - n=1 . " # ! " # when the sample point positions are xn = nL/N. Since f(x)isperiodic,we have f(0) = f(L), so then above simplifies to N 1 1 − 2πkx γ = f(x )exp i n k N n − L n=0 ! " # 77 We can use this to evaluate coefficients, at least in cases with evenly sampled data (pretty frequent). It’s also worth noting that while these results were derived using the trapezoidal rule, there is a sense in which that are exact. Recall that N 1 − 1 aN ak = − ,a=1, 1 a ̸ !k=0 − then N 1 k i2πm − i 2πm 1 e e N = − =0, 1 ei2πm/N !k=0 / 0 − since m is an integer, making the numerator zero. In the case that m =0, or is a multiple of N,thenthesumisN. So N 1 − 2πkm N if m =0,N,2N,... exp i = N 10else !k=0 " # Then consider the sum N 1 N 1 N 1 − 2πkn − − 2πkxn′ 2πkn ck exp i = γn′ exp i exp i N - − L . N !k=0 " # !k=0 n!′=0 " # " # N 1 N 1 − − n n = γ exp i2πk( − ′ ) n′ N n!′=0 !k=0 " # N 1 − = yn′ δn,n′ N n!′=0 = Nyn N 1 1 − 2πkn = y = c exp i . ⇒ n N k N !k=0 " # This is the inverse discrete Fourier transform (inv. DFT). This proves that the matrix with entries 1 2πkn U = exp i kn √ − N N " # is a unitary matrix. So we can recover the original values exactly by per- forming the inverse DFT. So you can move freely back and force between the original values and the Fourier coefficients. 78 We can compute this on a computer because the sum is finite • This discrete formula only gives sample values y = f(x ). So if the • n n function is oscillating rapidly between samples, the DFT won’t capture this, so DFT just gives some idea of the function. If the function is real, then can use this symmetry to simplify further. Sup- pose all y are real and consider c for N/2 <k N 1, so k = N r for n k ≤ − − 1 r<N/2. Then ≤ N 1 − 2π(N r)n cN r = yn exp i − − − N n=0 ! " # N 1 − 2πrn = y exp ( i2πn )exp i n − N n=0 ! " # N 1 − 2πrn = y exp i = c′ n N r n=0 ! " # so then cN 1 = c1 ,cN 2 = c2′ , etc. So when calculating the DFT of a real − ′ − function, we only have to calculate c for 0 k<N/2. However, if the y k ≤ n are complex, then we need to calculate all N Fourier coefficients. Bring up dft.py. This program uses exp from the cmath package, which isn’t the quickest way to calculate the DFT. We can instead do FFT. If we shift the positions of the sample points. then not much changes. Suppose that instead of taking samples at xn = nL/N, we take them at xn′ = xn +∆. Then N 1 − 2πk(x + ∆) c = f(x + ∆)exp i n k n − L n=0 ! " # N 1 2πk∆ − 2πkxn =exp i f(x′ )exp i − L n − L n=0 " # ! " # N 1 2πk∆ − 2πkxn =exp i y′ exp i , − L n − L n=0 " # ! " # where yn′ = f(xn′ ) are the new samples. We can absorb the phase factors into 2πk∆ N 1 2πkn the coefficients as c =exp i c so that c = − y exp i k′ L k k′ n=0 n′ − L so that DFT is independent of where the samples are taken. 2 3 4 2 3 We can distinguish between Type-I DFT where we divide interval [0,L] into N slices and take samples at endpoints, and a Type-II where we take samples at the midpoints of slices. 79 3.5.2 2D Fourier transform It’s useful for image processing, for instance in astronomy (classic case: Hub- ble image correction). Suppose we have M N grid of samples y . First × mn do a FT on the rows: N 1 − 2πln c′ = y exp i , ml mn − N n=0 ! " # and then FT the m variable: N 1 − 2πkm c = c′ exp i . kl ml − M n=0 ! " # Combined, these read N 1 N 1 − − km ln c = y exp i2π + . kl mn − M N m=0 n=0 ! ! " " ## What is the FT doing? Breaking down a signal into its frequency com- ponents, like a signal analyzer. Bring up dft.py.Thefirstspikeisthe frequency of the main wave, and the others are harmonics. Discrete cosine transform Recall that if a function is symmetric about x = L/2 (the midpoint) then we can write ∞ 2πkx f(x)= α cos k L !k=0 " # We cannot do this for all functions. However, if we’d like to do so, we can by just sample a function over an interval, and then adding it to its mirror image, i.e., 80 So we make the function symmetric, and when the samples are, we have y0 = yN ,y1 = yN 1,y2 = yN 2, etc. We then get for the DFT: − − N 1 − 2πkn c = y exp i k n − N n=0 ! " # N/2 N 1 2πkn − 2πkn = y exp i + y exp i n − N n − N n=0 ! " # n=!N/2+1 " # N/2 N 2πkn 2πk(N n) = yn exp i + yN n exp i − − N − N n=0 ! " # n=!N/2+1 " # where in the final line we used exp(i2πk)=1. Make a change of variables N n n to get − → N/2 N/2 1 2πkn − 2πkn c = y exp i + y exp i k n − N n N n=0 n=1 ! " # ! " # N/2 1 2πk(N/2) − 2πkn = y + y cos +2 y cos . 0 N/2 N n N n=1 " # ! " # Usually though, the discrete cosine transform is applied to real values, which means that the ck coefficients are real. In this case, we have the cN r = − cr′ = cr, and the inverse transform is N 1 1 − 2πkn y = c exp i n N k N !k=0 " # N/2 N 1 1 2πkn − 2πkn = c exp i + c exp i N ⎡ k N k N ⎤ !k=0 " # k=!N/2+1 " # ⎣N/2 N 1 ⎦ 1 2πkn − 2π(N k)n = ck exp i + cN k exp i − N ⎡ N − − N ⎤ !k=0 " # k=!N/2+1 " # ⎣N/2 N/2 1 ⎦ 1 2πkn − 2πkn = c exp i + c exp i N ⎡ k N k − N ⎤ !k=0 " # !k=1 " # ⎣ N/2 1 ⎦ 1 2πn(N/2) − 2πkn = c + c cos +2 c cos N ⎡ 0 N/2 N k N ⎤ " # !k=1 " # ⎣ ⎦ 81 which is the inverse discrete cosine transform.

View Full Text

Details

  • File Type
    pdf
  • Upload Time
    -
  • Content Languages
    English
  • Upload User
    Anonymous/Not logged-in
  • File Pages
    11 Page
  • File Size
    -

Download

Channel Download Status
Express Download Enable

Copyright

We respect the copyrights and intellectual property rights of all users. All uploaded documents are either original works of the uploader or authorized works of the rightful owners.

  • Not to be reproduced or distributed without explicit permission.
  • Not used for commercial purposes outside of approved use cases.
  • Not used to infringe on the rights of the original creators.
  • If you believe any content infringes your copyright, please contact us immediately.

Support

For help with questions, suggestions, or problems, please contact us