Fourier Series

Imagine a thin piece of wire, which only gains or loses heat through its ends. The temperature $u(x,t)$ is a function of the position x along the wire and the time t. It is a solution to the heat equation

$$u_t = a^2 u_{xx}.$$

The solution to the one-dimensional heat equation with an arbitrary initial distribution is an infinite sum

$$\sum_{n=1}^\infty b_n \exp \left(-\dfrac{n^2 \pi^2 a^2 t}{L^2}\right) \sin \left(\dfrac{\pi n x}{L}\right).$$

If $u(x,0)$ is the initial distribution, then the $b_n$ 's are given by

$$u(x,0) = \sum_{n=1}^\infty b_n \sin \left(\dfrac{\pi n x}{L}\right).$$

That is, $u(x,0)$ is expressed as an infinite sum of sines.

A Fourier series represents a function $f(x)$ as an infinite sum of trigonometric functions:

$$f(x) \sim \dfrac{a_0}{2} + \sum_{n=1}^\infty \left(a_n \cos \dfrac{\pi n x}{L} + b_n \sin \dfrac{\pi n x}{L}\right).$$

Consider integrable functions f and g defined on the interval $-L \le x \le L$ , where $L > 0$ . Define the inner product of f and g by

$$\innp{f}{g} = \dfrac{1}{L} \int_{-L}^L f(x) g(x)\,dx.$$

Example. Verify the linearity and symmetry axioms for an inner product for

$$\innp{f}{g} = \dfrac{1}{L} \int_{-L}^L f(x) g(x)\,dx.$$

Let $a \in \real$ and $f_1$ and $f_2$ be integrable functions on $-L \le x \le L$ . Using properties of integrals, I have

$$\innp{a f_1 + f_2}{g} = \dfrac{1}{L} \int_{-L}^L (a f_1(x) + f_2(x)) g(x)\,dx =$$

$$a \cdot \dfrac{1}{L} \int_{-L}^L f_1(x) g(x)\,dx + \dfrac{1}{L} \int_{-L}^L f_2(x) g(x)\,dx = a \innp{f_1}{g} + \innp{f_2}{g}.$$

Symmetry is easy:

$$\innp{f}{g} = \dfrac{1}{L} \int_{-L}^L f(x) g(x)\,dx = \dfrac{1}{L} \int_{-L}^L g(x) f(x)\,dx = \innp{g}{f}.$$

Note that this should be called "inner product" (with quotes), since it isn't positive definite. Since $[f(x)]^2 \ge 0$ , it follows that

$$\innp{f}{f} = \dfrac{1}{L} \int_{-L}^L f(x) \cdot f(x)\,dx = \dfrac{1}{L} \int_{-L}^L [f(x)]^2\,dx \ge 0.$$

But you could have a function which was nonzero --- for example, a function which was 0 at every point in $-L \le x \le L$ , but nonzero at a single point --- such that $(f, f) = 0$ .

We can get around this problem by confining ourselves to continuous functions. Unfortunately, many of the functions we'd like to apply Fourier series to aren't continuous.

Theorem. ( Orthogonality Relations)

$$ \eqalign { \dfrac{1}{L} \int_{-L}^L \cos \left(\dfrac{\pi j x}{L}\right) \cos \left(\dfrac{\pi k x}{L}\right)\,dx & = \cases{0 & if $j \ne k$ \cr 1 & if $j = k$ \cr}\cr \dfrac{1}{L} \int_{-L}^L \cos \left(\dfrac{\pi j x}{L}\right) \sin \left(\dfrac{\pi k x}{L}\right)\,dx & = 0\cr \dfrac{1}{L} \int_{-L}^L \sin \left(\dfrac{\pi j x}{L}\right) \sin \left(\dfrac{\pi k x}{L}\right)\,dx & = \cases{0 & if $j \ne k$ \cr 1 & if $j = k$ \cr}\cr } $$

Example. I'll illustrate the first formula with some numerical examples.

If I take different cosines, I should get 0. I'll try

