# Calculus

## Fourier Series # Definition of Fourier Series and Typical Examples

Baron Jean Baptiste Joseph Fourier (1768 − 1830) introduced the idea that any periodic function can be represented by a series of sines and cosines which are harmonically related.

To consider this idea in more detail, we need to introduce some definitions and common terms.

## Basic Definitions

A function $$f\left( x \right)$$ is said to have period $$P$$ if $$f\left( {x + P} \right) = f\left( x \right)$$ for all $$x.$$ Let the function $$f\left( x \right)$$ has period $$2\pi.$$ In this case, it is enough to consider behavior of the function on the interval $$\left[ { - \pi ,\pi } \right].$$

1. Suppose that the function $$f\left( x \right)$$ with period $$2\pi$$ is absolutely integrable on $$\left[ { - \pi ,\pi } \right]$$ so that the following so-called Dirichlet integral is finite:
$\int\limits_{ - \pi }^\pi {\left| {f\left( x \right)} \right|dx} \lt \infty ;$
2. Suppose also that the function $$f\left( x \right)$$ is a single valued, piecewise continuous (must have a finite number of jump discontinuities), and piecewise monotonic (must have a finite number of maxima and minima).

If the conditions $$1$$ and $$2$$ are satisfied, the Fourier series for the function $$f\left( x \right)$$ exists and converges to the given function (see also the Convergence of Fourier Series page about convergence conditions.)

At a discontinuity $${x_0}$$, the Fourier Series converges to

$\lim\limits_{\varepsilon \to 0} \frac{1}{2}\left[ {f\left( {{x_0} - \varepsilon } \right) - f\left( {{x_0} + \varepsilon } \right)} \right].$

The Fourier series of the function $$f\left( x \right)$$ is given by

$f\left( x \right) = \frac{{{a_0}}}{2} + \sum\limits_{n = 1}^\infty {\left\{ {{a_n}\cos nx + {b_n}\sin nx} \right\}} ,$

where the Fourier coefficients $${{a_0}},$$ $${{a_n}},$$ and $${{b_n}}$$ are defined by the integrals

${a_0} = \frac{1}{\pi }\int\limits_{ - \pi }^\pi {f\left( x \right)dx} ,\;\; {a_n} = \frac{1}{\pi }\int\limits_{ - \pi }^\pi {f\left( x \right)\cos nx dx} ,\;\; {b_n} = \frac{1}{\pi }\int\limits_{ - \pi }^\pi {f\left( x \right)\sin nx dx} .$

Sometimes alternative forms of the Fourier series are used. Replacing $${{a_n}}$$ and $${{b_n}}$$ by the new variables $${{d_n}}$$ and $${{\varphi_n}}$$ or $${{d_n}}$$ and $${{\theta_n}},$$ where

${d_n} = \sqrt {a_n^2 + b_n^2} ,\;\; \tan {\varphi _n} = \frac{{{a_n}}}{{{b_n}}},\;\; \tan {\theta _n} = \frac{{{b_n}}}{{{a_n}}},$

we can write:

$f\left( x \right) = \frac{{{a_0}}}{2} + \sum\limits_{n = 1}^\infty {{d_n}\sin \left( {nx + {\varphi _n}} \right)} \;\; \text{or}\;\; f\left( x \right) = \frac{{{a_0}}}{2} + \sum\limits_{n = 1}^\infty {{d_n}\cos\left( {nx + {\theta _n}} \right)} .$

## Fourier Series of Even and Odd Functions

The Fourier series expansion of an even function $$f\left( x \right)$$ with the period of $$2\pi$$ does not involve the terms with sines and has the form:

$f\left( x \right) = \frac{{{a_0}}}{2} + \sum\limits_{n = 1}^\infty {{a_n}\cos nx} ,$

where the Fourier coefficients are given by the formulas

${a_0} = \frac{2}{\pi }\int\limits_0^\pi {f\left( x \right)dx} ,\;\; {a_n} = \frac{2}{\pi }\int\limits_0^\pi {f\left( x \right)\cos nxdx} .$

Accordingly, the Fourier series expansion of an odd $$2\pi$$-periodic function $$f\left( x \right)$$ consists of sine terms only and has the form:

$f\left( x \right) = \sum\limits_{n = 1}^\infty {{b_n}\sin nx} ,$

where the coefficients $${{b_n}}$$ are

${b_n} = \frac{2}{\pi }\int\limits_0^\pi {f\left( x \right)\sin nxdx} .$

Below we consider expansions of $$2\pi$$-periodic functions into their Fourier series assuming that these expansions exist and are convergent.

## Solved Problems

Click or tap a problem to see the solution.

### Example 1

