I love this question! I've been learning some of this in my Digital and Analog Communications class.
This is a perfect example of what is called the Gibbs phenomenon. It's what happens when a square wave is passed through a low-pass filter.
In the above picture, we see the waveforms of two low-pass filters. Any signal that falls underneath the large peak at the center of the graph is allowed through. Ideally, no other wave component is allowed to pass, that is all waves that fall outside the central peak are filtered out. However, you can see where the low-pass filter still exists outside the main filtering frequency. Higher frequencies that we want filtered out are still slipping past, generating the diminishing sine wave you see at the top and bottom of the square wave. As we make the low-pass filter narrower, the Gibbs phenomenon also gets smaller, but can never be made to disappear.
Basically, it's a technical limitation and a fact of life that really has no effect on you unless for some bizarre reason you need a completely clean square wave.
You can also see the Gibbs phenomenon in your DMG square wave there. Notice how the wave seems to extend beyond it's logical point and ripples ever so slightly before settling back down into the primary wave? The DMG square wave appears to be on a very narrow low-pass filter, resulting in a very small Gibbs phenomenon.
EDIT: additionally, the Gibbs phenomenon can be seen in the generation of square waves themselves. You can generate a square wave by combining multiple sine waves together, with the result being a square wave exhibiting the Gibbs phenomenon. The greater the number of harmonics (the number of sine waves you are combining), the smaller the Gibbs phenomenon. If you want, I can try to teach you the math, but I'm afraid I barely understand it myself.
Last edited by scienceguy8 (Feb 23, 2010 4:46 pm)