$$\dfrac{1}{L} \int_{-L}^L \cos \left(\dfrac{3\pi x}{L}\right) \cos \left(\dfrac{7\pi x}{L}\right)\,dx.$$

Use the identity

$$\cos a \cos b = \dfrac{1}{2}\left(\cos(a + b) + \cos (a - b)\right).$$

I get

$$\cos \left(\dfrac{3\pi x}{L}\right) \cos \left(\dfrac{7\pi x}{L}\right) = \dfrac{1}{2}\left[\cos \left(\dfrac{10\pi x}{L}\right) + \cos \left(\dfrac{4\pi x}{L}\right)\right].$$


$$\dfrac{1}{L} \int_{-L}^L \cos \left(\dfrac{3\pi x}{L}\right) \cos \left(\dfrac{7\pi x}{L}\right)\,dx = \dfrac{1}{L} \int_{-L}^L \dfrac{1}{2}\left[\cos \left(\dfrac{10\pi x}{L}\right) + \cos \left(\dfrac{4\pi x}{L}\right)\right]\,dx =$$

$$\dfrac{1}{2L}\left[\dfrac{L}{10\pi} \sin \left(\dfrac{10\pi x}{L}\right) + \dfrac{L}{4\pi} \sin \left(\dfrac{4\pi x}{L}\right)\right]_{-L}^L = 0.$$

(Remember that the sine of a multiple of $\pi$ is 0!)

If I do the integral with both cosines the same, I use the double angle formula:

$$\dfrac{1}{L} \int_{-L}^L \cos \left(\dfrac{3\pi x}{L}\right) \cos \left(\dfrac{3\pi x}{L}\right)\,dx = \dfrac{1}{2L} \int_{-L}^L \left[1 + \cos\left(\dfrac{6\pi x}{L}\right)\right]\,dx =$$

$$\dfrac{1}{2L}\left[x + \dfrac{L}{6\pi} \sin\left(\dfrac{6\pi x}{L}\right)\right]_{-L}^L = 1.$$

There is nothing essentially different in the derivation of the general formulas.

In terms of the (almost) inner product defined above, the orthogonality relations are:

$$ \eqalign { \innp{\cos \left(\dfrac{\pi j x}{L}\right)}{\cos \left(\dfrac{\pi k x}{L}\right)} & = \cases{0 & if $j \ne k$ \cr 1 & if $j = k$ \cr}\cr \innp{\cos \left(\dfrac{\pi j x}{L}\right)}{\sin \left(\dfrac{\pi k x}{L}\right)} & = 0\cr \innp{\sin \left(\dfrac{\pi j x}{L}\right)}{\sin \left(\dfrac{\pi k x}{L}\right)} & = \cases{0 & if $j \ne k$ \cr 1 & if $j = k$ \cr}\cr } $$

