Skip to main content
\(\newcommand{\id}{\mathrm{id}}\) \( \newcommand{\Span}{\mathrm{span}}\) \( \newcommand{\kernel}{\mathrm{null}\,}\) \( \newcommand{\range}{\mathrm{range}\,}\) \( \newcommand{\RealPart}{\mathrm{Re}}\) \( \newcommand{\ImaginaryPart}{\mathrm{Im}}\) \( \newcommand{\Argument}{\mathrm{Arg}}\) \( \newcommand{\norm}[1]{\| #1 \|}\) \( \newcommand{\inner}[2]{\langle #1, #2 \rangle}\) \( \newcommand{\Span}{\mathrm{span}}\)
Mathematics LibreTexts

4.2: The Trigonometric Series

4.2.1 Periodic functions and motivation

As motivation for studying Fourier series, suppose we have the problem

\[ x'' + \omega^2_0 x=f(t), \]

for some periodic function \( f(t)\). We have already solved

\[  x''+ \omega^2_0 x=F_0 \cos( \omega t). \]

One way to solve (4.2.1) is to decompose \(f(t)\) as a sum of cosines (and sines) and then solve many problems of the form (4.2.2). We then use the principle of superposition, to sum up all the solutions we got to get a solution to (4.2.1).

Before we proceed, let us talk a little bit more in detail about periodic functions. A function is said to be periodic with period \(P\) if \( f(t)\) for all \(t\). For brevity we will say \( f(t)\) is \(P-\)periodic. Note that a \(P-\)periodic function is also \(2P-\)periodic, \(3P-\)periodic and so on. For example, \( \cos(t)\) and \( \sin(t)\) are \( 2 \pi -\)periodic. So are \( \cos(kt)\) and \( \sin(kt)\) for all integers \( k\). The constant functions are an extreme example. They are periodic for any period (exercise).

Normally we will start with a function \(f(t)\) defined on some interval \( [-L, L]\) and we will want to extend periodically to make it a \( 2L-\)periodic function. We do this extension by defining a new function \(F(t)\) such that for \(t\) in\( [-L, L]\), \( F(t)=f(t)\). For \(t\) in \( [L, 3L]\), we define \( F(t)=f(t-2L)\), for \(t\) in \( [-3L, -L]\), \( F(t)=f(t+2L)\), and so on. We assumed that \( f(-L)=f(L)\). We could have also started with \(f\) defined only on the half-open interval \( (-L, L]\) and then define \( f(-L)=f(L)\).

Example \(\PageIndex{1}\):

Define \( f(t)=1-t^2\) on \([-1, 1]\). Now extend periodically to a 2-periodic function. See Figure 4.2.

 

PIC

Figure 4.2: Periodic extension of the function \( 1-t^2\).

You should be careful to distinguish between \( f(t)\) and its extension. A common mistake is to assume that a formula for \( f(t)\) holds for its extension. It can be confusing when the formula for \( f(t)\) is periodic, but with perhaps a different period.

Exercise \(\PageIndex{1}\):

Define \( f(t)= \cos t\) on \([\dfrac{ - \pi}{2}, \dfrac{ \pi}{2} ]\). Take the \(\pi -\)periodic extension and sketch its graph. How does it compare to the graph of \( \cos t\)?

4.2.2 Inner product and eigenvector decomposition

Suppose we have a symmetric matrix, that is \( A^T=A\). We have said before that the eigenvectors of \( A\) are then orthogonal. Here the word orthogonal means that if \( \vec{v}\) and \( \vec{w}\) are two distinct (and not multiples of each other) eigenvectors of \( A\), then \( \left \langle \vec{v}, \vec{w} \right \rangle=0\). In this case the inner product \(\left \langle \vec{v}, \vec{w} \right \rangle\) is the dot product, which can be computed as \( \vec{v}^T \vec{w}\).

To decompose a vector \( \vec{v}\) in terms of mutually orthogonal vectors \( \vec{w}_1\) and \( \vec{w}_2\) we write

\[  \vec{v} = a_1 \vec{w}_1+a_2 \vec{w}_2.\]

Let us find the formula for \(a_1\) and \(a_2\). First let us compute

\[  \left \langle \vec{v}, \vec{w}_1 \right \rangle = \left \langle a_1 \vec{w}_1 + a_2 \vec{w}_2, \vec{w}_1 \right \rangle = a_1  \left \langle \vec{w}_1, \vec{w}_1 \right \rangle + a_2  \left \langle \vec{w}_2, \vec{w}_1 \right \rangle= a_1  \left \langle \vec{w}_1, \vec{w}_1 \right \rangle. \]

Therefore,

\[ a_1= \dfrac{\left \langle \vec{v}, \vec{w}_1 \right \rangle}{\left \langle \vec{w}_1, \vec{w}_1 \right \rangle}.\]

Similarly

\[ a_2= \dfrac{\left \langle \vec{v}, \vec{w}_2 \right \rangle}{\left \langle \vec{w}_2, \vec{w}_2 \right \rangle}.\]

You probably remember this formula from vector calculus.

Example \(\PageIndex{2}\)

Write \( \vec{v}=\left[ \begin{array}{c} 2 \\ 3 \end{array} \right] \) as a linear combination of \( \vec{w}_1=\left[ \begin{array}{c} 1 \\ -1 \end{array} \right] \) and \( \vec{w}_2=\left[ \begin{array}{c} 1 \\ 1 \end{array} \right] \).

First note that \( \vec{w}_1\) and \( \vec{w}_2\) are orthogonal as \( \left \langle \vec{w}_1, \vec{w}_2 \right \rangle = 1(1)+(-1)1=0\). Then

\[  a_1= \dfrac{\left \langle \vec{v}, \vec{w}_1 \right \rangle}{\left \langle \vec{w}_1, \vec{w}_1 \right \rangle}= \dfrac{2(1)+3(-1)}{1(1)+(-1)(-1)}=\dfrac{-1}{2}, \\ a_2= \dfrac{\left \langle \vec{v}, \vec{w}_2 \right \rangle}{\left \langle \vec{w}_2, \vec{w}_2 \right \rangle}=\dfrac{2+3}{1+1}= \dfrac{5}{2}.\]

Hence

\[  \left[ \begin{array}{c} 2 \\ 3 \end{array} \right]=\dfrac{-1}{2} \left[ \begin{array}{c} 1 \\ -1 \end{array} \right]+ \dfrac{5}{2} \left[ \begin{array}{c} 1 \\ 1 \end{array} \right]. \]

4.2.3 The Trigonometric Series

Instead of decomposing a vector in terms of eigenvectors of a matrix, we will decompose a function in terms of eigenfunctions of a certain eigenvalue problem. The eigenvalue problem we will use for the Fourier series is

\[ x'' + \lambda x=0,~~~~ x(- \pi)=x(\pi)~~~~x'(- \pi)=x'( \pi).\]

We have previously computed that the eigenfunctions are \(1, \cos(kt), \sin(kt)\). That is, we will want to find a representation of a \( 2 \pi -\)periodic function \( f(t)\) as

\[ f(t)= \dfrac{a_0}{2}+ \sum^{\infty}_{n=1}a_n \cos(nt)+b_n \sin(nt).\]

This series is called the Fourier series2 or the trigonometric series for \(f(t)\). We write the coefficient of the eigenfunction \(1\) as \( \dfrac{a_0}{2}\) for convenience. We could also think of \( 1= \cos(0t)\), so that we only need to look at \( \cos(kt)\) and \( \sin(kt)\).

As for matrices we want to find a projection of \(f(t)\) onto the subspace generated by the eigenfunctions. So we will want to define an inner product of functions. For example, to find \( a_n\) we want to compute \( \left \langle f(t), \cos(nt) \right \rangle \). We define the inner product as

\[ \left \langle f(t), g(t)  \right \rangle = \int^{\pi}_{-\pi} f(t)g(t)dt. \]

With this definition of the inner product, we have seen in the previous section that the eigenfunctions \( \cos(kt)\)(including the constant eigenfunction), and \( \sin(kt)\) are orthogonal in the sense that

\[ \left \langle \cos(mt), \cos(nt) \right \rangle = 0 ~~~~ {\rm{for}}~ m \neq n, \\ \left \langle \sin(mt), \sin(nt) \right \rangle = 0 ~~~~ {\rm{for}}~ m \neq n, \\ \left \langle \sin(mt), \cos(nt) \right \rangle = 0 ~~~~ {\rm{for~all}}~ m {\rm{~and~}} n.\]

By elementary calculus for \( n=1,2,3, \ldots .\) we have \(  \left \langle \cos(nt), \cos(nt) \right \rangle = \pi\) and \(  \left \langle \sin(nt), \sin(nt) \right \rangle = \pi\). For the constant we get that \(  \left \langle 1, 1 \right \rangle = 2 \pi\). The coefficients are given by

\[  a_n= \dfrac{ \left \langle f(t), \cos(nt) \right \rangle}{\left \langle \cos(nt), \cos(nt) \right \rangle}= \dfrac{1}{ \pi} \int^{\pi}_{-\pi} f(t) \cos(nt)dt, \\ b_n= \dfrac{ \left \langle f(t), \sin(nt) \right \rangle}{\left \langle \sin(nt), \sin(nt) \right \rangle}= \dfrac{1}{ \pi} \int^{\pi}_{-\pi} f(t) \sin(nt)dt.  \]

Compare these expressions with the finite-dimensional example. For \( a_0\) we get a similar formula

\[ a_0 = 2 \dfrac{ \left \langle f(t), 1 \right \rangle}{\left \langle 1, 1 \right \rangle} \dfrac{1}{ \pi} \int^{\pi}_{-\pi} f(t)dt. \]

Let us check the formulas using the orthogonality properties. Suppose for a moment that

\[ f(t)= \frac{a_0}{2}+ \sum^\infty_{n=1}a_n \cos(nt)+b_n \sin(nt). \]  

Then for \( m \geq 1\) we have

\[ \left \langle f(t), \cos(mt) \right \rangle = \left \langle \frac{a_0}{2}+ \sum^\infty_{n=1}a_n \cos(nt)+b_n \sin(nt), \cos(mt) \right \rangle \\ =\frac{a_0}{2}\left \langle 1, \cos(mt) \right \rangle +\sum^\infty_{n=1}a_n \left \langle \cos(nt), \cos(mt) \right \rangle + b_n \left \langle \sin(nt), \sin(mt) \right \rangle \\ = a_m \left \langle \cos(mt), \cos(mt) \right \rangle . \]

And hence \( a_m=\frac{\left \langle f(t), \cos(mt) \right \rangle}{\left \langle \cos(mt), \cos(mt) \right \rangle}.\)

Exercise \(\PageIndex{2}\):

Carry out the calculation for \(a_0\) and \(b_m\).

Example \(\PageIndex{3}\):

Take the function

\[ f(t)=t\]

for \(t\) in \((- \pi, \pi]\). Extend \( f(t)\) periodically and write it as a Fourier series. This function is called the sawtooth.

PIC

Figure 4.3: The graph of the sawtooth function.

The plot of the extended periodic function is given in Figure 4.3. Let us compute the coefficients.

Solution

We start with \(a_0\),

\[  a_0 = \frac{1}{\pi} \int^\pi_{-\pi} tdt=0.\]

We will often use the result from calculus that says that the integral of an odd function over a symmetric interval is zero. Recall that an odd function is a function \( \varphi(t)\) such that \( \varphi(-t) = - \varphi(t)\). For example the functions \( t, \sin t\), or (importantly for us) \( t \cos(nt)\) are all odd functions. Thus

\[  a_n=\frac{1}{\pi} \int^\pi_{-\pi} t \cos(nt)dt=0.\]

Let us move to \( b_n\). Another useful fact from calculus is that the integral of an even function over a symmetric interval is twice the integral of the same function over half the interval. Recall an even function is a function \(\varphi(t)\) such that \( \varphi(-t) =  \varphi(t)\). For example \( t \sin(nt)\) is even.

\[  b_n= \frac{1}{\pi} \int^\pi_{-\pi} t \sin(nt)dt \\ = \frac{2}{\pi} \int^\pi_{0} t \sin(nt)dt \\ = \frac{2}{\pi} \left( \left[  \frac{-t \cos(nt)}{n}\right] ^\pi_{t=0}+\frac{1}{n} \int^\pi_{0}  \cos(nt)dt\right) \\= \frac{2}{\pi} \left( \frac{- \pi \cos(n \pi)}{n}+0\right) \\ = \frac{-2 \cos(n \pi)}{n}=\frac{2(-1)^{n+1}}{n}.\]

We have used the fact that

\[  \cos(n \pi)=(-1)^n= \left\{ \begin{array}{c} 1~~~~ {\rm{~if~}} n {\rm{~even,~}}\\ -1~~~~ {\rm{~if~}} n {\rm{~odd.~}} \end{array} \right.\]

The series, therefore, is

\[  \sum^\infty_{n=1} \frac{2(-1)^{n+1}}{n} \sin(nt).\]

Let us write out the first 3 harmonics of the series for \(f(t)\).

\[  2 \sin(t)- \sin(2t)+ \frac{2}{3} \sin(3t)+ \cdots\]

The plot of these first three terms of the series, along with a plot of the first 20 terms is given in Figure 4.4.

PICPIC

Figure 4.4: First 3 (left graph) and 20 (right graph) harmonics of the sawtooth function.

Example \(\PageIndex{4}\):

Take the function

\[  f(t)= \left\{ \begin{array}{cc} 0&~~~~ {\rm{~if~}} - \pi < t \leq 0, \\ \pi& {\rm{~if~}} 0 < t \leq \pi. \end{array} \right.\]

Extend \(f(t)\) periodically and write it as a Fourier series. This function or its variants appear often in applications and the function is called the square wave.

PIC

Figure 4.5: The graph of the square wave function.

The plot of the extended periodic function is given in Figure 4.5. Now we compute the coefficients. Let us start with \(a_0\)

\[  a_0= \frac{1}{\pi} \int^\pi_{-\pi} f(t)dt= \frac{1}{\pi} \int^\pi_{0} \pi dt= \pi . \]

Next,

\[ a_n = \frac{1}{\pi} \int^\pi_{-\pi} f(t) \cos(nt)dt= \frac{1}{\pi} \int^\pi_{0} \pi \cos(nt)dt= 0 . \]

And finally

\[b_n = \frac{1}{\pi} \int^\pi_{-\pi} f(t) \sin(nt)dt \\= \frac{1}{\pi} \int^\pi_{0} \pi \sin(nt)dt \\= \left[  \frac{- \cos(nt)}{n}\right]_{t=0}^{\pi} \\ =\frac{1- \cos( \pi n)}{n}=\frac{1-(-1)^n}{n}= \left\{ \begin{array}{c} \frac{2}{n}~~~~ {\rm{~if~}} n {\rm{~is~odd,~}}\\ 0~~~~ {\rm{~if~}} n {\rm{~is~even.~}} \end{array} \right.\]

The Fourier series is

\[ \frac{\pi}{2} + \sum^{\infty}_{n=1~ n~ \rm{odd}} \frac{2}{n} \sin(nt)+\sum^{\infty}_{k=1} \frac{2}{2k-1} \sin((2k-1)t).\]

Let us write out the first 3 harmonics of the series for \(f(t)\).

\[ \frac{\pi}{2}+2 \sin(t)+ \frac{2}{3} \sin(3t)+ \cdots\]

The plot of these first three and also of the first 20 terms of the series is given in Figure 4.6.

PIC PIC

Figure 4.6: First 3 (left graph) and 20 (right graph) harmonics of the square wave function.

We have so far skirted the issue of convergence. For example, if \(f(t)\) is the square wave function, the equation

\[  f(t)= \frac{\pi}{2} + \sum_{k=1}^{\infty}\frac{2}{2k-1} \sin((2k-1)t).\]

is only an equality for such \(t\) where \(f(t)\) is continuous. That is, we do not get an equality for \(t= - \pi, 0, \pi\) and all the other discontinuities of \(f(t)\). It is not hard to see that when \(t\) is an integer multiple of \(\pi\) (which includes all the discontinuities), then

\[  \frac{\pi}{2} + \sum_{k=1}^{\infty}\frac{2}{2k-1} \sin((2k-1)t)=\frac{\pi}{2}.\]

We redefine \(f(t)\) on \([- \pi, \pi]\) as

\[ f(t)=\left\{ \begin{array}{cc} 0 &~~~~ {\rm{~if~}} - \pi<t<0, \\ \pi & {\rm{~if~}} 0<t<\pi, \\ \pi/2& ~~~~~~~~~~~~~~~~~~ {\rm{~if~}} t= - \pi, t=0, {\rm{~or~}} t=\pi,  \end{array} \right. \]

and extend periodically. The series equals this extended \(f(t)\) everywhere, including the discontinuities. We will generally not worry about changing the function values at several (finitely many) points.

We will say more about convergence in the next section. Let us however mention briefly an effect of the discontinuity. Let us zoom in near the discontinuity in the square wave. Further, let us plot the first 100 harmonics, see Figure 4.7. You will notice that while the series is a very good approximation away from the discontinuities, the error (the overshoot) near the discontinuity at \( t= \pi\) does not seem to be getting any smaller. This behavior is known as the Gibbs phenomenon. The region where the error is large does get smaller, however, the more terms in the series we take.

PIC

Figure 4.7: Gibbs phenomenon in action.

We can think of a periodic function as a “signal” being a superposition of many signals of pure frequency. For example, we could think of the square wave as a tone of certain base frequency. It will be, in fact, a superposition of many different pure tones of frequencies that are multiples of the base frequency. On the other hand a simple sine wave is only the pure tone. The simplest way to make sound using a computer is the square wave, and the sound is very different from nice pure tones. If you have played video games from the 1980s or so, then you have heard what square waves sound like.

2Named after the French mathematician Jean Baptiste Joseph Fourier (1768 – 1830).

Contributors