How do you evaluate the integral $\dfrac{1}{\pi} \int_{-\pi}^\pi x\sin(nx)dx$ and How do you evaluate the integral $$\dfrac{1}{\pi} \int_{-\pi}^\pi x\sin(nx)dx$$
I am new to Fourier series and integration so need help here. I have no idea how to evaluate this integral. Can you do this steps by steps so I can follow and learn more?
Thank you!
PS: How do you make the integral sign larger with Latex?
 A: Set $u(x)=x$ and $v^\prime(x)=\sin(nx)$. In other words, $v(x)=-\frac 1 n \cos(nx)$.
Then the integration by parts formula is
$$\int_a^b u(x)v^\prime(x)dx=\left[u(x)v(v)\right]_a^b-\int_a^bu^\prime(x)v(x)dx$$
In other words,
$$\begin{split}
\int_{-\pi}^\pi x\sin(nx)dx &= \left[ -\frac x n\cos(nx)\right]_{-\pi}^{\pi}+\frac 1 n\int_{-\pi}^\pi \cos(nx)dx\\
&= -\frac {2\pi} n
\end{split}$$
That's if $n\neq 0$. For $n=0$, the integral is $0$.
A: As the other answers have suggested, use integration by parts.
Here's an explanation:
Note that the product rule states:
$$\dfrac{d}{dx}\big(u(x)\cdot v(x)\big) = u(x)\dfrac{dv(x)}{dx}+ \dfrac{du(x)}{dx}v(x)$$
If one "multiplies" both sides by $dx$, and integrate you obtain:
$$u(x)\cdot v(x) = \int u(x) \dfrac{dv(x)}{dx}dx + \int v(x)\dfrac{du(x)}{dx} dx$$
Subtracting the right term from the right hand side, we obtain:
$$u(x)v(x) - \int v(x)\dfrac{du(x)}{dx} dx = \int u(x) \dfrac{dv(x)}{dx}dx$$
The idea is to select $u(x)$ and $v(x)$ so that you can follow the pattern suggested by these equations - drastically simplifying the integral. There's even a helpful acronym for how to select the function $u(x)$. LIPET
Logs
Inverse Trig
Polynomials
Exponentials
Trig
One would select the first of whichever functions in the acronym you'd find first - here'd you select $u(x) = x$, and $\dfrac{dv}{dx} = \sin(nx)$.
The integral is:
$$\frac{1}{\pi}\int_{-\pi}^{\pi}x\sin(nx)dx = \frac{1}{\pi}\int_{-\pi}^{\pi}u\dfrac{dv(x)}{dx}dx = \bigg[-\dfrac{1}{n}x\cos(nx)\bigg]_{-\pi}^{\pi} - \int_{-\pi}^{\pi}-\dfrac{1}{n}\cos(nx)dx$$
$$= -\dfrac{2\pi}{n}$$
Now, if $n=0$, the whole integral is zero.
I hope this helps!
A: Hint:
Integration by parts to  eliminate the factor $x$:
$$u=x, \quad \mathrm d v=\cos nx\,\mathrm d x.$$
whence $\;\mathrm du=\mathrm dx,\quad  v=\frac1n\sin nx$. 
Next use the integration by parts formula:
$$\int_a^bu\,\mathrm dv=uv\bigg|_a^b-\int_a^b v\,\mathrm du.$$
