Skip to content Skip to navigation

Connexions

You are here: Home » Content » Fourier Series Approximation of a Square Wave

Navigation

Recently Viewed

This feature requires Javascript to be enabled.
 

Fourier Series Approximation of a Square Wave

Module by: Don Johnson. E-mail the author

Summary: Shows how to use Fourier series to approximate a square wave, as opposed to the sinusoidal waves seen previously.

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.

Example 1

Figure 1: Fourier series approximation to sqt sq t . The number of terms in the Fourier sum is indicated in each plot, and the square wave is shown as a dashed line over two periods.
Fourier series approximation of a square wave
Fourier series approximation of a square wave (fourier4.png)

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 =2T0T2cos2πktTsin2πktTd t 2TT2Tcos2π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=k134π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.

Figure 2: The upper plot shows the power spectrum of the square wave, and the lower plot the rms error of the finite-length Fourier series approximation to the square wave. The asterisk denotes the rms error when the number of terms K K in the Fourier series equals 99.
Power spectrum and rms error
Power spectrum and rms error (fourier5.png)

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.

Exercise 1

Calculate the harmonic distortion for the square wave.

Solution

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

Figure 3: Fourier series approximation to sqt sq t . The number of terms in the Fourier sum is indicated in each plot, and the square wave is shown as a dashed line over two periods.
Figure 3 (fourier4.png)

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.

Content actions

Download module as:

PDF | EPUB (?)

What is an EPUB file?

EPUB is an electronic book format that can be read on a variety of mobile devices.

Downloading to a reading device

For detailed instructions on how to download this content's EPUB to your specific device, click the "(?)" link.

| More downloads ...

Add module to:

My Favorites (?)

'My Favorites' is a special kind of lens which you can use to bookmark modules and collections. 'My Favorites' can only be seen by you, and collections saved in 'My Favorites' can remember the last module you were on. You need an account to use 'My Favorites'.

| A lens I own (?)

Definition of a lens

Lenses

A lens is a custom view of the content in the repository. You can think of it as a fancy kind of list that will let you see content through the eyes of organizations and people you trust.

What is in a lens?

Lens makers point to materials (modules and collections), creating a guide that includes their own comments and descriptive tags about the content.

Who can create a lens?

Any individual member, a community, or a respected organization.

What are tags? tag icon

Tags are descriptors added by lens makers to help label content, attaching a vocabulary that is meaningful in the context of the lens.

| External bookmarks