Integration by parts help Integration by parts 
$$x\tan^{-1}x~dx=\frac12\left(x^2+1\right)\tan^{-1}x-\frac12x+c$$
and 
$$x^2e^{-3x}dx =-\frac13e^{-3x}\left(x^2+\frac23x+\frac29\right)+c$$
I have
$$d(uv)=u~dv+v~du$$
Can anyone please help me?
 A: First one:
Recall that $d(\arctan(x)) = \dfrac{dx}{1+x^2}$.
$$\int x \arctan(x) dx = \underbrace{\int \arctan(x) d\left(\dfrac{x^2}2 \right)}_{\displaystyle \int v du} = \overbrace{\dfrac{x^2 \arctan(x)}2}^{\displaystyle uv} - \underbrace{\int \dfrac{x^2}{2(1+x^2)}dx}_{\displaystyle \int u dv}$$
Now
$$\int \dfrac{x^2}{2(1+x^2)}dx = \int \dfrac{1+x^2-1}{2(1+x^2)}dx = \int \dfrac{dx}2 - \int \dfrac{dx}{2(1+x^2)} = \dfrac{x}2 - \dfrac{\arctan(x)}2$$
Hence, we get that
$$\int x \arctan(x) dx = \dfrac{x^2 \arctan(x)}2 - \dfrac{x}2 + \dfrac{\arctan(x)}2 + c = \dfrac{(1+x^2) \arctan(x)}2 - \dfrac{x}2 + c$$

Second one:
$$\int x^2 e^{-3x} dx = \underbrace{\int x^2 d \left(\dfrac{e^{-3x}}{-3}\right)}_{\displaystyle \int v du} = \overbrace{\dfrac{e^{-3x}}{-3} x^2}^{\displaystyle uv} - \underbrace{\int \dfrac{e^{-3x}}{-3} (2x) dx}_{\displaystyle \int u dv} = \dfrac{e^{-3x}}{-3} x^2 + \dfrac23 \int xe^{-3x} dx$$
Now let us do integration by parts again to evaluate $\displaystyle \int xe^{-3x} dx$.
$$\int xe^{-3x} dx = \underbrace{\int x d \left(\dfrac{e^{-3x}}{-3}\right)}_{\displaystyle \int v du} = \overbrace{x \dfrac{e^{-3x}}{-3}}^{\displaystyle uv} - \underbrace{\int \dfrac{e^{-3x}}{-3} dx}_{\displaystyle \int u dv} = -\dfrac{x e^{-3x}}3 - \dfrac{e^{-3x}}{27}$$
Putting this back, we get that
$$\int x^2 e^{-3x} dx = -\dfrac13 e^{-3x}x^2 - \dfrac29 e^{-3x}x - \dfrac2{27} e^{-3x} + c = - \dfrac{e^{-3x}}3 \left(x^2 + \dfrac{2x}3 + \dfrac2{27}\right) + c$$
A: Hold onto your hat: 
For the integral $$\int x^2e^{-3x}dx$$ we will let $u= x^2$ and $dv=e^{-3x}dx$. Thus, $du = 2x dx$ and $v = \dfrac{e^{-3x}}{-3}$. 
Thus we have  $$\int x^2e^{-3x}dx = x^2 \frac{e^{-3x}}{-3} - \int 2x \dfrac{e^{-3x}}{-3} dx.$$ 
For the latter integral above, we simplify and factor out the constants so that we have $$\dfrac{2}{-3} \int x e^{-3x}dx.$$
Now we let $u= x$, $dv = e^{-3x}dx$. Then $du=dx, v=\dfrac{e^{-3x}}{-3}$. Hence we have $$\dfrac{2}{-3} \int x e^{-3x}dx = \dfrac{2}{3} \left( x \dfrac{e^{-3x}}{-3} - \int  \dfrac{e^{-3x}}{-3} dx\right) = \dfrac{2}{-3} \left(x \dfrac{e^{-3x}}{-3}  + \dfrac{e^{-3x}}{-9} \right).$$
Putting this all together, 
$$\int x^2e^{-3x}dx = e^{-3x} \left(\frac{1}{-3} x^2 - \frac{2}{9}x -\frac{2}{27} \right) + C$$
