Skip to the content of the web site.

Lecture 25

Lecture 24 | Lecture 26


This topic covers

25.1 Fourier Series

In your MATH 215 course, you have at this point discussed orthogonal bases of vector spaces and dimension. We will now use this concept in this class.

Recall that the inner product of two functions defined on an interval tex:$$[a, b]$$ is defined as

tex:$$\langle f(t), g(t) \rangle = \int_a^b f(t) g(t) dt$$

and an orthogonal set of functions tex:$${g_1, g_2, g_3, ..., g_n}$$ are a set of functions such that

tex:$$\langle g_i, g_j \rangle = \int_a^b g_i(t) g_j(t) dt = \left \{ \matrix{ \|g_i\|_2^2 & i = j \cr 0 & i \ne j} \right.$$.

A function such that

tex:$$\langle g(t), g(t) \rangle = \int_a^b g^2(t) dt = \|g\|_2^2 < \infty$$

is said to be square integrable and the vector space of all square-integrable functions on the interval tex:$$[a, b]$$ is given the name tex:$$L^2[a, b]$$. Square integrability will be a property which is used throughout electrical and computer engineering and will be used in ECE 207 Signals and Systems in 2B.

We will now look at a number of bases of square-integrable functions.

Given any interval tex:$$[a, b]$$ of width tex:$$T$$, the set of functions

tex:$$1, \cos\left(\frac{2\pi}{T} t\right), \sin\left(\frac{2\pi}{T} t\right), \cos\left(2\frac{2\pi}{T} t\right), \sin\left(2\frac{2\pi}{T} t\right), \cos\left(3\frac{2\pi}{T} t\right), \sin\left(3\frac{2\pi}{T} t\right), \ldots$$

forms a basis for tex:$$L^2[a, b]$$.

This basis is called the Fourier series or Fourier basis of square-integrable functions defined on the interval tex:$$[a, b]$$. Recall also from MATH 215 that we may use projections to map an arbitrary function tex:$$f(t)$$ onto one of the orthogonal basis vectors using

tex:$$\frac{\langle g_k(t), f(t)\rangle}{\langle g_k(t), g_k(t)\rangle}g_k(t)$$

and we may therefore write that

tex:$$f(t) = \sum_{k = 0}^\infty \right(\frac{\langle g_k(t), f(t)\rangle}{\langle g_k(t), g_k(t)\rangle}\right) g_k(t)$$

where the ratios in the parentheses are constants are and called Fourier coefficients.

Historical Note

Joseph Fourier published a paper with Fourier series in 1807 before the concept of vector spaces was formalized by Giuseppe Peano in the late 1800s.

Well, the origin is obvious from the name: It was the French mathematical physicist Jean-Baptist Joseph Fourier (1768-1830) who introduced these series. As a person, the man was rather weird, and if you are interested I'll tell you some stories about his life in class. What he did for mathematics nd physics, however, history will never forget. In fact, Fourier belongs to the select company of work whose work is so fundamental that their names are used as adjectives!

To understand the impact of Fourier's ideas, picture this scene: The year is 1807 and a paper submitted by Fourier to the French Academy reaches the hands of three of the greatest mathematicians of the time (for refereeing). Now these were no average guys: Lagrange, Laplace, and Legendre. And the paper makes a significant impression on them, although they point out that Fourier had failed to prove his main result; without such a proof, Fourier's claim was simply outrageous. One may believe that jealousy was involved, but that is not the case for this is what Fourier claimed:

  • Take a function tex:$$f(t)$$ defined on tex:$$(-\pi, \pi)$$.
  • The function tex:$$f$$ need not be nice: it can have an arbitrary but finite number of discontinuities.
  • Extend the function periodically over the real line; that is, take the function on tex:$$(-\pi, \pi)$$ and repeat it forever to the left and to the right.
  • Then tex:$$f(t) = \frac{a_0}{2} + \sum_{n = 1}^\infty\left( c_n \cos(nt) + s_n \sin(nt) \right )$$ tex:$$c_n = \frac{1}{\pi} \int_{-\pi}^\pi f(t) \cos(nt) dt$$ and tex:$$s_n = \frac{1}{\pi} \int_{-\pi}^\pi f(t) \sin(nt) dt$$ for tex:$$n = 1, 2, 3, \ldots$$.
  • Moreover, this series converges to tex:$$f(t)$$ for each point where the function is continuous and the series converges to tex:$$\frac{1}{2}\left(f(t^+) + f(t^-)\right)$$ at any point where the function is discontinuous.

Why is this outrageous? Suppose that the function tex:$$f$$ has a jump discontinuity at some point tex:$$t_0$$. Therefore, tex:$$f'(t_0)$$ does not exist, and yet all the functions in the series are infinitely differentiable everywhere; so how can one hope to represent a function with no derivative at a point by a series of other functions that have derivatives at all points.

25.2 Fourier Series on the Interval [-π, π]

We will begin with a very simple interval: tex:$$[-\pi, \pi]$$. In this case, the width of the interval is tex:$$T = 2\pi$$ and therefore the basis functions are

tex:$$1, \cos\left(t\right), \sin\left(t\right), \cos\left(2 t\right), \sin\left(2 t\right), \cos\left(3 t\right), \sin\left(3 t\right), \ldots$$.

These functions are orthogonal on this interval, for example,

tex:$$\int_{-\pi}^\pi \cos\left(3t\right) \sin\left(7t\right) dt = 0$$.

On the other hand, we must also calculate:

tex:$$\langle g_k(t), g_k(t)\rangle$$

for each of these functions. In the case of the function 1, it is easy:

tex:$$\langle 1, 1\rangle = \int_{-\pi}^\pi 1^2 dt = 2\pi$$.

Calculating the others may appear initially to be more difficult; however, look at the squares of each of these functions, as is shown in Figure 1.


Figure 1. The squares of tex:$$\sin(t), \sin(2t), \sin(3t), \cos(t), \cos(2t), \cos(3t)$$ on the interval tex:$$[-\pi, \pi]$$.

In each case, the region below the function occupies half the area of the rectangle of width tex:$$2\pi$$ and height 1. Consequently, it must be true that

tex:$$\langle \cos(nt), \cos(nt)\rangle = \int_{-\pi}^\pi \cos^2(nt) dt = \pi$$
tex:$$\langle \sin(nt), \sin(nt)\rangle = \int_{-\pi}^\pi \sin^2(nt) dt = \pi$$

for any integer tex:$$k \ge 1$$.

Consequently, we get the traditional definition of a Fourier series from linear algebra:

tex:$$f(t) = \frac{1}{2\pi} \int_{-\pi}^\pi f(t) dt + \frac{1}{\pi}\sum_{k = 1}^\infty \left( \int_{-\pi}^\pi \cos(kt) f(t) dt \right ) \cos(kt) + \frac{1}{\pi}\sum_{k = 1}^\infty \left( \int_{-\pi}^\pi \sin(kt) f(t) dt \right ) \sin(kt)$$.

For clarity, for a given function tex:$$f(t)$$ we will define

tex:$$c_0 = \frac{1}{2\pi} {\int_{-\pi}^\pi f(t) dt$$

and

tex:$$c_k = \frac{1}{\pi}\int_{-\pi}^\pi \cos(kt) f(t) dt$$
tex:$$s_k = \frac{1}{\pi}\int_{-\pi}^\pi \sin(kt) f(t) dt$$

and thus we may write the Fourier series as

tex:$$f(t) = c_0 + \sum_{k = 1}^\infty c_k \cos(kt) + \sum_{k = 1}^\infty s_k \sin(kt)$$.

Approximating Functions

A Fourier series has an infinite number of terms; however, engineers cannot practically deal with an infinite series. Fortunately, for almost all functions which engineers will ever encounter, we may approximate a function with a finite Fourier series

tex:$$f(t) = \frac{1}{2\pi} \int_{-\pi}^\pi f(t) dt + \frac{1}{\pi}\sum_{k = 1}^N \left( \int_{-\pi}^\pi \cos(kt) f(t) dt \right ) \cos(kt) + \frac{1}{\pi}\sum_{k = 1}^N \left( \int_{-\pi}^\pi \sin(kt) f(t) dt \right ) \sin(kt)$$

where tex:$$N$$ is some sufficiently large integer.

Example 1

Consider the function tex:$$f:[-\pi, \pi] \rightarrow {\bf R}$$ given by tex:$$f(t) = t$$.

First, this function is odd and therefore tex:$$\int_{-\pi}^\pi t dt = 0$$ and tex:$$\int_{-\pi}^\pi \cos(kt) t dt = 0$$ for all values of tex:$$k \ge 1$$. Therefore tex:$$c_k = 0$$ for all tex:$$k \ge 0$$. Determining the other coefficients requires us to solve

tex:$$s_k = \frac{1}{\pi}\int_{-\pi}^\pi t \sin(kt) dt$$.

This requires one integration by parts, that is, tex:$$\int_a^b u dv = uv|_a^b - \int_a^b v du$$ where in this case, tex:$$u(t) = t$$ and tex:$$v(t) = -\frac{1}{k}\cos(kt)$$. Therefore

tex:$$s_k = \frac{1}{\pi}\int_{-\pi}^\pi t \sin(kt) dt = -\frac{1}{\pi} \left . t\frac{1}{k}\cos(kt)\right|_{t = -\pi}^\pi + \frac{1}{k \pi} \int_{-\pi}^\pi \cos(kt) dt$$.

The second integral is zero and the first term simplifies to

tex:$$s_k = -\frac{2\cos(k\pi)}{k}$$.

We note that tex:$$cos(\pi) = -1$$, tex:$$cos(2\pi) = 1$$, tex:$$cos(3\pi) = -1$$, and thus tex:$$cos(k\pi) = (-1)^k$$, and thus we have

tex:$$s_k = -\frac{2(-1)^k}{k} = \frac{2(-1)^{k + 1}}{k}$$.

Therefore, our Fourier series is

tex:$$t = \sum_{k = 1}^\infty \frac{2(-1)^{k + 1}}{k} \sin(kt)$$.

To see how this series approximates the function tex:$$t$$, let us consider the partial sums:

tex:$$t \approx \frac{2}{1} \sin(t)$$,
tex:$$t \approx \frac{2}{1} \sin(t) - \frac{2}{2} \sin(2t)$$,
tex:$$t \approx \frac{2}{1} \sin(t) - \frac{2}{2} \sin(2t) + \frac{3}{2} \sin(3t)$$, and
tex:$$t \approx \frac{2}{1} \sin(t) - \frac{2}{2} \sin(2t) + \frac{3}{2} \sin(3t) - \frac{4}{2} \sin(4t)$$

and these are shown in Figure 2.


Figure 2. The first four Fourier series approximations of the function tex:$$f(t) = t$$.

As you will note, with each new term added to the series, the approximation becomes better (though more wavy). Figure 3 shows an animation of how more and more terms being added to the Fourier series results in a better and better approximation.


Figure 3. An animation showing the first fifty-one Fourier series approximations of the function tex:$$f(t) = t$$.

Note that Figure 3 is not a continuous movie. Each successive frame draws the Fourier series approximation with one additional term. Because the magnitude of each additional term grows successively smaller, it appears as if it is a continuous movie.

You will notice that at any one point, it appears to converge; however, there is a jump in the approximations near the end points. We will revisit this again.

Example 2

Next, consider the function tex:$$f:[-\pi, \pi] \rightarrow {\bf R}$$ given by tex:$$f(t) = t^2$$.

First, this function is odd and therefore tex:$$\int_{-\pi}^\pi \sin(kt) t^2 dt = 0$$ for all values of tex:$$k \ge 1$$. Determining the other coefficients requires us to solve

tex:$$c_0 = \frac{1}{2\pi}\int_{-\pi}^\pi t^2 dt = \frac{1}{2\pi} \frac{1}{3} \left. t^2 \right |_{t = -\pi}^\pi = \frac{2\pi^3}{6\pi} = \frac{\pi^2}{3}$$

and, using two integration by parts,

tex:$$c_k = \frac{1}{2\pi}\int_{-\pi}^\pi \cos(kt) t^2 dt = \frac{4 (-1)^k}{k^2}$$.

Thus, we have the Fourier series approximation

tex:$$t^2 = \frac{\pi^2}{3} + \sum_{k = 1}^\infty \frac{4 (-1)^k}{k^2} \cos(kt)$$.

The first five approximations are

tex:$$t^2 \approx \frac{\pi^2}{3}$$,
tex:$$t^2 \approx \frac{\pi^2}{3} - \frac{4}{1} \cos(t)$$,
tex:$$t^2 \approx \frac{\pi^2}{3} - \frac{4}{1} \cos(t) + \frac{4}{4} \cos(2t)$$,
tex:$$t^2 \approx \frac{\pi^2}{3} - \frac{4}{1} \cos(t) + \frac{4}{4} \cos(2t) - \frac{4}{9} \cos(3t)$$, and
tex:$$t^2 \approx \frac{\pi^2}{3} - \frac{4}{1} \cos(t) + \frac{4}{4} \cos(2t) - \frac{4}{9} \cos(3t) + \frac{4}{16} \cos(4t)$$

and these are shown in Figure 4.


Figure 4. The first five Fourier series approximations of the function tex:$$f(t) = t^2$$.

You will notice that the first approximation is a constant function: it is the constant function which has the same integral of the function tex:$$f(t) = t^2$$ on the interval tex:$$[-\pi, \pi]$$.

As you will note, with each new term added to the series, the approximation becomes better. Figure 5 shows an animation of how more and more terms being added to the Fourier series results in a better and better approximation.


Figure 5. An animation showing the first fifty-one Fourier series approximations of the function tex:$$f(t) = t^2$$.

You will notice that, unlike the previous example, it appears to converge everywhere without an overshoot at either end. This will, again be explained later.

Example 3

Next, consider the function tex:$$f:[-\pi, \pi] \rightarrow {\bf R}$$ given by tex:$$f(t) = \left \{ \matrix{ 0 & t < 0 \cr 1 & t \ge 0 } \right .2$$. This is the unit step function shown in Figure 6.


Figure 6. The unit step function on the interval tex:$$[-\pi, \pi]$$.

tex:$$c_0 = \frac{1}{2\pi}\int_{-\pi}^\pi f(t) dt = \frac{1}{2\pi}\int_0^\pi 1 dt = \frac{\pi}{2\pi} = \frac{1}{2}$$.

The cosine terms, however, are all zero:

tex:$$c_k = \frac{1}{\pi}\int_{-\pi}^\pi \cos(kt) f(t) dt = \frac{1}{\pi}\int_0^\pi \cos(kt) dt = 0$$.

The sine terms are more interesting:

tex:$$s_k = \frac{1}{\pi}\int_{-\pi}^\pi \sin(kt) f(t) dt = \frac{1}{\pi}\int_0^\pi \sin(kt) dt = \frac{1}{\pi} \left( -\frac{1}{k} \cos(kt) \right |_{t = 0}^\pi = \frac{1 - cos(k\pi)}{\pi k} = \frac{1 - (-1)^k}{k\pi}$$.

Thus, if tex:$$k$$ is odd, the coefficient is tex:$$s_k = \frac{2}{k\pi}$$; while if tex:$$k$$ is even, the coefficient is tex:$$s_k = 0$$. Therefore, we may write the Fourier series as

tex:$$t^2 = \frac{1}{2} + \sum_{k = 1}^\infty \frac{2}{k} \sin\left((2k - 1)t\right)$$.

The first five terms different approximations are

tex:$$f(t) \approx \frac{1}{2}$$,
tex:$$f(t) \approx \frac{1}{2} + \frac{2}{1} \sin(t)$$,
tex:$$f(t) \approx \frac{1}{2} + \frac{2}{1} \sin(t) + \frac{2}{3} \sin(3t)$$,
tex:$$f(t) \approx \frac{1}{2} + \frac{2}{1} \sin(t) + \frac{2}{3} \sin(3t) + \frac{2}{5} \sin(5t)$$, and
tex:$$f(t) \approx \frac{1}{2} + \frac{2}{1} \sin(t) + \frac{2}{3} \sin(3t) + \frac{2}{5} \sin(5t) + \frac{4}{7} \sin(7t)$$

and these are shown in Figure 7.


Figure 7. The first five different Fourier series approximations of the unit step function.

In this case, again, you may notice the jumps at tex:$$-\pi$$, tex:$$0$$, and tex:$$\pi$$. The first twenty-six different approximations are shown in Figure 8.


Figure 8. An animation showing the first fifty-one Fourier series approximations of the unit step function.

Example 4

Consider the function tex:$$f:[-\pi, \pi] \rightarrow {\bf R}$$ given by tex:$$f(t) = u\left(t + \frac{\pi}{4}\right) - u\left(t - \frac{\pi}{4}\right)$$ or tex:$$f(t) = \cases{ $1$ & $-\frac{\pi}{4} \le t \le \frac{-pi}{4}$ \cr
$0$ & otherwise }$$.

The function is shown in Figure 9.


Figure 9. The function defined on tex:$$(-\pi, \pi)$$.

We can calculate the coefficients using integration: tex:$$c_n = \frac{1}{\pi}\int_{-\pi/4}^{\pi/4} \cos(nt) dt = \frac{2}{\pi n} \sin\left( \frac{\pi}{4} n\right )$$ and tex:$$s_n = 0$$ for tex:$$n = 0, 1, 2, \ldots$$.

The first approximation is tex:$$S_0(t) = \frac{1}{4}$$ and the next is tex:$$S_1(t) = \frac{1}{4} + \frac{\sqrt{2}}{\pi}\cos(t)$$, followed by tex:$$S_2(t) = \frac{1}{4} + \frac{\sqrt{2}}{\pi}\cos(t)  + \frac{1}{\pi}\cos(2t) + $$. Figure 10 shows various approximations. Figure 11 is an animation showing the first hundred approximations.








Figure 10. The approximations tex:$$S_0(t)$$ through tex:$$S_6(t)$$, though because tex:$$c(4) = 0$$, the approximations tex:$$S_3(t)$$ and tex:$$S_4(t)$$ are unchanged.


Figure 11. An animation showing tex:$$S_0(t)$$ through tex:$$S_{100}(t)$$ to demonstrate how they converge to the target function.

Note that Figure 11 is not a continuous movie. Each successive frame draws the Fourier series approximation with one additional term. Because the magnitude of each additional term grows successively smaller, it appears as if it is a continuous movie.

It becomes apparent in Figure 11 how the sequence of functions does appear to converge everywhere and, in addition, each approximation appears to be very close to 0.5 at the points tex:$$t = \pm \frac{\pi}{4}$$.

Example 5

Consider the modification of the function shown in Figure 12 which adds a spike of width 0.1 around the point tex:$$t = 2$$.


Figure 12. The function in Figure 9 with a spike added around tex:$$t = 2$$.

Figure 13 shows the approximations tex:$$S_1(t), S_2(t), S_3(t)$$ while Figure 14 shows the first 101 approximations.




Figure 13. The first three Fourier approximations of the function shown in Figure 12.


Figure 14. An animation showing tex:$$S_0(t)$$ through tex:$$S_{100}(t)$$ to demonstrate how they converge to the target function shown in Figure 12.

25.3 Periodic Extensions and Power Signals

In all of these cases, the function has been approximated on the interval tex:$$[-\pi, \pi]$$ and we have only plotted the solution on that interval. There is no reason not to plot the solutions over a larger interval and for Examples 1 through 4, these are shown in Figures 15 through 18.


Figure 15. The plot of the approximation tex:$$t \approx \frac{2}{1} \sin(t) - \frac{2}{2} \sin(2t) + \frac{3}{2} \sin(3t) - \frac{4}{2} \sin(4t) + \cdots + \frac{9}{2} \sin(9t) - \frac{10}{2} \sin(10t)$$.


Figure 16. The plot of the approximation tex:$$t^2 \approx \frac{\pi^2}{3} - \frac{4}{1} \cos(t) + \frac{4}{4} \cos(2t) - \frac{4}{9} \cos(3t) + \cdots + \frac{4}{64} \cos(8t) - \frac{4}{81} \cos(9t) + \frac{4}{100} \cos(10t) $$.


Figure 17. The plot of the approximation tex:$$f(t) = \left \{ \matrix{ 0 & t < 0 \cr 1 & t \ge 0 } \right .  \approx \frac{1}{2} + \frac{2}{1} \sin(t) + \frac{2}{3} \sin(3t) + \frac{2}{5} \sin(5t) + \frac{2}{7} \sin(7t) + \frac{2}{9} \sin(9t)$$.

In each case, the result is an approximation of the function defined on tex:$$[-\pi, \pi]$$ but repeated periodically. Given any function defined on tex:$$[-\pi, \pi]$$, this repetition of the function outside the interval is called the periodic extension of the function.

The power of such a periodic function is defined as

tex:$$\frac{1}{2\pi} \int_{-\pi}^\pi f^2(t) dt$$,

or, for the periodic extension of a function defined on an interval tex:$$[a, b]$$ as

tex:$$\frac{1}{b - a} \int_a^b f^2(t) dt$$.

For example, the power of the functions in Examples 1 through 4 are tex:$$\frac{\pi^2}{3}$$, tex:$$\frac{\pi^4}{5}$$, tex:$$\frac{1}{2}$$, and tex:$$\frac{1}{4}$$. This will be used in the course ECE 207 Signals and Systems the response of a system based on periodic input will be covered in significantly more detail.