# How do you find the antiderivative of int (xsin^2x) dx?

Jan 16, 2017

$\int \left(x {\sin}^{2} x\right) \mathrm{dx} = \frac{1}{4} {x}^{2} - \frac{1}{4} x \sin \left(2 x\right) - \frac{1}{8} \cos \left(2 x\right) + C$

#### Explanation:

It's often very advantageous to rewrite ${\sin}^{2} x$ in integrals using the identity $\cos \left(2 x\right) = 1 - 2 {\sin}^{2} x$. Solving for ${\sin}^{2} x$ in this shows that ${\sin}^{2} x = \frac{1}{2} \left(1 - \cos \left(2 x\right)\right)$. Thus:

$\int x {\sin}^{2} x \mathrm{dx} = \int \frac{1}{2} x \left(1 - \cos \left(2 x\right)\right) \mathrm{dx}$

Expanding:

$= \frac{1}{2} \int x \mathrm{dx} - \frac{1}{2} \int x \cos \left(2 x\right) \mathrm{dx}$

The first integral is basic:

$= \frac{1}{2} {x}^{2} / 2 - \frac{1}{2} \int x \cos \left(2 x\right) \mathrm{dx}$

$= \frac{1}{4} {x}^{2} - \frac{1}{2} \int x \cos \left(2 x\right) \mathrm{dx}$

Now performing integration by parts:

$\left\{\begin{matrix}u = x \text{ "=>" "du=dx \\ dv=cos(2x)" "=>" } v = \frac{1}{2} \sin \left(2 x\right)\end{matrix}\right.$

Note that going from $\mathrm{dv}$ to $v$ requires a substitution of its own.

Then the integral equals:

$= \frac{1}{4} {x}^{2} - \frac{1}{2} \left(u v - \int v \mathrm{du}\right)$

$= \frac{1}{4} {x}^{2} - \frac{1}{2} \left(\frac{1}{2} x \sin \left(2 x\right) - \int \frac{1}{2} \sin \left(2 x\right) \mathrm{dx}\right)$

$= \frac{1}{4} {x}^{2} - \frac{1}{4} x \sin \left(2 x\right) + \frac{1}{4} \int \sin \left(2 x\right) \mathrm{dx}$

Note that $\int \sin \left(2 x\right) \mathrm{dx} = - \frac{1}{2} \cos \left(2 x\right)$:

$= \frac{1}{4} {x}^{2} - \frac{1}{4} x \sin \left(2 x\right) - \frac{1}{8} \cos \left(2 x\right) + C$