# Does low-pass filtering a square wave cause a 'ringing' to develop in the signal?

Using the figure below as an example, I wonder if it is possible that the small oscillations in the signal at the time of each step shift could be caused solely by the application of a low-pass filter to a pure square wave?

These ringing artifacts are due to the Gibbs phenomenon. They are indeed caused by lowpass filtering a function with discontinuities. What you see is basically the oscillations of the step response of the lowpass filter. The oscillations can be reduced (or completely eliminated) by choosing a lowpass filter with less or no ringing in its step response. E.g. a Gaussian filter has no ringing at all. However, lowpass filters with well-behaved step responses perform worse in the frequency domain in terms of passband deviation, transition band roll-off, and stopband attenuation.

• Matt - Not sure this is 100% correct. Please look at my answer - one of us must be slightly wrong. Commented Jul 3, 2013 at 21:11
• @Izhaki: so where do you think we disagree? Commented Jul 3, 2013 at 21:50
• In the statement " The oscillations can be reduced (or completely eliminated) by...". My claim is that the oscillations will happen regardless of the filter used. Commented Jul 3, 2013 at 22:04
• Izhaki is claiming that the Gibbs phenomenon is fundamental to low pass filtering. Matt L is correctly pointing out that the Gibbs phenomenon is caused by ripples in the impulse response of the filter. Gaussian filters do not have ripples in their impulse response: dsp.stackexchange.com/questions/3002/…. Commented Jul 3, 2013 at 22:08
• @WanderingLogic: Also dsp.stackexchange.com/q/9745/29 Commented Jul 6, 2013 at 6:14

I think it is worth pointing out that any lowpass filter will reshape a pure square wave to something like in your illustration, regardless of the filter being used.

Reason is that a pure square wave requires an infinite amount of harmonics (a square wave is made of a fundamental frequency and odd harmonics at a level of 1/h). The moment a lowpass filter is applied - you no longer have infinite amount of harmonics, thus these ripples start popping out.

In the following illustration, only 5 sine harmonics are shown, but the sum (resembling square wave) is that of 60. You can see the ripples there as well. The way to get rid of them is to carry on adding harmonics ad infinitum. If you do so and then apply a lowpass just above the 60th harmonic - you'll get something similar to the square in this illustration:

• This is an interesting, if incomplete, argument. You are only considering the amplitude of the low passfilter. Many lowpass filters also have non-trivial phase and thus not only the amplitude but also the relative positions of the harmonics are changed. More often than not, this will reduce Gibbs phenomon. Your picture is also wrong since it doesn't show the alternating sign of the harmonics. If you add them all up with the same phase you get no square wave at all. Commented Jul 4, 2013 at 8:13
• The graph was generated by presenting each of (1/h)*sin(hx), and the sum of which - how can it be wrong? Also, while I might be overlooking something big time, I didn't know that the harmonics of a squarewave alternate - seems by the illustration that they aren't. Commented Jul 4, 2013 at 9:05
• Odd harmonics only, I should add. Commented Jul 4, 2013 at 9:37
• Sorry, my bad. You only need to alternate signs if you use a cosine expansion that's symmetric around t = 0. For a sine expansion you just add the sines directly and get x(-t) = -x(t). Commented Jul 4, 2013 at 10:23