Chapter 7: Fourier Series

NOTE: Math will not display properly in Safari - please use another browser

The material covered in this chapter is also presented in Boas Chapter 7, Sections 3, 4, 5, 7, 8, and 9.

7.1 Introduction

Why do a violin and a flute playing the same note sound so different? They are, after all, generating sounds waves of the same frequency. Shouldn't these waves make the same impression on our ears and be heard as identical sounds?

An element of answer is that the violin and the flute are made from different materials --- wood for the violin, brass for the flute --- and use different methods to produce the sound --- a bowed string for the violin, a column of air for the flute. It is not surprising, therefore, that different instruments should produce different sounds. But our ears know nothing of the construction and playing of instruments; how do they actually distinguish the sounds? The answer is that the sound waves generated by different instruments come with different forms, even when they come with the same (dominant) frequency. And waves of different forms are easily distinguished by the ear. A violin and a flute sound different because they produce different wave forms.

Series of graphs
Figure 7.1: Waves of the same (dominant) frequency, but of different forms. In each case the wave (shown on the right) is synthesized from four elementary sine waves (shown on the left). Different mixtures produce different wave forms.

Waves of the same (dominant) frequency but of different forms are shown in Fig.7.1. In each case the wave is synthesized from four simple waves of the form sin(2πft), in which f is the frequency. The dominant frequency is by definition the lowest, and in the plot it is set to f=1. The other waves have frequencies f=2, f=3, and f=4, so that they oscillate twice, three times, and four times as fast as the dominant wave, respectively; these are the harmonics, or overtones, of the fundamental frequency. The exact mixture of waves determines the precise shape of the total wave; different mixtures produce waves of different forms.

A deeper answer to the question can now be given. A violin and a flute sound different because the sound waves entering the ear come as different mixtures of elementary waves. In this case the mixture would involve a very large number of overtones, but the point is still that different mixtures produce different wave forms, and that waves of different forms can easily be distinguished by the ear.

Any periodic function f(t) can be thought of as being synthesized from a (potentially infinite) number of elementary sine and cosine waves. The topic of this chapter, Fourier series, is all about finding out the precise mixture that corresponds to a given shape. Fourier analysis, along with the generalizations examined in the next few chapters, is one of the most powerful tools of mathematical physics. It has many, many applications in virtually all areas of physics.

7.2 Fourier Series

We consider a function f(x) that is periodic with period 2π, so that f(x+2π)=f(x). Our claim is that any such function can be represented as a Fourier series of the form

f(x)=c0+a1cos(x)+a2cos(2x)+a3cos(3x)++b1sin(x)+b2sin(2x)+b3sin(3x)+=c0+n=1ancos(nx)+n=1bnsin(nx),

where c0, a1, a2, b1, b2, and so on are constant coefficients. Each member of the sum is itself a periodic function. For example, c0 evaluated at x+2π is still c0, while sin[n(x+2π)]=sin(nx+2nπ)=sin(nx)cos(2nπ)+cos(nx)sin(2nπ)=sin(nx), since cos(2nπ)=1 and sin(2nπ)=0. Because a sum of periodic functions is necessarily periodic, and because we have an infinity of choices in the selection of the coefficients c0, an and bn, it is intuitively clear that the claim is true, that any periodic function can be decomposed in the Fourier series of Eq.(7.1).

You will have noticed that we changed our notation with respect to Sec.7.1. Here we let x be the independent variable, and take f(x) to be periodic with period 2π. In the introduction we used t as the independent variable, and took the wave f(t) to be periodic with period 1. It is easy to see that the variables are related by x=2πt. A simple rescaling of x can accommodate any other period, and we shall explore this freedom systematically in Sec.7.7.

It can be advantageous to re-express the Fourier series of Eq.(7.1) in terms of the complex exponential

eiϕ=cosϕ+isinϕ.

In terms of this we have that

