Fourier series exercise Given $f(x)$ continuous and derivable in $ [0,\pi]$, $f(0)=f(\pi)=0, f'(0)=f'(\pi)$ and 
$$ F_N(x,x')= \sum_{n=1}^Nn\cos(nx)\sin(nx') $$
find $$\lim_{N\to \infty} \int_0^\pi f(x')F_N(x,x')dx' $$
I can expand in Fourier series the function $f$ in its domain as: $f(x) = \sum_{n=1}^\infty a_n \sin(nx)$, where $ a_n=\int_0^\pi f(x)\sin(nx)dx$. Then 
$$ \lim_{N\to \infty} \int_0^\pi f(x')F_N(x,x')dx'= \lim_{N\to \infty}\sum_{n=1}^Nn\cos(nx) \int_0^\pi f(x')\sin(nx')dx'= \lim_{N\to \infty}\sum_{n=1}^Na_nn\cos(nx)=\lim_{N\to \infty}\frac{d}{dx}\sum_{n=1}^N a_n\sin(nx)=f'(x)  $$
Is it correct to say from the beggining that $f(x) = \sum_{n=1}^\infty a_n \sin(nx)$, or should I use the whole Fourier series with cosines? I did this because the function goes to zero in $0$ and $\pi$. Then I'm not sure if I can exchange integrals with sums and derivatives. 
 A: The Fourier series of $f(x)$ is given by$$f(x)=\frac{a_0}{2}+\sum_{n=1}^\infty\left[a_n\cos\left(\frac{n\pi x}l\right)+b_n\sin\left(\frac{n\pi x}l\right)\right]$$where $l=\pi/2$ is half the fundamental period of $f(x)$.$$a_n=\frac1l\int_0^{2l}f(x)\cos\left(\frac{n\pi x}l\right)dx,n\ge0\\b_n=\frac1l\int_0^{2l}f(x)\sin\left(\frac{n\pi x}l\right)dx,n\ge1$$
You can also  obtain both the Fourier cosine and sine series for $f(x)$ in the given domain. Consider the odd extension$$g(x)=\begin{cases}f(x),&\pi\ge x\ge0\\-f(-x),&-\pi\le x<0\end{cases}$$The fundamental period of $g$ is $2\pi.~g$ is odd, hence $a_n=0$.$$b_n=\color{red}{\frac1\pi}\int_{-\pi}^{\pi}g(x)\sin(nx)dx=\color{red}{\frac2\pi}\int_0^\pi f(x)\sin(nx)dx\\g(x)=\sum_{n=1}^\infty b_n\sin(nx)$$Note the $\frac2\pi$ factor, which you missed out in your answer. Thus, your answer should be $\frac\pi2f'(x)$.

You can similarly find out the Fourier cosine series of $f(x)$ by considering its even extension$$h(x)=\begin{cases}f(x),&\pi\ge x\ge0\\f(-x),&-\pi\le x<0\end{cases}$$
