Solution (source code)

= Solution

The periodic ramp is an <odd function>, so $a_0=a_n=0$. <Integration by parts> gives
$$
b_n=\frac2\pi\int_0^\pi x\sin(nx)\,dx=\frac{2(-1)^{n+1}}n.
$$
Thus the <Fourier series of a periodic sawtooth> is
$$
\boxed{x=2\sum_{n=1}^{\infty}\frac{(-1)^{n+1}}n\sin(nx),\qquad-\pi<x<\pi.}
$$
The periodic function is smooth at $x=\pi/2$, so the <Dirichlet-Jordan convergence theorem> permits evaluation there. Even-index terms vanish and odd-index sines alternate in sign, giving
$$
\boxed{1-\frac13+\frac15-\frac17+\cdots=\frac\pi4.}
$$