# Fourier series for $x\cos(x)$

I am attempting to find the fourier series for $$f(x) = x\cos x$$ for $$-\pi < x < \pi$$. The method is fine however I find that for $$n = 1$$ I am unable to evaluate the coefficient $$b_1$$.

$$f(x) = \sum_{n=1}^{\infty}{b_n\sin(nx)}$$ since $$f(x)$$ is an odd function.

Calculating my coefficients yields $$b_n = -\left(\frac{\cos((n+1)\pi)}{n+1}+\frac{\cos((n-1)\pi)}{n-1}\right)$$

This is clearly not defined at $$n=1$$, how should I proceed?

Note: this is an intermediary step in order to find the fourier series of $$x(1+\cos x)$$ if you wanted context.

• Directly integrate $x\sin(x) \cos(x)$. Dec 15, 2020 at 21:32
• @CameronWilliams ah - that would make sense :), how stupid of me. Dec 15, 2020 at 21:35
• Not stupid! It happens. Same issue with integrating $e^{i(n-m)}$ and evaluating at the endpoints. Dec 15, 2020 at 21:50

Your assertion comes from produt-to-sum formula $$\sin s\cos t=\frac12\sin(s+t)+\frac12\sin(s-t)$$

So the integrand of interest in the various passages is still $$\frac12\sin((n+1)x)+\frac12\sin((n-1)x)$$. The only difference is that for $$n=1$$ its antiderivative is no longer $$-\frac{\cos((n-1)x)}{2(n-1)}-\frac{\cos((n+1)x)}{2(n+1)}$$.