cosϕ=12(eiϕ+eiϕ),sinϕ=12i(eiϕeiϕ),

and substitution into Eq.(7.1) with ϕ=nx yields

f=c0+n=112an(einx+einx)+n=112ibn(einxeinx)=c0+n=112(anibn)einx+n=112(an+ibn)einx.

If we now introduce the notation

cn:=12(anibn),cn:=12(an+ibn),

the Fourier series becomes

f=c0+n=1cneinx+n=1cneinx,

and if we further let nn in the second sum, we obtain

f(x)=n=cneinx.

This is the complex form of the Fourier series, which contains, in an attractive and economical package, the same information as Eq.(7.1).


Exercise 7.1: The complex exponential is about to become an essential tool, and it is important for you to be thoroughly acquainted with it. So please do take the time to refresh your knowledge and understanding. As a test, draw the circle eiϕ in the complex plane, with ϕ the angle from the real axis. Then without doing any calculation, evaluate ei0, eiπ/2, eiπ/2, eiπ, eiπ, e3iπ/2, and e2iπ. Verify your answers with Eq.(7.2). If any of this is a struggle for you, you need to spend more time and sort things out.



Exercise 7.2: Verify Eq.(7.3), and reproduce the steps that lead to Eq.(7.7).


It is important to understand that in Eq.(7.7), the function f(x) is real, even though it is decomposed in terms of complex functions. It is easy to go back to the real form of Eq.(7.1) by reversing the steps. The original coefficients an and bn are given by

a0=2c0,an=cn+cn,bn=i(cncn)

in terms of cn and cn, and substitution of these relations along with Eq.(7.2) into Eq.(7.7) brings us back to Eq.(7.1).


Exercise 7.3: Verify Eq.(7.8), and show that Eq.(7.1) can be obtained from Eq.(7.7).


7.3 Fourier Coefficients

A typical task of Fourier analysis is to obtain the coefficients cn (or an and bn) when f(x) is known. This answers the important question: which mixture of sine and cosine waves forms the function f(x)?

We keep working with the complex form of the Fourier series, as given by Eq.(7.7), which we rewrite as

f=c0+c1eix+c2e2ix++c1eix+c2e2ix+.

To extract the coefficients cn we rely on the identity

2π0enixdx=2πδn0,

which we encountered before (in a slightly different guise) in Sec.4.7 --- see Eq.(4.38) --- and Sec.5.6 --- see Eq.(5.35). The identity, in fact, applies to any interval of length 2π; the integral could go from x0 to x0+2π, with x0 completely arbitrary. The choice x0=π is sometimes convenient.


Exercise 7.4: You should have done this before, but here's another chance: verify Eq.(7.10) in the more general form x0+2πx0enixdx=2πδn0.


The trick to get each cn is to multiply both sides of Eq.(7.9) by einx and integrate from x=0 to x=2π (or any other interval of length 2π). To get c0, for example, multiply by ei0x=1 and integrate; we get

2π0fdx=c02π0dx+c12π0eixdx+c22π0e2ixdx++c12π0eixdx+c22π0e2ixdx+,

and since each integral vanishes except for the first one, we obtain 2π0fdx=2πc0, which gives us c0. As another example, let us calculate c1. This time we multiply Eq.(7.9) by eix and integrate, to get

2π0feixdx=c02π0eixdx+c12π0dx+c22π0eixdx++c12π0e2ixdx+c22π0e3ixdx+.

This time it is only the second integral that doesn't vanish, and we obtain \newline 2π0feixdx=2πc1, which gives us c1.

The general result is clearly

cn=12π2π0f(x)enixdx=12πx0+2πx0f(x)enixdx;

in the second expression we indicate that the integral can be evaluated for any interval of length 2π. Thus, the (complex) Fourier coefficients are obtained by evaluating the integrals of Eq.(7.13). Then Eq.(7.8),

an=cn+cn,bn=i(cncn),

