Integration by Substitution
"Integration by Substitution" (also called "u-substitution") is a method to find an integral, but only when it can be set up in a special way.
The first and most vital step is to be able to write your integral in this form:

Note that you have g(x) and its derivative g'(x)
It might make more sense as is an example:

Here f=cos, and you have g=x2 and its derivative of 2x
This integral is good to go!
If your integral is set up like that, then you can do this substitution:

Then you can integrate f(u), and finish by putting g(x) back as a replacement for u.
Like this:
Example: ∫cos(x2) 2x dx
We know (from above) that it is in the right form to do the substitution:

Now integrate:
∫cos(u) du = sin(u) + C
And finally put u=x2 back again:
sin(x2) + C
So ∫cos(x2) 2x dx = sin(x2) + C worked out really nicely! (Well, I knew it would.)
This method only works on some integrals of course, and it may need rearranging:
Example: ∫cos(x2) 6x dx
Oh no! It is 6x, not 2x. Our perfect setup is gone.
Never fear! Just rearrange the integral like this:
∫cos(x2) 6x dx = 3∫cos(x2) 2x dx
(You are allowed to pull constant multipliers outside the integration, see Rules of Integration).
Then proceed as before:
3∫cos(u) du = 3 sin(u) + C
Now put u=x2 back again:
3 sin(x2) + C
Done!
Now we are ready for a slightly harder example:
Example: ∫x/(x2+1) dx
Let me see ... the derivative of x2+1 is 2x ... so how about we rearrange it like this:
∫x/(x2+1) dx = ½∫2x/(x2+1) dx
Then we have:

Then integrate:
½∫1/u du = ½ ln(u) + C
Now put u=x2+1 back again:
½ ln(x2+1) + C
And how about this one:
Example: ∫(x+1)3 dx
Let me see ... the derivative of x+1 is ... well it is simply 1.
So we can have this:
∫(x+1)3 dx = ∫(x+1)3 · 1 dx
Then we have:

Then integrate:
∫u3 du = (u4)/4 + C
Now put u=x+1 back again:
(x+1)4 /4 + C
So there you have it.
In Summary
If you can put an integral in this form:

Then you can make u=g(x) and integrate ∫f(u) du
And finish up by re-inserting g(x) where u is.