The Fourier Series

Pure mathematics is much more than an armory of tools and techniques for the applied mathematician. On the other hand, the pure mathematician has ever been grateful to applied mathematics for stimulus and inspiration. From the vibrations of the violin string they have drawn enchanting harmonies of Fourier Series, and to study the triode valve they have invented a whole theory of non-linear oscillations.

George Frederick James Temple In 100 Years of Mathematics: a Personal Viewpoint (1981).


Figure 1: Jean-Baptiste Joseph Fourier(source wikipedia)

The Fourier Series is a very important mathematics tool discovered by Jean-Baptiste Joseph Fourier in the 18th century. The Fourier series is used in many important areas of science and engineering. They are used to give an analytical approximate description of complex periodic function or series of data.  In this blog, I am going to give a short introduction to it.

Let start with some definition. A function {f(t)} is said to be periodic with period T (T being a nonzero constant) if it if it is defined for all real {\Re} and if there is some positive number, T, such that

f(t+T)=f(t)

An example of periodic functions are the sinusoidal function (or sinusoidal oscillation or sinusoidal signal)} given by the function  f(t) = A \sin(\omega t + \phi) where

  • {A > 0}: Amplitude. It gives how high the graph {f(t)} rises above the t-axis at its maximum values.
  • {\phi}: phase lag. Position of the maximum of the function.
  • {\tau=\phi/\omega}: the time delay or time shift. It tell you how far the graph of the {\cos(\omega t)} has been shifted along the t-axis.
  • {\omega} : angular frequency. It gives the number of complete oscillation of {f(t)} in a time interval of length {2\pi}.
  • {\nu=\omega/2 \pi}: frequency of {f(t)}. It gives the number of complete oscillation of {f(t)} in a time interval of length 1.
  • {P=2\pi/\omega=1/\nu}: period.Time required for one complete oscillation.
Fig1

If the function {f(t)} is a periodic function with period {p} The function in the interval {[-p,p]} can be represented by a trigonometric series as:

f(t)=\frac{a_0}{2}+\sum_{n=1}^{\infty}a_n\cos (\frac{n\pi t}{p})+\sum_{n=1}^{\infty}b_n\sin (\frac{n \pi t}{p}) \ \ \ \ \ (1)

namely as a summation of sinusoidal functions of different frequency and amplitude that allows to approximate any periodic function with any level of accuracy.

Fig2

In order to achieve this result we need to calculate the coefficients {a_n} and {b_n} in the series. But for that, we need to recall of properties of these functions and of their integrals.

 Integral of Orthogonal Functions

\int_{-\pi}^{\pi} \cos (nt) \cos (mt) dt=\frac{1}{2}\int_{-\pi}^{\pi} \cos(n+m)t dt +\frac{1}{2}\int_{-\pi}^{\pi} \cos(n-m)t dt \ \ \ \ \ (2)

This means that for {n \neq m}:

\int_{-\pi}^{\pi} \cos (nt) \cos (mt) dt= 0 \ \ \ \ \ (3)

for {n=m}:

\int_{-\pi}^{\pi} \cos (nt) \cos (mt) dt= \pi \ \ \ \ \ (4)

\displaystyle \int_{-\pi}^{\pi} \sin (nt) \cos (mt) dt=\frac{1}{2}\int_{-\pi}^{\pi} \sin((n+m)t) dt +\frac{1}{2}\int_{-\pi}^{\pi} \sin((n-m)t) dt \ \ \ \ \ (5)

This means for all value of {m} that  \int_{-\pi}^{\pi} \cos (nt) \cos (mt) dt= 0 \ \ \ \ \ (6)

\displaystyle \int_{-\pi}^{\pi} \sin (nt)\sin (mt) dt=\frac{1}{2}\int_{-\pi}^{\pi} \cos((n-m)t) dt +\frac{1}{2}\int_{-\pi}^{\pi} \cos((n+m)t) dt \ \ \ \ \ (7)

This means that for {n \neq m}:

\int_{-\pi}^{\pi} \sin (nt) \sin (mt) dt= 0 \ \ \ \ \ (8)

for {n=m}:

\int_{-\pi}^{\pi} \sin (nt) \sin (mt) dt= \pi \ \ \ \ \ (9)

Determination of {a_0}

We start to integrate both the members of the Fourier series from {-\pi} to {\pi}

\int_{-\pi}^{\pi} f(t)dt=\int_{-\pi}^{\pi}\left[\frac{a_0}{2}+\sum_{n=1}^{\infty}a_n \cos (nt)+\sum_{n=1}^{\infty}b_n\sin (nt) \right] dt

\int_{-\pi}^{\pi}f(t)dt=\frac{a_0}{2}\int_{-\pi}^{\pi}dt +\int_{-\pi}^{\pi} \left(\sum_{n=1}^{\infty}a_n\cos (nt)\right)dt+\int_{-\pi}^{\pi} \left(\sum_{n=1}^{\infty}b_n\sin (nt)\right)dt

For the integrals formulas that we have derived before, we obtain

