TITLE: When to do u-substitution and when to integrate by parts
QUESTION [26 upvotes]: I'm in my first semester of calculus, so the problems I'm facing are about as hard as those on KhanAcademy calculus playlist. I'm currently doing integration, a somewhat difficult part of the course. Doing derivatives is mechanics; finding the integral is an art. 
The two main techniques showed are

u-substitution
integration by parts

My question is: are there any rules of thumb (preferably with a logical reason behind it) of when to use which?

REPLY [2 votes]: While other answer provide the general guideline it's often not obvious to see when to use which.
First look at a table of differentials to see if you can find any pattern you can work towards algebraically to find the anti-derivative. For example if your integrand has a square root in the denominator and a constant numerator your anti-derivative may be one of the inverse hyperbolic functions.
Consider integration by parts in these cases:

To eliminate logarithm, inverse trigonometric and inverse hyperbolic functions:
$$\int x^2 \mathrm{ln}(x) dx = \frac{x^3}{3} \mathrm{ln}(x) - \int \frac{x^3}{3x} dx = \frac{x^3}{3} \mathrm{ln}(x) - \frac{x^3}{9} + C$$
Of course the other factor should be easy to integrate.
To rotate exponentials, trigonometric and hyperbolic functions. The exponential function's antiderivative is itself, sines and cosines switch, hyperbolic sines and cosines switch as well. This can be used to repeatedly differentiate the attached factor while keeping the exponential intact, hoping something simpler comes out of it:
$$\int f(x) e^x dx = f(x)e^x - \int f'(x) e^x dx$$
This is especially useful if your $f(x)$ is a polynomial.
To reduce powers of trigonometric or exponential functions. Some good examples of the method can be found at Integration by reduction formulae
.
The general idea is using integral by parts when integrating $f(x)$ with respect to $x$ such that the integral for $f(x)$ appears again on the right side. Now you have an equation where you should bring the integral back to the left so the antiderivative remains on the right.

Consider using substitution:

To get rid of linear subexpressions. You can always do this: $\int f(ax+b) dx = \frac{1}{a}\int f(u) du$, with $u = ax + b$.
If you see powers differ by only 1, check if you can factor out the lower power: $\int x^{n-1} f(a x^n + b) dx = \frac{1}{na} \int f(u) du$ with $u = ax^n + b$. Then you eliminate the power altogether.
If you have $x^2$ only and square roots but no $x$, the $\sqrt{ax^2 + b}$ is a candidate for trigonmetric and hyperbolic substution with $x = \sqrt{\frac{b}{a}} \mathrm{sinh}\, \theta$ and $dx = \sqrt{\frac{b}{a}} \mathrm{cosh}\, \theta$. So it becomes $\sqrt{b \mathrm{sinh}^2\, \theta + b} = \sqrt{b}\sqrt{\mathrm{sinh}^2\, \theta + 1} = \sqrt{b}\sqrt{\mathrm{cosh}^2\, \theta} = \sqrt{b}|\mathrm{cosh}\, \theta| = \sqrt{b}\mathrm{cosh}\, \theta$ .