# Fourier Series of a Square Wave (and Why Bandwidth Matters)

Blog Post created by KeysightOscilloscopes on Sep 1, 2016

By: Drew Hanken

Have you ever wondered, “What is this ringing I am seeing in my signal? Why is there preshoot and overshoot on a simple square wave? How is a preshoot possible when it appears to be precausal to downstream information?”

I have been an R&D engineer here at Keysight/Agilent Technologies for the last five years. Fourier series is a topic that was covered in a recent graduate class as a method for solving partial differential equations. I’ll explain the occurrence of this ringing from the perspective of the underlying theory, and then relate it back to using an oscilloscope.

In short, this ringing is a phenomenon that presents itself because of the method an oscilloscope uses to construct a signal – by summing the frequency components of the signal. This method of building a signal is known as Fourier series. It is the most useful way for an oscilloscope to process and measure a signal because it deconstructs the signal into its frequency components for analysis. The inherent discontinuity of a square wave presents some problems with this reconstruction method that can be understood by exploring the mathematical theory. Understanding this can help you to select the right oscilloscope for your measurement needs. It’s also worth noting that this method is used by all oscilloscopes, it’s not just a Keysight method.

First off, you need to understand that any arbitrary function f(x) can be constructed by the sum of simple sine or cosine functions that vary in amplitude and frequency. More specifically, any function of x, f(x), can be built using an infinite series of sine waves with coefficients An and increasing frequencies (n*pi).

Sine and cosine functions can both be used for Fourier series because they both have the property of orthogonality. There are a few other functions that satisfy the orthogonality requirement including Bessel functions and Legendre polynomials. While these functions are useful for problems in cylindrical or polar coordinates, they do not apply to this discussion. The definition of orthogonality for a function φ is that it must satisfy the following condition:

Using the above definition, it is possible to solve for the coefficients (An) for any function, and build the function, using orthogonal functions.

You can see that any function can be constructed using an infinite series of terms, and approximated by a finite number of sine waves. Every function has a unique set of coefficients, An, that are substituted into the sum. The values of these coefficients determine the function that will be reconstructed.  It is easy to picture changing the amplitude of a sine wave by multiplying it by a coefficient. This would be a Fourier series with only one term, and would return the desired function with the magnitude changed. Let’s look at constructing a linear line using sine and cosine functions. This is tougher to picture because a line is not oscillatory, but the addition of multiple sine or cosine terms will begin to take the shape of a line.

You can see that the more terms that are summed, the closer the approximation becomes to the actual function. Theoretically, if an infinite number or terms are used, the Fourier series will cease to be an approximation and take the exact shape of the function.

Now, let’s take a look at a square wave and how it appears when constructed using Fourier series the same way an oscilloscope would. We will first write a step function of length (L) that, when repeated periodically, will be our representation of a square wave.

As stated earlier, this function can be rewritten as an infinite series of an orthogonal function φ:

With choosing a sine wave as the orthogonal function in the above expression, all that is left is to solve for the coefficients to construct a square wave and plot the results.

One important takeaway from this formula is that the series composition of a square wave only uses the odd harmonics. This stems from the fact that a square wave is an odd function, which has important implications on measuring signals of this sort. Given a 1 Gb/s square wave, the bandwidth of the measurement device must now exceed 3 Gb/s to capture more information than the primary frequency. Each incremental harmonic that is captured will start to look more like a square wave with faster rising and falling edges as seen below.

The rise time of the plotted signals gets smaller as the number of terms increases. The highest term in the Fourier series will correspond to the highest frequency that is used to construct the signal. Thus, the rise time is dictated by this last term, which in turn dictates highest frequency. An ideal square wave will have a zero rise time – but that would take infinite bandwidth to reproduce with this method. This square wave’s discontinuity is the heart of the problem, and is the reason for the preshoot and overshoot seen above. Taking a closer look at these areas of the wave, you can see that the ringing in the signal does not change in magnitude with the number of terms and remains at roughly 18% of the amplitude. It will, however get thinner as more terms are used and be a smaller source of error. This ringing caused by a discontinuity is referred to as Gibbs Phenomenon, and is unavoidable when the signal is properly constructed using Fourier series. That is not to say that other sources of ringing are not present, but it is important to be aware of this behavior at discontinuities.

Given this information, you can see why it is important to select the right oscilloscope based on your measurement needs. If you need to capture the slew rate of your transceiver, or to open the area of your eye diagram, you may need a higher bandwidth oscilloscope to capture the frequency content of the higher order harmonics and to reduce the effects of ringing on your capture.