Unit 3.1: Trigonometric Fourier Series#
Any periodic waveform can be approximated by a DC component (which may be 0) and the sum of the fundamental and harmomic sinusoidal waveforms. This has important applications in many applications of electronics but is particularly crucial for signal processing and communications.
Colophon#
An annotatable worksheet for this presentation is available as Worksheet 2.
The source code for this page is fourier_series/1/trig_fseries.md.
You can view the notes for this presentation as a webpage (Unit 3.1: Trigonometric Fourier Series).
This page is downloadable as a PDF file.
Agenda#
Motivating examples
Wave analysis and the Trig. Fourier Series
Symmetry in Trigonometric Fourier Series
Computing coefficients of Trig. Fourier Series in MATLAB
Gibbs Phenomenon
Motivating Examples#
This Fourier Series demo, developed by Members of the Center for Signal and Image Processing (CSIP) at the School of Electrical and Computer Engineering at the Georgia Institute of Technology, shows how periodic signals can be synthesised by a sum of sinusoidal signals.
It is here used as a motivational example in our introduction to Fourier Series. (See also Fourier Series from Wolfram MathWorld referenced in the Quick Reference on Canvas.)
To install this example, download the zip file and unpack it somewhere on your MATLAB path.
Wave Analysis#
Jean Baptiste Joseph Fourier (21 March 1768 – 16 May 1830) discovered that any periodic signal could be represented as a series of harmonically related sinusoids.
An harmonic is a frequency whose value is an integer multiple of some fundamental frequency.
For example, the frequencies 2 MHz, 3 Mhz, 4 MHz are the second, third and fourth harmonics of a sinusoid with fundamental frequency 1 Mhz.
The Trigonometric Fourier Series#
Any periodic waveform
or equivalently (if more confusingly)
where
Notation#
The first term
is a constant and represents the DC (average) component of the signal .The terms with coefficients
and together represent the fundamental frequency component of at frequency .The terms with coefficients
and together represent the second harmonic frequency component of at frequency .
And so on.
Since any periodic function
Sums of sinusoids#
In general, the sum of two or more sinusoids does not produce a sinusoid as shown below.

