Fourier Approximation

Consider the step function

f(x) = 0 for -pi < x < 0
f(x) = 1 for 0 <= x <= pi

Here is a series of Fourier Approximations:
results.gif
We observe oscillations at the interface, which is called the Gibbs Phenomena.

Approximation that includes the first 500 terms:
results2.gif