Trigonometric series approximation to a square wave
This demonstration plots a square wave function with period one along with an approximating trigonometric series.
If n terms are requested, the approximating series is
\[
x(t) = \sqrt{\frac{\pi}{2}}\left(\sin(2\pi t) + \frac{\sin(6\pi t)}{3} + \cdots + \frac{\sin(2\pi(2n - 1)t)}{n}\right).
\]