Example 4.40. Write the Fourier series for the function $f(x)$ defined by the conditions

$$
\begin{gathered}
f(x)=f(x+2 \pi) \ (2 \pi \text{-periodicity }), \\
f(x)=f(-x) \text{ (evenness) } \\
f(x)=x, \ 0 \leqslant x \leqslant \pi .
\end{gathered}
$$
Solution. Since the function in question is even, its coefficients $b_{k}$ will be zero, and the coefficients $a_{k}$ are calculated using formulas (4.11)

$$
a_{0}=\frac{1}{\pi} \int_{-\pi}^{\pi} f(x) d x=\frac{2}{\pi} \int_{0}^{\pi} x d x=\left.\frac{2}{\pi} \frac{x^{2}}{2}\right|_{0} ^{\pi}=\pi
$$

For $k=1,2, \ldots$

$$
\begin{aligned}
a_{k}= & \frac{1}{\pi} \int_{-\pi}^{\pi} f(x) \cos k x d x=\frac{2}{\pi} \int_{0}^{\pi} x \cos k x d x= \\
& =\frac{2}{\pi}\left(\left.x \frac{\sin k x}{k}\right|_{0} ^{\pi}+\left.\frac{\cos k x}{k^{2}}\right|_{0} ^{\pi}\right)= \\
= & \frac{2}{\pi} \frac{(-1)^{k}-1}{k^{2}}=\left\{\begin{array}{l}
0, k-\text { even } \\
-\frac{4}{\pi} \frac{1}{k^{2}}, k-\text { odd. }
\end{array}\right.
\end{aligned}
$$

Let's write the Fourier series of this function

$$
f(x) \sim \frac{\pi}{2}-\frac{4}{\pi} \sum_{k=1}^{\infty} \frac{\cos (2 k-1) x}{(2 k-1)^{2}}
$$