# Math2111: Chapter 1: Fourier series. Section 4: Examples and general periodic functions

In this blog entry you can find lecture notes for Math2111, several variable calculus. See also the table of contents for this course. This blog entry printed to pdf is available here.

In this part we calculate the Fourier series for some given functions $f:[-\pi, \pi] \to \mathbb{R}$. We also define Fourier series for functions $f:[a, b] \to \mathbb{R}.$

Examples of Fourier series

Example (sawtooth wave function) Find the Fourier series of the function

$\displaystyle f(x) = x \quad \mbox{for } -\pi < x < \pi,$

$\displaystyle f(x) = f(x+2\pi) \quad \mbox{for } x \in \mathbb{R}.$

Further we define $f((2n + 1) \pi) = 0$ for $n \in \mathbb{Z}.$

The graph of the function can be found here. We calculate the Fourier coefficients $a_k$ for $k \ge 0$. Notice that $f$ is an odd function, that is, $f(x) = - f(-x)$ and $\cos (kx)$ is an even function. Hence $f(x) \cos (kx)$ is an odd function for all $k \ge 0.$ Therefore $a_k = \int_{-\pi}^\pi f(x) \cos (kx) \, \mathrm{d} x = 0$. (You can convince yourself of this fact by doing the integral.)

To calculate $b_k$ for $k \ge 1$, notice that $\sin (kx)$ is an odd function, hence $f(x) \sin (kx)$ is even and therefore

$\displaystyle \begin{array}{lcl} b_k & = & \frac{1}{\pi} \int_{-\pi}^\pi f(x) \sin (kx) \, \mathrm{d} x \\ && \\ & = & \frac{2}{\pi} \int_0^\pi x \sin (kx) \, \mathrm{d} x \\ && \\ & = & - \frac{2 \cos (k\pi)}{k} \\ && \\ & = & \frac{2 (-1)^{k+1}}{k}.\end{array}$

The Fourier series is therefore given by

$\displaystyle Sf(x) = \sum_{k=1}^\infty \frac{2 (-1)^{k+1}}{k} \sin (kx).$

An illustration how the partial sums of the Fourier series

$\displaystyle S_nf(x) = \sum_{k=1}^n \frac{2 (-1)^{k+1}}{k} \sin (kx)$

approximate the function $f$ can be found here and here. $\Box$

The oscillations of $S_nf$ around any jump discontinuity of $f$ are known as the Gibbs phenomenon.

Question In the sawtooth example: to which values do the partial sums $S_nf(x)$ converge as $n \to \infty$? (See the theorem on pointwise convergence from the previous post.) $\Box$

Exercise(rectangular wave function) Find the Fourier series of the function

