Fourier series of $f(x)=\pi-x$ $$f(x)=\pi-x \qquad x \in [0,2 \pi[$$

$$a_0=\frac{1}{\pi} \ \int_0^{2 \pi}f(x) \ dx=\frac{1}{\pi} \ \int_0^{2 \pi} (\pi-x) \ dx=0$$

$$a_n=\frac{1}{\pi} \ \int_0^{2 \pi} \cos(nx) \ dx=\frac{1}{\pi} \ \int_0^{2 \pi}(\pi \ \cos(nx)-x \ \cos(nx)) \ dx=$$
$$\frac{1}{\pi} \ \Big( \ \Big[\frac{\pi}{n} \ \sin(nx) \Big]_0^{2 \pi}-\Big[\frac{x}{n} \ \sin(nx)+\frac{1}{n^2} \ \cos(nx) \Big]_0^{2 \pi} \Big)=0 $$

$$b_n=\frac{1}{\pi} \ \Big( \ \Big[\ -\frac{\pi}{n} \ \cos(nx) \Big]_0^{2 \pi}-\Big[-\frac{x}{n} \ \cos(nx)+\frac{1}{n^2} \ \sin(nx) \Big]_0^{2 \pi} \Big)=\frac{2}{n}$$

$$f(x)=2 \sum_{n=1}^{+\infty} \frac{1}{n} \ \sin(nx)$$
Is it correct?
 A: Slight errors: 
$$
\begin{align}
%
  a_{0} &= \frac{1}{\pi} \int_{-\pi }^{\pi } f(x) \, dx = 2\pi \\[5pt]
%
  b_{k} &= \frac{1}{\pi } \int_{-\pi }^{\pi } f(x) \sin (k x) \, dx = (-1)^k \frac{2}{k \pi}
%
\end{align}
$$
The decay of the amplitudes is linear:

The series expansion looks like
$$
 \pi - x = \pi - 2 \sin (x) + \sin (2x) - \frac{2}{3} \sin (3x) + \frac{1}{2} \sin \left( 4x \right) - \dots
$$
Convergence sequence:




A: Any function $F(x)$ defined on $[0,2\pi]$ expands as the Fourier series
$$ F(x) = \dfrac{A_0}2 + \sum^\infty_{n=1}A_n\cos(nx) + \sum^\infty_{n=1} B_n \sin(nx),$$
$$\text{where} \qquad A_0 = \frac1\pi\!\int_0^{2\pi}\!\!\!\!\!F(x)dx, \quad 
   A_n = \frac1\pi\!\int_0^{2\pi}\!\!\!\!\!F(x)\cos(nx)dx, \quad 
   B_n = \frac1\pi\!\int_0^{2\pi}\!\!\!\!\!F(x)\sin(nx)dx. $$
Thus, for $f(x) = \pi-x$, these coefficients are computed as follows:
$$\begin{split}
a_0 &= \frac1\pi\!\int_0^{2\pi}\!\!\!(\pi-x)dx = 0, \\
a_n &= \frac1\pi\!\int_0^{2\pi}\!\!\!(\pi-x)\cos(nx)dx
     = \frac{1-\cos(2n\pi)-n\pi\sin(2n\pi)}{n^2\pi}, \\
b_n &= \frac1\pi\!\int_0^{2\pi}\!\!\!(\pi-x)\sin(nx)dx
     = \frac{2\cos(n\pi)\big[n\pi\cos(n\pi)-\sin(n\pi)\big]}{n^2\pi}.
\end{split}$$
Therefore, its Fourier series is given by
$$\sum_{n=1}^\infty \frac1{n^2\pi} \Big\{ \big[ 1 -\cos(2n\pi) -n\pi\sin(2n\pi) \big] \cos(nx) + 2\cos(n\pi) \big[ n\pi\cos(n\pi) -\sin(n\pi) \big] \sin(nx) \Big\}.$$