Let the function $$f\left( x \right)$$ be $$2\pi$$-periodic and suppose that it is presented by the Fourier series:

$f\left( x \right) = \frac{{{a_0}}}{2} + \sum\limits_{n = 1}^\infty {\left\{ {{a_n}\cos nx + {b_n}\sin nx} \right\}}.$

Calculate the coefficients $${{a_0}},$$ $${{a_n}},$$ and $${{b_n}}.$$

### Example 2

Find the Fourier series for the square $$2\pi$$-periodic wave defined on the interval $$\left[ { - \pi ,\pi } \right]:$$

$f\left( x \right) = \begin{cases} 0, & \text{if} & - \pi \le x \le 0 \\ 1, & \text{if} & 0 < x \le \pi \end{cases}.$

### Example 1.

Let the function $$f\left( x \right)$$ be $$2\pi$$-periodic and suppose that it is presented by the Fourier series:

$f\left( x \right) = \frac{{{a_0}}}{2} + \sum\limits_{n = 1}^\infty {\left\{ {{a_n}\cos nx + {b_n}\sin nx} \right\}}.$

Calculate the coefficients $${{a_0}},$$ $${{a_n}},$$ and $${{b_n}}.$$

Solution.

To define $${{a_0}},$$ we integrate the Fourier series on the interval $$\left[ { - \pi ,\pi } \right]:$$

$\int\limits_{ - \pi }^\pi {f\left( x \right)dx} = \pi {a_0} + \sum\limits_{n = 1}^\infty {\left[ {{a_n}\int\limits_{ - \pi }^\pi {\cos nxdx} + {b_n}\int\limits_{ - \pi }^\pi {\sin nxdx} } \right]}.$

For all $$n \gt 0$$,

$\int\limits_{ - \pi }^\pi {\cos nxdx} = \left. {\left( {\frac{{\sin nx}}{n}} \right)} \right|_{ - \pi }^\pi = 0\;\; \text{and}\;\;\; \int\limits_{ - \pi }^\pi {\sin nxdx} = \left. {\left( { - \frac{{\cos nx}}{n}} \right)} \right|_{ - \pi }^\pi = 0.$

Therefore, all the terms on the right of the summation sign are zero, so we obtain

$\int\limits_{ - \pi }^\pi {f\left( x \right)dx} = \pi {a_0}\;\;\text{or}\;\; {a_0} = \frac{1}{\pi }\int\limits_{ - \pi }^\pi {f\left( x \right)dx} .$

In order to find the coefficients $${{a_n}},$$ we multiply both sides of the Fourier series by $$\cos mx$$ and integrate term by term:

$\int\limits_{ - \pi }^\pi {f\left( x \right)\cos mxdx} = \frac{{{a_0}}}{2}\int\limits_{ - \pi }^\pi {\cos mxdx} + \sum\limits_{n = 1}^\infty {\left[ {{a_n}\int\limits_{ - \pi }^\pi {\cos nx\cos mxdx} + {b_n}\int\limits_{ - \pi }^\pi {\sin nx\cos mxdx} } \right]} .$

The first term on the right side is zero. Then, using the well-known Product-to-Sum Identities, we have

$\int\limits_{ - \pi }^\pi {\sin nx\cos mxdx} = \frac{1}{2}\int\limits_{ - \pi }^\pi {\left[ {\sin{\left( {n + m} \right)x} + {\sin \left( {n - m} \right)x}} \right]dx} = 0,$
$\int\limits_{ - \pi }^\pi {\cos nx\cos mxdx} = \frac{1}{2}\int\limits_{ - \pi }^\pi {\left[ {\cos {\left( {n + m} \right)x} + {\cos \left( {n - m} \right)x}} \right]dx} = 0,$

if $$m \ne n.$$

In case when $$m = n$$, we can write:

$\int\limits_{ - \pi }^\pi {\sin nx\cos mxdx} = \frac{1}{2}\int\limits_{ - \pi }^\pi {\left[ {\sin 2mx + \sin 0} \right]dx} ,\;\; \Rightarrow \int\limits_{ - \pi }^\pi {{\sin^2}mxdx} = \frac{1}{2}\left[ {\left. {\left( { - \frac{{\cos 2mx}}{{2m}}} \right)} \right|_{ - \pi }^\pi } \right] = \frac{1}{{4m}}\left[ { - \cancel{\cos \left( {2m\pi } \right)} + \cancel{\cos \left( {2m\left( { - \pi } \right)} \right)}} \right] = 0;$
$\int\limits_{ - \pi }^\pi {\cos nx\cos mxdx} = \frac{1}{2}\int\limits_{ - \pi }^\pi {\left[ {\cos 2mx + \cos 0} \right]dx} ,\;\; \Rightarrow \int\limits_{ - \pi }^\pi {{\cos^2}mxdx} = \frac{1}{2}\left[ {\left. {\left( {\frac{{\sin 2mx}}{{2m}}} \right)} \right|_{ - \pi }^\pi + 2\pi } \right] = \frac{1}{{4m}}\left[ {\sin \left( {2m\pi } \right) - \sin \left( {2m\left( { - \pi } \right)} \right)} \right] + \pi = \pi .$

