Fun with Fourier! Using the supplied Mathematica code, answer each question (Q) on a separate sheet of paper. There is no need to print off any Mathematica results. Start with a pure tone that has exactly twenty cycles in the sampling interval. Notice that the Fourier has peaks at approximately 20 and 256-20... Q1: Why the Abs[] in the plot? Q2: Why are there two peaks for one frequency? N1=256 data = Table[N[Sin[20 2 Pi k/N1] ], {k, N1}]; ListLinePlot[data] Data=Fourier[data]; ListLinePlot[Abs[Data],PlotRange->All] Q3: But where are those Fourier peaks exactly? ListLinePlot[Abs[Data],PlotRange->{{1,30},All}] ListLinePlot[Abs[Data],PlotRange->{{230,260},All}] Q4: The input wave had an amplitude of 1, what is the magnitude of the resulting Fourier transform? (Note it's not 1-to-1; different versions of "Fourier" will produce different scaling factors.) What happens if we have a constant added to the wave (so called DC Offset)? data = Table[N[Sin[20 2 Pi k/N1] +1 ], {k, N1}]; ListLinePlot[data] Data=Fourier[data]; ListLinePlot[Abs[Data],PlotRange->{{1,30},All}] Q5: The input wave had an amplitude of 1 and a DC Offset of 1, what are the magnitudes of the resulting Fourier coefficients? (Note it's not 1-to-1; different versions of "Fourier" will produce different scales and the DC Offset scale is different from the sinusoidal amplitude scale.) If you want the harmonic number to exactly match where the data is: Data2=RotateLeft[Data,1] ListLinePlot[Abs[Data2],PlotRange->{{1,30},All}] This has the added benefit of moving the usually uninteresting DC Offset to the end of the list. If we make a complex wave we can have just one peak: data = Table[N[Exp[I 20 2 Pi k/N1] ], {k, N1}]; ListLinePlot[Re[data]] ListLinePlot[Im[data]] ListLinePlot[{Re[data],Im[data]},PlotRange->{{1,30},All}] Note: Re[] takes the real part of a complex number, Im[] the imaginary Data=Fourier[data]; ListLinePlot[Abs[Data],PlotRange->All] data = Table[N[Exp[-I 20 2 Pi k/N1] ], {k, N1}]; Data=Fourier[data]; ListLinePlot[Abs[Data],PlotRange->All] Q6: Which one had the peak at about 20? InverseFourier takes the inverse Fourier transform: data = Table[N[Sin[20 2 Pi k/N1] ], {k, N1}]; Data=Fourier[data]; data2=InverseFourier[Data] Max[Abs[data2-data]] Q7: What is the maximum difference between data and InverseFourier[Fourier[data]]? This difference is "round off error" due to the limited precision of computer calculations. In real life signals usually come with noise...here we add some random noise to the sinusoidal: data = Table[N[Sin[20 2 Pi k/N1] + (RandomReal[] - 1/2)], {k, N1}]; it looks rough (and real, i.e., usual); now Fourier Transform: Data=Fourier[data]; ListLinePlot[Abs[Data],PlotRange->{{1,30},All}] We added random noise with amplitude +-.5 to a sinusoidal of amplitude 1, nevertheless the peak stands out. We can estimate the noise where the signal is not: Mean[Abs[Part[Data,25;;230]]] Q8: What is the ratio: signal/noise in the Fourier transformed Data? We can make a combination of frequencies: data = Table[N[Sin[10 2 Pi k/N1] + 2 Sin[15 2 Pi k/N1] + 3 Sin[20 2 Pi k/N1] ], {k, N1}]; ListLinePlot[data] Data=Fourier[data]; ListLinePlot[Abs[Data],PlotRange->{{1,30},All}] Data2=RotateLeft[Data,1]; Q9: Are the amplitudes of these frequencies as expected? What is the proportionality factor between amplitude and Fourier coefficient? Abs[{Data2[[10]],Data2[[15]],Data2[[20]]}] Here is a more complex combination: data = Table[N[Sin[10 2 Pi k/N1] + 1/3 Sin[3 10 2 Pi k/N1] + 1/5 Sin[5 10 2 Pi k/N1] + 1/7 Sin[7 10 2 Pi k/N1]], {k, N1}]; ListLinePlot[data] ListLinePlot[data,PlotRange->{{1,50},All}] Q10: Describe (words) what this input wave looks like. Data=Fourier[data]; ListLinePlot[Abs[Data],PlotRange->{{1,80},All}] ListLinePlot[Abs[Data],PlotRange->{{160,260},All}] Q11: report each harmonic number & corresponding Fourier coefficient here is a "sawtooth" wave: data = Table[N[Mod[k,20]-2416/256], {k, N1}]; ListLinePlot[data]; Data=Fourier[data]; ListLinePlot[Abs[Data],PlotRange->{{1,80},All}] ListLinePlot[Abs[Data],PlotRange->All] Q12: report the first four harmonic number & corresponding Fourier coefficient Below is a "running average" of five successive data points Q13: describe how the data2 and Data2 differ from data and Data data2=Table[Sum[data[[k]],{k,Max[1,i-5],i}]/5,{i,N1}]; ListLinePlot[data2]; Data2=Fourier[data2]; ListLinePlot[Abs[Data2],PlotRange->All]; Heterodyne: Lets take our basic tone and multiple it by another tone (this one complex) data = Table[N[Sin[20 2 Pi k/N1] ], {k, N1}]; data2 = Table[N[Sin[20 2 Pi k/N1] Exp[-I 5 2 Pi k/N1] ], {k, N1}]; Data=Fourier[data]; Data2=Fourier[data2]; ListLinePlot[Abs[Data],PlotRange->{{1,30},All}] ListLinePlot[Abs[Data2],PlotRange->{{1,30},All}] ListLinePlot[Abs[Data],PlotRange->{{230,260},All}]; ListLinePlot[Abs[Data2],PlotRange->{{230,260},All}]; Q14: What is the result? If we use a real tone: data = Table[N[Sin[20 2 Pi k/N1] ], {k, N1}]; data2 = Table[N[Sin[20 2 Pi k/N1] Sin[ 5 2 Pi k/N1] ], {k, N1}]; Data=Fourier[data]; Data2=Fourier[data2]; ListLinePlot[Abs[Data],PlotRange->{{1,30},All}] ListLinePlot[Abs[Data2],PlotRange->{{1,30},All}] ListLinePlot[Abs[Data],PlotRange->{{230,260},All}]; ListLinePlot[Abs[Data2],PlotRange->{{230,260},All}]; Q15: What is the result? FYI: perhaps the trig identity: 2 sin(A) sin(B)= cos(A-B) - cos(A+B) is a familiar form of these results FYI2: You might recall "beats"...same story Q16: Assume you sampled every 0.1ms (i.e. Delta =10^-4 sec) for N=1024 total samples, so the total time sampling was about 0.1 sec. What is the actual frequency (in Hz) of the first non-DC FFT component, i.e., the one Mathematica reports in Data[[2]].