To generate this picture use fourier_series1.m.
Evaluation of the Fourier series coefficients#
The coefficients are obtained from the following expressions (valid for any periodic waveform with fundamental frequency
Odd, Even and Half-wave Symmetry#
Odd and even symmetry#
An odd function is one for which
. The function is an odd function.An even function is one for which
. The function is an even function.
Half-wave symmetry#
A periodic function with period
is a function for whichA periodic function with period
, has half-wave symmetry if
Symmetry in Trigonometric Fourier Series#
There are simplifications we can make if the original periodic properties has certain properties:
If
is odd, and there will be no cosine terms soIf
is even, there will be no sine terms and . The DC may or may not be zero.If
has half-wave symmetry only the odd harmonics will be present. That is and is zero for all even values of (0, 2, 4, …)
Symmetry in Common Waveforms#
To reproduce the following waveforms (without annotation) publish the script waves.m.
Squarewave#

Average value over period
is …?It is an odd/evenfunction?
It has/has not half-wave symmetry
?
Shifted Squarewave#

Average value over period
is …?It is an odd/even function?
It has/has not half-wave symmetry
?
Sawtooth#

Average value over period
is …?It is an odd/even function?
It has/has not half-wave symmetry
?
Triangle#

Average value over period
is …?It is an odd/evenfunction?
It has/has not half-wave symmetry
?
Symmetry in fundamental, Second and Third Harmonics#
In the following,
Fundamental#

Average value over period
is …?It is an odd/evenfunction?
It has/has not half-wave symmetry
?
Second Harmonic#

Average value over period
is …?It is an odd/even function?
It has/has not half-wave symmetry
?
Third Harmonic#

Average value over period
is …?It is an odd/even function?
It has/has not half-wave symmetry
?
Some simplifications that result from symmetry#
The limits of the integrals used to compute the coefficents
and of the Fourier series are given as which is one periodWe could also choose to integrate from
If the function is odd, or even or has half-wave symmetry we can compute
and by integrating from and multiplying by 2.If we have half-wave symmetry we can compute
and by integrating from and multiplying by 4.
(For more details see page 7-10 of Karris)
Computing coefficients of Trig. Fourier Series in MATLAB#
As an example let’s take a square wave with amplitude

Solution#
clear all
cd ../matlab
format compact;
setappdata(0, "MKernel_plot_format", 'svg')
syms t n A pi theta
n = [1:11];
DC component
half_a0 = (1/(2*pi))*(int(A,theta,0,pi)+int(-A,theta,pi,2*pi))
half_a0 =
0
Compute harmonics
ai = (1/pi)*((int(A*cos(n*theta),theta,0,pi) + int(-A*cos(n*theta),theta,pi,2*pi)));
bi = (1/pi)*((int(A*sin(n*theta),theta,0,pi)+int(-A*sin(n*theta),theta,pi,2*pi)));
Reconstruct
ft = half_a0;
for k=1:length(n)
ft = ft + ai(k)*cos(k*t) + bi(k)*sin(k*t);
end;
Make numeric
ft_num = subs(ft,A,1.0);
Print using 4 sig digits
ft_num = vpa(ft_num, 4)
ft_num =
(sin(t)*((2.0*cos(pi) + 1.0)*(cos(pi) - 1.0) - 1.0*cos(pi) + 1.0))/pi + (cos(4.0*t)*(0.5*sin(4.0*pi) - 0.25*sin(8.0*pi)))/pi + (cos(8.0*t)*(0.25*sin(8.0*pi) - 0.125*sin(16.0*pi)))/pi + (sin(5.0*t)*(0.2*cos(10.0*pi) - 0.2*cos(5.0*pi) + 0.4*sin(2.5*pi)^2))/pi + (sin(10.0*t)*(0.1*cos(20.0*pi) - 0.1*cos(10.0*pi) + 0.2*sin(5.0*pi)^2))/pi + (sin(9.0*t)*(0.1111*cos(18.0*pi) - 0.1111*cos(9.0*pi) + 0.2222*sin(4.5*pi)^2))/pi + (sin(11.0*t)*(0.09091*cos(22.0*pi) - 0.09091*cos(11.0*pi) + 0.1818*sin(5.5*pi)^2))/pi + (sin(3.0*t)*(0.3333*cos(6.0*pi) - 0.3333*cos(3.0*pi) + 0.6667*sin(1.5*pi)^2))/pi + (sin(6.0*t)*(0.1667*cos(12.0*pi) - 0.1667*cos(6.0*pi) + 0.3333*sin(3.0*pi)^2))/pi + (sin(7.0*t)*(0.1429*cos(14.0*pi) - 0.1429*cos(7.0*pi) + 0.2857*sin(3.5*pi)^2))/pi + (sin(2.0*t)*(sin(pi)^2 + sin(pi)^2*(4.0*sin(pi)^2 - 3.0)))/pi + (sin(4.0*t)*(0.25*cos(8.0*pi) - 0.25*cos(4.0*pi) + 0.5*sin(2.0*pi)^2))/pi + (sin(8.0*t)*(0.125*cos(16.0*pi) - 0.125*cos(8.0*pi) + 0.25*sin(4.0*pi)^2))/pi + (cos(9.0*t)*(0.2222*sin(9.0*pi) - 0.1111*sin(18.0*pi)))/pi + (cos(5.0*t)*(0.4*sin(5.0*pi) - 0.2*sin(10.0*pi)))/pi + (cos(10.0*t)*(0.2*sin(10.0*pi) - 0.1*sin(20.0*pi)))/pi + (cos(2.0*t)*(0.5*sin(2.0*pi) + 0.5*sin(2.0*pi)*(4.0*sin(pi)^2 - 1.0)))/pi + (cos(11.0*t)*(0.1818*sin(11.0*pi) - 0.09091*sin(22.0*pi)))/pi + (cos(3.0*t)*(0.6667*sin(3.0*pi) - 0.3333*sin(6.0*pi)))/pi + (cos(6.0*t)*(0.3333*sin(6.0*pi) - 0.1667*sin(12.0*pi)))/pi + (cos(t)*(sin(pi) - 1.0*sin(pi)*(2.0*cos(pi) - 1.0)))/pi + (cos(7.0*t)*(0.2857*sin(7.0*pi) - 0.1429*sin(14.0*pi)))/pi
Plot result
ezplot(ft_num),grid
Plot original signal (we could use heaviside
for this as well)
ezplot(ft_num)
hold on
clear pi
t = [-3,-2,-2,-2,-1,-1,-1,0,0,0,1,1,1,2,2,2,3]*pi;
f = [-1,-1,0,1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,1];
plot(t,f,'r-')
grid
title('Square Wave Reconstructed from Sinewaves')
hold off
To run the full solution yourself download and run square_ftrig.mlx.
The Result confirms that:
: function is odd : for even - half-wave symmetry
ft =
(4*A*sin(t))/pi + (4*A*sin(3*t))/(3*pi) + (4*A*sin(5*t))/(5*pi) + (4*A*sin(7*t))/(7*pi) + (4*A*sin(9*t))/(9*pi) + (4*A*sin(11*t))/(11*pi)
Note that the coefficients match those given in the textbook (Section 7.4.1).
Using symmetry - computing the Fourier series coefficients of the shifted square wave#

Calculation of Fourier coefficients for Shifted Square Wave Exploiting half-wave symmetry. This is almost the same procedure as before. You can confirm the results by downloading and executing this file: shifted_sq_ftrig.mlx.
clear all
syms theta n A pi
assume(n, 'integer')
Define harmonics
n = [1:11];
DC component
half_a0 = 0
Compute harmonics - use half-wave symmetry
ai = (4/pi)*int(A*cos(n*theta),theta,0,(sym(pi)/2));
bi = zeros(size(n));
Reconstruct f(t) from harmonic sine functions
syms t
ft = half_a0;
for k=1:length(n)
ft = ft + ai(k)*cos(k*t) + bi(k)*sin(k*t);
end
Make numeric and print to 4 sig. figs.
ft_num = subs(ft,A,1.0);
ft_num = vpa(ft_num, 4)
plot result and overlay original signal (we could use heaviside
for this as well.
clear pi
ezplot(ft_num)
hold on
th = [-3,-2,-2,-2,-1,-1,-1,0,0,0,1,1,1,2,2,2,3]*pi;
f = [-1,-1,0,1,1,0,-1,-1,0,1,1,0,-1,-1,0,1,1];
plot(th-pi/2,f,'r-')
axis([-10,10,-1.5,1.5])
grid
title('Shifted Square Waveform Reconstructed from Cosines')
hold off
As before
We observe that this function is even, so all
coefficents will be zeroThe waveform has half-wave symmetry, so only odd indexed coefficents will be present.
Further more, because it has half-wave symmetry we can just integrate from
and multiply the result by 4.
Note that the coefficients match those given in the textbook (Section 7.4.2).
Gibbs Phenomenon#
In an earlier slide we found that the trigonometric for of the Fourier series of the square waveform is
This figure shows the approximation for the first 11 harmonics:

As we add more harmonics, the sum looks more and more like a square wave. However the crests do not become flattened; this is known as Gibbs Phenomenon and it occurs because of the discontinuity of the perfect sqare waveform as it changes from