Differential Equations for EngineersXYZ Homework Edition

⇩ Download ▾

4.2 The Trigonometric Series

Periodic Functions and Motivation

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

x + ω 0 2 x = f ( t ) , \label{eq:1} x'' + \omega^2_0 x=f(t),

(4.2.1)

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

x + ω 0 2 x = F 0 cos ( ω t ) . \label{eq:2} x''+ \omega^2_0 x=F_0 \cos( \omega t).

(4.2.2)

One way to solve (4.2.1) is to decompose f(t)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 PP if f(t)f(t) for all tt. For brevity we will say f(t)f(t) is PP-periodic. Note that a PP-periodic function is also 2P2P-periodic, 3P3P-periodic and so on. For example, cos(t)\cos(t) and sin(t)\sin(t) are 2π2 \pi -periodic. So are cos(kt)\cos(kt) and sin(kt)\sin(kt) for all integers kk. The constant functions are an extreme example. They are periodic for any period (exercise).

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

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

Inner Product and Eigenvector Decomposition

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

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

v = a 1 w 1 + a 2 w 2 . \vec{v} = a_1 \vec{w}_1+a_2 \vec{w}_2. \nonumber

Let us find the formula for a1a_1 and a2a_2. First let us compute

v , w 1 = a 1 w 1 + a 2 w 2 , w 1 = a 1 w 1 , w 1 + a 2 w 2 , w 1 = 0 = a 1 w 1 , w 1 . \langle \vec{v}, \vec{w_1} \rangle = \langle a_1 \vec{w}_1 + a_2 \vec{w}_2, \vec{w_1} \rangle = a_1 \langle \vec{w}_1, \vec{w_1} \rangle + a_2 \underbrace{\langle \vec{w}_2, \vec{w_1} \rangle}_{=0} = a_1 \langle \vec{w}_1, \vec{w_1} \rangle. \nonumber

Therefore,

a 1 = v , w 1 w 1 , w 1 . a_1= \dfrac{\left \langle \vec{v}, \vec{w}_1 \right \rangle}{\left \langle \vec{w}_1, \vec{w}_1 \right \rangle}. \nonumber

Similarly

a 2 = v , w 2 w 2 , w 2 . a_2= \dfrac{\left \langle \vec{v}, \vec{w}_2 \right \rangle}{\left \langle \vec{w}_2, \vec{w}_2 \right \rangle}. \nonumber

You probably remember this formula from vector calculus.

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 + λ x = 0 , x ( π ) = x ( π ) x ( π ) = x ( π ) . x'' + \lambda x=0,~~~~ x(- \pi)=x(\pi)~~~~x'(- \pi)=x'( \pi). \nonumber

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

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

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

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

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

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

cos ( m t ) , cos ( n t ) = 0 for  m = n , sin ( m t ) , sin ( n t ) = 0 for  m = n , sin ( m t ) , cos ( n t ) = 0 for all  m  and  n . \begin{align}\begin{aligned} \langle \, \cos (mt)\,, \, \cos (nt) \, \rangle = 0 & \qquad \text{for } m \not= n, \\ \langle \, \sin (mt)\,, \, \sin (nt) \, \rangle = 0 & \qquad \text{for } m \not= n, \\ \langle \, \sin (mt)\,, \, \cos (nt) \, \rangle = 0 & \qquad \text{for all } m \text{ and } n.\end{aligned}\end{align} \nonumber

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

1 , 1 = π π 1 · 1 d t = 2 π . \left \langle 1, 1 \right \rangle = \int_{\pi}^{\pi}1\cdot 1\: dt= 2 \pi. \nonumber

The coefficients are given by

a n = f ( t ) , cos ( n t ) cos ( n t ) , cos ( n t ) = 1 π π π f ( t ) cos ( n t ) d t , b n = f ( t ) , sin ( n t ) sin ( n t ) , sin ( n t ) = 1 π π π f ( t ) sin ( n t ) d t . \begin{align}\begin{aligned} 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.\end{aligned}\end{align} \nonumber

