Solution (source code)

= Solution

Substituting the <Fourier coefficient>s into the <Fourier partial sum> and summing the finite geometric series gives
$$
s_n(f,x)=\frac1{2\pi}\int_{\mathbb T}f(t)\sum_{k=-n}^ne^{ik(x-t)}dt
=\frac1\pi\int_{\mathbb T}D_n(x-t)f(t)dt,
$$
where
$$
\boxed{D_n(u)=\frac{\sin((n+\tfrac12)u)}{2\sin(u/2)}}.
$$