Fourier sine series of $x^2$ When I am trying to compute $$\frac{2}{l}\int_{0}^{l}x^2\sin\left(\frac{n\pi x}{l}\right)dx$$
I let $u = x^2$, $du = 2x dx$, $dv = \sin\left(\frac{n\pi x}{l}\right)$, $v = -\frac{l}{n \pi}\cos\left(\frac{n\pi x}{l}\right)$. Thus applying integration by parts I get $$-\frac{2l^2}{n\pi}\cos(n\pi) + \frac{4l^2}{n^2 \pi^2}\sin(n\pi) + \frac{4l}{n^2 \pi^2}\cos(n\pi)$$
Just want to check if this is right.
 A: The integral in question is as follows.
\begin{align}
\int x^2 \, \sin\left(\frac{n \pi x}{l}\right) \, dx &= - \frac{l \, x^2}{n \pi} \cos\left(\frac{n \pi x}{l}\right) + \frac{2 l}{n \pi} \, \int x \, \cos\left(\frac{n\pi x}{l} \right) \, dx \\
&= \left( 2 \, \left(\frac{l}{n \pi}\right)^3 - \frac{l x^2}{n \pi} \right) \, \cos\left(\frac{n \pi x}{l}\right) + \frac{2 l^2 x}{(n \pi)^2} \, \sin\left(\frac{n \pi x}{l}\right).
\end{align}
Applying limits yields
\begin{align}
\int_{0}^{l} x^2 \, \sin\left(\frac{n \pi x}{l}\right) \, dx &=
 \left( 2 \, \left(\frac{l}{n \pi}\right)^3 - \frac{l^3}{n \pi} \right) \, (-1)^n - 2 \, \left(\frac{l}{n \pi}\right)^3 \\
&= \frac{l^3 \, (-1)^{n-1}}{n \pi} - 2 \, \left(\frac{l}{n \pi}\right)^3 \, (1- (-1)^n). 
\end{align}
This leads to
\begin{align}
\left(\frac{x}{l}\right)^2 &= \sum_{n=1}^{\infty} \left[\frac{2}{l^3} \, \int_{0}^{l} u^{2} \, \sin\left(\frac{n \pi u}{l}\right) \, du \right] \, \sin\left(\frac{n \pi x}{l}\right) \\
&= \frac{2}{\pi} \, \sum_{n=1}^{\infty} \frac{(-1)^{n-1}}{n} \, \sin\left(\frac{n \pi x}{l}\right) - \frac{4}{\pi^3} \, \sum_{n=0}^{\infty} \frac{1}{(2n+1)^3} \, \sin\left(\frac{(2n+1) \, \pi x}{l}\right). 
\end{align}
