The Fourier series for a square wave is: \[f(x) = {4 \over \pi } {\sum_{n=1,3,5,...}^\infty {1 \over n}} \sin \left(\frac{n \pi x}{L}\right)\]
For the purpose of simulation, and we really can't go to infinity in the upper equation, we will go to \(N \) initially being \(N = 1 \) and changable through the slider above.
The function will become: \[f(x) = {4 \over \pi } {\sum_{n=1,3,5,...}^N {1 \over n}} \sin \left(\frac{n \pi x}{L}\right)\]
\(L \) is half of the square wave period \(T \) so the period of the wave is \(T = 2 L \).