Gibbs phenomenon of Fourier series

Let \(f(x)\) be an appropriate one-periodic function of \(x\in\mathbb{R}\). Its fourier series is given by \[ f(x) \sim \sum_{n=-\infty}^\infty C_ne^{2\pi i nx}, \quad C_n := \int_0^1 e^{-2\pi i nx} f(x) dx. \] The \(N\)-th partial sum of the series is denoted by \[ S_N(x) := \sum_{n=-N}^N C_ne^{2\pi i nx}. \] The well-known facts on the behavior of \(S_N\) as (\(N\rightarrow\infty\)) are the following: A MATLAB code gibbs.m. creates the animation of the Gibbs phenomenon of the Fourier series of one-periodic piecewise \(C^1\) functions given by \[ f(x) := \begin{cases} 1 &\ (n \leqq x \leqq n+1/2), \\ 0 &\ (n+1/2 < x < n+1), \end{cases} \quad g(x) := x-n \quad (n \leqq x < n+1), \quad n\in\mathbb{Z}. \] Their Fourier series are given by \[ f(x) \sim \sum_{l=0}^\infty \frac{2\sin\bigl(2\pi(2l+1)x\bigr)}{\pi(2l+1)}, \quad g(x) \sim 1 - \sum_{n=1}^\infty \frac{\sin(2\pi nx)}{\pi n}. \]