Fourier Transform of Single Frequency Sines and Cosines

Fourier Transform Of Single Frequency Sines And Cosines

The Fourier transform (FT) of function $f(x)$ is defined as follows: $$ F(k) = \frac{1}{\sqrt{2 \pi}} \int_{-\infty}^{\infty} f(x) e^{-ikx} dx $$ The FT is dervived from a Fourier series in complex notation. The Fourier series expands a function into a weighted set of orthogonal basis functions. In case of the FT, the basis functions are sines and cosines. Sines and cosines are periodic on $2\pi$ meaning that the functions repeat themselves at increments of $2 \pi$. The principle idea is that we can represent most functions as a linear combination - a weighted sum - of sine and cosine basis functions. When a function of time $t$ is Fourier transformed, the components of the FT correspond to frequencies of the basis sines and cosines. Frequency is proportional to inverse time. The FT space is often called reciprocal space. If the function transformed were a function of position $x$, the FT is a function of inverse position. In this post, we create some simple examples to illustrate the process. The idea is that a single sine or cosine function, since it equals one of the basis functions, should produce a single frequency component in Fourier space. On the domain $ t \in [-\pi,\pi] $ we define the four functions $\cos(mt),\sin(mt), m=3,8$ and their Fourier transforms. So with $m=3,8$ the functions are $$ f_1(t) = \cos(3t) $$ $$ f_2(t) = \cos(8t) $$ $$ f_3(t) = \sin(3t) $$ $$ f_4(t) = \sin(8t) $$ The result plots of each function and its FT are shown below and the python code to generate them is included below. In each plot, the function is plotted in the top panel and the FT of the function is plotted in the bottom panel.
In each FT panel, three things are plotted: 1: the absolute value AKA complex modulus. 2: the real component and 3: the imaginary component. In the FT of the cosine functions, we get $2$ peaks in the FT. They are real with zero imaginary component and they are located at $\pm m$. So for $\cos(3t)$ we get two negative real only peaks centered at $+3$ and $-3$. For $\cos(8t)$ we get two positive real only peaks centered at $+8$ and $-8$.

For $\sin(mt)$ we are seeing two peaks in each case as well. But now we have zero real components, each of the peaks is imaginary only. These results are mostly what we would expect since the the sine components of terms the complex Fourier series are the imaginary terms. The cosine terms are real. The peaks in the sine wave FT's also come in pairs centered at $\pm m$.

The only remaining question is why are there $2$ peaks in each case and what determines the sign of these peaks? In the FT of the cosines, the peaks have the same sign, both negative when $m=3$ and positive when $m=8$. Read more about the reason for that in the theoretical background section of this article (see text right under equation 10).

Would you like to experiment with this example? The Github project is availabe here: https://github.com/aruymgaart/AMATH/tree/master/DFT_and_Fourier_series.

The plots were generated with the following Python script. The code for the same in MATLAB is included as well in the comments.

Comments

Popular posts from this blog

Data science & ML Video Tutorials Part II - Group & Set Theory (Groups, Rings & Fields)

Finite Difference Simulation of a Helmholtz Resonator - 2D Acoustic Wave Equation

Combination Finite Difference & Spectral Solution to Advection-Diffusion PDE