\int_{-\pi}^{\pi}f(t)dt=\frac{a_0}{2}\int_{-\pi}^{\pi}dt +0 + 0=\pi a_0

namely, a_0=\frac{1}{\pi}\int_{-\pi}^{\pi} f(t)dt

{A_0=a_0/2} is equal to the average value of the function {f(t).}

Determination of {a_n}

We start by multiplying both the members of the Fourier series by {\cos (mt)} and then integrate from {-\pi} to {\pi}

\int_{-\pi}^{\pi} f(t)\cos (mt) dt=\int_{-\pi}^{\pi}\left[a_0+\sum_{n=1}^{\infty}a_n\cos(nt)+\sum_{n=1}^{\infty}b_n\sin (nt)\right]\cos (mt) dt

Shall we consider the integrals that we get on the right-hand-side:

First term: \int_{-\pi}^{\pi}a_0\cos (mt) dt =0

The second integral for {m=n} is equal to:

\int_{-\pi}^{\pi} \sum_{n=1}^{\infty}a_n\cos (nt)\cos (mt) dt = a_n\pi

The third integral for the orthonormality of the function is always equal to:

\int_{-\pi}^{\pi} \sum_{n=1}^{\infty}b_n\sin (nt)\cos (mt) dt = 0

Therefore:

\int_{-\pi}^{\pi}f(t)\cos (nt) dt=a_n\pi

namely, for {m= 1, 2, 3, ...}:

a_n=\frac{1}{\pi}\int_{-\pi}^{\pi}f(t)\cos (nt) dt

Determination of {b_n}

We start by multiplying both the members of the Fourier series by {\sin(mt)} and then integrate from {-\pi} to {\pi}

\int_{-\pi}^{\pi}f(t)\sin(mt) dt=\int_{-\pi}^{\pi}\left[a_0+\sum_{n=1}^{\infty}a_n\cos(nt)+\sum_{n=1}^{\infty}b_n\sin (nt)\right]\sin(mt) dt

Shall we consider the integrals that we get on the right-hand-side:

First term:

\int_{-\pi}^{\pi}a_0\sin(mt) dt =0

Second term:

\int_{-\pi}^{\pi} \sum_{n=1}^{\infty}a_n\cos (nt)\sin(mt) dt = 0

Third term:

\int_{-\pi}^{\pi} \sum_{n=1}^{\infty}b_n\sin (nt)\sin(mt) dt = b_n\pi

Therefore:

\int_{-\pi}^{\pi}f(t)\sin(nt) dt=b_n\pi

namely, for {m= 1, 2, 3, ...}:

b_n=\frac{1}{\pi}\int_{-\pi}^{\pi}f(t)\sin(nt) dt

Summary

The coefficients of the Fourier series 

By replacing m with n we can finally express the coefficient of the series in the final form.

a_0=\frac{1}{\pi}\int_{-\pi}^{\pi}f(t)dt

a_n=\frac{1}{\pi}\int_{-\pi}^{\pi}f(t)\cos (nt) dt

b_n=\frac{1}{\pi}\int_{-\pi}^{\pi}f(t)\sin(nt) dt  with {n=1,2,3,...}

or in the same way we can integrate in the interval {0-2\pi} with the same result:

a_0=\frac{1}{\pi}\int_{0}^{2\pi}f(t)dt

a_n=\frac{1}{\pi}\int_{0}^{2\pi}f(t)\cos (nt) dt

b_n=\frac{1}{\pi}\int_{0}^{2\pi}f(t)\sin(nt) dt

For a given generic interval {[-p,p]}

a_0=\frac{1}{p}\int_{-p}^{p}f(t)dt

a_n=\frac{1}{p}\int_{-p}^{p}f(t)\cos (\frac{n\pi t}{p}) dt

b_n=\frac{1}{p}\int_{-p}^{p}f(t)\sin(\frac{n\pi t}{p}) dt  with {n=1,2,3,...}

and the Fourier series is give by

f(t)=\frac{a_0}{2}+\sum_{n=1}^{\infty}a_n\cos (\frac{n\pi t}{p})+\sum_{n=1}^{\infty}b_n\sin (\frac{n \pi t}{p})


Example 1

In this example, we will calculate the Fourier coefficient of a the square wave function. This function is of paramount importance in digital electronics since it used in the electronic signal to represent unit of information (bit) as on/off state.

Mathematically, the square wave is represented by functions as

f(x)=\begin{cases} 1 & {0 < x <= \pi}, \\ 0 & \pi<x <= 2 \pi \end{cases} 

The plot of the extended periodic function is given in the following figure.

Figure 2: The function of the Exercise 1.

We now calculate the Fourier coefficients starting from the term  a_0

a_0 = \frac{1}{\pi} \int_{0}^{2\pi} f(t) ~dt

a_0 = \frac{1}{\pi} \left[\int_{0}^\pi f(t) ~dt +\int_{\pi}^{2\pi} f(t) ~dt \right]= 1.

The coefficients a_n are given by