In other words, the sine and cosine functions form an orthnormal set (again, allowing that we don't quite have an inner product here).

As a constant function, I'll use $\dfrac{1}{\sqrt{2}}$ . You can verify that this is perpendicular to the sines and cosines above, and that it has length 1.

For vectors in an inner product space, you can get the components of a vectors by taking the inner product of the vector with elements of an orthonormal basis. For example, if $\{u_1, u_2, \ldots, u_n\}$ is an orthonormal basis, then a vector x can be written as a linear combination of the u's by taking inner product of x with the u's:

$$x = \langle x, u_1 \rangle u_1 + \langle x, u_2 \rangle u_2 + \cdots + \langle x, u_n \rangle u_n.$$

By analogy, I might try to expand a function in terms of the sines and cosines by taking the inner product of f with the sines and cosines, and the constant function $\dfrac{1}{\sqrt{2}}$ . Doing so, I get

$$a_n = \dfrac{1}{L} \int_{-L}^L f(x) \cos \left(\dfrac{\pi n x}{L}\right)\,dx$$

$$b_n = \dfrac{1}{L} \int_{-L}^L f(x) \sin \left(\dfrac{\pi n x}{L}\right)\,dx$$

The cosine term is $a_n \cos \dfrac{\pi
   n x}{L}$ .

The sine term is $b_n \sin \dfrac{\pi n
   x}{L}$ .

If I set $n = 0$ in the $a_n$ formula, then since $\cos \dfrac{\pi \cdot 0 \cdot x}{L} = 1$ , I'd get

$$a_0 = \dfrac{1}{L} \int_{-L}^L f(x) \,dx.$$

So for the constant function $\dfrac{1}{\sqrt{2}}$ , the coefficient is

$$\dfrac{1}{L} \int_{-L}^L f(x) \cdot \dfrac{1}{\sqrt{2}}\,dx = \dfrac{1}{\sqrt{2}} \cdot \dfrac{1}{L} \int_{-L}^L f(x) \,dx = \dfrac{1}{\sqrt{2}} a_0.$$

But my constant function is $\dfrac{1}{\sqrt{2}}$ , so the constant term in the series will be

$$\dfrac{1}{\sqrt{2}} a_0 \cdot \dfrac{1}{\sqrt{2}} = \dfrac{1}{2} a_0.$$

Putting everything together gives the Fourier series for $f(x)$ :

$$f(x) = \dfrac{a_0}{2} + \sum_{n=1}^\infty \left(a_n \cos \dfrac{\pi n x}{L} + b_n \sin \dfrac{\pi n x}{L}\right).$$

You can interpret it as an expression for f as an infinite "linear combination" of the orthnormal sine and cosine functions.

There are several issues here. For one thing, this is an infinite sum, not the usual finite linear combination which expresses a vector in terms of a basis. Questions of convergence always arise with infinite sums. Moreover, even if the infinite sum converges, why should it converge to $f(x)$ ?

In addition, we're only doing this by analogy with our results on inner product spaces, because this "inner product" only satisfies two of the inner product axioms.

It's important to know that these issues exist, but their treatment will be deferred to an advanced course in analysis.

Before doing some examples, here are some notes about computations.

You can often use the complex exponential (DeMoivre's formula) to simplify computations:

$$\exp \left(\dfrac{\pi i n x}{L}\right) = \cos \left(\dfrac{\pi n x}{L}\right) + i \sin \left(\dfrac{\pi n x}{L}\right).$$

Specifically, let

$$c_k = \dfrac{1}{L} \int_{-L}^L f(x) \exp \left(\dfrac{\pi i n x}{L}\right)\,dx.$$


$$a_n = \re c_n, \quad b_n = \im c_n.$$

This allows me to compute a single integral, then find the real and imaginary parts of the result to get the sine and cosine coefficients.

On some occasions, symmetry can be used to obtain the values of some of the coefficients.

1. If a function is even --- that is, if $f(x) = f(-x)$ for all x, so the graph is symmetric about the y-axis --- then $b_n = 0$ for all n.

2. If a function is odd --- that is, if $f(-x) = -f(x)$ for all x, so the graph is symmetric about the origin --- then $a_n = 0$ for all n.

This makes sense, since the cosine functions are even and the sine functions are odd.

Here's a final remark before I get to the examples. A sum of periodic functions is periodic. Since sine and cosine are periodic, you can only expect to represent periodic functions by a Fourier series. Therefore, outside the interval $-L \le
   x \le L$ , you must "repeat" $f(x)$ in periodic fashion (so $f(x) = f(x + L)$ for all x).

For example, consider the function $f(x) = x$ , $-1 \le x < 1$ . $L = 1$ , so I must "repeat" the function every two units. Picture:

$$\hbox{\epsfysize=2in \epsffile{fourier1.eps}}$$

The Fourier expansion of $f(x)$ only converges to $y = x$ on the interval $-1 < x < 1$ . Outside of that interval, it converges to the periodic function in the picture (except perhaps at the jump discontinuities).

Example. Find the Fourier expansion of

$$f(x) = \cases{-1 & if $-1 \le x < 0$ \cr 1 & if $0 \le x < 1$\cr} \quad\hbox{and}\quad f(x) = f(x + 2) \hbox{ for all } x.$$

$$\hbox{\epsfysize=1.5in \epsffile{fourier2.eps}}$$

This graph is called a square wave.

This is an odd function, so $a_k = 0$ for all k --- that is, all the cosine terms vanish. I'll compute all the coefficients anyway so you can see this directly.

Compute the constant term first:

$$a_0 = \dfrac{1}{1} \int_{-1}^1 f(x)\,dx = 0.$$

Next, compute the $c_n$ terms:

$$c_n = \dfrac{1}{1} \int_{-1}^2 f(x) e^{\pi i n x}\,dx = -\int_{-1}^0 e^{\pi i n x}\,dx + \int_0^1 e^{\pi i n x}\,dx =$$

$$\left[\dfrac{i}{\pi n} e^{\pi i n x}\right]_{-1}^0 + \left[-\dfrac{i}{\pi n} e^{\pi i n x}\right]_0^1 = \dfrac{i}{\pi n}\left(1 - e^{-\pi i n}\right) - \dfrac{i}{\pi n}\left(e^{\pi in} - 1\right).$$


$$e^{-\pi n i} = \cos \pi n - i \sin \pi n = \cos \pi n = (-1)^n$$

$$e^{\pi n i} = \cos \pi n + i \sin \pi n = \cos \pi n = (-1)^n$$


$$c_n = \dfrac{2i}{\pi n}\left(1 - (-1)^n\right).$$


$$a_n = \re c_n = 0, \quad\hbox{and}\quad b_n = \im c_n = \dfrac{2}{\pi n}\left(1 - (-1)^n\right).$$

So the Fourier expansion is

$$f(x) \sim \sum_{n=1}^\infty \dfrac{2}{\pi n}\left(1 - (-1)^n\right) \sin \pi nx.$$

Here are the graphs of the first, fifth, and tenth partial sums:

$$\hbox{\epsfxsize=1.5in \epsffile{fourier3.eps}} \hskip0.25in \hbox{\epsfxsize=1.5in \epsffile{fourier4.eps}} \hskip0.25in \hbox{\epsfxsize=1.5in \epsffile{fourier5.eps}}$$ Notice the ``ringing'' at the points of discontinuity, and how the graphs are approaching the original square wave.

Note that if $x = 0$ , all the terms of the series are 0, and the series converges to 0. In fact, under reasonable conditions --- specifically, if f is of bounded variation in an interval around a point c --- the Fourier series will converges to the average of the left and right-hand limits at the point. In this case, the left-hand limit is -1, the right-hand limit is 1, and their average is 0. On the other hand, $f(0)$ was defined to be 1.

Example. Find the Fourier expansion of

$$f(x) = \cases{1 & if $-1 \le x < 0$ \cr (x - 1)^2 & if $0 \le x < 1$\cr} \quad\hbox{and}\quad f(x) = f(x + 2) \hbox{ for all } x.$$

$$\hbox{\epsfysize=1.5in \epsffile{fourier6.eps}}$$

Compute the constant term first:

$$a_0 = \int_{-1}^1 f(x)\,dx = \int_{-1}^0 1\,dx + \int_0^1 (x - 1)^2\,dx = \left[ x \right]_{-1}^0 + \left[\dfrac{1}{3} (x - 1)^3\right]_0^1 = \dfrac{4}{3}.$$

Next, compute the higher order terms:

$$c_n = \int_{-1}^1 f(x) e^{\pi i n x}\,dx = \int_{-1}^0 e^{\pi i n x}\,dx + \int_0^1 (x - 1)^2 e^{\pi i n x}\,dx =$$

$$\left[\dfrac{-i}{\pi n} e^{\pi i n x}\right]_{-1}^0 + \left[\left(-\dfrac{i}{\pi n} (x - 1)^2 + \dfrac{2}{\pi^2 n^2} (x - 1) + \dfrac{2i}{\pi^3 n^3}\right) e^{\pi i n x}\right]_0^1 =$$

$$-\dfrac{i}{\pi n}\left(1 - e^{-\pi n i}\right) + \dfrac{2i}{\pi^3 n^3} e^{\pi i n} + \dfrac{i}{\pi n} + \dfrac{2}{\pi^2 n^2} - \dfrac{2i}{\pi^3 n^3}.$$


$$c_n = -\dfrac{i}{\pi n}\left(1 - (-1)^n\right) + \dfrac{2i}{\pi^3 n^3} (-1)^n + \dfrac{i}{\pi n} + \dfrac{2}{\pi^2 n^2} - \dfrac{2i}{\pi^3 n^3} =$$

$$\dfrac{i}{\pi n}(-1)^n + \dfrac{2i}{\pi^3 n^3} (-1)^n + \dfrac{2}{\pi^2 n^2} - \dfrac{2i}{\pi^3 n^3}.$$

Now take real and imaginary parts:

$$a_n = \re c_n = \dfrac{2}{\pi^2 n^2}, \quad b_n = \im c_n = \dfrac{1}{\pi n}(-1)^n - \dfrac{2}{\pi^3 n^3} \left(1 - (-1)^n\right).$$

The Fourier series is

$$f(x) \sim \dfrac{2}{3} + \sum_{n=1}^\infty \left(\dfrac{2}{\pi^2 n^2} \cos \pi nx + \left(\dfrac{1}{\pi n}(-1)^n - \dfrac{2}{\pi^3 n^3} \left(1 - (-1)^n\right)\right) \sin \pi nx\right).\quad\halmos$$

Example. Find the Fourier expansion of

$$f(x) = \cases{ x + \pi & if $-\pi \le x < 0$ \cr 0 & if $0 \le x < \pi$\cr} \quad\hbox{and}\quad f(x) = f(x + 2 \pi) \quad\hbox{for all}\quad x.$$

$$\hbox{\epsfysize=1.5in \epsffile{fourier7.eps}}$$

Compute the constant term first:

$$a_0 = \dfrac{1}{\pi} \int_{-\pi}^\pi f(x)\,dx = \dfrac{1}{\pi} \int_{-\pi}^0 (x + \pi)\,dx + \dfrac{1}{\pi} \int_0^\pi (0)\,dx = \dfrac{1}{\pi} \left[\dfrac{1}{2} x^2 + \pi x\right]_{-\pi}^0 = \dfrac{\pi}{2}.$$

Next, compute the higher order terms. As in the computation of $a_0$ , I only need the integral from $\pi$ to 0, since the function equals 0 from 0 to $\pi$ :

$$c_n = \dfrac{1}{\pi} \int_{-\pi}^\pi f(x) e^{\pi i n x/\pi}\,dx = \dfrac{1}{\pi} \int_{-\pi}^0 (x + \pi) e^{i n x}\,dx = \dfrac{1}{\pi} \left[\dfrac{1}{i n} (x + \pi) e^{i n x} + \dfrac{1}{n^2} e^{i n x}\right]_{-\pi}^0 =$$

$$\dfrac{1}{\pi} \left(\dfrac{1}{i n} \cdot \pi + \dfrac{1}{n^2} - \dfrac{1}{i n} \cdot 0 \cdot e^{-\pi i n} - \dfrac{1}{n^2} e^{-\pi i n}\right) = \dfrac{1}{i n} + \dfrac{1}{\pi n^2} - \dfrac{1}{\pi n^2} e^{-\pi i n} =$$

$$-\dfrac{1}{n} i + \dfrac{1}{\pi n^2} - \dfrac{1}{\pi n^2} (-1)^n.$$


$$a_n = \dfrac{1}{\pi n^2} - \dfrac{1}{\pi n^2} (-1)^n \quad\hbox{and}\quad b_n = -\dfrac{1}{n}.$$

The series is

$$f(x) \sim \dfrac{\pi}{4} + \sum_{n=1}^\infty \left( \left(\dfrac{1}{\pi n^2} - \dfrac{1}{\pi n^2} (-1)^n\right) \cos n x - \dfrac{1}{n} \sin n x\right).\quad\halmos$$

Contact information

Bruce Ikenaga's Home Page

Copyright 2016 by Bruce Ikenaga