The Fourier series representation of a signal, as expressed for
a square wave by

st=
a
0
+∑
k
=1∞
a
k
cos2πktT+∑
k
=1∞
b
k
sin2πktT
s
t
a
0
k
1
a
k
2
k
t
T
k
1
b
k
2
k
t
T

(1)
says that the left and right sides are "equal". We need to
investigate equality through an example.

Let's find the spectrum of the square wave
sqt
sq
t
.
The expressions for the Fourier coefficients have the common
form

a
k
b
k
=2T∫0T2cos2πktTsin2πktTd
t
−2T∫T2Tcos2πktTsin2πktTd
t
a
k
b
k
2
T
t
0
T
2
2
k
t
T
2
k
t
T
2
T
t
T
2
T
2
k
t
T
2
k
t
T

(2)
The cosine coefficients

a
k
a
k
are all zero, and the sine coefficients are

b
k
={4πk if k is odd0 if k is even
b
k
4
k
k is odd
0
k is even

(3)
Thus, the Fourier series for the square wave is

sqt=∑k∈13…4πksin2πktT
sq
t
k
k
1
3
…
4
k
2
k
t
T

(4)
As we see in

Figure 1, the
Fourier series requires many more terms to provide the same
quality of approximation as we found with the

half-wave
rectified sinusoid.
We can verify that more terms are needed by considering the
power spectrum and the approximation error shown in

Figure 2.

This difference between the two Fourier series results because
the half-wave rectified sinusoid's Fourier coefficients are
proportional to
1k2
1
k
2
while those of the square wave are proportional to
1k
1
k
.
In short, the square wave's coefficients decay more slowly
with increasing frequency. Said another way, the square-wave's
spectrum contains more power at higher frequencies than does
the half-wave-rectified sinusoid.

Calculate the harmonic distortion for the square wave.

Total harmonic distortion in the square wave is
1−4π2=20%
1
4
2
20
%
.

When comparing the square wave to its Fourier series
representation it is not clear that the two are equal. The fact
that the square wave's Fourier series requires more terms for a
given representation accuracy is not important. However, close
inspection of Figure 3 does reveal a
potential issue: Does the Fourier series really equal the square
wave at *all* values of
t
t?
In particular, at each step-change in the square wave, the
Fourier series exhibits a peak followed by rapid
oscillations. As more terms are added to the series, the
oscillations seem to become more rapid and smaller, but the
peaks are not decreasing. Consider this mathematical question
intuitively: Can a discontinuous function, like the square wave,
be expressed as a sum, even an infinite one, of continuous ones?
One should at least be suspicious, and in fact, it can't be thus
expressed. This issue brought
Fourier
much criticism from the French Academy of Science (Laplace,
Legendre, and Lagrange comprised the review committee) for
several years after its presentation on 1807. It was not
resolved for also a century, and its resolution is interesting
and important to understand from a practical viewpoint.

The extraneous peaks in the square wave's Fourier series
*never* disappear; they are termed
Gibb's phenomenon after the American physicist
Josiah Willard Gibbs. They occur whenever the signal is
discontinuous, and will always be present whenever the signal
has jumps. Let's return to the question of equality; how can the
equal sign in the
definition of
the Fourier series
be justified? The partial answer is that pointwise—each and
every value of
t
t—equality
is *not* guaranteed. What mathematicians
later in the nineteenth century showed was that the rms error of
the Fourier series was always zero.

limit
K
→
∞
rms
ε
K
=0
K
rms
ε
K
0

(5)
What this means is that the difference between an actual signal
and its Fourier series representation may not be zero, but the
square of this quantity has

*zero* integral!
It is through the eyes of the rms value that we define equality:
Two signals

s
1
t
s
1
t
,

s
2
t
s
2
t
are said to be equal in the

mean square if

rms
s
1
−
s
2
=0
rms
s
1
s
2
0
.
These signals are said to be equal

pointwise if

s
1
t=
s
2
t
s
1
t
s
2
t
for all values of

tt. For Fourier
series, Gibb's phenomenon peaks have finite height and zero
width: The error differs from zero only at isolated
points--whenever the periodic signal contains
discontinuities--and equals about 9% of the size of the
discontinuity. The value of a function at a finite set of points
does not affect its integral. This effect underlies the reason
why defining the value of a discontinuous function, like we
refrained from doing in defining the

step function, at its
discontinuity is meaningless. Whatever you pick for a value has
no practical relevance for either the signal's spectrum or for
how a system responds to the signal. The Fourier series value
"at" the discontinuity is the average of the values on either
side of the jump.