understanding integration by change of variables I'm having trouble understanding integration by the method of change of variables. Can someone elaborate the method with an example?

For instance, $\int_0^{5\pi} \frac{\sin t}{2+\cos t } dt$ using $s=\cos t$ as a new variable.
Let $f: [c,d]\to \Bbb R$ be a continuous function and $\varphi: [a,b]\to [c,d]$ be a continuously differentiable, bijective function (sometimes bijectivity isn't strictly required, but it's easier to prove with this assumption).  Then

$$\int_a^b f(\varphi(t))\varphi'(t)\ dt = \int_{c}^{d} f(x)\ dx$$

Here's an image (from an old project of mine) that hopefully shows roughly what $\varphi$ does.  $\varphi$ is a function which maps one interval (on the real number line) to another interval.



This formula is easy to derive from the chain rule and the Fundamental Theorem of Calculus.

The thing that many calculus students don't understand immediately is that this formula can be run left-to-right or right-to-left.

Left-to-right
Sometimes the easiest thing to do is to manipulate our integrand until we get it into the form $f(\varphi(t))\varphi'(t)$.  Then we can simplify it by just setting $x = \varphi(t)$ and using the above formula.  For example, consider the integral $$\int_0^4 \frac{t}{(1+t^2)^2}\ dt$$  In this case if we realize that $$\frac{t}{(1+t^2)^2} = \frac{\frac 12(1+t^2)'}{(1+t^2)^2} = \frac 12 \left(\frac{1}{(1+t^2)^2}\right)\left(1+t^2\right)' = \frac 12f(\varphi(t))\varphi'(t)$$ then we can set $x=1+t^2 = \varphi(t)$.  First we note that $\varphi: [0,4]\to [1,17]$ is bijective so then we can use our formula to simplify this integral to $$\frac 12\int_{1}^{17} \frac 1{x^2}\ dx$$ which is much easier to evaluate.  This type of substitution is called a pushforward.

Right-to-left
Sometimes it'll be easier just to compose your function $f$ with a function that has some property that'll simplify your integral.  For instance consider this similar looking integral $$\int_0^{4} \frac{1}{1+x^2}\ dx$$ Here you can see that if you take $\varphi(t) = \tan(t)$ and compose it with the function $f(x) = \frac 1{1+x^2}$ then you'll be able to use the fact that $1+\tan^2(t) = \sec^2(t) = \cos^{-2}(t)$ to simplify this integral.  Then we just use the change of variables formula to get $$f(x) = \frac{1}{1+x^2} \\ \implies f(\varphi(t))\varphi'(t) = \left(\frac{1}{1+\tan^2(t)}\right)(\tan(t))' = \frac{\sec^2(t)}{\sec^2(t)} = 1$$ That definitely simplifies our integrand.  

But before we can set up the new integral we'll need to find the inverse of $\tan$ and check for bijectivity.  The (restricted) inverse of $\tan$ is $\arctan$.  Using that we find that the endpoints of our interval in the domain of $\tan$ should be $\arctan(0) = 0$ and $\arctan(4)$.  And we know that $\tan: [0,\arctan(4)] \to [0,4]$ is a bijection.  Then our new integral becomes $$\int_{0}^{\arctan(4)} dt$$ which is much easier to evaluate.  This type of substitution is called a pullback.



Make sure that you understand the difference between pushforwards and pullbacks.  In elementary calculus courses they both go under the title of "$u$-substitution" but they actually require different mindsets to find the appropriate substitution.  For pushforwards we try to manipulate our integrand until we recognize it as a composition of the form $f(\varphi(t))\varphi'(t)$ (possibly with a constant factor that we can pull out of the integral).  For pullbacks we try to find a function $\varphi$ that has properties that'll help us simplify our integral.

For the integral in your question the best approach would be to use a pushforward.  That is, if you recognize that $$\frac{\sin(t)}{2+\cos(t)} = \frac{-(2+\cos(t))'}{2+\cos(t)} = -\left(\frac{1}{2+\cos(t)}\right)(2+\cos(t))'$$ then you can use the change of variables formula.

You may notice, however, that $\phi(t) = 2+\cos(t)$ is not bijective on $[0,5\pi]$.  However it is bijective on $[0,\pi]$, $[\pi, 2\pi]$, etc.  See if you can figure out how to handle this on your own.  Is there some condition you see (or can guess without proof) on when $\varphi$ can be non-bijective in pushforwards?
$\int \frac{\sin(t)}{2+cos(t)}dt$. Let $u=2+\cos(t) \to du=-\sin(t) dt$. Now we have $\int -\frac{1}{u} du = -\ln(u) +C$. Finally the integral is $-\ln(2+\cos(t)) +C$