$x\cos(x)=-\frac{1}{2} \sin(x) + 2\sum_{n=2}^{\infty} \frac{(-1)^n n \sin(nx)}{n^2-1}$ for $x\in (-\pi,\pi)$ I am trying to establish the following $x\cos(x)=-\frac{1}{2} \sin(x) + 2\sum_{n=2}^{\infty} \frac{(-1)^n n \sin(nx)}{n^2-1}$ for $x\in (-\pi,\pi)$
The right sight looks the the Fourier expansion of the left hand side. Am I correct in saying for $f(x)=x\cos(x)$, the right hand side should be $\sum_{n=1}^{\infty} \langle f, \sin(nx) \rangle \sin(nx) + \sum_{m=0}^{\infty} \langle f, \cos(mx) \rangle \cos(mx)$
 A: The function $x\cos(x)$ is an odd function on $(-\pi,\pi)$, which means that its Fourier series on $(-\pi,\pi)$ is a sin series. The function $x\cos(x)|_{x=-\pi}=\pi$ and $x\cos(x)|_{x=\pi}=-\pi$. So the Fourier series converges to $0$ at $x=\pm \pi$; otherwise it converges to $x\cos(x)$ on $(-\pi,\pi)$. Using trig identities
$$
    \sin(nx+x) = \sin(nx)\cos(x)+\cos(nx)\sin(x) \\
    \sin(nx-x) = \sin(nx)\cos(x)-\cos(nx)\sin(x) \\
    \sin(nx+x)+\sin(nx-x)=2\sin(nx)\cos(x).
$$
The coefficient of $\sin(nx)$ for $n > 1$ is
\begin{align}
       \frac{1}{\pi}\int_{-\pi}^{\pi}x\cos(x)\sin(nx)dx & = \frac{1}{2\pi}\int_{-\pi}^{\pi}x\sin(nx+x)+x\sin(nx-x)\,dx \\
   & = -\left.x\frac{\cos((n+1)x)}{2\pi(n+1)}\right|_{x=-\pi}^{\pi}+\int_{-\pi}^{\pi}\frac{\cos((n+1)x)}{2\pi(n+1)}dx \\
   & -\left.x\frac{\cos((n-1)x)}{2\pi(n-1)}\right|_{x=-\pi}^{\pi}+\int_{-\pi}^{\pi}\frac{\cos((n-1)x)}{2\pi(n-1)}dx \\
   & = -\frac{\cos((n+1)\pi)}{n+1}-\frac{\cos((n-1)\pi)}{n-1} \\
   & = (-1)^{n}\left[\frac{1}{n+1}+\frac{1}{n-1}\right] \\
   & = \frac{2 (-1)^{n}n}{n^2-1}
\end{align}
I'll leave the coefficient for $n=1$ for you.
