Show that $x(\pi - x)= \frac{\pi^2}{6}-\sum_{k=1}^{\infty} \frac{\cos(2kx)}{k^2}$ Show that
$$x(\pi - x)= \frac{\pi^2}{6}-\sum_{k=1}^{\infty} \frac{\cos(2kx)}{k^2}$$
for $ 0<x<\pi$
My idea:
I've defined the periodic function 
$$f(x) = 0 \text{ if } x \in [- \pi, 0) \text{ and }$$
$$f(x)=x(\pi-x) \text{ if } x \in [0, \pi)$$
and make the Fourier Series of f.But, imediatly we have 
$$a_o = \frac{1}{\pi} \int_0^{\pi} x(\pi -x) dx = \frac{\pi^2}{6}$$
So I am seeing a problem since we should use $ a_o/2. $Also,
$$b_n = \frac{1}{\pi} \int_0^{\pi} x(\pi-x) sin(nx) dx = \frac{-n \pi \sin(n \pi) - 2 cos(n \pi) +2}{n^3 \pi} = \frac{4}{n^3 \pi} $$
If $ n = 2k+1$. So the series term with $\sin(n x) $ cannot be zero.
Since the f is continuous over $ (0, \pi)$, I thought the series should converge tl the given function.What am I doing wrong?
P.s: for the cosine part, I've obtained exactly the series part given an answer.
P.S.S: we usethat the fourier series is
$$SF_f = \frac{a_o}{2} + \sum_{n=1}^{\infty} a_n \cos(nx) + b_n \sin(nx)$$
Edit:
I've found this searching about Fourier series. Since the function f is even on $(0,\pi$), does the theorem holds or it must be even in $R$?
Edit 2:
$$f(x) = -x(\pi+x) \text{ if } x \in [- \pi, 0) \text{ and }$$
$$f(x)=x(\pi-x) \text{ if } x \in [0, \pi)$$
Is even and the equality, now, holds.
 A: Target function
$$
f(x) = x \left(\pi - x \right)
$$

To reproduce the answer, use an even reflection of the function:
$$
\begin{align}
 r(x) &= x \left(\pi - x \right), \quad x\ge 0, \\
 l(x) &= -x \left(\pi + x \right), \quad x < 0.
\end{align}
$$

Fourier amplitudes
$$
\begin{align}
%
a_{0} &= \frac{1}{\pi} \left(
\int_{-\pi}^{0} l (x) \, dx +
\int_{0}^{\pi} r (x) \, dx  
\right)
= \frac{\pi ^3}{3} \\[5pt]
%
a_{k} &= \frac{1}{\pi} \left(
\int_{-\pi}^{0} l (x) \, dx +
\int_{0}^{\pi} r (x) \, dx  
\right) = -\frac{2 \left((-1)^k+1\right)}{k^2}
\\[5pt]
%
b_{k} &= \frac{1}{\pi} \left(
\int_{-\pi}^{0} l (x) \, dx +
\int_{0}^{\pi} r (x) \, dx  
\right) = 0
%
%
\end{align}
$$
The first few terms in the series look like
$$
\begin{array}{rr}
 k & a_{k} \\\hline
 1 & 0 \\
 2 & -1 \\
 3 & 0 \\
 4 & -\frac{1}{4} \\
 5 & 0 \\
 6 & -\frac{1}{9} \\
\end{array}
$$
Fourier Series
$$
\begin{align}
 f(x) 
&= \frac{a_{0}}{2} + \sum_{k=1}^{\infty} \frac{-2 \left((-1)^k+1\right)}{k^2}\cos \left( kx \right) \\[3pt]
&= \frac{\pi^{3}}{6} - \sum_{k=1}^{\infty} k^{-2} \cos \left( 2kx \right)
\end{align}
$$
Building the approximation

