Originally Posted by

**Reckoner** Don't worry! Integration by parts can be tricky at first, but once you get used to it you can get quite good at it. If you aren't sure at first which values to use for each "part," just take a good guess and see if you wind up with something simple enough to evaluate. If not, try again! You will get the hang of it.

In this case we want $\displaystyle \int\left(xe^x\right)^2\,dx = \int x^2e^{2x}\,dx$.

The formula for integration by parts is $\displaystyle \int u\,dv = uv - \int v\,du$. Here's my suggestion: for $\displaystyle dv$ choose the most complicated portion of the integrand *that you know how to integrate*. In our case, $\displaystyle e^{2x}$ is the most complicated factor, but it is integrated easily. So we would have

$\displaystyle \begin{array}{rclcrcl}

u & = & x^2 & \Rightarrow & du & = & 2x\,dx\\

dv & = & e^{2x}\,dx & \Rightarrow & v & = & \frac12e^{2x}

\end{array}$

Once you make your substitutions, you will end up with

$\displaystyle uv - \int v\,du = \frac12x^2e^{2x} - \int xe^{2x}\,dx$

This integral, $\displaystyle \int xe^{2x}\,dx$, will require another application of integration by parts.

In general, here's some tips for choosing your $\displaystyle u$ and $\displaystyle dv$:

For integrals of the form $\displaystyle \int x^n\sin x\,dx$ (and other trig functions), let $\displaystyle u = x^n$ and $\displaystyle dv = \sin x\,dx$.

Similarly, for integrals of the form $\displaystyle \int x^ne^x\,dx$, let $\displaystyle u = x^n$ and $\displaystyle dv = e^x\,dx$.

For the integrals $\displaystyle \int e^x\sin x\,dx$ or $\displaystyle \int e^x\cos x\,dx$, let $\displaystyle u = \sin x$ or $\displaystyle u = \cos x$, and let $\displaystyle dv = e^x\,dx$. Use integration by parts twice, and you will actually end up with an equation that can be solved for the desired integral.

For integrals like $\displaystyle \int\ln x\,dx$ or $\displaystyle \int\arcsin x\,dx$, let $\displaystyle u$ be the entire integrand with $\displaystyle dv = dx$.