can be exploited to find an and bn, and the real form of the Fourier transform can be constructed from Eq.(7.1). We will learn to become familiar with these steps in the examples that follow.


Exercise 7.5: Substitute Eq.(7.13) into Eq.(7.14) to obtain an and bn as integrals involving f(x) and ordinary trigonometric functions. Verify that the general result for an applies to a0.


7.4 Square Wave

As a first example we examine a square wave described by

f(x)={10x<π0πx<2π;

the definition is extended to x<0 and x2π according to the periodicity requirement f(x+2π)=f(x). The function is plotted in Fig.7.2.

""
Figure 7.2: Square wave of periodicity 2π and its representation as three truncated Fourier series.

We make use of Eq.(7.13) to calculate the complex coefficients cn. For c0 we have

c0=12π2π0f(x)dx=12ππ0(1)dx+12π2ππ(0)dx=12.

For cn we get

cn=12π2π0f(x)einxdx=12ππ0einxdx=12πeinxin|π0=i2πn(einπ1).

But einπ=(eiπ)n=(1)n, so that the factor within brackets is (1)n1, which is equal to 0 when n is even, and to 2 when n is odd. We therefore have that cn=0 when n is even, and

cn=iπn

when n is odd. Notice that c0 cannot be obtained directly from this relation, because the manipulations required to evaluate the integral for cn do not apply when n=0.

Equation (7.14) allows us to obtain an and bn from cn and cn=+i/(πn). We get an=0 and

bn=2πn

when n is odd. Making the substitution in Eq.(7.1) returns

f(x)=12+2πn=1,3,5,1nsin(nx).

Apart from the constant 1/2, the series involves sine functions only. A typical property of Fourier series is that the coefficients an and bn tend to decrease as n increases; in the case of a square wave we see that bnn1. This implies that a sum truncated after a relatively small number of terms usually offers a very good approximation to the infinite series. This is illustrated in Fig.7.2, where we see that a Fourier series truncated after just five terms does a decent job at reproducing the square wave; truncation after twenty terms, of course, does a lot better. The wave's abrupt transitions at x=0, x=π, and so on, give the Fourier series a serious challenge, because we are attempting to synthesize a discontinuous function with a bunch of continuous sine waves. As we shall see in a moment, Fourier series do better when f(x) is continuous.

7.5 Triangle Wave

As a second example we examine a triangle wave described by

f(x)={xπx<0x0x<π;

the definition is extended to x<π and xπ according to the periodicity requirement f(x+2π)=f(x). The function is plotted in Fig.7.3. Notice that here we choose (π,π) as the reference interval, instead of (0,2π) as in the preceding section. The reason is that the description of the triangle wave is simpler in (π,π) than it would be in (0,2π). Recall from Sec.7.3 that only the length of the interval matters, and that the choice of starting point is arbitrary.

""
Figure 7.3: Triangle wave of periodicity 2π and its representation as three truncated Fourier series.

We exploit Eq.(7.13) with x0=π to calculate the Fourier coefficients. For c0 we have

c0=12πππf(x)dx=12π0π(x)dx+12ππ0(x)dx=π2.

For cn we get

cn=12πππf(x)einxdx=12π0πxeinxdx+12ππ0xeinxdx=1+inx2πn2einx|0π+1+inx2πn2einx|π0=12πn2[1(1inπ)einπ]+12πn2[(1+inπ)einπ1]=1πn2[1(1)n],

where we used the fact that e±inπ=(e±iπ)n=(1)n. The factor within brackets is 0 when n is even, and 2 when n is odd. We therefore have that cn=0 when n is even, and

cn=2πn2

when n is odd.

We next get an and bn from Eq.(7.14), and find that bn=0 and

an=4πn2

when n is odd. Making the substitution in Eq.(7.1), we arrive at

f(x)=π24πn=1,3,5,1n2cos(nx).

Apart from the constant π/2, the series involves cosine functions only. Here we see that the coefficients are proportional to n2, and therefore decrease much faster than those of the square wave considered previously. This implies that a smaller number of terms will be required of the Fourier series to give an adequate representation of the triangle wave. This fact is illustrated in Fig.7.3, which shows that we get a decent triangle with just two terms; with eight terms we are close to perfection. In the case of a triangle wave, continuity of the function allows the cosines to do a very good job of synthesizing the function.

7.6 Rectified Sine Wave

As a third example we examine the rectified sine wave described by

f(x)=|sinx|;

the function is automatically periodic with period 2π. We choose (0,2π) as the reference interval, and note that while f(x)=sinx when 0x<π, f(x)=sinx when πx<2π. The function is plotted in Fig.7.4.

""
Figure 7.4: Rectified sine wave and its representation as three truncated Fourier series.

From Eq.(7.13) we get

c0=12π2π0f(x)dx=12ππ0sinxdx12π2ππsinxdx=2π

and

cn=12π2π0f(x)einxdx=12ππ0sinxeinxdx12π2ππsinxeinxdx=14πiπ0(eixeix)einxdx14πi2ππ(eixeix)einxdx=ei(n1)x4π(n1)|π0ei(n+1)x4π(n+1)|π0ei(n1)x4π(n1)|2ππ+ei(n+1)x4π(n+1)|2ππ=(1)n114π(n1)(1)n+114π(n+1)1(1)n14π(n1)+1(1)n+14π(n+1)=(1)n112π(n1)(1)n+112π(n+1).

Both numerators are equal to 2 when n is even, and to 0 when n is odd. With a bit of simplification, we finally obtain that cn=0 when n is odd, and

cn=2π(n21)

when n is even. These manipulations are not valid when n=±1, but a separate calculation reveals that c1=c1=0.


Exercise 7.6: Reproduce the steps leading to Eq.(7.30), and verify that c1=c1=0.


Combining Eqs.(7.14) and (7.30), we get that bn=0 and

an=4π(n21)

when n is even. The Fourier series associated with the rectified sine wave is therefore

f(x)=2π4πn=2,4,6,1n21cos(nx).

Here also we find that the coefficients decrease rapidly with increasing n. As Fig.7.4 shows, the Fourier series truncated after a small number of terms gives an excellent representation of the rectified sine wave.

7.7 Change of Interval

In our developments so far we have assumed that f(x) is periodic with period 2π, so that f(x+2π)=f(x). This choice of period is convenient, because the elementary waves making up the Fourier series are of the simple form sin(nx) and cos(nx). But in a typical application of Fourier series the period may not be 2π, and we should generalize our formulation to handle such cases. We still require f(x) to be periodic, but the period shall now be 2L instead of 2π. The new condition of periodicity is

f(x+2L)=f(x).

The factor of 2 in front of L is conventional and introduced for convenience.

The change of period is easily accommodated by a rescaling of the independent variable. While the old variable xold had a periodicity of 2π, the new variable xnew must have a periodicity of 2L, and it is easy to see that this is achieved by the transformation xnew=(L/π)xold. The new set of elementary waves are sin(nxold)=sin(nπxnew/L), cos(nxold)=cos(nπxnew/L), and the Fourier series now takes the form

f(x)=12a0+n=1ancos(nπxL)+n=1bnsin(nπxL)=n=cneinπx/L,

where we henceforth omit the label ``new'' on x. The rescaling implies that the Fourier coefficients are now given by

cn=12L2L0f(x)einπx/Ldx=12Lx0+2Lx0f(x)einπx/Ldx.

The relation of Eq.(7.14) is unaffected by the rescaling, so that we still have

an=cn+cn,bn=i(cncn).


Exercise 7.7: Verify that Eq.(7.35) gives the correct expression for the Fourier coefficients when the period is 2L instead of 2π.


7.8 Sawtooth Wave

As a final example we construct the Fourier representation of a sawtooth wave described by

f(x)=x,L<x<L

with f(x+2L)=f(x). The wave is plotted in Fig.7.5.

""
Figure 7.5: Sawtooth wave and its representation as three truncated Fourier series. The periodicity length was set to L=1.

The Fourier coefficients are obtained from Eq.(7.35), in which we set x0=L. For c0 we get

c0=12LLLf(x)dx=12LLLxdx=x24L|LL=0.

For cn we have

cn=12LLLf(x)einπx/Ldx=12LLLxeinπx/Ldx=L+inπx2π2n2einπx/L|LL=L2π2n2[(1+inπ)einπ(1inπ)einπ]=(1)niLnπ.

From this and Eq.(7.36) we obtain an=0 and

bn=(1)n2Lnπ=(1)n+12Lnπ.

The Fourier representation of the sawtooth wave is therefore

f(x)=2Lπn=1(1)n+1nsin(nπxL).

The series involves sine functions only. The coefficients alternate in sign and decrease as n1 with increasing n. Three different truncations are shown in Fig.7.5. We see that as in the case of the square wave in Sec.7.4, the Fourier series has difficulties reproducing the discontinuities of the sawtooth function.

7.9 Even and Odd Functions

The astute reader will have noticed that the Fourier series constructed in Secs. 7.4, 7.5, 7.6, and 7.8 involved either sine waves or cosine waves, but not both. This has to do with the simplicity of our examples; typical Fourier series will implicate both types of waves. But the question arises: why only sine functions for the square and sawtooth waves, and why only cosine functions for the triangle and rectified sine waves?

The reason is that when f(x) is an even function of x, so that f(x)=f(x), its Fourier series can contain only cosine waves (which are even) and must exclude sine waves (which are odd). Similarly, when f(x) is an odd function of x, so that f(x)=f(x), its Fourier series can contain only sine waves and must exclude cosine waves.


Exercise 7.8:Verify that in the case of a square wave, f(x)1/2 is an odd function of x. Verify that f(x) is an even function in the case of triangle and rectified sine waves. Finally, verify that in the case of a sawtooth wave, f(x) is an odd function.


Suppose that f(x) is an even function of x. As stated, its Fourier series can admit cosine waves only, and it must take the form

f(x)=c0+n=1ancos(nπxL).

Such a series is known as a cosine Fourier series, and in this case the coefficients an can be obtained directly. We have

an=cn+cn=12LLLf(x)(einπx/L+einπx/L)dx=1LLLf(x)cos(nπxL)dx,

and notice that the integrand is an even function of x, since it is the product of two even functions. The integral from x=L to x=0 is therefore equal to the integral from x=0 to x=L, and we can write

an=2LL0f(x)cos(nπxL)dx

in the case of an even function.


Exercise 7.9: Prove that the product of two even functions is even, that the product of two odd functions is also even, and that the product of even and odd functions is odd.


Suppose now that f(x) is an odd function of x. This time the Fourier series can only admit sine waves, so that

f(x)=n=1bnsin(nπxL).

Such a series is known as a sine Fourier series, and the coefficients bn can be calculated directly as follows. We have

bn=i(cncn)=i2LLLf(x)(einπx/Leinπx/L)dx=1LLLf(x)sin(nπxL)dx.

This time the integrand is the product of two odd functions, which again makes it an even function. We therefore arrive at

bn=2LL0f(x)sin(nπxL)dx

for the Fourier coefficients.


Exercise 7.10: Prove that bn=i(cncn)=0 when f(x) is an even function of x. Show also that an=cn+cn=0 when f(x) is an odd function of x.


for the Fourier coefficients. A similar calculation also reveals that

c0=1LL0f(x)dx

in the case of an even function.


Exercise 7.11: Prove that the product of two even functions is even, that the product of two odd functions is also even, and that the product of even and odd functions is odd.


Suppose now that f(x) is an odd function of x. This time the Fourier series can only admit sine waves, so that

f(x)=n=1bnsin(nπxL).

Such a series is known as a sine Fourier series, and the coefficients bn can be calculated directly as follows. We have

bn=i(cncn)=i2LLLf(x)(einπx/Leinπx/L)dx=1LLLf(x)sin(nπxL)dx.

This time the integrand is the product of two odd functions, which again makes it an even function. We therefore arrive at

bn=2LL0f(x)sin(nπxL)dx

for the Fourier coefficients.


Exercise 7.12: Prove that bn=i(cncn)=0 when f(x) is an even function of x. Show also that an=cn+cn=0 when f(x) is an odd function of x.


7.10 Practice Problems

  1. (Boas Chapter 7, Section 5, Problem 2) Find the Fourier series for the function f(x) defined by f=0 for πx<0, f=1 for 0x<π/2, and f=0 for π/2x<π. The function is periodic with period 2π. Plot the function over a few periods, as well as a few truncations of the Fourier series.

  2. (Boas Chapter 7, Section 5, Problem 3) Find the Fourier series for the function f(x) defined by f=0 for πx<π/2 and f=1 for π/2x<π. The function is periodic with period 2π. Plot the function over a few periods, as well as a few truncations of the Fourier series.

  3. (Boas Chapter 7, Section 5, Problem 7) Find the Fourier series for the function f(x) defined by f=0 for πx<0 and f=x for 0x<π. The function is periodic with period 2π. Plot the function over a few periods, as well as a few truncations of the Fourier series.

  4. (Boas Chapter 7, Section 5, Problem 11) Find the Fourier series for the function f(x) defined by f=0 for πx<0 and f=sinx for 0x<π. The function is periodic with period 2π. Plot the function over a few periods, as well as a few truncations of the Fourier series.

  5. (Boas Chapter 7, Section 7, Problem 12) Show that if a real function f(x) is expanded in a Fourier series of complex exponentials, then cn=(cn), with the asterisk denoting complex conjugation.

  6. (Boas Chapter 7, Section 8, Problem 15b) Find the Fourier series for the function f(x) defined by f=1+2x for 1x<0 and f=12x for 0x<1. The function is periodic with period 2. Plot the function over a few periods, as well as a few truncations of the Fourier series.

  7. (Boas Chapter 7, Section 8, Problem 15c) Find the Fourier series for the function f(x) defined by f=x+x2 for 1x<0 and f=xx2 for 0x<1. The function is periodic with period 2. Plot the function over a few periods, as well as a few truncations of the Fourier series.

  8. (Boas Chapter 7, Section 8, Problem 18) Find the Fourier seriesfor the function f(x) defined by f=x2 for 0x<10. The function is periodic with period 10. Plot the function over a few periods, as well as a few truncations of the Fourier series.

  9. (Boas Chapter 7, Section 9, Problem 11) Find the Fourier series for the even function f(x) defined by f=coshx for πx<π. The function is periodic with period 2π. Plot the function over a few periods, as well as a few truncations of the Fourier series.

  10. Find the Fourier series for the odd function f(x) defined by f=sinhx for πx<π. The function is periodic with period 2π. Plot the function over a few periods, as well as a few truncations of the Fourier series.

 

7.11 Challenge Problems

  1. Consider the function

    f(x)=4x(1|x|),1x1,

    defined to be periodic with period 2, so that f(x+2)=f(x).

    a) Find the Fourier series of this function.

    b) On the same graph, plot f(x) together with its Fourier series truncated after a single term.

    c) On the same graph, plot f(x) together with its Fourier series truncated after two terms.

    d) On the same graph, plot f(x) together with its Fourier series truncated after three terms.

  2. Consider the function

    f(x)=x2,πxπ,

    defined to be periodic with period 2π, so that f(x+2π)=f(x).

    a) Sketch the function on the interval 3πx3π.

    b) Obtain the Fourier series of this function.

    c) From your result in part (b), determine the exact value of the sum n=1n2.