a_n= \frac{1}{\pi} \int_{-\pi}^{\pi} f(t) \cos(nt) dt =\frac{1}{\pi}\int_{0}^{\pi} {\pi} \cos(n)dt =0.

And finally

\begin{aligned} b_n & = \frac{1}{\pi} \int_{-\pi}^\pi f(t) \sin (nt) ~dt \\ &= \frac{1}{\pi} \int_{0}^\pi \pi \sin (nt) ~dt \\ &= \left[ \frac{- \cos (nt)}{n} \right]_{t=0}^\pi \\ &= \frac{1 - \cos (\pi n)}{n} \\ &= \frac{1 - {(-1)}^n}{n}\end{aligned}

or

b_n=\begin{cases} \frac{2}{n} & \text{if } n \text{ is odd} , \\0 & \text{if } n \text{ is even} \end{cases}

The Fourier series is

f(t)=\frac{\pi}{2} + \sum_{\substack{n=1\\n \text{ odd}}}^{\infty} \frac{2}{n} \, \sin (n t)= \frac{\pi}{2} + \sum_{k=1}^{\infty} \frac{2}{2k-1} \, \sin \bigl( (2k-1)\, t \bigr) .

In this way, for example, the first 3 harmonics of the series are

f(t)= \frac{\pi}{2} +2 \, \sin (t)+\frac{2}{3} \, \sin (3t)+ \cdots

Example 2

In this second example the square wave signal is defined as a odd function such that f(x)=-f(-x) and mathematically, the square wave is represented by functions as

f(x)=\begin{cases} -1 & {-\pi < x <= 0}, \\ 1 & 0<x <= \pi \end{cases} 

The plot of the extended periodic function is given in the following figure.

Figure 3: The function of the Exercise 2.

We now calculate the Fourier coefficients starting from the term  a_0

a_0 = \frac{1}{\pi} \int_{-\pi}^\pi f(t) ~dt = \frac{1}{\pi} \int_{0}^\pi \pi ~dt = \pi .

The coefficients a_n are given by

a_n= \frac{1}{\pi} \int_{-\pi}^{\pi} f(t) \cos(nt) dt =\frac{1}{\pi}\int_{0}^{\pi} {\pi} \cos(n)dt =0.

And finally

\begin{aligned} b_n & = \frac{1}{\pi} \int_{-\pi}^\pi f(t) \sin (nt) ~dt \\ &= \frac{1}{\pi} \int_{0}^\pi \pi \sin (nt) ~dt \\ &= \left[ \frac{- \cos (nt)}{n} \right]_{t=0}^\pi \\ &= \frac{1 - \cos (\pi n)}{n} \\ &= \frac{1 - {(-1)}^n}{n} \end{aligned}

or

b_n=\begin{cases} \frac{2}{n} & \text{if } n \text{ is odd} , \\0 & \text{if } n \text{ is even} \end{cases}

The Fourier series is

f(t)=\frac{\pi}{2} + \sum_{\substack{n=1\\n \text{ odd}}}^{\infty} \frac{2}{n} \, \sin (n t)= \frac{\pi}{2} + \sum_{k=1}^{\infty} \frac{2}{2k-1} \, \sin \bigl( (2k-1)\, t \bigr) .

The plot of the first 100 terms of the series is given in the following animation.

Figure 4: Animation showing the first 100 terms of the Fourier series for the square wave curve of Example 2. The animation was generated using a Gnuplot script available to this interesting website.

The overshoting oscillations in correspondence of the discontinuity of the square wave is called Gibbs phenomenon by W. Gibbs that pointed it out in a  letter to Nature in 1899. The oscillation overshoot the function of a fixed amount  that can be calculated. In addition, the function oscillate with an amplitude that is decreating going far from the discontinuity point.


Fourier Series using Complex Notation 

Let {f(x)} be a piecewise linear function on {[-L,L]} (This means that {f(x)} may possess a finite number of finite discontinuities on the interval). Then {f(x)} can be expanded in a

f(x)=\frac{a_0}{2}+\sum_{n=1}^{\infty} \left[ a_n\cos \frac{n\pi x}{L}+b_n\sin\frac{n\pi x}{L} \right] \ \ \ \ \ (10)

Using Euler’s identities:

\begin{aligned} \cos \theta &=& \frac{e^{i\theta}+e^{-i\theta}}{2}\\ \sin \theta &=& \frac{e^{i\theta}-e^{-i\theta}}{2i} \end{aligned}

where {i=\sqrt{-1}},

the Fourier series of {f(x)} can be written in a more compact from as

\displaystyle f(x) = \sum_{n=-\infty}^{\infty} c_n e^{i n\pi x/L} \ \ \ \ \ (11)

where

c_n = \frac{1}{2L} \int_{-L}^{L} f(x)e^{-in\pi x/L}dx \ \ \ \ \ (12)

\displaystyle c_n=\begin{cases} (a_n-b_n)/2 & n<0 \\ (a_n+b_n)/2 & n>0 \\ a_0/2 & n=0 \end{cases}

Leave a comment

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