Thus,

$\int\limits_{ - \pi }^\pi {f\left( x \right)\cos mxdx} = {a_m}\pi ,\;\; \Rightarrow {a_m} = \frac{1}{\pi }\int\limits_{ - \pi }^\pi {f\left( x \right)\cos mxdx} ,\;\; m = 1,2,3, \ldots$

Similarly, multiplying the Fourier series by $$\sin mx$$ and integrating term by term, we obtain the expression for $${{b_m}}:$$

${b_m} = \frac{1}{\pi }\int\limits_{ - \pi }^\pi {f\left( x \right)\sin mxdx} ,\;\; m = 1,2,3, \ldots$

Rewriting the formulas for $${{a_n}},$$ $${{b_n}},$$ we can write the final expressions for the Fourier coefficients:

${a_n} = \frac{1}{\pi }\int\limits_{ - \pi }^\pi {f\left( x \right)\cos nxdx} ,\;\; {b_n} = \frac{1}{\pi }\int\limits_{ - \pi }^\pi {f\left( x \right)\sin nxdx} .$

### Example 2.

Find the Fourier series for the square $$2\pi$$-periodic wave defined on the interval $$\left[ { - \pi ,\pi } \right]:$$

$f\left( x \right) = \begin{cases} 0, & \text{if} & - \pi \le x \le 0 \\ 1, & \text{if} & 0 < x \le \pi \end{cases}.$

Solution.

First we calculate the constant $${{a_0}}:$$

${a_0} = \frac{1}{\pi }\int\limits_{ - \pi }^\pi {f\left( x \right)dx} = \frac{1}{\pi }\int\limits_0^\pi {1dx} = \frac{1}{\pi } \cdot \pi = 1.$

Find now the Fourier coefficients for $$n \ne 0:$$

${a_n} = \frac{1}{\pi }\int\limits_{ - \pi }^\pi {f\left( x \right)\cos nxdx} = \frac{1}{\pi }\int\limits_0^\pi {1 \cdot \cos nxdx} = \frac{1}{\pi }\left[ {\left. {\left( {\frac{{\sin nx}}{n}} \right)} \right|_0^\pi } \right] = \frac{1}{{\pi n}} \cdot 0 = 0,$
${b_n} = \frac{1}{\pi }\int\limits_{ - \pi }^\pi {f\left( x \right)\sin nxdx} = \frac{1}{\pi }\int\limits_0^\pi {1 \cdot \sin nxdx} = \frac{1}{\pi }\left[ {\left. {\left( { - \frac{{\cos nx}}{n}} \right)} \right|_0^\pi } \right] = - \frac{1}{{\pi n}} \cdot \left( {\cos n\pi - \cos 0} \right) = \frac{{1 - \cos n\pi }}{{\pi n}}.$

Since $$\cos n\pi = {\left( { - 1} \right)^n},$$ we can write:

${b_n} = \frac{{1 - {{\left( { - 1} \right)}^n}}}{{\pi n}}.$

Thus, the Fourier series for the square wave is

$f\left( x \right) = \frac{1}{2} + \sum\limits_{n = 1}^\infty {\frac{{1 - {{\left( { - 1} \right)}^n}}}{{\pi n}}\sin nx} .$

We can easily find the first few terms of the series. By setting, for example, $$n = 5,$$ we get

$f\left( x \right) = \frac{1}{2} + \frac{{1 - \left( { - 1} \right)}}{\pi }\sin x + \frac{{1 - {{\left( { - 1} \right)}^2}}}{{2\pi }}\sin 2x + \frac{{1 - {{\left( { - 1} \right)}^3}}}{{3\pi }}\sin 3x + \frac{{1 - {{\left( { - 1} \right)}^4}}}{{4\pi }}\sin 4x + \frac{{1 - {{\left( { - 1} \right)}^5}}}{{5\pi }}\sin 5x + \ldots = \frac{1}{2} + \frac{2}{\pi }\sin x + \frac{2}{{3\pi }}\sin 3x + \frac{2}{{5\pi }}\sin 5x + \ldots$

The graph of the function and the Fourier series expansion for $$n = 10$$ is shown below in Figure $$2.$$