What is Fourier Series? and It’s Beauty

Kazi Abu Rousan
The Startup
Published in
8 min readJun 7, 2020
Joaquin Phoenix Joker using 6000 epicycles(For full video click )

Regarding the research of d’Alembert and Euler could one not add that if they knew this expansion, they made but a very imperfect use of it. They were both persuaded that an arbitrary and discontinuous function could never be resolved in series of this kind, and it does not even seem that anyone had developed a constant in cosines of multiple arcs, that first problem which I had to solve in the theory of heat. —J. Fourier

“What is Fourier Series?” using 3000 epicycles

The Begining

It all starts when Joseph Fourier started to analyze the Heat Equation which looks like:

Here T represent Temperature at any position x at time t

This equation is what we call A Linear Partial Differential Equation , what it means is ,

If we have 2 solutions(Φ1 and Φ2) which are different and satisfies a Boundary condition then we can write:

A new solution=Y = (a ×Φ1 )+ (b ×Φ2)

where a and b are 2 arbitrary constants which depends upon the Initial Conditions. But how it is so powerful . As we know the solution will give us some combination of sine and cosine function. So what?

To understand what I mean , let’s take a simple example. We will consider an imaginary perfect metal rod, which have 2 different temperatures on two different sides with respect to it’s midpoint. Let’s see what I mean graphically:

The rod has 2 different temperatures on 2 different side w.r.t it’s midpoint.

So, If we mark temperature on Y-axis and position on X-axis, then as you can see, we get what we call a Step Function.

But wait a minute, I have told you the solution we get from the Heat Equation are Linear combination of cosine or sine function.

But our assumed system of Rod should also be solvable with the same method and should give us A Linear combination of Sine and Cosine(i.e., we will get Step function using Periodic sine and cosine function?? w.t.f)

This is where Fourier make a move , what we call a pro gamer move and become immortal in the world of Science.

Step function using Combination of sine and cosine

As you can see in the video, As we keep adding the cosine or sine or their combination (depends on boundary condition) with appropriate coefficients(in our discussion similar to a and b),we are getting something close to our desired function. But our function is discontinuous and even that can’t stop us!!, Now you understand how powerful it is? You may say, well It looks like our function but it is not exactly that, I will say yes you are right. What we have is just an approximation but as we add more and more solutions of the Differential Equation shown above , We will get more and more close to our function. Here I have given you a playing thing, Try increasing number of terms and see how you approaches to that function(More general square wave).

Now we understand the idea behind this beautiful method. So, Now let’s see how to calculate one.

Fourier Series of a Function:

If a function f(x) of some real variable x, defined and integrable in the interval (c,c+2L), satisfies Dirichlet’s Conditions i.e.,

  1. f(x) is single valued and finite,
  2. f(x) is piecewise continuous having at most finite number of finite discontinuities,
  3. f(x) has at most finite number of maxima and minima within the interval,

then f(x) can be expanded in this interval into the following series, called Fourier Series

Notice, I have not written that f(x) is periodic as we can write f(x) as a series even if the function is not periodic.

If we consider the function of time with a period of T i.e., in the interval (c,c+T), Then we can write

Where ω=2π/T and T = 2L.

Triangular Wave formation using just pure sine waves

The GIF where the Square wave(Step Function for a particular case) or Triangular wave is formed as an example of this series. As you can see we are just adding pure waves with certain frequency and amplitude. They are just waves and not have any circles in it.

In these 2 equations a0, an and bn are called Fourier Constants and are given by

The value of (a0/2) is found by putting n = 0 , so I have not written it.

If you want the proof, just use the orthogonality of sine and cosine .

So, We have seen that we can expand any function(which satisfies certain conditions) into a series of sine and cosine. But where are the circles which you see in the Joker or What is Fourier series gif? To understand this we have to go back to the equation

exp(iθ) = cos(θ)+i sin(θ) ; Where i is the square root of -1

This equation tells us that exp(iθ) represent a circle as cos(θ) and sin(θ) also does the same. Using this simple but powerful identity we can write the f(x) in terms of exponential functions and in 2D plane they are represented by circles.

Like you see in this video, We have drawn a perpendicular from it’s tip to the Imaginary axis. The curve created because of it is our good old sine curve.

Similarly we can get a cosine curve if we draw a perpendicular from the tip to real axis.

So, using the upper identity we can write f(x) as:

Now you see from where those circles come from.

Adding each exponent term of the complex Fourier expansion for square wave

In this series each exponent term actually represent a rotating circle with a certain frequency(given by the term inside bracket) and a certain radius(given by cn). Those circles join together(one after another to their radius’s end like shown in the GIF file) to give you the curve or function as you have seen before.

Here cn is equivalent to (an-ibn)/2 and c-n is equivalent to (an+ibn)/2. Those constants are given by,

The problems concerning the possibility of expressing a function by Fourier Series are cumbersome. Fortunately almost all functions associated with physical problems are covered by the Dirichlet’s Conditions. Fourier’s Theorem is a set of conditions sufficient to imply the convergence of The Fourier Series to some function closely related to the given function.

Convergence of The Series:

If f(x) and f`(x) are sectionally continuous in -L to L and f(x) satisfies Dirichlet conditions then according to Fourier Theorem we can say:

The Fourier series of f(x) converges to (f(x+)+f(x-))/2

If f(x) is discontinuous at a point x0, then the Fourier series of f(x) converges to (f(x0+ɛ)+f(x0-ɛ))/2 as ɛ→0.

Odd-Even Function Trick:

When we expand any function we have an equation with a Left hand side and Right hand side . As both sides must be equal, If one side has even function , then another one must be even and if one is odd then other must be odd also. This simple idea is very far reaching and it reduces the complexity of calculation.

As we know cosine is an even function so if f(x)=f(-x), then Expansion of f(x) only contains terms with cosines and if f(x)=-f(-x), then Expansion of f(x) only contains terms with Sine as sine is a odd function.

Calculation:

Let’s calculate the fourier series of the square wave as an example:

As you can see the Square wave is defined as shown here.

As you can notice f(t)=-f(-t), this means we must have odd terms only when we expand this function. This means we will only have the sine terms i.e., the terms whose coefficient are bn. This insight reduced our half work and we will now only consider sine terms and not cosines.

To solve this problem as i have told before , we just need bn due to the symmetry as shown in the figure. To understand it’s intuition see the p5.js sketch hyperlinked with the text “Playing Thing” before the discussion Fourier Series of a Function.

This is the Square wave where T = 3
This is the solution.

As you can see here I have used the series of sine and cosine expansion(with an=0), but you can also expand the Square wave using exponent terms , which is signified by the fact that you can create that using Rotating Phasors(vectors) as shown before.

End:

The Fourier Series is a way of representing certain functions(mostly all periodic functions). From classical physics to Quantum Mechanics, even in data processing, It is used . It is one of the most powerful tool ever created by Maths.

We have discussed so much but even now there are many topics left. This post is already long so we will discuss the remaining things later. I hope this article will help you in building intuition and will help you in solving many basic problems. With this let’s end our discussion here.

If you want to make any drawing using epicycles, here is my github link (click upon the github word and you just need python nothing more). Just download that repository and use it for creating beautiful animations. But remember the best result will come when the used images will be single-line drawing(As an example see this white background gif).

OR you can visit here, I have written this Sketch try it out to draw circular Fourier Series(As an example see the screenshot)

Upper one is the Drawing and Lower one is the Series Breakdown to circle

Copyright stuff:

All the images and gif used here are all created using a python library called Manim , developed by Grant Sanderson and p5.js developed by Lauren McCarthy . All equations and calculations used are written by me using Latex.

--

--