Excel Fourier Analysis for Students
Excel Fourier Analysis for Students
May 2012
Recommended Citation
Oliveira, Margarida Prof.; Nápoles, Suzana Prof.; and Oliveira, Sérgio Eng. (2012) Fourier Analysis: Graphical Animation and Analysis
of Experimental Data with Excel, Spreadsheets in Education (eJSiE): Vol. 5: Iss. 2, Article 2.
Available at: http://epublications.bond.edu.au/ejsie/vol5/iss2/2
This Regular Article is brought to you by the Bond Business School at ePublications@bond. It has been accepted for inclusion in Spreadsheets in
Education (eJSiE) by an authorized administrator of ePublications@bond. For more information, please contact Bond University's Repository
Coordinator.
Fourier Analysis: Graphical Animation and Analysis of Experimental Data
with Excel
Abstract
According to Fourier formulation, any function that can be represented in a graph may be approximated by
the “sum” of infinite sinusoidal functions (Fourier series), termed as “waves”.The adopted approach is
accessible to students of the first years of university studies, in which the emphasis is put on the understanding
of mathematical concepts through illustrative graphic representations, the students being encouraged to
prepare animated Excel-based computational modules (VBA-Visual Basic for Applications).Reference is made
to the part played by both trigonometric and complex representations of Fourier series in the concept of
discrete Fourier transform. Its connection with the continuous Fourier transform is demonstrated and a brief
mention is made of the generalization leading to Laplace transform.As application, the example presented
refers to the analysis of vibrations measured on engineering structures: horizontal accelerations of a one-
storey building deriving from environment noise. This example is integrated in the curriculum of the
discipline “Matemática Aplicada à Engenharia Civil” (Mathematics Applied to Civil Engineering), lectured at
ISEL (Instituto Superior de Engenharia de Lisboa. In this discipline, the students have the possibility of
performing measurements using an accelerometer and a data acquisition system, which, when connected to a
PC, make it possible to record the accelerations measured in a file format recognizable by Excel.
Keywords
Fourier Analysis; movie clips in spreadsheets; spectral analysis; experimental data.
Distribution License
This work is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 4.0
License.
1 Introduction
If we had to choose a mathematical topic extensively used in science and
technology, the Fourier Analysis would be one of the first choices. Due to its various
applications, this subject, which is included in most curricula of the first years of
mathematics and engineering courses, is a privileged theme to illustrate a
mathematical teaching methodology based on the development of interactive
applications that interconnect the different types of mathematical knowledge. Using
visual representations of the main mathematical notions involved, we promote a
critical consideration on the associated concepts, which is essential to a deep
understanding of the subject.
The use of such dynamic applications [8], [9] becomes more meaningful when
compared with the mere use of text books. For a long time, we have used text books
which contained only images of an inevitably static nature. The development of
technologies led to the creation of appealing software containing animated graphs,
usually developed in a sophisticated programming language, and thus becoming a
possible teaching tool, but only from the user's point of view.
The approach addressed here aims to demonstrate that this subject can be studied in
a structured and cohesive manner by interconnecting students' previous
mathematical knowledge.
For the purpose, we use visual representations of the main mathematical notions
involved to encourage students' critical thinking.
The representation of mathematical ideas has been one of the mathematicians'
concerns over the years. Regardless of its type of representation, whether geometric,
algebraic or graphic, it has been of the general consensus that mathematical learning
becomes easier when different types of representations are used [1].
Based on the belief that the construction of different representations by the students
themselves is an advantage, this article suggests the development and/or use of
Excel-based computational applications [7], [6] with animations, in order to
visualize some of the mathematical concepts involved.
For instance, using the application waves.xls it is possible to study trigonometric
functions of the type f(t)=a cos(ω t)+b sin(ω t) and to observe the changes in the graphs
of these functions when the values of a, b and ω are modified. Using the application
Fourier_movie.xls, it is possible to visualize a movie showing the approximation of a
function by a Fourier series in a given interval.
The use of a spreadsheet enables students to develop animated computational
modules on their own, being an advantage when compared with the use of
previously built modules. This tool makes it possible to obtain remarkable results in
terms of graphic animations (of a high pedagogical value) with just some basic
programming notions of Visual Basic (VBA – Visual Basic for Applications).
Lastly, we present an example, which, despite its simplicity, enables the students to
understand the relevance of studying Fourier Analysis.
b A= a2 + b2
a b
0 b atan ( b ) a>0 , b>0
t
T= 2π
T/4 T/2 3T/4 a
ω A φ
φ = atan ( ba ) + 2π a>0 , b<0
a a
atan ( ba ) + π a<0
-A
τ = φ/ω
A - Wave amplitude f - Wave frequency in Hz or cycle/s f = 1 / T
T - Wave period τ - Horizontal position of the maximum (between 0 and T)
ω - Wave frequency (rad/s) ω = 2π /T φ - Phase angle (between 0 and 2π)
http://epublications.bond.edu.au/ejsie/vol5/iss2/2 2
Oliveira et al.: Fourier Analysis with Excel
11∆ω
Wave 11
10 ∆ω
Wave 10
9 ∆ω
Wave 9
8 ∆ω Wave 8
7∆ω
Wave 7
a n= a(ωn )
6∆ω Wave 6
an , bn 5 ∆ω Wave 5
4 ∆ω Wave 4 ∆ω = 2
π
bn= b(ωn) T
3 ∆ω
Wave 3
2 ∆ω Wave 2
∆ω Wave 1 Wave n = an cos(ωn.t) + bn sin( ωn.t)
fT(t)
ωn = n. 2 π = n.∆ω
te
0 Wave 0 =c
Mean value of fT(t) in the range [0, T]
T
0 t
T
F(
T
2
where a n = a(ωn) and bn = b(ωn) are real functions representing the waves coefficients.
Figure 2: Decomposition into sinusoidal waves of a function f(t), defined in an interval [0, T] [4].
Afterwards, we will show that the coefficients a n and bn of each “wave” n can be
determined through elementary mathematical concepts (particularly using the
concept of mean value of a function in a given interval) and that the concept of
Fourier Transform can be understood, in easier terms, as the result of the “junction”
of values a n and bn into a single (complex!) figure of the form (a n - i bn )T / 2 .
Actually, a n = a(ωn ) and bn = b(ωn ) are real functions of a discrete variable and
1 2 3 10
, , , ... , ... (in Hz) (2)
T T T T
or
2π 2π 2π 2π
, 2. , 3. , ... 10. , ... (in rad/s) (3)
T T T T
2π
Considering ∆ω = , the frequencies of the mentioned “waves” are written as
T
follows
ω1= ∆ω, ω2= 2∆ω, ω3= 3∆ω, ω4= 4∆ω, ... ωn = n∆ω (4)
In this expression, each sinusoidal wave (“wave n”) can be written as the linear
combination of trigonometric functions (cosine and sine), i.e.,
http://epublications.bond.edu.au/ejsie/vol5/iss2/2 4
Oliveira et al.: Fourier Analysis with Excel
and
The resulting issue is to know how to determine constant c and the coefficients an
and bn of the various waves, which make it possible to approximate a given function
f in a certain interval [ 0,T] .
T
1
T ∫0
v m = f (t) T
= f (t)dt (8)
f vm . T = A = vm = 1 A
T
f = f(t)
A
vm
0 T t
Figure 3: Use of the concept of integral to calculate the mean value of a function in an interval [ 0,T ] .
Initially, Fourier observed that due to the periods of the various waves being
submultiples of T, the mean value of each “wave n” in interval T was invariably
null, i.e., wave n T = 0 with n = 1,2,3 …
Thus,
f T (t) T
= c T
+ wave 1 T + wave 2 T + wave 3 T + ... (9)
1424 3 14243 14243
0 0 0
Therefore, the value of constant (c) must be exactly equal to the mean value of
function f(t) in interval T, i.e.,
T
1
c = f (t) T
= ∫ f (t) dt (10)
T0
f T (t).cos ( ω1.t ) T
= c.cos ( ω1.t ) T + wave1.cos ( ω1.t ) T
+ wave2.cos ( ω1.t ) T + ... (11)
144244 3 144424443
0 0
becoming
f (t).cos ( ω1.t ) T
= wave1.cos ( ω1.t ) T
(12)
i.e.,
f (t).cos ( ω1.t ) T
= a1.cos ( ω1.t ) + b1sin ( ω1.t ) .cos ( ω1.t ) (13)
T
considering that the mean value of function cos2(t) in interval [ 0,2π] is precisely 1/2
(see figure 4).
2
Figure 4: Graphic representation of function cos (t) and of the corresponding mean value in the interval [0,2π]
( vm = 1/ 2 ).
Thus, it is possible to obtain coefficient a1 as the double of the mean value in [0,T] of
function f(t) multiplied by cos(ω1t) , i.e.,
2T
a1 = 2. f (t).cos ( ω1.t )
T ∫0
T
= f (t) cos(ω1t)dt (15)
http://epublications.bond.edu.au/ejsie/vol5/iss2/2 6
Oliveira et al.: Fourier Analysis with Excel
Likewise, the mean value in [0,T] of each wave multiplied by sen(ω1t) is also
invariably null, except for the case of wave 1, which gives the possibility of
determining b1, in a similar manner as the one used for determining a1. Therefore,
we can conclude that it should be
T
2
b1 = 2. f (t).sin ( ω1.t )
T ∫0
T
= f (t) sin(ω1t)dt (16)
By applying this reasoning to the subsequent waves, we can easily conclude that the
coefficients an and bn can be determined through expressions similar to the former
ones. Fourier concluded thus that the determination of the coefficients of the various
waves of the series is simply just a matter of determining the mean values!
T
1
T ∫0
c = f (t) T
= f (t)dt
T
2
a n = 2. f (t).cos ( ωn .t )
T ∫0
T
= f (t) cos(ωn t)dt , n = 1, 2, 3, ...
T
2
b n = 2. f (t).sin ( ωn .t )
T ∫0
T
= f (t) sin(ωn t)dt , n = 1, 2, 3, ...
t , 0 ≤ t < 2.5
f (t) = (17)
1 , 2.5 ≤ t ≤ 5
To obtain the approximation of this function through a Fourier series, a
computational application can be developed, which will make it possible, for each
wave n, to calculate automatically the values of ωn , a n e b n .
Figure 5 shows the application developed in Excel. A table is created with the values
of (t, f(t)) and then two columns to calculate f (t) cos(ωn t) and f (t) sin(ωn t) . Of note is
the fact that initially a cell is reserved to T and another one to ∆ω : ∆ω = 2 π / T . For
each wave n (of which the value is introduced in cell D5), the value of ωn : ωn = n ∆ω
is calculated. Since a n = 2 f (t) cos(ωn t) and bn = 2 f (t) sin(ωn t) , we just have to use
function Average() of Excel, which makes it possible to calculate the mean value of a
set of values.
Figure 6 shows the results obtained after using the application above for waves 1, 2,
3 and 10.
Mean value
vm ∼ 1.1251
vm vm
0 t
T=5
Wave n = 1 a 1∼ -0.5066
( Period T )
b1 ∼ 0.1590
0 t
T
Wave n = 2 a 2 ∼ 0.0025
( Period T ) b2∼ -0.3975
2
0 t
T
Wave n = 3 a 3∼ -0.0567
( Period T ) b3 ∼ 0.0530
3
0 t
T
Sum of waves 1 to 10
0 t
T
http://epublications.bond.edu.au/ejsie/vol5/iss2/2 8
Oliveira et al.: Fourier Analysis with Excel
To complete the application, it will be useful to add a command button, which, after
clicking, will give the possibility of visualizing (as a movie) the approximation of
the function by sum of waves.
Figure 7 shows a table being created after clicking the button "Fourier Coefficients".
In the last column (column X), a formula is to be introduced for calculating the sum
of the values of the previous columns. For the purpose, the function Sum of Excel is
used.
By adding the last series of data to the graph, the intended approximation will be
obtained, which will make it possible to create an elucidative animation.
=I$3*COS(I$2*$G6)+I$4*SIN(I$2*$G6)
Figure 8 present the approximation of the function f(t) by partial Fourier sums of 5,
10, 20 and 50 waves.
3.0 3.0
2.5 2.5
5 waves 10 waves
2.0 2.0
1.5 1.5
1.0 1.0
0.5 0.5
0.0 0.0
0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0
3.0 3.0
2.5 2.5
20 waves 50 waves
2.0 2.0
1.5 1.5
1.0 1.0
0.5 0.5
0.0 0.0
0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0
+∞
a − i b n iω n t a n + i b n − iω n t
f T (t) = v m + ∑ n e + e (21)
n =1 2 2
http://epublications.bond.edu.au/ejsie/vol5/iss2/2 10
Oliveira et al.: Fourier Analysis with Excel
a 0 − i b 0 iω0t +∞ a n − i b n iωn t −1
a − i b n i ωn t
f T (t) = e +∑ e + ∑ n e (22)
2 n =1 2 n =−∞ 2
which, assuming now that n = … ,-3, -2, -1, 0 ,1, 2, 3, … , it can be simplified as
follows:
∞
a n − i b n iω n t
f T (t) = ∑
n =−∞ 2
e , − ∞ < ωn = n.∆ω < +∞ (23)
i.e.,
T
a n − i bn 1
= ∫ f (t) e−i ωn t dt (27)
2 T0
We usually designate as Discrete Fourier Transform of the function f(t), in the finite
interval of length T, the complex function FT (ωn ) (function of a discrete real
variable, ωn ) given by
T
FT (ωn ) = ∫ f T (t)e− iωn t dt , − ∞ < ωn = n.∆ω < +∞ (28)
0
or
a n − i bn
FT (ωn ) = .T , − ∞ < ωn = n.∆ω < +∞ (29)
2
So, FT (ωn ) is a complex function with real part a(ωn ).T / 2 , and imaginary
part −b(ωn ).T / 2 .
Hence, the graphic representation of the Discrete Fourier Transform FT (ωn ) , of a
given time function f T (t) , must always be based on two graphs, the
representations adopted for the graph of the real part being Re ( F(ωn ) ) = a(ωn )T / 2
(even function); and for the graph of the imaginary part being
Im ( F(ωn ) ) = − b(ωn )T / 2 (odd function).
http://epublications.bond.edu.au/ejsie/vol5/iss2/2 12
Oliveira et al.: Fourier Analysis with Excel
3.3 From Fourier Series to Fourier Integral. Continuous Fourier Transform and
Laplace Transform
1 ∞ 2π
f T (t) = ∑ FT (ωn ) eiωn t ,
T n =−∞
ωn = n.∆ω , ∆ω =
T
(31)
When T→ ∞ (we we can assume a domain interval of the form ]-T/2, T/2[, which tends
ω (∆ω→dω). The
to ]-∞, +∞[ ) the function f(t) is defined in R, and ∆ω tends to dω
discrete variable ωn tends
tend to a continuous variable ω (ωn →ω), and the summation
signal should thus “be replaced” by the integral signal ( ∑ → ∫ : “sum of infinite
infinitesimal parcels ”) becoming then
+∞ +∞
1
∫ F(ω).ei ω t dω , ∫ f (t)
− iω t
f (t) = with F(ω) = (t)ee dt (33)
2π −∞ −∞
the so-called
called Continuous Fourier Transform of the function f(t) defined
defin in R.
Lastly, it is interesting
resting to notice that the Laplace transform currently used to solve
differential equations can be seen as a generalization of Fourier Transform,
Transform in which
the pure imaginary iω is replaced by the complex s = σ + iω. On the basis of this
conclusion,, such a sequence could be adopted in Mathematics athematics curricula for
introducing the subject of Laplace transforms, enabling thus the students to easily
understand it.
4 Use of Fourier series for the interpretation of experimental results.
Decomposition of accelerograms
acce into sinusoidal waves
Know the “waves” that compose a function, besides allowing the development of
powerful mathematical tools to solve differential equations, may have a direct
application to the analysis of experimental results, as shown below.
Let us assume, for instance, the experimental analysis of the dynamic behaviour of a
scale model of a one-storey
storey building with a 5 kg mass and 8600 N/m stiffness (a
single-degree dynamic system like the mass-spring
mass spring system presented in [5]).
[5])
With a small accelerometer
celerometer and a proper acquisition system, we obtained a record of
thee horizontal accelerations (see figure 10). The accelerations were measured for 15 s
using a sample frequency of 51.2 values per second (512 in 10 s), on a model of a
one-storey building g (horizontal accelerations measured at floor level, according to
the lower stiffness direction), being only subject to the action of the so-called
so white
noise or environmentt excitation (voices,
(voices draughts, etc.).
http://epublications.bond.edu.au/ejsie/vol5/iss2/2 14
Oliveira et al.: Fourier Analysis with Excel
On the basis of the acceleration graph of the figure above, it is not possible to obtain
information about the dynamic characteristics of the structure; we can only state
that during the acquisition time (15 s), the structure (scale model) presented
horizontal accelerations, with maximum values of about 0.03 ms-2.
For instance, it would be useful to obtain information about the natural frequency
ωN of the structure.
Is it possible to obtain further information in the record to disclose more
information about the dynamic characteristics of the structure? Clearly, the
measured accelerations are necessarily influenced by the structural characteristics of
the building; in another building, under the same excitation conditions, but with
different mass characteristics and/or stiffness, we would most certainly obtain a
different acceleration record!
This leads us to believe, that this particular record is likely to contain some further
information about the structure. The notion is that it might be possible to have
access to that information if the accelerogram is decomposed into waves, using
Fourier's concept.
First, we included in the spreadsheet the values of the addressed function, in table
format (in this case, the function corresponds to the accelerations measured
throughout 15 s): in a first column we entered the values of t and in a second
column the values of the measured accelerations, which corresponds, in this case, to
768 pairs of measured values since 51.2 acceleration values per second were
recorded, for a 15-second period.
Using the application presented in section 2.3, coefficients an and bn, as well as the
mean value, are automatically computed (Figure 11). Repeating that procedure for
all subsequent waves (a Visual Basic routine can be used) makes it possible to get
the values of an and bn for all waves. The wave’s amplitudes An are also computed in
order to get the Amplitude Spectrum (figure 12), that is a function of wave’s
frequencies (in cycles/s or Hz; 1 Hz = 2π rad/s).
The analysis of the amplitude spectrum, show that, from among the various waves,
into which the measured accelerogram can be decomposed, the frequency wave of
approximately 6.733 Hz clearly stands out due to its amplitude – the amplitude
spectrum presents a very well defined peak in the frequency 6.733 Hz.
Indeed, this result is the intended “new information” about the structure, which
could not be obtained through the direct analysis of the measured accelerogram
(time field): the observed peak in the Spectrum of amplitudes means that the
Fourier discovery about the possibility of decomposing functions into series of
sinusoidal waves gives the possibility of identifying experimentally the natural
frequency of the model of the one-storey building tested: in this case, the natural
frequency identified is ωN = 6,733 Hz .
Figure 11: Decomposition of an accelerogram into waves. Organization of a spreadsheet to compute Fourier
coefficients using the average function, with a subroutine in VisualBasic to calculate the amplitude spectrum
(Spectrum.xls).
Figure 12: Measured accelerogram and corresponding amplitude spectrum: the wave amplitudes forming the
measured accelerogram are represented as a function of the corresponding frequency (cycles/s or Hz).
http://epublications.bond.edu.au/ejsie/vol5/iss2/2 16
Oliveira et al.: Fourier Analysis with Excel
Once the stiffness and mass values of the building model are determined, we may
calculate analytically the value of the natural frequency, being only necessary to
determine the value of expression k / m for k=8600 N/m and m=5 Kg, which
corresponds to the value of the natural frequency. The value obtained is 6.60 Hz,
which is approximately equal to the one obtained experimentally.
5 Conclusion
The presented innovative approach of the Fourier analysis allows us to show how
the computational modelling can be used to facilitate a deep study of a
mathematical topic that is generally included on the mathematics subjects of the
engineering and science courses. It is a topic which enables students to see
interesting connections between technology, science, engineering and many of the
main topics studied since high school: trigonometric and exponential functions,
integrals, Euler’s formula for complex numbers, series, Fourier and Laplace
transforms, numerical methods, etc. It is proposed a methodology where both
students and teachers should engage themselves on the development of interactive
computational applications with command buttons, scroll bars, suggestive graphics
and animations.
An innovative graphical representation is presented to illustrate how Fourier series
are used to approximate functions defined over a finite interval (“approximation
through a sum of infinite waves with increasing frequencies”). The mathematical
formalism is gradually introduced.
It is shown that when we get a deeper understanding of the subject we are able to
see the beauty and simplicity of the mathematics used: after all, the coefficients of
the Fourier series can be computed as simple average values, making use of the
Average() built-in Excel function! That’s it!
It is shown in detail how an Excel spreadsheet can be organized to compute (simple
VBA programming) the nth first coefficients of the Fourier series that approximates
any function (with graphical representation) defined over a real finite interval.
There’s an animation included on the suggested computational application which,
for any given function, shows how the function can be approximated considering
the partial sum of the first nth terms of the corresponding Fourier series.
Lastly it is shown how Fourier analysis can be used over a set of experimental data.
The vibrations of a scale model of a 1-floor building were studied. The measured
acceleration record (collected using an accelerometer and a data acquisition system)
was analysed with the Excel application to obtain the corresponding amplitude
spectrum. A peak was clearly identified at a frequency that corresponds to one of
the main structural parameters used by civil engineers to design a seismic resistant
building: the natural frequency of the first vibration mode of the building.
References
http://epublications.bond.edu.au/ejsie/vol5/iss2/2 18