This MATLAB simulation shows how a periodic square wave can be built by summing sine and cosine waves with specific frequencies and amplitudes (Fourier series). Each term in the Fourier series is shown in the upper plot. The sum of the terms (shown in the top plot) and the actual square wave are shown in the bottom plot. Change the number of terms in the Fourier series using the slider bar. As the number of terms increases, the summation approaches the actual square wave.
This simulation requires MATLAB.