Problem 2. The objective is to compute Fourier coefficients numerically and to analyze the Gibbs phenomenon.
Let $f = f(x)$ be a $2\pi$-periodic function defined for $x \in (-\pi, \pi]$ by $f(x) = x$. Let $S_n(x) = \sum_{k=1}^n b_k \sin(kx)$, where
$b_k = (1/\pi) \int_{-\pi}^\pi f(x) \sin(kx) dx$.
Do the following:
(1) Plot the graphs of $S_n(x)$ for $n = 10, 50, 100$ and $x \in [-\pi, \pi]$. The choice of the procedure to compute $b_k$ is
up to you. Keep in mind that if you divide the interval $[-\pi, \pi]$ to approximate the integral, your step size
must be small enough to \"see\" the oscillations of the sines.
(2) Estimate $\max_{x \in [-\pi, \pi]} S_n(x)$ for $n = 10, 50, 100$.
(3) Compute $\lim_{n \to \infty} S_n(\pi - \pi/n)$ (either compute analytically or guess from the graphs). This is a quantitative
measure of the Gibbs phenomenon.