Purrier Series (Meow) and Making Images Speak

Fourier series can be explained as expressing a repetitive curve as sum of sine curves. Since “summation of sine waves” interpretation shows how many of waves are there at each frequency, it is widely used in engineering, physics, and mathematics. The main idea in this interpretation is that sine and cosine functions are mutually orthogonal, like vectors which are perpendicular to each other.

\(\displaystyle{\frac{1}{\pi}\int \limits_{-\pi}^{\pi} {\color{black}\sin({\color{red}n} x)}{\color{black} \sin({\color{blue}m} x)} dx = \begin{cases} 1, & {\color{red}n} = {\color{blue}m} \\ 0, & {\color{red}n} \neq {\color{blue}m}\end{cases}}\)

\(\displaystyle{\frac{1}{\pi}\int \limits_{-\pi}^{\pi} {\color{black}\cos({\color{red}n} x)}{\color{black} \cos({\color{blue}m} x)} dx = \begin{cases} 1, & {\color{red}n} = {\color{blue}m} \\ 0, & {\color{red}n} \neq {\color{blue}m}\end{cases}}\)

\(\displaystyle{\frac{1}{\pi}\int \limits_{-\pi}^{\pi} {\color{red}\sin({\color{red}n} x)}{\color{blue} \cos({\color{blue}m} x)} dx =0}\)

Reminder; if two unit vectors are orthogonal, result is the same.

\({\bf \hat{{\color{red}e}}}_{\color{red}i} \cdot {\bf \hat{{\color{blue}e}}}_{\color{blue}j} = \begin{cases} 1, & {\color{red}i} ={\color{blue} j} \\ 0,&  {\color{red}i} \neq {\color{blue}j} \end{cases}\)

Joseph Fourier

Although it was first discovered by Euler, Fourier realized and demonstrated its importance in analysis of waves; therefore it is known by his name. It is defined as (well, yes it has many forms, but Fourier defined it as):

\(\displaystyle{f(x) = \frac{a_0}{2} + \sum \limits_{n = 1}^N \left[ a_n {\color{red} \sin(n x)} + b_n {\color{blue}\cos(nx)}\right]},\)

\(f(x)\) is a periodic function for \(x \in [-\pi, \pi]\) of which we want to find the representation. \(a_0\) is a constant,

\(a_0 = \displaystyle{\frac{1}{\pi} \int \limits_{-\pi}^{\pi} f(x) dx }\)

 \(a_n\) and \(b_n\) defined as:

\(a_n = \displaystyle{\frac{1}{\pi} \int \limits_{-\pi}^{\pi} f(x) {\color{blue} \cos(nx) }dx },\)

\(b_n = \displaystyle{\frac{1}{\pi} \int \limits_{-\pi}^{\pi} f(x) {\color{red}\sin(nx) }dx }.\)

I would like to show Fourier transformations of some functions, because it is basically fun (ᵔᴥᵔ)

Our first function is a signal which is switching between +1 and -1:

A simple signal switching between +1 and -1. Now, we try to interpret this as sum of sines. The more terms we add, the merrier.

Now we are trying to interpret it as a Fourier series. Each sine wave has a certain frequency. We have to find how many of them are there for each frequency. I am writing the resultant Fourier series :

\(f(x) = \displaystyle{ \sum \limits_{n = 1,3,5,7…}^{\infty} \left(\frac{4}{n \pi}\right)\sin\left(\frac{n \pi x}{L}\right)}\)

\(L\), which is the period of \(f(x)\), is \(2\pi\) for this example. In the animations below, I will show the Fourier series for n values of \(n = 1,3,5,7,9,11,13,15\).

How was that? Isn’t it marvelous? (。◕‿◕。) One can think of a sine wave as the distance covered by the shadow of a ball which turns around a circle. For this “square signal” wave, adding more terms means turning circles with smaller radius around the former circle with higher speeds. Frequency of these turning circles is increasing in odd numbers (leaving the math to you). As we add more circles (more n’s), we get closer to the function that we started with (green lines). Also, you might notice the curves that I added transparently in the background. These curves are known as the cycloid curves! (I mentioned them in a previous article [It’s in Turkish by the way])

I can show how it approaches to the function as we add more terms in this way : We can add terms up to \(n = 240\)!

Allons-y! Now we take a “saw-tooth-like” signal and expand it to a Fourier series.

“Saw tooth” signal.

When we expand it to a Fourier series, we obtain the following relation:

\(f(x) = \displaystyle{\frac{1}{2}} -\displaystyle{  \sum \limits_{n = 1}^{\infty}\left( \frac{1}{n \pi}\right)\sin\left(\frac{n \pi x}{L}\right)}\)

Again, the more terms we add, the closer we get to this function. In animations below, I presented cases for \(n = 1,2,3,4,5,6,7,8\).

The transparent curve is, indeed, a cycloid curve!

Finally, I will expand a triangle-shaped wave to a Fourier series, but it is not as funny as the previous ones. The “triangular wave” is this:

Triangular Wave.

I derived its Fourier transformation as follows:

\(f(x) = \displaystyle{  \sum \limits_{n = 1,3,5,7,…}^{\infty} \left(\frac{8}{\pi^2} \frac{(-1)^{\frac{(n-1)}{2}}}{n^2}\right)\sin\left(\frac{n \pi x}{L}\right)}\)

As we add more terms, circles rapidly get so small that they don’t look nice as the previous ones. Anyway, I am adding animations for the first three terms as \(n = 1,3,5\) :

So, where do we use this wisdom? Basically, everywhere! This Fourier analysis thing is like four operations in engineering or science. For example, you have a signal like a noise. You want to analyze it. Suddenly, the Purrier Transform jumps into your lap, and says (or meows) how many waves are there for each frequency.

Purr and Fourier analysis.

In the figure above, you obtain the Fourier transform of a sound, and it says that the proportion of a wave with specific frequency (1 Hz) is very high with respect to others in the composition of this sound.T

here are a lot of charming applications of this in image and audio processing. I would like to show you, here, an interesting application.

In this work, sound can be extracted from a video by using a very sophisticated Fourier analysis.It means that, you can catch all your neighbor’s gossips about you just by silently videotaping her flower in the living room, which is… also a little bit creepy.

Article and animations: Bilgecan Dede
Special thanks for translation: Gurkan Sonmez (Unfortunately there are no articles of him yet)
The original article in Turkish: Fuyye Serisi

The following two tabs change content below.

Bilgecan Dede

Yazar: Bilgecan Dede (tümünü gör)

18 thoughts on “Purrier Series (Meow) and Making Images Speak

  • 11 December 2018 at 20:44

    Music and Sound Design Implications seem likely from your work.

    Synthesis from additive sine waves is nothing new (Additive Synthesis and in particular Fast Fourier Transform FFT) but I haven’t seen anyone that has tried your technique to recreate sound. I think the future of sound design and things like samplers (For example piano or violin played by a keyboard that play backs samples of music) are soon to be a thing of the past once additive synthesis is developed more. I feel like we are still stuck in 2004 in music production with additive synthesis. Would love to know if anyone is looking at this work to be used with audio re-synthesis?

  • 12 December 2018 at 02:41

    Merhaba! Smarter Everyday brought me hear (and the link in one of your replies). Well done! Aferin.

    In a certain sense, the attempt of Ptolemy of describing the movement of the planets through epicycles, is a kind of Fourier decomposition of their real movements, don’t you agree?

  • 14 December 2018 at 05:49

    wow that’s neat! you should make an applet so people can mess up with it. tsk

  • 16 December 2018 at 09:53

    Bazı periyodik fonksiyonları rahat bir şekilde fourer serisine açabiyoruz.örneğin ekg dalgalarınıda fourer serisi şeklinde açabirmiyiz yada ekg dalgaları hangi fonksiyonlardan oluşur?

  • 8 January 2019 at 19:17

    Excellent work,
    I will keep in touch.
    It has been valuable to me.


    Gerardo DFS

  • 17 April 2019 at 10:18

    I’m absolutely blown away by this article!

    I have read a lot about Fourier series. It has always been a magical thing and finally you have shown me the trick. I love it!

    Thank you very much. Is there any chance that you send me the matematica notebooks used to do this? Or the link if you have published it on the wolfram demonstration projects page.

    Thank you for your brilliant work!

  • 1 June 2019 at 23:42

    An astounding and brilliant piece of work. This is the way Fourier should be taught. I’ll be diving into my mathematica to recreate.

  • Pingback:Fourier Series Visualization Using React Hooks - 浮生插电

  • Pingback:Coding Challenge #125: Fourier Series | Watch Movies Online

  • Pingback:Using Blender to run Python and visualizing the Fourier Series - 浮生插电

  • 27 December 2019 at 23:32

    Artykuł godny polecenia. Gratulacje!!!
    Piękno matematyki w czystej formie.

  • 10 January 2020 at 05:56

    You are a genius. Thank you. Salutes you from Argentina.

  • 4 April 2020 at 15:30

    How can I resolve Gibbs phenomenon? You cannot just add up term by term because it is an infinite serie, not summation, as you can see that summation of continous function to get a discountinous fuction like square wave fuction, so overshoot and undershoot occur at jump point?

  • 18 April 2020 at 01:53

    This is amazing you blow my mind !
    If I understood correctly you did the animations on Mathematica ?
    If it the case would you be willing to share the files ? I’m an engineering student and I would love playing around with Matematica and those animations.
    Thanks !

  • 24 January 2021 at 02:00

    I always disliked Fourier because, for the most part, I did not understand its importance. I YouTubed it, which led me to Smarter Every Day, which led me to this article. Also, I never understood how sinusoidal waves could create square and saw-tooth waves, but now I know. I must say the video and this article helped me understand its importance. Creating images from pure sinusoidal signals is mindblowing.
    Thanks! Regards from Pakistan!

  • 10 March 2021 at 23:03

    Wonderful! Congrats and thank you very, very much. Beautiful work.


Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.