Mathematica - Fourier Series PDF
Mathematica - Fourier Series PDF
Craig Beasley
Department of Electrical and Systems Engineering
Washington University in St. Louis
St. Louis, MO
April 24, 2012
The Fourier series is a tool for solving partial differential equations. It is used most often when the system
in question has periodic behavior. The basic idea is similar to the power series a periodic function is
modeled as an infinite sum of sine and cosine functions. Like with the power series, the more terms in the
series that we use, the closer the series converges onto the original function.
Another use for the Fourier series is to analyze the frequencies present in a system. Because each
coefficient is related to a particular integer multiple of some base frequency, they give an indication how
much each frequency contributes to the overall function.
Fourier Series by Direct Integration
Computing an integral in Mathematica is fairly painless, and it's tempting to simply use that to generate a
function of n that can be evaluated.
Let's consider the following half-wave rectifier:
Below are the three integrals used to find the coefficients of the series. Notice that two of them are being
defined as functions of n. This is for later usage.
Tables
With the Fourier coefficients now defined as functions of n, they can be quickly evaluated. This process
can be further expedited by constructing a table. The Table command follows similar syntax as other
Mathematica commands: Table [ function, { variable , lower limit , upper limit , step size } ]. The lower limit
can be omitted if the sequence is to start at one, and the step size can be omitted if it is equal to one.
FourierSeries
Instead of simply computing Fourier coefficients, an entire series of n terms may be generated. This will
be a complex exponential that must be expanded using the ComplexExpand command. For older
versions of Mathematica (versions prior to 7.0), this will require a Needs["`FourierSeries"] command be
called before performing any of the Fourier commands.
Prior to using any of the Fourier commands, it behooves the user to check the help file. Click "More
Information" and look for FourierParameters. This will tell you what the default settings are for the limits of
integration on the Fourier coefficients, as well as how to change them.
In trigonometric form:
The FourierParameters command will be covered in more detail later in the document.
Syntax for the FourierSeries command is: FourierSeries [ function , variable , number of terms ]
To illustrate convergence, multiple partial sums of an increasing number of terms will be graphed.
FourierTrigSeries
Instead of using the ComplexExpand command, a user could use the FourierTrigSeries command.
FourierParameters
Changing the FourierParameters setting allows control over the limits of integration on the coefficients,
and therefore, the base frequency of the series. Some work will go into calculating what value for b will
give the proper limits of integration. There is ordinarily no reason to change a from its default setting,
which is 1. Consider the following function:
When plotted, you will see that the ripples are being pushed to the points of discontinuity, and that there
is some overshoot present whenever the function transitions between values. All of the oscillations of the
sine and cosine functions used to approximate the series are piling up at the points of discontinuity. This
overshoot does not die out as the frequency is increased, and in fact it often increases as additional terms
are added on. The overshoot does approach a finite limit, however. This is known as the Gibbs
phenomenon. You should also notice that all of the curves are passing through a value halfway between
the right- and left-hand limits.
th
To illustrate convergence, periodicity, and overshoot, here is a plot of terms out to the 100 harmonic. As
you can see, the series has converged nicely onto the original rectangular waveform.
FourierCoefficient
If you are looking for a specific coefficient, there is the FourierCoefficient command. Syntax for the
FourierCoefficient command is: FourierCoefficient [ function , variable , term ]. Users should be aware that
this command is for the complex exponential form. It is not recommended that it be used in this course,
and is included for completeness.