$\displaystyle f(x) = \left\{ \begin{array}{rl} -1 & \mbox{for } -\pi \le x < 0, \\ 1 & \mbox{for } 0 \le x < \pi, \end{array} \right.$

and $f(x) = f(x+2\pi)$ for all $x \in \mathbb{R}$.

Question Do we have

$\displaystyle \lim_{n \to \infty} S_nf(x) = f(x) \quad \mbox{for all } x \in \mathbb{R}$?

Provide an argument for your answer. (See the theorem on pointwise convergence from the previous post.) $\Box$

Odd and even functions

A function $f$ is called odd if $f(x) = -f(-x)$ for all $x$ in the domain of $f$ and $f$ is called even if $f(x) = f(-x)$ for all $x$ in the domain of $f$. Examples for odd functions are $\sin x, \tan x, x^3, \ldots$. Examples for even functions are $\cos x, x^2,$

Exercise Let $f_1, f_2$ be odd and $g_1, g_2$ be even. Assuming that the functions below are well defined, state which ones are odd and which ones are even.

1. $f_1 f_2$
2. $f_1 g_1$
3. $g_1 g_2$
4. $f_1/f_2$
5. $f_1/g_1$
6. $g_1/g_2$
7. $f^\prime_1$
8. $g^\prime_1$
9. $f_1(g_1)$
10. $g_1(f_1)$
11. $f_1(f_2)$
12. $g_1(g_2)$
13. Which function is both odd and even?

The Fourier coefficients of odd and even functions

We can now use the fact that the if $f$ is odd then $\int_{-\pi}^\pi f(x) \, \mathrm{d} x = 0$ and that if $f$ is even, then $\int_{-\pi}^\pi f(x) \, \mathrm{d} x = 2 \int_{0}^\pi f(x) \, \mathrm{d} x$.

• If $f$ is odd, then $a_k = 0$ for all $k \ge 0$ and

$\displaystyle b_k = \frac{2}{\pi}\int_0^\pi f(x) \sin (kx).$

Exercise State an analoguous result if $f$ is even. $\Box$

As we have seen above, recognising whether the function is odd or even helps to reduce the amount of calculations necessary.

General periodic functions

Assume now that the function $f$ is periodic, but the period is $2L$ rather than $2\pi$, that is

$\displaystyle f(x) = f(x+2L) \quad \mbox{for all } x \in \mathbb{R}.$

Then we can still define a Fourier series.

Question If $f$ is periodic with period $2\pi$, what is the period length of the function $g(x) = f\left( \frac{\pi x}{L} \right)$?

Exercise Show that

$\displaystyle \begin{array}{rcl} \int_{-L}^L \cos^2 \left(\frac{k\pi x}{L}\right) \, \mathrm{d} x & = & L \quad \mbox{for all } k \ge 1, \\ && \\ \int_{-L}^L \sin^2 \left(\frac{k\pi x}{L}\right) \, \mathrm{d} x & = & L \quad \mbox{for all } k \ge 1, \\ && \\ \int_{-L}^L \cos\left(\frac{k' \pi x}{L} \right) \sin \left(\frac{k\pi x}{L}\right) \, \mathrm{d} x & = & 0 \quad \mbox{for all } k, k' \ge 0, \\ && \\ \int_{-L}^L \cos\left(\frac{k' \pi x}{L} \right) \cos \left(\frac{k\pi x}{L}\right) \, \mathrm{d} x & = & 0 \quad \mbox{for all } k > k' \ge 0, \\ && \\ \int_{-L}^L \sin\left(\frac{k' \pi x}{L} \right) \sin \left(\frac{k\pi x}{L}\right) \, \mathrm{d} x & = & 0 \quad \mbox{for all } k > k' \ge 1. \end{array}$

Let $f: \mathbb{R} \to \mathbb{R}$ be periodic with period $2L$, bounded and integrable on $[-L, L]$. Let

$\displaystyle \begin{array}{rcl} a_k & = & \frac{1}{L} \int_{-L}^L f(x) \cos \left( \frac{k\pi x}{L} \right) \, \mathrm{d} x \quad \mbox{for } k \ge 0, \\ b_k & = & \frac{1}{L} \int_{-L}^L f(x) \sin \left(\frac{k\pi x}{L} \right) \, \mathrm{d} x \quad \mbox{for } k \ge 1. \end{array}$

Then the formal series

$\displaystyle Sf(x) = \frac{a_0}{2} + \sum_{k=1}^\infty \left[a_k \cos \left(\frac{k\pi x}{L}\right) + b_k \sin \left(\frac{k\pi x}{L} \right) \right]$

is called the Fourier series of $f$.

Exercise Let $f$ have period $2L$ where

$\displaystyle f(x) = \frac{x}{2L} \quad \mbox{for } 0 \le x < 2L.$

Calculate the Fourier series and compare your result with the solution from here. Further, even though $f$ is not odd we still have $a_k = 0$ for $k \ge 1$. How can you obtain this result without doing any integration? $\Box$

Fourier sine and cosine series

If a function is only defined on, say, $[0,L]$, then we can extend it to $[-L, L]$ by making $f$ either odd by setting $f(x) = - f(-x)$ for $-L < x < 0$ or even by setting $f(x) = f(-x)$ for $-L < x < 0$. Hence we can then calculate the Fourier series of $f$. If we make $f$ odd, then the Fourier series is called Fourier sine series, whereas if we extend $f$ even, then the Fourier series is called Fourier cosine series (in the first case $a_k = 0$, whereas in the second case $b_k = 0$).

Exercise Let

$\displaystyle f(x) = 1 \quad \mbox{for } 0 \le x \le 1.$

Let $f_e$ be the even extension $2$-periodic extension of $f$ and let $f_o$ be the odd $2$-periodic extension of $f$.

1. Sketch the graphs of $f_e$ and $f_o$ on the interval $[-3, 3]$.
2. Find $Sf_e$ and sketch its graph on $[-3,3]$.
3. Find $Sf_o$ and sketch its graph on $[-3,3]$.
4. Show that $1 - \frac{1}{3} + \frac{1}{5} - \frac{1}{7} + \cdots = \frac{\pi}{4}$.