Compare these expressions with the finite-dimensional example. For a0a_0 we get a similar formula

a 0 = 2 f ( t ) , 1 1 , 1 1 π π π f ( t ) d t . 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. \nonumber

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

f ( t ) = a 0 2 + n = 1 a n cos ( n t ) + b n sin ( n t ) . f(t)= \frac{a_0}{2}+ \sum^\infty_{n=1}a_n \cos(nt)+b_n \sin(nt). \nonumber

Then for m1m \geq 1 we have

f ( t ) , cos ( m t ) = a 0 2 + n = 1 a n cos ( n t ) + b n sin ( n t ) , cos ( m t ) = a 0 2 1 , cos ( m t ) + n = 1 a n cos ( n t ) , cos ( m t ) + b n sin ( n t ) , sin ( m t ) = a m cos ( m t ) , cos ( m t ) . \begin{align}\begin{aligned} \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. \end{aligned}\end{align} \nonumber

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

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

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

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

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

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

f ( t ) = { 0 i f π < t < 0 , π i f 0 < t < π , π / 2 i f t = π , t = 0 , o r t = π , 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. \nonumber

and extend periodically. The series equals this extended f(t)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 6\PageIndex{6}. 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=π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.

Interactive figureGibbs phenomenon in the square-wave Fourier seriesDrag the Highest harmonic kept slider from 1 to 39.
A dashed square wave steps between two levels, and a wavy solid curve chases it, overshooting just past each jump and then rippling as it settles onto the flat stretches. Turning up the number of harmonics packs the ripples closer together and crowds them in toward the jumps, so most of the curve flattens onto the square wave — but the single tall spike beside each jump refuses to come down, holding its height however far the slider is pushed. Even settings look identical to the odd one below. Adjustable parameter: Highest harmonic kept (n) = 3. Viewing window: x from -3.8 to 3.8, y from -0.78 to 3.92.
XYZ Graph · viewer build 5edf91b
Lebl's Figure 5 freezes this at two settings, 3 harmonics and 20; here you can sweep between them and past them. The dashed trace is the square wave itself; the solid curve is the partial sum of his own series pi/2 + 2 sin t + (2/3) sin 3t + (2/5) sin 5t +.... At the default 3 you are looking at his left-hand panel exactly, and at 20 at his right-hand one. Drag between them and the ripples multiply and crowd in toward the jumps at t = 0 and t = +/- pi, but the tall spike beside each jump refuses to come down: its peak falls only from 3.456 to 3.424 across that whole drag, and never drops below 3.4227 = 1.0895*pi -- a permanent overshoot of 8.95 % of the jump height pi. Even-numbered settings look identical to the odd one below them, because a square wave has no even harmonics at all: this section computes b_n = 0 for every even n.
Close-up of the Gibbs phenomenon: the blue partial sum ripples about a flat green line at the true value of about 3.14, the wiggles growing toward the jump until the tallest reaches roughly 3.42.
Figure 6\PageIndex{6}: 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. This base frequency is called the fundamental frequency. The square wave will be a superposition of many different pure tones of frequencies that are multiples of the fundamental frequency. In music, the higher frequencies are called the overtones. All the frequencies that appear are called the spectrum of the signal. On the other hand a simple sine wave is only the pure tone (no overtones). The simplest way to make sound using a computer is the square wave, and the sound is very different from a pure tone. If you ever played video games from the 1980s or so, then you heard what square waves sound like.

Footnotes

[1] Named after the French mathematician Jean Baptiste Joseph Fourier (1768 – 1830).

Adapted from Differential Equations for Engineers by Jiří Lebl (https://www.jirka.org/diffyqs/), © Jiří Lebl, licensed under CC BY-SA 4.0. Changes were made. License: CC-BY-SA-4.0.

These eBooks are a prerelease and are not yet certified conformant with WCAG 2.1 AA or ADA Title II. Every page is built against an automated accessibility gate, and the published editions will meet ADA Title II requirements when they release in late September 2026. If something is unusable, please tell us.