I have to find a series that in $0\leq x\leq \pi$: $$x\sin(x) = \sum_{n=0}^{\infty} a_n\sin(2nx) $$ It seems to be impossible because on $x=\pi/2$ we get $ \pi/2 = 0$. However I tried to do it (as part of another exercise which apparentelly I'm on the wrong path), just as we do in classical Fourier:
$$\int_{0}^{\pi} x\sin(x)\cdot\sin(2mx) dx = \sum_{n=0}^{\infty}a_n\int_{0}^{\pi} \sin(2nx)\cdot\sin(2mx) dx$$
I could solve it and find that $$a_n = \dfrac{-16n}{\pi(2n-1)^2 (2n+1)^2}$$ which is of course a wrong solution.
At what stage I was wrong? Is it somehow possible to develop a series (even without $\pi/2$)?
Hint:
As I said in the comments already, it is important to realize that fourier theory does not give you pointwise convergence of the series, only L2-convergence. Therefore it is not a contradction that the fourier series at $x = \pi/2$ does not agree with the function. Note that the functions $\sin(2nx)$, $n \in \mathbb{N}$ are not an orthonormal basis of $L^{2}(0,\pi)$, wich means that
$$\int_{0}^{\pi} x\sin(x)\cdot\sin(2mx) dx = \sum_{n=0}^{\infty}a_n\int_{0}^{\pi} \sin(2nx)\cdot\sin(2mx) dx$$
does not imply
$$a_{n} = \int_{0}^{\pi} x\sin(x)\sin(2nx)\; dx.$$
Now, to solve the problem: Use classical fourier theory to find coeffcients $a_{n}, n\in\mathbb{Z}$ such that $$\frac{x}{2}\sin\left(\frac{x}{2}\right) = \sum_{n\in\mathbb{Z}} \hat a_{n} \sin(nx)\quad \text{in} \; L^2(0,2\pi).$$ You can then easily find coefficients $a_{n}$ for $n\in \mathbb{N}$ such that $$\frac{x}{2}\sin\left(\frac{x}{2}\right) = \sum_{n=0}^{\infty} a_{n} \sin(nx), \quad \text{in}\; L^{2}(0,2\pi)$$ holds.
Now, for $N \in \mathbb{N}$ we can substitute $ u = x/2$ to obtain
$$\int_{0}^{2\pi}\left|\frac{x}{2}\sin\left(\frac{x}{2}\right) - \sum_{n=0}^{N} a_{n} \sin(nx) \right|^2\;dx = 2\int_{0}^{\pi} \left|u\sin\left(u\right) - \sum_{n=0}^{N} a_{n} \sin(2nu) \right|^2\;du $$
For $N \to \infty$, the left hand side goes to $0$, so the right hand side must go to $0$ as well and we see that the coefficents $a_{n}$ solve the problem.