What is the definite integral of... $$\int^L_{-L} x \sin(\frac{\pi nx}{L})$$
I've seen something like this in Fourier theory, but I'm still not sure how to approach this integral. Wolfram Alpha gives me the answer, but no method. Integrate by parts? Substitution?
 A: Integrate by parts letting $u = x, dv = \sin(ax) dx$, and so $du = dx, v = -\cos (ax)/a$ and you have
$$\int x \sin(ax) dx = \int u \cdot dv = uv - \int v \cdot du 
  = \frac{-x\cos(ax)}{a} + \frac{1}{a} \int \cos(ax) dx,$$
which should be much easier.
A: If $n=0,$ this is simple, so suppose not. Use the substitution $$u=\frac{n\pi}lx,$$ so that $$x=\frac{l}{n\pi}u,$$ and so $$\int_{-l}^lx\sin\left(\frac{n\pi}lx\right)\,dx=\frac{l^2}{n^2\pi^2}\int_{-n\pi}^{n\pi}u\sin u\,du,$$ then integrate by parts.
A: Whenever you have $p(x)f(x)$, where $p(x)$ is a polynomial, and $f(x)$ is a function like $\sin(x)$ or $e^x$, such that differentiating doesn't increase its "order," integration by parts is always a good technique.  Differentiate the polynomial so it becomes "less complicated," and integrate the other function.
$$\int_{-L}^Lx\sin\left(\frac{n\pi x}{L}\right)\,dx$$
Let $u = x, dv=\sin\left(\frac{n\pi x}{L}\right)dx$.  Then $du = dx$ and $v = \frac{-L}{n\pi}\cos\left(\frac{n\pi x}{L}\right)$.
Thus,
$$\int_{-L}^Lx\sin\left(\frac{n\pi x}{L}\right)\,dx = \frac{-xL}{n\pi}\cos\left(\frac{n\pi x}{L}\right)\Bigg|_{-L}^L - \int_{-L}^L\frac{-L}{n\pi}\cos\left(\frac{n\pi x}{L}\right)\,dx$$
A: For what it's worth, WolframAlpha will show you the steps to evaluate the indefinite integral associated with this definite integral.  It's then just a matter of plugging in the limits and subtracting.
Here are the steps returned by WolframAlpha via the Mathematica interface:

