Fourier Series Examples
Fourier Series Examples
https://lpsa.swarthmore.edu/Fourier/Series/ExFS.html
Fourier Series Examples
Contents
- Even Pulse Function (Cosine Series)
- Even Square Wave (Exploiting Symmetry)
- Even Square Wave (Exponential Series)
- Even Triangle Wave (Cosine Series)
- Odd Function (Sawtooth Wave)
- Functions that are neither even nor odd
- Effect of Function Symmetry on Coefficients
- Some Comments about the Pulse Function
This document derives the Fourier Series coefficients for several functions. The functions shown here are fairly simple, but the concepts extend to more complex functions.
Even Pulse Function (Cosine Series)
Consider the periodic pulse function shown below. It is an even function with period T. The function is a pulse function with amplitude A, and pulse width Tp. The function can be defined over one period (centered around the origin) as:
xT(t)=⎧⎨⎩A,|t|≤Tp20,|t|>Tp2,−T2<t≤T2
Aside: the periodic pulse function
The periodic pulse function can be represented in functional form as ΠT(t/Tp). During one period (centered around the origin)
ΠT(t)={1,|t|≤120,|t|>12,−T2<t≤T2
ΠT(t) represents a periodic function with period T and pulse width ½. The pulse is scaled in time by Tp in the function ΠT(t/Tp) so:
ΠT(tTp)=⎧⎨⎩1,|t|≤Tp20,|t|>Tp2,−T2<t≤T2
This can be a bit hard to understand at first, but consider the sine function. The function sin(x/2) twice as slow as sin(x) (i.e., each oscillation is twice as wide). In the same way ΠT(t/2) is twice as wide (i.e., slow) as ΠT(t).
The Fourier Series representation is
xT(t)=a0+∞∑n=1(ancos(nω0t)+bnsin(nω0t))
Since the function is even there are only an terms.
xT(t)=a0+∞∑n=1ancos(nω0t)=∞∑n=0ancos(nω0t)
The average is easily found,
a0=ATpT
The other terms follow from
an=2T∫TxT(t)cos(nω0t)dt,n≠0
Any interval of one period is allowed but the interval from -T/2 to T/2 is straightforward in this case.
an=2TT2∫−T2xT(t)cos(nω0t)dt
Since xT(t)=A between -Tp/2 to +Tp/2 and zero elsewhere the integral simplifies and can be solved
an=2T+Tp2∫−Tp2Acos(nω0t)dt=2TAnω0sin(nω0t)∣∣∣+Tp2−Tp2=2TAnω0(sin(+nω0Tp2)−sin(−nω0Tp2))
Since sine is an odd function, sin(a)-sin(-a)=2sin(a), and using the fact that ω0=2π/T and
an=4TAnω0sin(nω0tp2)=4An2πsin(nπtpT)=2Anπsin(nπtpT)
This result is further explored in two examples.
Example 1: Special case, Duty Cycle = 50%
Consider the case when the duty cycle is 50% (this means that the function is high 50% of the time, or Tp=T/2), A=1, and T=2. In this case a0=average=0.5 and for n≠0:
an=2Anπsin(nπtpT)=2Anπsin(nπ2)n=0,1,2,3,4,5,...sin(nπ2)=0,1,0,−1,0,1,...={−1n−12,nodd0,nevenan={2Anπ(−1n−12),nodd0,neven,n≠0
The values for an are given in the table below. Note: this example was used on the page introducing the Fourier Series. Note also, that in this case an (except for n=0) is zero for even n, and decreases as 1/n as n increases.
n | an |
0 | 0.5 |
1 | 0.6366 |
2 | 0 |
3 | -0.2122 |
4 | 0 |
5 | 0.1273 |
6 | 0 |
7 | -0.0909 |
Average + 1st harmonic up to 3rd harmonic ...5th harmonic ...7th ...21st
The graph shows the function xT(t) (blue) and the partial Fourier Sum (from n=0 to n=N) (red)
N∑n=0ancos(ω0t)
as well as the highest frequency harmonic, aNcos(Nω0t)
(dotted magenta). Lower frequency harmonics in the summation are thin dotted blue lines (but harmonics with an0
are not shown. You can change n by clicking the buttons. As before, note:
- As you add sine waves of increasingly higher frequency, the approximation improves.
- The addition of higher frequencies better approximates the rapid changes, or details, (i.e., the discontinuity) of the original function (in this case, the square wave).
- Gibb's overshoot exists on either side of the discontinuity.
- Because of the symmetry of the waveform, only odd harmonics (1, 3, 5, ...) are needed to approximate the function. The reasons for this are discussed below
- The rightmost button shows the sum of all harmonics up to the 21st harmonic, but not all of the individual sinusoids are explicitly shown on the plot. In particular harmonics between 7 and 21 are not shown.
Example 2: Special case, Duty Cycle = 40%
Now consider the case when the duty cycle is 40%, A=1, and T=2. In this case a0=average=0.4 and for n≠0:
an=4TAnω0sin(nω0tp2)=2Anπsin(0.4nπ)
The values for an are given in the table below (note: this example was used on the previous page).
n | an |
0 | 0.5 |
1 | 0.6055 |
2 | 0.1871 |
3 | -0.1247 |
4 | -0.1514 |
5 | -0.0000 |
6 | 0.1009 |
7 | 0.0535 |
Average + 1st harmonic up to 2nd harmonic ...3rd harmonic ...4th ...21st
The graph shows the function xT(t) (blue) and the partial Fourier Sum (from n=0 to n=N) (red)
N∑n=0ancos(ω0t)
Note that because this example is similar to the previous one, the coefficients are similar, but they are no longer equal to zero for n even.
Even Square Wave (Exploiting Symmetry)
In problems with even and odd functions, we can exploit the inherent symmetry to simplify the integral. We will exploit other symmetries later. Consider the problem above. We have an expression for an, n≠0
an=2TT2∫−T2xT(t)cos(nω0t)dt
If xT(t) is even, then the product xT(t)·cos(n·ω0t) is even (the product of two even functions is even). We can then use the fact that for an even function, e(t),
+a∫−ae(t)dt=2a∫0e(t)dt
so
an=4TT2∫0xT(t)cos(nω0t)dt
which generates the same answer as before. This will often be simpler to evaluate than the original integral because one of the limits of integration is zero.
Even Square Wave (Exponential Series)
Consider, again, the pulse function. We can also represent xT(t) by the Exponential Fourier Series
xT(t)=∞∑n=−∞cnejnω0t
We find the cn
cn=∫TxT(t)e−jnω0tdt
As before the integral is from -T/2 to +T/2 and make use of the facts that the function is constant for |t|<Tp/2 and zero elsewhere, and the T·ω0=2*·π.
cn=1T+T2∫−T2xT(t)e−jnω0tdt=1T+Tp2∫−Tp2Ae−jnω0tdt=A−Tjnω0e−jnω0t∣∣∣+Tp2−Tp2=A−j2πn(e−jnω0Tp2−e+jnω0Tp2)
Euler's identities dictate that e+jθ-e-jθ=2jsin(θ) so e-jθ-e+jθ=-2jsin(θ).
and cn=−2jA−j2πnsin(nω0Tp2)=Aπnsin(nω0Tp2)
Note that, as expected, c0=a0 and cn=an/2, (n≠0) (since this is an even function bn=0).
Even Triangle Wave (Cosine Series)
Consider the triangle wave
The average value (i.e., the 0th Fourier Series Coefficients) is a0=0. For n>0 other coefficients the even symmetry of the function is exploited to give
an=2T∫TxT(t)cos(nω0t)dt=2T+T2∫−T2xT(t)cos(nω0t)dt=4T+T2∫0xT(t)cos(nω0t)dt
Between t=0 and t=T/2 the function is defined by xT(t)=A-4At/T so
an=4T+T2∫0(A−4ATt)cos(nω0t)dt=4AT⎛⎜ ⎜⎝+T2∫0cos(nω0t)dt−4T+T2∫0tcos(nω0t)dt⎞⎟ ⎟⎠
Perform the integrations (either by hand using integration by parts, or with a table of integrals, or by computer) and use the fact that ω0·T=2·π
an=4AT⎛⎜⎝Tsin(πn)2πn+4TT2(2sin(πn2)2−πnsin(πn))4π2n2⎞⎟⎠
Since sin(π·n)=0 this simplifies to
an=4AT4TT22sin(πn2)24π2n2=8Asin(πn2)2π2n2
This answer is correct, but noting that
n=0,1,2,3,4,5,6,7,...sin(πn2)2=0,1,0,1,0,1,0,...=1−(−1)n2
yields an even simpler result
an={4A1−(−1)nπ2n2,nodd0,neven
Example 3: Triangle wave
If xT(t) is a triangle wave with A=1, the values for an are given in the table below (note: this example was used on the previous page).
n | an |
0 | 0 |
1 | 0.8106 |
2 | 0 |
3 | 0.0901 |
4 | 0 |
5 | 0.0324 |
6 | 0 |
7 | 0.0165 |
Average + 1st harmonic up to 3rd harmonic ...5th harmonic ...7th ...9th
Note: this is similar, but not identical, to the triangle wave seen earlier.
Note:
- As you add sine waves of increasingly higher frequency, the approximation gets better and better, and these higher frequencies better approximate the details, (i.e., the change in slope) in the original function.
- The amplitudes of the harmonics for this example drop off much more rapidly (in this case they go as 1/n2 (which is faster than the 1/n decay seen in the pulse function Fourier Series (above)). Conceptually, this occurs because the triangle wave looks much more like the 1st harmonic, so the contributions of the higher harmonics are less. Even with only the 1st few harmonics we have a very good approximation to the original function.
- There is no discontinuity, so no Gibb's overshoot.
- As before, only odd harmonics (1, 3, 5, ...) are needed to approximate the function; this is because of the symmetry of the function.
Odd Function (Sawtooth Wave)
Thus far, the functions considered have all been even. The diagram below shows an odd function.
In this case, a Fourier Sine Series is appropriate
xT(t)=∞∑n=1bnsin(nω0t)bn=2T∫TxT(t)sin(nω0t)dt
It is easiest to integrate from -T/2 to +T/2. Over this interval xT(t)=2At/T
.
bn=2T+T2∫−T2xT(t)sin(nω0t)dt=2T+T2∫−T22AtTsin(nω0t)dt
Performing the integration (and using the fact that ω0·T=2·π) the integral yields
bn=2TAT(sin(πn)−πncos(πn))π2n2
Using two simplification, sin(π·n)=0 and cos(π·n)=(-1)n gives
bn=−2Aπn(−1)n
Aside: using symmetry
In this case since xT(t) is odd and is multiplied by another odd function (sin(n·ω0t)), their product is even and the integral can be rewritten as:
bn=2T+T2∫−T2xT(t)sin(nω0t)dt=bn=4T+T2∫0xT(t)sin(nω0t)dt
Example 4: Odd Sawtooth Wave
If xT(t) is a sawtooth wave with A=1, the values for bn are given in the table below
n | bn |
1 | 0.6366 |
2 | -0.3183 |
3 | 0.2122 |
4 | -0.1592 |
5 | 0.1273 |
6 | -0.1061 |
7 | 0.0909 |
Average + 1st harmonic up to 2nd harmonic ...3rd ...4th ...5th ...20th
Note: this is similar, but not identical, to the sawtooth wave seen earlier.
Note:
- As you add sine waves of increasingly higher frequency, the approximation gets better and better, and these higher frequencies better approximate the details, (i.e., the change in slope) in the original function.
- Since this function doesn't look as much like a sinusoid as the triangle wave, the coefficients decrease less rapidly (as 1/n instead of 1/n2
- There is Gibb's overshoot caused by the discontinuity.
Functions that are neither even nor odd
So far, all of the functions considered have been either even or odd, but most functions are neither. This presents no conceptual difficult, but may require more integrations. For example if the function xT(t) looks like the one below
Since this has no obvious symmetries, a simple Sine or Cosine Series does not suffice. For the Trigonometric Fourier Series, this requires three integrals
xT(t)=a0+∞∑n=1(ancos(nω0t)+bnsin(nω0t))a0=2T∫TxT(t)dtan=2T∫TxT(t)cos(nω0t)dt,n≠0bn=2T∫TxT(t)sin(nω0t)dt
However, an exponential series requires only a single integral
xT(t)=+∞∑n=−∞cnejnω0tcn=1T∫TxT(t)e−jnω0tdt
For this reason, among others, the Exponential Fourier Series is often easier to work with, though it lacks the straightforward visualization afforded by the Trigonometric Fourier Series.
Example 5: Neither Even nor Odd
In this case, but not in general, we can easily find the Fourier Series coefficients by realizing that this function is just the sum of the square wave (with 50% duty cycle) and the sawtooth so
n | an | bn |
0 | 0.5 | ---- |
1 | 0.6366 | 0.6366 |
2 | 0 | -0.3183 |
3 | -0.2122 | 0.2122 |
4 | 0 | -0.1592 |
5 | 0.1273 | 0.1273 |
6 | 0 | -0.1061 |
7 | -0.0909 | 0.0909 |
From the relationship between the Trigonometric and Exponential Fourier Series
c0=a0 and cn=an2−jbn2forn≠0,with c−n=c∗n
n | cn |
-7 | -0.0455 + 0.0455j |
-6 | -0.0531j |
-5 | 0.0637 + 0.0637j |
-4 | -0.0796j |
-3 | -0.1061 + 0.1061j |
-2 | -0.1592j |
-1 | 0.3183 + 0.3183j |
0 | 0.5 |
1 | 0.3183 - 0.3183j |
2 | 0.1592j |
3 | -0.1061 - 0.1061j |
4 | 0.0796j |
5 | 0.0637 - 0.0637j |
6 | 0.0531j |
7 | -0.0455 - 0.0455j |
Average + 1st harmonic up to 2nd harmonic ...3rd ...4th ...5th ...20th
Note: this is similar, but not identical, to the sawtooth wave seen earlier.
Note:
- As you add sine waves of increasingly higher frequency, the approximation gets better and better, and these higher frequencies better approximate the details, (i.e., the change in slope) in the original function.
- There is Gibb's overshoot caused by the discontinuities.
Effect of Function Symmetry on Coefficients
If the function xT(t) has certain symmetries, we can simplify the calculation of the coefficients.
Symmetry Trigonometric Series and Symmetry
Symmetry | Simplification |
xT(t) is even | a0=averagean=4T+T2∫0xT(t)cos(nω0t)dt,n≠0bn=0 |
xT(t) is odd | an=0bn=4T+T2∫0xT(t)sin(nω0t)dt |
xT(t) has half-wave symmetry. A function can have half-wave symmetry without being either even or odd. |
an=bn=0,nevenan=4T+T2∫0xT(t)cos(nω0t)dt,noddbn=4T+T2∫0xT(t)sin(nω0t)dt,nodd |
The first two symmetries are were discussed previously in the discussions of the pulse function (xT(t) is even) and the sawtooth wave (xT(t) is odd).
Half-wave symmetry is depicted the diagram below.
The top function, xT1(t), is odd (xT1(t)=-xT1(-t)), but does not have half-wave symmetry. The bottom function, xT2(t) is nether even nor odd, but since xT2(t)=-xT2(t-T/2), it has halfwave symmetry. To visualize this imagine shifting the function by half a period (T/2); for half-wave symmetry the shifted function should be the mirror image of the original function (about the horizontal axis) as shown below
The reason the coefficients of the even harmonics are zero can be understood in the context of the diagram below. The top graph shows a function, xT(t) with half-wave symmetry along with the first four harmonics of the Fourier Series (only sines are needed because xT(t) is odd). The bottom graph shows the harmonics multiplied by xT(t).
Now imagine integrating the product terms from -T/2 to +T/2. The odd terms (from the 1st (red) and 3rd (magenta) harmonics) will have a positive result (because they are above zero more than they are below zero). The even terms (green and cyan) will integrate to zero (because they are equally above and below zero). Though this is a simple example, the concept applies for more complicated functions, and for higher harmonics.
The only function discussed with half-wave symmetry was the triangle wave and indeed the coefficients with even indices are equal to zero (as are all of the bn terms because of the even symmetry). The square wave with 50% duty cycle would have half wave symmetry if it were centered around zero (i.e., centered on the horizontal axis). In that case the a0 term would be zero and we have already shown that all the terms with even indices are zero, as expected.
Simplifications can also be made based on quarter-wave symmetry, but these are not discussed here.
Exponential Series and Symmetry
Since the coefficients cn of the Exponential Fourier Series are related to the Trigonometric Series by
c0=a0cn=an2−jbn2forn≠0c−n=c∗n
(assuming xT(t) is real) we can use the symmetry properties of the Trigonometric Series to find an and bn and hence cn.
However, in addition, the coefficients of cn contain some symmetries of their own. In particular,
- The magnitude of the cn terms are even with respect to n: |c-n|=|cn|.
- The angle of the cn terms are odd with respect to n: ∠c-n=-∠cn.
- The real part of cn is even (Re(c-n) = Re(cn)) and the imaginary part is odd (Im(c-n) =-Im(cn))
- If xT(t) is even, then bn=0 and cn is even and real.
- If xT(t) is odd, then an=0 and cn is odd and imaginary.
Some Comments about the Pulse Function
Let's examine the Fourier Series representation of the periodic rectangular pulse function, ΠT(t/Tp), more carefully.
Since the function is even, we expect the coefficients of the Exponential Fourier Series to be real and even(from symmetry properties). Furthermore, we have already calculated the coefficients of the Trigonometric Series, and could easily calculate those of the Exponential Series. However, let us do it from first principles. The Exponential Fourier Series coefficients are given by
Πt(tTp)=+∞∑n=−∞cnejnω0twithcn=1T∫TΠt(tTp)e−jnω0tdt
We can change the limits of integration to -Tp/2 and +Tp/2 (since the function is zero elsewhere) and proceed (the function is one in that interval, so we can drop it). We also make use of the fact the ω0=2π/T and Euler's identity for sine.
cn=1T+T2∫−T2Πt(tTp)e−jnω0tdt=1T+Tp2∫−Tp2e−jnω0tdt=1−jnω0T(e−jnω0Tp2−e+jnω0Tp2)=1−jn2π(e−jnπTpT−e+jnπTpT)ω0=2πT=1−jn2π2jsin(−nπTpT)=1nπsin(nπTpT)=TpTsin(nπTpT)nπTpT
The last step in the derivation is performed so we can use the sinc() function (pronounced like "sink"). This function comes up often in Fourier Analysis.
sinc(x)=sin(πx)πx
With this definition the coefficients simplify to
cn=TpTsinc(nTpT)
Aside: the "sinc()" function
The sinc function has several important features:
- sinc(x)=0 for all integer values of x except at x=0 where sinc(0)=1. This is because sin(π·n)=0 for all integer values of n. However at n=0 we have sin(π·n)/(π·n) which is zero divided by zero, but by L'Hôpital's rule get a value of 1.
- The first zeros away from the origin occur when x=±1.
- The function decays with an envelope of 1/(π·x) as x moves from the origin. This is because the sin() function has successive maxima with an amplitude of 1, and the sin function is divided by π·x.
The diagram below shows cn vs n for several values of the duty cycle, Tp/T.
Duty cycle = 0.1 ...0.25 ...0.5 ...0.75 ...0.9
The graph on the left shows the time domain function. If you hit the middle button, you will see a square wave with a duty cycle of 0.5 (i.e., it is high 50% of the time). The period of the square wave is T=2·π;. The graph on the right shown the values of cn vs n as red circles vs n (the lower of the two horizontal axes; ignore the top axis for now). The blue line goes through the horizontal axis whenever the argument of the sinc() function, n·Tp/T is an integer (except when n=0.). In particular the first crossing of the horizontal axis is given by n·Tp/T=1 or n=T/Tp (note this is not an integer values of Tp). There are several important features to note as Tp is varied.
- As Tp decreases (along with the duty cycle, Tp/T), so does the value of c0. This is to be expected because c0 is just the average value of the function and this will decrease as the pulse width does.
- As Tp decreases, the "width" of the sinc() function broadens. This tells us that as the function becomes more localized in time (i.e., narrower) it becomes less localized in frequency (broader). In other words, if a function happens very rapidly in time, the signal must contain high frequency coefficients to enable the rapid change.
- Let us call the "width" of the sinc() function the width of the main lobe (i.e., between the first two zero crossings around ω=0), Δn=2·T/Tp. If we call the width of the pulse Δt=tp then
(Δn)⋅(Δt)=(2TTp)⋅(Tp)=2T=constant
-
This tells us explicitly that the product of width in frequency (i.e., Δn) multiplied by the width in time (Δt) is constant - if one is doubled, the other is halved. Or - as one gets more localized in time, it is less localized in frequency. We will discuss this more later.
© Copyright 2005 to 2019 Erik Cheever This page may be freely used for educational purposes.
Comments? Questions? Suggestions? Corrections?
Erik Cheever Department of Engineering Swarthmore College