Guided Research-Fall 2013 Fourier series and Fourier Transform Advisors: Dr. Jonas Meyer Dr. Clark T. Merkel 12/14/2013 Loras College By Ram Gautam and Jacob Hertel 1 Table of Contents: S.N. Content 1 Introduction 2 Fourier series 3 Odd and Even Function 4 Examples 5 Experimental verification of Fourier Series 5 Fourier Transform 6 Discrete Fourier Transform 7 Fast Fourier Transform Examples 8 Dominant Frequency of Sound Waves 9 Dominant Frequency of Seismic Waves 10 Work Citations Page No. 2 Introduction: Fourier series and Fourier transform is a guided research topic worked under the mentorship of Dr. Jonas Meyer and Dr. Clark T. Merkel. The goal of this research is the Fourier analysis of vibrating signals. The vibrating signals can be periodic, non-periodic, continuous, and discrete. At the end of the research the following problem statements will be addressed: - Experimentally verify the Fourier series (square wave only). Determine the dominant frequencies of a sound wave. Determine the dominant frequencies of seismic wave. Fourier series and Fourier Transform is completely a new topic for us. After completing this research we will learn about Fourier series, Fourier Transform, Discrete Fourier Transform, and Fast Fourier Transform. We will also learn why Fast Fourier Transform is used to find the dominant frequency of both sound wave and seismic wave. Fourier series: The Fourier series is defined by an offset constant and an infinite series of cosine and sine terms defined by the integer multiples of the fundamental frequency and a set of constants.1 In simple language a Fourier series is a series of periodic functions (typically sinusoids) that represents another periodic function. The mathematical representation of Fourier series under period 2π is given as: ∞ ππ π(π₯) = + ∑[ππ cos(ππ₯) + ππ sin(ππ₯)]. − − − − − − − − − − − − − − − − − − − − (1) 2 π=1 Where π0 , ππ and ππ are known as the coefficient of Fourier series. In order to find the coefficients ππ , ππ and ππ following integral identity was used: 0, π 1.) ∫−π cos ππ₯ cos ππ₯ ππ₯ = {2π, π, π≠π π = π = 0} π=π≠0 π 0, π≠π 2.) ∫−π sin ππ₯ sin ππ₯ ππ₯ = { } π, π = π ≠ 0 1 Dr. Clark T. Merkel note. 3 π 3.) ∫−π cos ππ₯ sin ππ₯ ππ₯ = 0 We can compute ππ over an interval of length 2π by multiplying both sides of equation by 1 and integrating over [– π, π]. ∞ π π π −π −π ππ π ∫ π(π₯)ππ₯ = ∫ 1 ππ₯ + ∑ [ππ ∫ cos(ππ₯) ππ₯ + ππ ∫ sin(ππ₯) ππ₯] 2 −π −π π=1 = ππ 2 ∗ 2π = πππ We can compute ππ ,where π ≥ 1 by multiplying both sides of equation 1 by cos(ππ₯) and integrating over[−π, π]. π ∫ π(π₯) cos(ππ₯) ππ₯ −π = ππ π ∫ cos(ππ₯) ππ₯ 2 −π ∞ π π + ∑ [ππ ∫ cos(ππ₯) cos ππ₯ ππ₯ + ππ ∫ sin(ππ₯) cos ππ₯ ππ₯ ] π=1 −π −π π = ππ ∫ cos(ππ₯) cos(ππ₯) ππ₯ = π ππ −π Similarly we compute ππ , where π ≥ 1 ππ¦ multiplying both sides of equation 1 by multiplying by sin(ππ₯) and integrating over[−π, π]. π ∫ π(π₯) sin(ππ₯) ππ₯ = πππ −π Finally rearranging all computation we will get the following results: π0 = 1 π ∫ π(π₯)ππ₯. − − − − − − − − − − − − − − − − − − − − − − − − − − − − −(2) π −π 1 π ππ = ∫ π(π₯) cos( ππ₯) ππ₯. − − − − − − − − − − − − − − − − − − − − − − − − −(3) π −π 1 π ππ = ∫ π(π₯) sin(ππ₯) ππ₯. − − − − − − − − − − − − − − − − − − − − − − − − − − (4) π −π Thus using the equations 2, 3, and 4 coefficients π0 , ππ and ππ can be easily calculated. 4 π π But if the limit of integration of equation 1 is changed from[−π, π]π‘π [− 2 , 2] then equation 1 will be: ∞ ππ 2πππ‘ 2πππ‘ π(π‘) = + ∑[ππ cos ( ) + ππ sin( )]. − − − − − − − − − − − − − − − − −(5) 2 π π π=1 The variable is changed to the integration variable t in order to show that the limit of integration of Fourier series can be changed to any periodic limit. And the coefficients of equation 5, π0 , ππ , ππ can be computed as using the following formulas: π 2 2 π0 = ∫ π(π‘)ππ‘. − − − − − − − − − − − − − − − − − − − − − − − − − − − − − − (6) π −π 2 π 2 2 2πππ‘ ππ = ∫ π(π‘) cos ( ) ππ‘ − − − − − − − − − − − − − − − − − − − − − − − −(7) π −π π 2 π 2 2 2πππ‘ ππ = ∫ π(π‘) sin ( ) ππ‘ − − − − − − − − − − − − − − − − − − − − − − − −(8) π −π π 2 Frequency components: Let us suppose π‘ represents time then the frequency associated with the 1 fundamental sinusoid in the series is ππ = π measured in cycle per second or hertz. π0 = 2πππ = Now, 2ππ π 2π π (πππ/π ) = 2ππππ = ππ0 . Thus equation 5 will be: ∞ ππ π(π‘) = + ∑[ππ cos(2π ππ0 π‘) + ππ sin(2πππ0 π‘)] − − − − − − − − − − − − − − − −(9) 2 π=1 π(π‘) = ππ 2 + ∑∞ π=1[ππ cos(π π€0 π‘) + ππ sin(ππ€0 π‘)] − − − − − − − − − − − − − − − −(10) This equation gives the result of Fourier series components in terms of their frequencies. The first term in cosine or sine is called fundamental frequency and the other terms are the harmonics frequencies. 5 Even function: A function π(π‘) is said to be even if π(−π‘) = π(π‘) for all the values of t which is symmetric about the vertical axis (t=0) which means that the graph of function π(π‘)remains unchanged after reflecting about y-axis. πΉπππ’ππ 1. πΈπ£ππ ππ’πππ‘πππ From the graph it can be concluded that the symmetrical range about vertical axis for odd function is zero. Thus we do not need to calculate ππ . In general, ∞ ππ π(π‘) = + ∑[ππ cos(π π‘). − − − − − − − − − − − − − − − − − − − − − − − − −(11) 2 π=1 ∞ ππ π(π‘) = + ∑[ππ cos(2π ππ0 π‘). − − − − − − − − − − − − − − − − − − − − − − −(12) 2 π=1 ∞ ππ π(π‘) = + ∑[ππ cos(π π€0 π‘) − − − − − − − − − − − − − − − − − − − − − − − −(13) 2 π=1 The coefficients of even function are: 2 π π0 = ∫ π(π‘)ππ‘ π 0 ππ = 2 π ∫ π(π‘) cos( ππ‘) ππ‘ π 0 ππ = 0 6 Odd function: A function π(π‘) is said to be odd function if π(−π‘) = −π(π‘) for all the values of t which is symmetric with respect to the origin. πΉπππ’ππ 2. πππ ππ’πππ‘πππ From the graph it can be concluded that the symmetrical range about vertical axis for even function is zero. This means that we do not need to calculate π0 and ππ .Thus the Fourier series for the odd function will be: ∞ π(π‘) = ∑[ππ s ππ(π π‘) − − − − − − − − − − − − − − − − − − − − − − − − − − − (14) π=1 The coefficients of odd function are: π0 = 0 ππ = 0 2 π ππ = ∫ π(π‘) cos( ππ‘) ππ‘ π 0 7 Example 1: π(π₯) = |π₯| , −π < π₯ < π Calculating ππ 1 π 1 π π0 = ∫ π(π₯)ππ₯ = ∫ π₯ ππ₯ π −π π −π 1 π₯2 =π 2 (from −π < π₯ < π ) =0 Calculating ππ ππ = 1 1 π 1 π ∫ π(π₯) cos( ππ₯) ππ₯ = ∫ π₯ cos( ππ₯) ππ₯ π −π π −π 0 1 π = π ∫−π π₯ cos( ππ₯) ππ₯ + π ∫0 π₯ cos( ππ₯) ππ₯ Now using integration by parts: ππ = 2 ∗ = 1 π 1 1 ( π₯ ∗ π sin(ππ₯) − ∫ π sin ππ₯ ππ₯) (From0 < π₯ < π) 2 cos ππ ( 2 − 1 ) ππππ 0 π‘π π π π By series approximation we know that cos ππ₯ = (−1)π = 2((−1)π −1) ππ2 Calculating ππ ππ = 1 π 1 π ∫ π(π₯) sin(ππ₯) ππ₯ = ∫ x sin(ππ₯) ππ₯ π −π π −π 1 0 1 π ππ = π ∫−π π₯ sin( ππ₯) ππ₯ + π ∫0 π₯ sin( ππ₯) ππ₯ (This is an odd function.) 8 πΉπππ’ππ 4. π πΏπΆ πππππ’ππ‘ The summation of odd function over certain range like −π π‘π π is zero. Also the result in a series of sine terms is expected for the approximation of an odd function. i.e. π(0) = 0 and π(ππ) = 0. The same result will be obtained by doing integrations by parts. Thus ππ = 0 Hence the Fourier series of the above function is: ∞ ππ π(π₯) = + ∑[ππ cos(ππ₯)] 2 π=1 ∞ π ((−1n ) − 1) π(π₯) = + ∑ 2[ ] cos ππ₯ 2 ππ2 π=1 Let π = (2π + 1), π€βππβ ππ π‘βπ πππππππ‘πππ ππ πππ ππ’πππ‘πππ ∞ π 2 ((−12π+1 ) − 1) |π₯| = + ∑[ cos((2π + 1)π₯)] 2 π π2 π=0 Now expanding the above equation: π(π₯) = π 2 4 1 1 π 9 25 − [cos(π₯) + cos(3π₯) + cos(5π₯) + β― … …] This is the required Fourier series of the given function. 9 Example 2: π(π₯) = { 0 −π <π₯ < 0 } 1 0<π₯<π We know that π(π₯) = ππ 2 + ∑∞ π=0[ππ cos(ππ₯) + ππ sin(ππ₯)]. Calculating ππ 1 π 1 0 1 π π0 = ∫ π(π₯)ππ₯ = ∫ 0 ππ₯ + ∫ 1 ππ₯ = 1 π −π π −π π 0 Compute ππ ππ = 1 π ∫ π(π₯) cos( ππ₯) ππ₯ π −π 1 0 1 π ∫ 0 ππ₯ + ∫ 1 cos( ππ₯) ππ₯ π −π π 0 1 ππ₯ = π ∗ sin ππππ 0 π‘π π π =0 Compute ππ ππ = 1 π ∫ π(π₯) sin(ππ₯) ππ₯ π −π 0 1 1 π = π ∫−π 0 sin(ππ₯) ππ₯ + π ∫0 1 sin(ππ₯) ππ₯ 1 =π∗ − cos(ππ₯) π 1 = − π [cos =− = (−1)π ππ ππ₯ + ππππ 0 π‘π π 0 − cos π] π 1 ππ −(−1)π +1 ππ But, π(π₯) = 1 ππ 2 + ∑∞ π=0[ππ cos(ππ₯) + ππ sin(ππ₯)] =2 + 0 + ∑∞ π=0[ −(−1)1 +1 π(2π+1) ∗ sin(2π + 1) π₯] 10 1 2 1 1 =2 + π [sin(π₯) + 3 sin(3π₯) + 5 sin(5π₯) + β― . ] This is the required Fourier series of the given function. In summary the Fourier series are used to represent arbitrary periodic functions as a linear combination of set of complete, orthogonal functions, namely, the set of harmonic cosines and sine. From the linear combination of sine and cosine we can easily find the fundamental frequency and harmonic frequency as well. Experimental verification of Fourier series: πΉπππ’ππ 4. π πΏπΆ πππππ’ππ‘ A RLC electric circuit is shown above. We are now trying to show the experimental verification of Fourier series. This is an experimental setup developed by Rutgers School of Engineering and Electrical and Computer Engineering. We are now trying to experimentally verify Fourier series comparing the theoretical and experimental obtained π0 π ππ values of a square wave. Theoretical calculation of π½π πΉπ΄πΊ for the first four harmonics of a square wave: πΉππ 5: πππ’πππ π€ππ£π 11 The above square wave can be represented as: −1, π ≤π‘<0 2 π πππ 0 ≤ π‘ ≤ 2 πππ − π(π‘) = { 1, This square wave is an odd function because the function is symmetric about the origin. Thus, ππ = 0 π 2 ππ = 2 2πππ‘ ∫ π(π‘) sin ( ) ππ‘ π π − π 2 π 2 = 2 2πππ‘ ∗ 2 ∫ sin ( ) ππ‘ π π 0 After mathematical calculation, ππ = 2 [1 − cos(ππ)] ππ But, cos(ππ) = (−1)π ππ = 2 [1 − (−1)π ] ππ Thus, 6ππ‘ 10ππ‘ sin ( π ) sin ( π ) 4 2ππ‘ π(π‘) = [(sin ( )) + + + β―..] π π 3 5 But we know that π = 2π π which is called as angular frequency. Hence the above equation can be generalized as: π(π‘) = 4π΄ π 1 ∑∞ π=1 π sin(ππ0 π‘) , where A is the amplitude of the square wave in Volts. The 4π΄ amplitude was measured 12.55 mv and π∗π gives the peak amplitude of the square wave. The peak amplitude of the first four harmonic of the input waves are calculated below: 12 When π = 1, π΄0 = 4∗12.55 When π = 3, π΄0 = 4∗12.55 When π = 5, π΄0 = When π = 7, π΄0 = = 15.9 ππ£. π = 5.32 ππ£. 3∗π 4∗12.55 5∗π 4∗12.55 7∗π = 3.195 ππ£. = 2.73 ππ£. However the RMS values of these harmonics are calculated below: General formula: π0(π ππ) = π΄0 √2 When π = 1, π0(π ππ) = (15.9) When π = 3, π0(π ππ) = (5.32) When π = 5, π0(π ππ) = (3.195) When π = 7, π0(π ππ) = (2.73) √2 √2 √2 √2 − − − − − − − − − − − − − − − − − − − − − − − −(15) = 11.24 ππ£ = 3.76 ππ£ = 2.25 ππ£ = 1.93 ππ£ Experimentally calculating π½ππΉπ΄πΊ of a square wave: π 1 2 3 4 5 6 7 8 9 10 π(π»π§) 2000 2000 2000 2000 2000 2000 2000 2000 2000 2000 π0 π ππ (ππ£) 42.2 4.2 121.1 8.5 126 12 197.8 17 103 21.3 In General: π0 π‘βππ − π0 ππ₯πππ % πππππ = | | − − − − − − − − − − − − − − − − − − − − − − − −(16) π0 π‘βππ 13 Now calculating the percentage error between theoretical value and experimentally value the following result is obtained: π0 π‘βππ −π0 ππ₯πππ When π = 1, % πππππ = | π0 π‘βππ π0 π‘βππ −π0 ππ₯πππ When π = 3, % πππππ = | π0 π‘βππ π0 π‘βππ −π0 ππ₯πππ When π = 5, % πππππ = | π0 π‘βππ π0 π‘βππ −π0 ππ₯πππ When π = 7, % πππππ = | π0 π‘βππ 11.24−42.2 |=| | = 275 % πππππ 11.24 3.76−121.2 |=| 2.25−126 |=| | = 3123 % πππππ 3.76 2.25 | = 5550 % πππππ 1.93−197.8 |=| 1.93 | = 10148 % πππππ There is a dramatic percentage error between experimentally calculated and theoretically calculated peak RMS voltage. This means that the experimental method we used was wrong. But this does not mean that the Fourier series cannot be proved experimentally. The high percentage error is due to the lack of good knowledge of using the Function Generator, Oscilloscope and Inductance box used for the experiment. Hence we could not experimentally verify the Fourier series. Fourier Transform: The idea of Fourier transform comes from the Fourier series. In the study of Fourier series, complicated but periodic functions are written as the sum of simple waves mathematically represented sine and cosines. But Fourier series cannot be solely periodic function. Hence Fourier transform is a form of Fourier series that comes into play when the period of the represented function is lengthy and is allowed to approach infinity. The Fourier Transform decomposes a waveform into sinusoids and from those sinusoids we can find the amplitude of frequency spectrum and phase shift of any non periodic vibrating signals or functions. Definition: ∞ Let the function π(π‘) be piecewise continuous for−∞ < π‘ < ∞, and let ∫−∞|π(π‘)| ππ‘ exist in the sense that result is finite. Then the Fourier transform of π(π‘) exists and is defined as ∞ πΉ[π(π‘)] = πΉ(ππ) = ∫ π(π‘)π −πππ‘ ππ‘ − − − − − − − − − − − − − − − − − − − − − −(17) −∞ 14 The transform, πΉ(ππ), represents the frequency spectrum of π(π‘) and it may be complex even though π(π‘) is real. The real part, | π(π‘) |, can be found using following formula: |π(π‘)| = √(π πππ(π (π‘))2 + πΌπππ(π(π‘))2 ) , which is the amplitude spectrum of π(π‘). The phase shift can be found using the following formula: ∅ = ππππ‘ππ(πΌπππ(π(π‘)/ π πππ(π(π‘)) The notation πΉ(ππ) emphasis the fact the Fourier transforms is a function of a complex variable. Note: π = 2ππ π ππ₯ = cos(π₯) + ππ ππ(π₯) Forward Fourier Transform: Forward Fourier Transform maps a time series (e.g. audio samples) into the series of frequencies (their amplitudes and phases) that composed the time series. ∞ πΉ(π) = ∫ π(π‘)π −πππ‘ ππ‘ − − − − − − − − − − − − − − − − − − − − − − − − − − − (18) −∞ Inverse Fourier Transform: Inverse Fourier Transform maps the series of frequencies (their amplitudes and phases) back into the corresponding time series. ∞ π(π‘) = ∫ πΉ(π)π πππ‘ ππ‘ − − − − − − − − − − − − − − − − − − − − − − − − − −(19) −∞ Forward and Inverse Fourier Transform are inverse to each other. Example 3: Find the Fourier Transform of the following function with ∝: π(π‘) = { 0, π΄π , −πΌπ‘ π‘<0 π‘≥0 15 Now we can check the validity of above function either it can be transformed into frequency domain or not. 0 ∞ ∞ ∫ |π(π‘)| ππ‘ = ∫|π΄| π −πΌπ‘ ππ‘ + ∫ |π΄| π −∝π‘ ππ‘ −∞ |π΄| πΌ 0 −∞ Which is finite for α>0. Thus the Fourier transform of the above function can be computed. Now using the definition of Fourier Transform: ∞ πΉ[π(π)] = ∫ π(π‘)π −πππ‘ ππ‘ −∞ ∞ = ∫ |π΄| π −∝π‘ π −πππ‘ ππ‘ −∞ ∞ = ∫ |π΄| π −(∝+ππ)π‘ ππ‘ 0 π −(πΌ+ππ)π‘ = −|π΄| (πΌ+ππ)π‘ ππππ 0 π‘π ∞ π = π΄ πΌ + ππ |π΄| Thus πΉ(ππ) = πΌ+ππ This amplitude spectrum can be determined by computing πΉ(ππ) π and phase spectrum tan−1 ( πΌ ) .This Fourier transforms represents a function of time in terms of frequency. Let |π΄| = 2 and πΌ = 2, then the Fourier Transform will be: πΉ(ππ) = |2| 2 + ππ Matlab code: -------------------------------------------------------t=[0:.1:4]; foft=2*exp(-2*t); %Plot magnitude of F(w) 16 w=[-4:.1:4]; Fw=2./(sqrt(2+w.^2));%Fourier Transform clf subplot(2,1,1),plot(t,foft) xlabel('t') ylabel('f(t)') title('Fourier Transform of f(t)') subplot(2,1,2),plot(w,Fw) axis([-4 4 0 1.1]) xlabel('Radian frequency w') ylabel('|F(w)'|) ---------------------------------------------------------------The plot of this transform is shown below: πΉππ 6: πΉππ’ππππ πππππ ππππ In figure 6, the function π(π‘) which was in time domain is transformed into frequency domain. Now it can be concluded that any integral function that is non periodic and continuous can be transformed from time domain to frequency domain as well as from frequency domain into time using Forward and Inverse Fourier Transform. Properties of Fourier Transform: 1.) Linearity: The Fourier Transform is a linear function of π₯(π‘). π₯1 (π‘) ↔ π1 (ππ) π₯2 (π‘) ↔ π2 (ππ) ππ₯1 (π‘) + ππ₯2 (π‘) ↔ ππ1 (ππ) + ππ2 (ππ) 17 2.) Time Shifting : πΉ[π₯(π‘ − π‘0 )] = π −ππ0 π‘ π(ππ) 3.) Time and Frequency Scaling: 1 π πΉ[π(ππ₯)] = |π| πΉ ( π ). where ‘a’ is a real non zero constant. Example 4: Compute the Fourier Transform of a triangular pulse shown below where T=A=1. πΉππ 7: πππππππ’πππ ππ’ππ π From the definition of Forward Fourier transform: ∞ πΉ(ππ) = ∫ π(π‘)π −π2πππ‘ ππ‘ −∞ ∞ πΉ(π) = ∫ π(π‘)[cos(2πππ‘) − ππ ππ(2πππ‘)] ππ‘ −∞ 1 πΉ(π) = ∫ π(π‘)[cos(2πππ‘)] ππ‘ −1 0 1 = ∫(1 + π‘)[cos(2πππ‘)] ππ‘ + ∫(1 − π‘)[cos(2πππ‘)] ππ‘ −1 Now, 0 18 0 ∫−1(1 + π‘)[cos(2πππ‘)] ππ‘ = (1 + π‘). = sin(2πππ‘) 2ππ − ∫( sin(2πft) 2πf ) ππ‘ from -1 to 0 1 − cos(2ππ) 4π 2 π 2 Note: cos(2π₯) = cos 2 π₯ − sin2 π₯ = 1 − 2 sin2 π₯ 2 sin2 π₯ = 1 − cos 2π₯ Thus using above trigonometric relation, 0 ∫(1 + π‘)[cos(2πππ‘)] ππ‘ = (π ππ2 (ππ))/(2π 2 π 2 ) − − − − − − − − − − − − − − − −(π) −1 1 ∫(1 + π‘)[cos(2πππ‘)] ππ‘ = (π ππ2(ππ))/(2π 2 π 2 ) − − − − − − − − − − − − − − − − − (π) 0 Adding equations a and b gives:πΉ(ππ) = 2sin2 (ππ) 2π 2 π 2 = sin2 (ππ) π2 π2 − − − − − − − − − − − −(π) Thus from equation c, it can be concluded that we can find frequency spectrum of any continuous pulse. Again Fourier transform would not be helpful to find the dominant frequency of sound and seismic wave because it only works with the signals that are continuous. A separate mechanism is necessary to figure out the dominant frequencies of the signals that are discrete. Hence we decided to use the idea of discrete Fourier transform to address our aforementioned problem. Discrete Fourier Transform: Discrete Fourier Transform is the numerical approximation of the exponential Fourier series and the integral Fourier transform of real valued signals by sums of finite length. In short hand, it is called DFT. It is used when both time and frequency variables are discrete. Let π(π‘) be the continuous signal which is the source of the data. Let N samples be denoted π1 π2 , π3 , π4 , …….. π5 , ,…….., ππ−1 , . Assume that a function π(π‘) is defined at a set of N 19 points, π(πππ ) for n =0,………….,N-1 values. The DFT is defined by the formula which yields the frequency spectrum at N points as: π−1 π πΉ( ) = ∑ π(πππ )π −2ππππ/π − − − − − − − − − − − − − − − − − − − − − − − −(20) πππ π=0 For k=0, ………,N-1. . The N sample points of the signal in time gives us N frequency 1 components with a spacing of ππ = π, where π = π ππ is the period of the sampled time signal. The DFT is assumed to have the form: πΉ(π) = πΉπ (π) + ππΉπ (π),where πΉπ (π)the real part of is transform and πΉπ (π) is the imaginary part of transform In simple language a digital signal of finite duration can be specified in the time domain as a sequence of N scaled impulses occurring at regular sampling instants: each impulse taking on the amplitude of the signal at that instant. The same signal may also be described as a combination of N complex sinusoidal components, each of a given frequency and phase, and each being a harmonic of the sampling rate/N. This frequency-domain representation can be obtained from the time-domain using DFT. The time domain and the frequency domain are simply different ways of representing the same digital signal. 2 Similar to the Fourier transform, the Discrete Fourier Transform can be divided into forward and inverse discrete Fourier Transform. Forward Discrete Fourier Transform: π −2ππππ/π −2ππππ/π πΉ (ππ ) = ∑π−1 or πΉπ = ∑π−1 − − − − − − − − − − − −(21) π=0 π(πππ )π π=0 ππ π π In DFT, the complex numbers π0 , … … … … . , ππ are transformed into complex numbersπΉ0 , … … … … . , πΉπ . In general πΉ|π| is the DFT of the sequence π|π| . Thus this equation can be written in matrix form as: πΉ[0] πΉ[1] = πΉ[2] ….. (πΉ[π − 1]) ( 2 3 1 1 1 1 π[0] 1 1 1 …… 1 2 3 π−1 π[1] π π π …. π 2 4 6 π−2 3 π π π …. π π[2] …………. ….. π−1 π π π−2 π π−3 … . π ) (π[π − 1]) http://www.phon.ucl.ac.uk/home/mark/basicdsp/05FourierTransform.pdf http://www.robots.ox.ac.uk/~sjrob/Teaching/SP/l7.pdf 20 Inverse Fourier Transform: 1 −2ππππ/π ππ = π ∑π−1 − − − − − − − − − − − − − − − − − − − − − − − − − − − (21) π=0 πΉπ π In inverse DFT, the complex numbers πΉ0 , … … … … . , πΉπ are transformed into complex numbersπ0 , … … … … . , ππ Example: 5 Determine the DFT for the discrete function. Find the amplitude and phase transform as well. 1, 0 ≤ π ≤ 4, ππ = { The total number of points are N=10. 0, 5 ≤ π ≤ 5, Now using the definition of DFT, 9 πΉπ = ∑ ππ π −2ππππ/10 π=0 0 0 0 0 0 πΉ0 = 1 ∗ π −2ππ∗0∗10 + 1 ∗ π −2ππ∗1∗10 + 1 ∗ π −2ππ∗2∗10 + 1 ∗ π −2ππ∗3∗10 + 1 ∗ π −2ππ∗4∗10 + 0 0 ∗ π −2ππ∗5∗10 + 0 + 0 + 0 + 0 + 0 = 1 + 1 + 1 + 1 + 1 + 0π = 5 + 0π Amplitude |π(π‘)| = √(π πππ(π (π‘))2 + πΌπππ(π(π‘))2 ) = √(52 + 02 ) = 5 0 Phase shift(∅) = ππππ‘ππ(πΌπππ(π(π‘)/π πππ(π(π‘)) = tan−1 (5) = 00 1 1 1 1 1 πΉ1 = 1 ∗ π −2ππ∗0∗10 + 1 ∗ π −2ππ∗1∗10 + 1 ∗ π −2ππ∗2∗10 + 1 ∗ π −2ππ∗3∗10 + 1 ∗ π −2ππ∗4∗10 + 0 1 ∗ π −2ππ∗5∗10 + 0 + 0 + 0 + 0 + 0 = 1 + π −0.6283π + π −1.257π + π −1.885π + π −2.513π + 0 = 1 + 0.809 − 0.587π + 0.309 − 0.951π − 0.309 − 0.951π − 0.809 − 0.588π = 1 − 3.077π Amplitude |π(π‘)| = √(π πππ(π (π‘))2 + πΌπππ(π(π‘))2 ) = √(12 + 3.0772 ) = 3.235 −3.077 Phase shift(∅) = ππππ‘ππ(πΌπππ(π(π‘)/π πππ(π(π‘)) = tan−1 ( 1 ) = −720 21 Now using same calculating methods DFT can be easily calculated. Thus, πΉ2 = 0 Amplitude |π(π‘)| = √(π πππ(π (π‘))2 + πΌπππ(π(π‘))2 ) = √(02 + 02 ) = 0 Phase shift(∅) = ππππ‘ππ(πΌπππ(π(π‘)/π πππ(π(π‘)) = 00 πΉ3 = 1 + 0.7265π Amplitude |π(π‘)| = √(π πππ(π (π‘))2 + πΌπππ(π(π‘))2 ) = √(12 + 0.72652 ) = 1.23 0.7265 Phase shift(∅) = ππππ‘ππ(πΌπππ(π(π‘)/π πππ(π(π‘)) = tan−1 ( 1 ) = 360 F4 = 0 Amplitude |π(π‘)| = √(π πππ(π (π‘))2 + πΌπππ(π(π‘))2 ) = √(02 + 02 ) = 0 Phase shift(∅) = ππππ‘ππ(πΌπππ(π(π‘)/π πππ(π(π‘)) = 00 πΉ5 = 1 Amplitude |π(π‘)| = √(π πππ(π (π‘))2 + πΌπππ(π(π‘))2 ) = √(12 + 02 ) = 1 0 Phase shift(∅) = ππππ‘ππ(πΌπππ(π(π‘)/π πππ(π(π‘)) = tan−1 (1) = 00 πΉ6 = 0 Amplitude |π(π‘)| = √(π πππ(π (π‘))2 + πΌπππ(π(π‘))2 ) = √(02 + 02 ) = 0 Phase shift(∅) = ππππ‘ππ(πΌπππ(π(π‘)/π πππ(π(π‘)) = 00 πΉ7 = 1 − 0.7265π 22 Amplitude |π(π‘)| = √(π πππ(π (π‘))2 + πΌπππ(π(π‘))2 ) = √(12 + 0.72652 ) = 1.23 −0.7265 Phase shift(∅) = ππππ‘ππ(πΌπππ(π(π‘)/π πππ(π(π‘)) = tan−1 ( ) = −360 1 πΉ8 = 0 Amplitude |π(π‘)| = √(π πππ(π (π‘))2 + πΌπππ(π(π‘))2 ) = √(02 + 02 ) = 0 Phase shift(∅) = ππππ‘ππ(πΌπππ(π(π‘)/π πππ(π(π‘)) = 00 πΉ9 = 1 + 3.077π Amplitude |π(π‘)| = √(π πππ(π (π‘))2 + πΌπππ(π(π‘))2 ) = √(12 + 3.0772 ) = 3.235 3.077 Phase shift(∅) = ππππ‘ππ(πΌπππ(π(π‘)/π πππ(π(π‘)) = tan−1 ( 1 ) = 720 The magnitude and phase shift of any digital signal can be calculated using DFT. Fast Fourier Transform: A fast Fourier transform (FFT) is an algorithm to compute the discrete Fourier transform (DFT) and its inverse. A Fourier transform converts time domain to frequency and vice versa; an FFT rapidly computes such transformations. As a result, fast Fourier transforms are widely used for many applications in engineering, science, and mathematics. The DFT is obtained by decomposing a sequence of values into components of different frequencies. This operation is useful in many fields but computing it directly from the definition is very slow. An FFT is a way to compute the same result more quickly: computing the DFT of N points using the definition takes O(N2) arithmetical operations, while a FFT can compute the same DFT in only O(N log N) operations. The difference in speed can be drastic when N is thousands or millions. Thus FFTs are of great importance for a digital signal processing. The FFT is the correct method to solve our problem statements. A very simple example is shown below calculating the Fourier transform at different frequencies. 23 Example 6: −3π‘ π‘≥0 Let π(π‘) = { 12 π 0 π‘<0 Using the concept of example 3, the Fourier Transform of given function can be obtained as: 12 (ππ) = . 3+ππ Matlab code: %--------------------------------------------------------------------N=128; t=linspace(0,3,N); f=12*exp(-3*t); Ts=t(2)-t(1); Ws=2*pi/Ts; % sampling frequency in rad/sec F=fft(f); % use matlab to compute the fft % now compute the positive frequency components and mult by % Ts=T/N to approximate F(w) Fp=F(1:N/2+1)*Ts ; % build the frequency axis from zero to the frequency Ws/2 W=Ws*(0:N/2)/N; F_exact = 12./(3+i*W); % evaluate the exact FT of f % now plot the results plot(W,abs(F_exact),W,abs(Fp),'ok') xlabel('Frequency, Rad/sec') ylabel('|F(w)|') title('Fourier Transforms at different Frequencies') %-------------------------------------------------------------------- πΉππ 8: πΉππ’ππππ πππππ ππππ ππ‘ πππππππππ‘ πππππ’ππππππ 24 From the figure 8, we can find the frequency spectrum at each point. Thus discrete Fourier Transform was a correct mathematical method to solve our aforementioned problems. Problem 1: Find Dominant Frequency of sound waves: Step 1: Record sound using Matlab. %This code records the sound in matlab. The recorded sound wave is saved as myRecording.wav. This matlab code was modified and rewritten under the instruction of Dr. Clark Merkel.% ---------------------------------------------------------------------function [Y,FS,time]=myRecord(record1,time,FS,NBits) if nargin<4 NBits=8; %bits per sample end if nargin<3 FS=11025 % samples/sec end if nargin<2 time = 5 %sec end if nargin<1 filename='myRecording.wav' end fprintf('Recording file: %s \n',filename) fprintf('Length: %f seconds \n',time) fprintf('Sample rate: %i \n',FS) fprintf('Sample Resolution: %i \n',NBits) disp(' ') disp(' ') Now_Recording=input('Hit enter when ready to record','s') Y = wavrecord(time*FS, FS, 1,NBits); fprintf('.\n.\n.\n.\n.\n.\n.\n.\n.\n') disp('Recording complete!') disp(' Hit enter to continue.') plot(Y) disp(' Hit enter to play back') pause wavplay(Y, FS); wavwrite(Y,FS,filename) ---------------------------------------------------------------------- 25 Step 2: Read file as Read_Wave_File.m %This code plays the sound file in .wav format and plots the sound wave as well. Then the dominant frequency of the graph is obtained using FFT. This matlab code was modified and rewritten under the instruction of Dr. Clark Merkel. % ---------------------------------------------------------------------FILE='MyRecording.wav' [y,FS,NBITS]=WAVREAD(FILE); figure(1) plot(y) time=length(y)/FS t=linspace(0,time,length(y)); np=16 N=2^np % points used SampleRate=FS % samples/s figure(2) plot(t(600:700),y(600:700)) grid xlabel('time [s]'), ylabel('y'),title('Finding Fundamental frequencies using FTT') figure(3) Y=fft(y,N); Pyy=Y.*conj(Y)/N; f=SampleRate*(0:N/2-1)/N; plot(f,Pyy(1:N/2)) PlotTitle=sprintf('np = %i',np) title(PlotTitle) grid axis([0, 1000, 0, 10]) xlabel('frequency [hz]'), ylabel('Freq Power Density') wavplay(y,SampleRate,'async') ---------------------------------------------------------------------- Original sound wave: 26 FFT of original sound waves gives: Hence the dominant frequencies are 5 Hz, 350 Hz and 700 Hz. Problem 2: Find Dominant frequency of seismic wave: ---------------------------------------------------------------% This matlab code pulls data from .sac file and gives a plot of seismic waves those are discrete. Then from the plotted graph fundamental frequency is found using FFT. This idea for this matlab code is obtained from ------------------------% function plot_this_sac(filename) [Ztime,Zdata,ZSAChdr] = fget_sac(filename) %[Ztime,Zdata,ZSAChdr] = fget_sac(‘MYJH.sac’) figure(1) plot(Ztime, Zdata,’b’) xlabel(‘time’) ylabel(‘magnitude’) grid on axis([200, 400, -1e6, 1e6]) SampleRate=1/(Ztime(2)-Ztime(1)) N=length(Ztime) figure(2) y=Zdata Y=fft(y,N); Pyy=Y.*conj(Y)/N; f=SampleRate*(0:N/2-1)/N; plot(f,Pyy(1:N/2)) %axis([0, 10, 0, 10]) xlabel(‘frequency [hz]’), ylabel(‘Freq Power Density’) %wavplay(y,SampleRate,’async’) 27 Original seismic wave: FFT of original seismic wave gives: Hence the dominant frequency is 2-3 Hz. 28 Conclusion: Fourier series and Fourier transform are the techniques to find the find dominant frequencies of any vibrating waves. But our goal is to find the fundamental frequency of sound and seismic waves which were not periodic, continuous, and contains countless points which is impossible to do by hand. Thus Fast Fourier Transform was used for the Fourier analysis of sound wave and seismic wave. The main techniques that are necessary for Fourier analysis are given below: Topic: Fourier Techniques Name Fourier Series Fourier Transform Characteristics π(π‘) continuous πΉ(ππ ) discrete π(π‘) continuous πΉ(ππ ) continuous Typical use Analysis of periodic functions and signals Frequency analysis of signals and systems DFT π(π‘π ) discrete πΉ(ππ ) discrete Computation of other transforms Analysis of sampled signals FFT π(π‘π ) discrete πΉ(ππ ) discrete Algorithm to compute the DFT 29 Work Citation: Harman L., Thomas, Advance Engineering Mathematics, PWS Publication Company Osgood, Brad, The Fourier Transform and its Application, Electrical Engineering Department, Stanford University. http://www.math.psu.edu/wysocki/M412/Notes412_8.pdf http://www.intmath.com/fourier-series/3-fourier-even-odd-functions.php http://www.engr.sjsu.edu/trhsu/Chapter%206%20Fourier%20series.pdf