= Solution
The given <square wave> agrees almost everywhere with an <odd function> on $(-\pi,\pi)$; its assigned value at the single point $0$ does not affect any <Fourier coefficient>. Thus $a_0=a_n=0$, while
$$
b_n=\frac2\pi\int_0^\pi\sin(nx)\,dx
=\frac{2(1-(-1)^n)}{\pi n}
=\begin{cases}4/(\pi n),&n\text{ odd},\\0,&n\text{ even}.\end{cases}
$$
The <Fourier series> is therefore
$$
\boxed{f(x)=\frac4\pi\sum_{r=0}^{\infty}\frac{\sin((2r+1)x)}{2r+1}\quad(-\pi<x<0\text{ or }0<x<\pi)}.
$$
The <Dirichlet convergence theorem for Fourier series> applies because the periodic extension is piecewise smooth. It gives $f(x)$ at each continuity point and the midpoint $0$ at the jumps, including $x=0$; it does not reproduce the assigned value $f(0)=-1$ there.
At the continuity point $x=\pi/2$, $\sin((2r+1)\pi/2)=(-1)^r$ and $f(\pi/2)=1$. Thus
$$
\boxed{1-\frac13+\frac15-\frac17+\cdots=\frac\pi4}.
$$
No evaluation at a discontinuity or rearrangement of the conditionally convergent series is involved.
Back to article page