A few of days ago I wrote an article about using a sloped average filter technique. My friend Noah commented that the distortion caused by a change in slope looked similar to that of the artifacts from the ringing artifact on a square wave. He is referring to what is known as the Gibbs Phenomenon. It shows that a square wave can be made from a series of sine waves added together.

Here is a little demo I put together to show the effect.

The equation that drives this function is:

Where *a* is amplitude (*a* ∈ **R** | 0 ≤ *a* < ∞), *f* is the frequency (*f* ∈ **R** | 0 ≤ *f* < ∞), *p* is phase (*p* ∈ **R** | -π ≤ *p* < π), and *n* is the number of sine waves to sum together (*n* ∈ **Z** | 1 ≤ *n* < ∞). If you can't follow the interval notions, have a quick look at this.

The summation looks worse than it is. It starts with a scale factor that keeps the asymptote near 1 and -1. In the sum itself has (2 *i* - 1) in it twice. This is just selecting all the odd numbers.

This phenomenon happens in actual electrical signals such as the square wave clock signal driving the CPU on the computer you are using. There is always some resistance, capacitance, and inductance in any length of wire which acts as a low-pass filter on the square wave signal. That results is the signal ringing.