Fourier Series Notes
Fourier Series Notes
In this chapter we discuss Fourier series and the application to the solution of PDEs by
the method of separation of variables. In the last section, we return to the solution of
the problems in Chapter 4 and also show how to solve Laplace’s equation. We discuss the
eigenvalues and eigenfunctions of the Laplacian. The application of these eigenpairs to the
solution of the heat and wave equations in bounded domains will follow in Chapter 7 (for
higher dimensions and a variety of coordinate systems) and Chapter 8 (for nonhomogeneous
problems.)
5.1 Introduction
As we have seen in the previous chapter, the method of separation of variables requires
the ability of presenting the initial condition in a Fourier series. Later we will find that
generalized Fourier series are necessary. In this chapter we will discuss the Fourier series
expansion of f (x), i.e.
∞ " #
a0 ! nπ nπ
f (x) ∼ + an cos x + bn sin x . (5.1.1)
2 n=1 L L
We will discuss how the coefficients are computed, the conditions for convergence of the
series, and the conditions under which the series can be differentiated or integrated term by
term.
Definition 11. A function f (x) is piecewise continuous in [a, b] if there exists a finite number
of points a = x1 < x2 < . . . < xn = b, such that f is continuous in each open interval
(xj , xj+1 ) and the one sided limits f (xj+ ) and f (xj+1− ) exist for all j ≤ n − 1.
Examples
1. f (x) = x2 is continuous on [a, b].
2. $
x 0≤x<1
f (x) = 2
x −x 1<x≤2
The function is piecewise continuous but not continuous because of the point x = 1.
3. f (x) = x1 − 1 ≤ x ≤ 1. The function is not piecewise continuous because the one
sided limit at x = 0 does not exist.
Definition 12. A function f (x) is piecewise smooth if f (x) and f # (x) are piecewise continuous.
Definition 13. A function f (x) is periodic if f (x) is piecewise continuous and f (x+p) = f (x)
for some real positive number p and all x. The number p is called a period. The smallest
period is called the fundamental period.
Examples
1. f (x) = sin x is periodic of period 2π.
85
2. f (x) = cos x is periodic of period 2π.
Note: If fi (x), i = 1, 2, · · · , n are all periodic of the same period p then the linear
combination of these functions n
!
ci fi (x)
i=1
5.2 Orthogonality
Recall that two vectors "a and "b in Rn are called orthogonal vectors if
n
!
"a · "b = ai bi = 0.
i=1
We would like to extend this definition to functions. Let f (x) and g(x) be two functions
defined on the interval [α, β]. If we sample the two functions at the same points xi , i =
1, 2, · · · , n then the vectors F" and G,
" having components f (xi ) and g(xi ) correspondingly,
are orthogonal if
n
!
f (xi )g(xi ) = 0.
i=1
Example 1
The functions sin x and cos x are orthogonal on [−π, π] with respect to w(x) = 1,
% π
1% π 1 1 1
sin x cos xdx = sin 2xdx = − cos 2x|π−π = − + = 0.
−π 2 −π 4 4 4
Definition 15. A set of functions {φn (x)} is called orthogonal system with respect to w(x)
on [α, β] if
% β
φn (x)φm (x)w(x)dx = 0, for m $= n. (5.2.1)
α
86
Definition 16. The norm of a function f (x) with respect to w(x) on the interval [α, β] is
defined by
$% &1/2
β
2
%f % = w(x)f (x)dx (5.2.2)
α
Definition 17. The set {φn (x)} is called orthonormal system if it is an orthogonal system
and if
%φn % = 1. (5.2.3)
Examples
' (
nπ
1. sin x is an orthogonal system with respect to w(x) = 1 on [−L, L].
L
For n $= m
% L
nπ mπ
sin x sin xdx
−L L L
% L ) *
1 (n + m)π 1 (n − m)π
= − cos x + cos x dx
−L 2 L 2 L
$ +L &
1 L (n + m)π 1 L (n − m)π +
= − sin x+ sin x ++ = 0
2 (n + m)π L 2 (n − m)π L −L
' (
nπ
2. cos x is also an orthogonal system on the same interval. It is easy to show that for
L
n $= m
% L
nπ mπ
cos x cos xdx
−L L L
% L ) *
1 (n + m)π 1 (n − m)π
= cos x + cos x dx
−L 2 L 2 L
$ &
1 L (n + m)π 1 L (n − m)π
= sin x+ sin x |L−L = 0
2 (n + m)π L 2 (n − m)π L
3. The set {1, cos x, sin x, cos 2x, sin 2x, · · · , cos nx, sin nx, · · ·} is an orthogonal system on
[−π, π] with respect to the weight function w(x) = 1.
We have shown already that
% π
sin nx sin mxdx = 0 for n $= m (5.2.4)
−π
% π
cos nx cos mxdx = 0 for n $= m. (5.2.5)
−π
87
The only thing left to show is therefore
% π
1 · sin nxdx = 0 (5.2.6)
−π
% π
1 · cos nxdx = 0 (5.2.7)
−π
and % π
sin nx cos mxdx = 0 for any n, m. (5.2.8)
−π
Note that % π
cos nx π 1
sin nxdx = − |−π = − (cos nπ − cos(−nπ)) = 0
−π n n
since
cos nπ = cos(−nπ) = (−1)n . (5.2.9)
1
In a similar fashion we demonstrate (5.2.7). This time the antiderivative sin nx vanishes
n
at both ends.
To show (5.2.8) we consider first the case n = m. Thus
% π % π
1 1
sin nx cos nxdx = sin 2nxdx = − cos 2nx|π−π = 0
−π 2 −π 4n
For n $= m, we can use the trigonometric identity
1
sin ax cos bx = [sin(a + b)x + sin(a − b)x] . (5.2.10)
2
Integrating each of these terms gives zero as in (5.2.6). Therefore the system is orthogonal.
The infinite series may or may not converge. Even if the series converges, it may not give
the value of f (x) at some points. The question of convergence will be left for later. In this
section we just give the formulae used to compute the coefficients ak , bk .
% L
1
a0 = f (x)dx, (5.3.2)
L −L
% L
1 kπ
ak = f (x) cos xdx for k = 1, 2, . . . (5.3.3)
L −L L
88
1%L kπ
bk = f (x) sin xdx for k = 1, 2, . . . (5.3.4)
L −L L
Notice that for k = 0 (5.3.3) gives the same value as a0 in (5.3.2). This is the case only if
a0
one takes as the first term in (5.3.1), otherwise the constant term is
2
1 %L
f (x)dx. (5.3.5)
2L −L
kπ
The factor L in (5.3.3)-(5.3.4) is exactly the square of the norm of the functions sin x and
L
kπ
cos x. In general, one should write the coefficients as follows:
L
% L
kπ
f (x) cosxdx
−L
ak = % L L , for k = 1, 2, . . . (5.3.6)
2 kπ
cos xdx
−L L
% L
kπ
xdx
f (x) sin
bk = −L L , for k = 1, 2, . . . (5.3.7)
% L
2 kπ
sin xdx
−L L
These two formulae will be very helpful when we discuss generalized Fourier series.
Example 2
Find the Fourier series expansion of
f (x) = x on [−L, L]
% L
1 kπ
ak = x cos xdx
L −L L
) " #2 *+
1 L kπ L kπ ++L
= x sin x+ cos x +
L kπ L kπ L −L
89
2 3
2
1
1
0 0
−1
−1
−2
−2 −3
−2 −1 0 1 2 −2 −1 0 1 2
3 3
2 2
1 1
0 0
−1 −1
−2 −2
−3 −3
−2 −1 0 1 2 −2 −1 0 1 2
Figure 28: Graph of f (x) = x and the N th partial sums for N = 1, 5, 10, 20
In figure 28 we graphed the function f (x) = x and the N th partial sum for N = 1, 5, 10, 20.
Notice that the partial sums converge to f (x) except at the endpoints where we observe the
well known Gibbs phenomenon. (The discontinuity produces spurious oscillations in the
solution).
Example 3
Find the Fourier coefficients of the expansion of
$
−1 for − L < x < 0
f (x) = (5.3.9)
1 for 0 < x < L
% 0 % L
1 kπ 1 kπ
ak = (−1) cos xdx + 1 · cos xdx
L −L L L 0 L
1 L kπ 0 1 L kπ L
= − sin x|−L + sin x| = 0,
L kπ L L kπ L 0
1%0 1%L
a0 = (−1)dx + 1dx
L −L L 0
1 1 1 1
= − x|0−L + x|L0 = (−L) + · L = 0,
L L L L
90
1.5 1.5
1 1
0.5 0.5
0 0
−0.5 −0.5
−1 −1
−1.5 −1.5
−2 −1 0 1 2 −2 −1 0 1 2
1.5 1.5
1 1
0.5 0.5
0 0
−0.5 −0.5
−1 −1
−1.5 −1.5
−2 −1 0 1 2 −2 −1 0 1 2
Figure 29: Graph of f (x) given in Example 3 and the N th partial sums for N = 1, 5, 10, 20
% 0 % L
1 kπ 1 kπ
bk = (−1) sin xdx + 1 · sin xdx
L −L L L 0 L
" # " #
1 L kπ 0 1 L kπ L
= (−1) − cos x|−L + − cos x|
L kπ L L kπ L 0
1 1
= [1 − cos(−kπ)] − [cos kπ − 1]
kπ kπ
2 . /
= 1 − (−1)k .
kπ
Therefore the Fourier series is
∞
! 2 . / kπ
f (x) ∼ 1 − (−1)k sin x. (5.3.10)
k=1 kπ L
The graphs of f (x) and the N th partial sums (for various values of N) are given in figure 29.
In the last two examples, we have seen that ak = 0. Next, we give an example where all
the coefficients are nonzero.
Example 4 $
1
L
+ 1 −L < x < 0
x
f (x) = (5.3.11)
x 0<x<L
91
8
0 −L L
−2
−4
−10 −8 −6 −4 −2 0 2 4 6 8 10
" #
1%0 1 1%L
a0 = x + 1 dx + xdx
L −L L L 0
1 x2 0 1 0 1 x2 L
= | + x| + |
L2 2 −L L −L L 2 0
1 L L+1
= − +1+ = ,
2 2 2
% " # %
1 0 1 kπ 1 L kπ
ak = x + 1 cos xdx + x cos xdx
L −L L L L 0 L
) " #2 *+
1 L kπ L kπ ++0
= 2
x sin x+ cos x +
L kπ L kπ L −L
) " #2 *+
1 L kπ 0 1 L kπ L kπ ++L
+ sin x|−L + x sin x+ cos x +
L kπ L L kπ L kπ L 0
92
1 1
0.8 0.8
0.6 0.6
0.4 0.4
0.2 0.2
0 0
−1 −0.5 0 0.5 1 −1 −0.5 0 0.5 1
1.5 1.5
1 1
0.5 0.5
0 0
−0.5 −0.5
−1 −0.5 0 0.5 1 −1 −0.5 0 0.5 1
Figure 31: Graph of f (x) given by example 4 (L = 1) and the N th partial sums for N =
1, 5, 10, 20. Notice that for L = 1 all cosine terms and odd sine terms vanish, thus the first
term is the constant .5
% 0 " # % L
1 1 kπ 1 kπ
bk = x + 1 sin xdx + x sin xdx
L −L L L L 0 L
) " #2 *+
1 L kπ L kπ ++0
= − x cos x + sin x +
L2 kπ L kπ L −L
) " #2 *+
1 L kπ 0 1 L kπ L kπ ++L
+ (− cos x)|−L + − x cos x+ sin x +
L kπ L L kπ L kπ L 0
1 L 1 1 L
= 2
(−L) cos kπ − + cos kπ − cos kπ
L kπ kπ kπ kπ
1 0 1
= − 1 + (−1)k L ,
kπ
therefore the Fourier series is
$ &
L+1 ! ∞
1−L. k
/ kπ 1 . k
/ kπ
f (x) = + 2
1 − (−1) cos x − 1 + (−1) L sin x
4 k=1 (kπ) L kπ L
The sketches of f (x) and the N th partial sums are given in figures 31-33 for various values
of L.
93
1 1
0.8
0.6 0.5
0.4
0.2 0
0
−0.5 0 0.5 −0.5 0 0.5
1.5 1.5
1 1
0.5 0.5
0 0
−0.5 −0.5
−0.5 0 0.5 −0.5 0 0.5
Figure 32: Graph of f (x) given by example 4 (L = 1/2) and the N th partial sums for
N = 1, 5, 10, 20
2 2
1.5
1.5
1
1
0.5
0.5
0
0 −0.5
−2 −1 0 1 2 −2 −1 0 1 2
2.5 2.5
2 2
1.5 1.5
1 1
0.5 0.5
0 0
−0.5 −0.5
−2 −1 0 1 2 −2 −1 0 1 2
Figure 33: Graph of f (x) given by example 4 (L = 2) and the N th partial sums for N =
1, 5, 10, 20
94
5.4 Relationship to Least Squares
In this section we show that the Fourier series expansion of f (x) gives the best approximation
of f (x) in the sense of least squares. That is, if one minimizes the squares of differences
between f (x) and the nth partial sum of the series
∞
, -
a0 ! kπ kπ
+ ak cos x + bk sin x (5.4.1)
2 k=1 L L
then the coefficients a0 , ak and bk are exactly the Fourier coefficients given by (5.3.6)-(5.3.7).
Let I(a0 , a1 , · · · , an , b1 , b2 , · · · , bn ) be defined as the “sum” of the squares of the differences,
i.e. % L
I= [f (x) − sn (x)]2 dx (5.4.2)
−L
th
where sn (x) is the n partial sum
n
, -
a0 ! kπ kπ
sn (x) = + ak cos x + bk sin x . (5.4.3)
2 k=1 L L
In order to minimize the integral I, we have to set to zero each of the first partial derivatives,
∂I
= 0, (5.4.4)
∂a0
∂I
= 0, j = 1, 2, · · · , n (5.4.5)
∂aj
∂I
= 0, j = 1, 2, · · · , n. (5.4.6)
∂bj
Differentiating the integral we find
% L
∂I ∂
= 2 [f (x) − sn (x)] [f (x) − sn (x)] dx
∂a0 −L ∂a0
% L
1
= −2 [f (x) − sn (x)] dx (5.4.7)
−L 2
% L ) n
, -*
a0 ! kπ kπ
= − f (x) − − ak cos x + bk sin x dx
−L 2 k=1
L L
kπ kπ
Using the orthogonality of the function 1 to all cos x and sin x we have
L L
% L
∂I a0
=− f (x)dx + 2L. (5.4.8)
∂a0 −L 2
Combining (5.4.8) and (5.4.4) we have
% L
1
a0 = f (x)dx
L −L
96
which is (5.3.2).
If we differentiate the integral with respect to aj for some j, then
% L ) n
, -*
∂I ∂ a0 ! kπ kπ
= 2 [f (x) − sn (x)] f (x) − − ak cos x + bk sin x dx
∂aj −L ∂aj 2 k=1 L L
% L " #
jπ
= 2 [f (x) − sn (x)] − cos x dx
−L L
(5.4.9)
jπ
Now we use the orthogonality of cos x to get
L
% L 2 3
∂I jπ jπ
0= = −2 f (x) − aj cos x cos xdx.
∂aj −L L L
Therefore % L % L
jπ jπ
2 aj cos2 xdx = 2 f (x) cos xdx.
−L L −L L
Solving for aj yields (5.3.6).
Similarly
∂I
=0
∂bj
will lead to % L % L
jπ
2 jπ
bj sin xdx = f (x) sin xdx
−L L −L L
which gives (5.3.7).
5.5 Convergence
If f (x) is piecewise smooth on [−L, L] then the series converges to either the periodic exten-
sion of f (x), where the periodic extension is continuous, or to the average of the two limits,
where the periodic extension has a jump discontinuity.
It is always helpful to give several examples and sketches.
Example 5
Given the function $
0, x < 0
f (x) = (5.5.1)
1, x > 0.
The following figures show the sketch of f (x), its periodic extension of period 2 and the
sketch of the Fourier series of f (x).
Notice that the sketch of f (x) on [−1, 1] is copied to [1, 3] and so on to the right and to
the left.
Notice that the only difference is at the points of discontinuity xn = ±n, n = 1, 2, . . .
97
8
0 −L L
−2
−4
−10 −8 −6 −4 −2 0 2 4 6 8 10
0 −L L
−2
−4
−10 −8 −6 −4 −2 0 2 4 6 8 10
0 −L L
−2
−4
−10 −8 −6 −4 −2 0 2 4 6 8 10
98
8
−L
0 L
−2
−4
−10 −8 −6 −4 −2 0 2 4 6 8 10
−2
−4
−10 −8 −6 −4 −2 0 2 4 6 8 10
Example 6
π
x, −L < x < 0
sin
L
L
f (x) = x, 0<x< (5.5.2)
2
L
L − x, <x<L
2
The Fourier series will be exactly the same since the periodic extension has no jump
discontinuity. See Figure 37 for the sketch of f (x) and Figure 38 for the sketch of the
periodic extension.
99
Let us now recall the definition of odd and even functions. A function f (x) is called odd
if
f (−x) = −f (x) (5.6.1)
and even, if
f (−x) = f (x). (5.6.2)
Since sin kx is an odd function, the sum is also an odd function, therefore a function f (x)
having a Fourier sine series expansion is odd. Similarly, an even function will have a Fourier
cosine series expansion.
Example 7
f (x) = x, on [−L, L]. (5.6.3)
The function is odd and thus the Fourier series expansion will have only sine terms, i.e. all
ak = 0. In fact we have found in one of the examples in the previous section that
∞
! 2L kπ
f (x) ∼ (−1)k+1 sin x (5.6.4)
k=1 kπ L
Example 8
f (x) = x2 on [−L, L]. (5.6.5)
The function is even and thus all bk must be zero.
+
1%L 2 2%L 2 2 x3 ++L 2L2
a0 = x dx = x dx = = , (5.6.6)
L −L L 0 L 3 +0 3
1%L 2 kπ
ak = x cos xdx =
L −L L
Use table of integrals
, -2
" #2 + " #3 +
1 L kπ ++L kπ 2 L kπ ++L
= 2x cos x+ + x − 2 sin x .
L kπ L −L L kπ L +−L
100
4 4
3 3
2 2
1 1
0 0
−1 −1
−2 −1 0 1 2 −2 −1 0 1 2
4 4
3 3
2 2
1 1
0 0
−2 −1 0 1 2 −2 −1 0 1 2
Figure 39: Graph of f (x) = x2 and the N th partial sums for N = 1, 5, 10, 20
If we go back to the examples in the previous chapter, we notice that the partial differ-
ential equation is solved on the interval [0, L]. If we end up with Fourier sine series, this
means that the initial solution f (x) was extended as an odd function to [−L, 0]. It is the
odd extension that we expand in Fourier series.
Example 9
Give a Fourier cosine series of
f (x) = x for 0 ≤ x ≤ L. (5.6.10)
This means that f (x) is extended as an even function, i.e.
$
−x −L ≤ x ≤ 0
f (x) = (5.6.11)
x 0≤x≤L
or
f (x) = |x| on [−L, L]. (5.6.12)
The Fourier cosine series will have the following coefficients
+
2%L 2 1 2 ++L
a0 = xdx = x = L, (5.6.13)
L 0 L 2 +0
) " #2 *+
2%L kπ 2 L kπ L kπ ++L
ak = x cos xdx = x sin x+ cos x +
L 0 L L kπ L kπ L 0
101
2 2
1.5 1.5
1 1
0.5 0.5
0 0
−2 −1 0 1 2 −2 −1 0 1 2
2 2
1.5 1.5
1 1
0.5 0.5
0 0
−2 −1 0 1 2 −2 −1 0 1 2
Figure 40: Graph of f (x) = |x| and the N th partial sums for N = 1, 5, 10, 20
) " #2 " #2 * " #2 .
2 L L 2 L /
= 0+ cos kπ − 0 − = (−1)k − 1 . (5.6.14)
L kπ kπ L kπ
Therefore the series is
L !∞
2L . k
/ kπ
|x| ∼ + (−1) − 1 cos x. (5.6.15)
2 k=1 (kπ)2 L
In the next four figures we have sketched f (x) = |x| and the N th partial sums for various
values of N.
To sketch the Fourier cosine series of f (x), we first sketch f (x) on [0, L], then extend the
sketch to [−L, L] as an even function, then extend as a periodic function of period 2L. At
points of discontinuity, take the average.
To sketch the Fourier sine series of f (x) we follow the same steps except that we take
the odd extension.
Example 10
sin Lπ x, −L < x < 0
f (x) = x, 0 < x < L2 (5.6.16)
L − x, L2 < x < L
The Fourier cosine series and the Fourier sine series will ignore the definition on the interval
[−L, 0] and take only the definition on [0, L]. The sketches follow on figures 41-43:
102
8
−L
0 L
−2
−4
−10 −8 −6 −4 −2 0 2 4 6 8 10
−4
−10 −8 −6 −4 −2 0 2 4 6 8 10
−4
−10 −8 −6 −4 −2 0 2 4 6 8 10
Figure 42: Sketch of the Fourier sine series and the periodic odd extension
Notes:
1. The Fourier series of a piecewise smooth function f (x) is continuous if and only if
f (x) is continuous and f (−L) = f (L).
2. The Fourier cosine series of a piecewise smooth function f (x) is continuous if and only
if f (x) is continuous. (The condition f (−L) = f (L) is automatically satisfied.)
3. The Fourier sine series of a piecewise smooth function f (x) is continuous if and only
if f (x) is continuous and f (0) = f (L).
Example 11
The previous example was for a function satisfying this condition. Suppose we have the
−4
−10 −8 −6 −4 −2 0 2 4 6 8 10
−4
−10 −8 −6 −4 −2 0 2 4 6 8 10
Figure 43: Sketch of the Fourier cosine series and the periodic even extension
103
following f (x) $
0 −L < x < 0
f (x) = (5.6.17)
x 0<x<L
The sketches of f (x), its odd extension and its Fourier sine series are given in figures 44-46
correspondingly.
8
0 −L L
−2
−4
−10 −8 −6 −4 −2 0 2 4 6 8 10
−1
−2
−3
−10 −8 −6 −4 −2 0 2 4 6 8 10
−1
−2
−3
−10 −8 −6 −4 −2 0 2 4 6 8 10
Figure 46: Sketch of the Fourier sine series is not continuous since f (0) $= f (L)
104
5.7 Term by Term Differentiation
In order to check that the solution obtained by the method of separation of variables satisfies
the PDE, one must be able to differentiate the infinite series.
1. A Fourier series that is continuous can be differentiated term by term if f # (x) is piecewise
smooth. The result of the differentiation is the Fourier series of f # (x).
2. A Fourier cosine series that is continuous can be differentiated term by term if f # (x) is
piecewise smooth. The result of the differentiation is the Fourier sine series of f # (x).
3. A Fourier sine series that is continuous can be differentiated term by term if f # (x) is
piecewise smooth and f (0) = f (L) = 0. The result of the differentiation is the Fourier
cosine series of f # (x).
Note that if f (x) does not vanish at x = 0 and x = L then the result of differentiation is
given by the following formula:
!'
∞ (
1 nπ 2 nπ
f # (x) ∼ [f (L) − f (0)] + bn + [(−1)n f (L) − f (0)] cos x. (5.7.1)
L n=1 L L L
Note that if f (L) = f (0) = 0 the above equation reduces to term by term differentiation.
Example 12
Given the Fourier sine series of f (x) = x,
∞
! L nπ
x∼2 (−1)n+1 sin x. (5.7.2)
n=1 nπ L
1 ∼ 1,
106
5.8 Term by Term Integration
A Fourier series of a piecewise smooth function f (x) can always be integrated
GL
term by term
and the result is a convergent infinite series that always converges to −L f (x)dx even if the
original series has jumps.
Example 13
The Fourier series of f (x) = 1 is
4 ! 1 nπ
1∼ sin x (5.8.1)
π n=1,3,... n L
The last sum is the constant term (n = 0) of the Fourier cosine series of f (x) = x, which is
% L
1 L
xdx = . (5.8.3)
L 0 2
Therefore
L 4L ! 1 nπ
x∼ − 2 cos x. (5.8.4)
2 π n=1,3,... n2 L
We have also found, as a by-product, the sum of the following infinite series
2 3
4L 1 1 L
2 2
+ 2 +··· =
π 1 3 2
or
1 1 π2
+ + · · · = . (5.8.5)
12 32 8
A second integration gives the Fourier sine series of
x2 L
− x
2 2
x2 L 4L2 ! 1 nπ
∼ x− 3 3
sin x
2 2 π n=1,3,... n L
In order to get the Fourier sine series of x2 , one must substitute the sine series of x in the
above and multiply the new right hand side by 2.
108