Andrew Que Sites list Photos
Projects Contact

I have expanded on the Gibbs Phenomenon demo I wrote about the other day. In addition to the plot of the series output, I have added the output of a Fast Fourier Transform (FFT).


The top graph is the signal. The bottom graph shows the first 150 values of the FFT output, interlacing the real and imaginary values. Arranged in this manner, the graph is the spectrum of the signal. Each column on the lower represents an increment of 1 Hz, so the full graph spans 0 and 150 Hz. The height of each bar is the amplitude of the sine wave at this frequency. The default graph is setup to create a square wave out of 10 sines waves. The first column is at 5 Hz with an amplitude of 0.6 * 4 / π. The 4 / π is the scale factor used in the series equation, and the 0.6 is the default amplitude. The next spike is at 15 Hz, and 1/3 the amplitude of the first; and the third is at 25 Hz and 1/5 the amplitude of the first. There are 10 bars in the FFT graph all together because the default number of sine waves to add together is 10.

The demo can switch between the appropriated square wave, and a true square wave. When the switch is made, note that the FFT graph only has bars adds additional graph, but the amplitude and position of the existing bars does not change. What this shows is that the series output and a square wave really do share the relation to one an other.

The idea behind a Fourier transform is to describe a function as a series of sine waves at different frequencies and amplitudes added together. A Fast Fourier Transform is a method to calculate the coefficients of for the amplitudes for equally spaced frequencies on a set of samples. Since the Gibbs Phenomenon is a series of sine waves added together, an FFT of this signal has a very predictable output.

While adjusting the values of the demo you will notice some interesting things. Frequencies between integer number produce bars on the FFT between that sweep over a range. This is because the output only has equally spaces sine waves every 1 Hz, so partial frequencies must consist the frequencies available. You may also notice small bars next to primary bars. This is caused by the accumulated in the FFT calculations—floating-point numbers only have to much precision.

Notice that the phase has no effect on the FFT output, which is expected.

So the amplitude may be a little confusing. To understand it we need to look at the series equation.

The scale factor is 4 / π. This will result in the steady-state of the square wave resting at amplitude. For example, the default settings of the demo have an amplitude of 0.6, and a look at the graph revels the ringing signal hovers right around 0.6. To get a known amplitude on the FFT, simple scale the desired amplitude by 4 / π. For example, setting the amplitude to 0.785 will result in the first FFT bar at 1.0 for amplitude. Setting the series sum to 1 will produce a sine wave with peaks at -1 and 1.

Feel free to experiment, and post if you find something interesting.