What's the integral of this fraction? 
Find $\displaystyle \int \dfrac{\cos^2(x)\sin(x)+2\sin(x)}{\cos^2(x)+1}dx$.

I tried splitting it up, but I don't think that helps. What is the best way to solve this?
 A: First, write the integral as $\displaystyle\int \dfrac{\cos^2 x + 2}{\cos^2 x + 1}\sin x \,dx$. 
Then, substitute $u = \cos x$, $du = -\sin x \,dx$ to get 
$\displaystyle\int \dfrac{\cos^2 x + 2}{\cos^2 x + 1}\sin x \,dx = -\int\dfrac{u^2+2}{u^2+1}\,du = -\int\left(1 + \dfrac{1}{u^2+1}\right)\,du$, 
which is easy to evaluate.
A: Set $u=\cos(x)$ then $du=-\sin(x)\ dx$ you will get
$$-\displaystyle \int \dfrac{u^2+2}{u^2+1}\ du$$
A: Notice, $$\int \frac{\cos^2 x\sin x+2\sin x}{\cos^2x+1}\ dx$$$$=\int \frac{(\cos^2 x+1)+1}{\cos^2x+1}(\sin x\ dx)$$
$$=-\int \left(1+\frac{1}{\cos^2x+1}\right)d(\cos x)$$
$$=-\left(\cos x +\tan^{-1}(\cos x)\right)+C$$
A: Keep in mind that whenever you make any substitution, you will be dividing by the derivative of the substitution, so look to see if something cancels. Remember, the whole point of making substitutions is to simplify things. In this case, $u=\cos x$ seems like a good choice for a substitution. As a first step just multiply by one, e.g. by $$\frac{\frac{du}{dx}}{\frac{du}{dx}}$$
First we have
$$u=\cos x$$
$$\frac{du}{dx}=\color{green}{-\sin x}$$
Next the integral
$$\begin{array}{lll}
\displaystyle\int\frac{\cos^2x\sin x+2\sin x}{\cos^2x+1}dx&=&\displaystyle\int\frac{\cos^2x\sin x+2\sin x}{\cos^2x+1}\cdot\frac{\frac{dx}{1}}{1}\\
&=&\displaystyle\int\frac{\cos^2x\sin x+2\sin x}{\cos^2x+1}\cdot\frac{\frac{dx}{1}}{1}\cdot\frac{\frac{du}{dx}}{\frac{du}{dx}}\\
&=&\displaystyle\int\frac{\cos^2x\sin x+2\sin x}{\cos^2x+1}\cdot\frac{\frac{dx}{1}}{1}\cdot\frac{\frac{du}{dx}}{\color{green}{-\sin x}}\\
&=&\displaystyle-\int\frac{\cos^2x+2}{\cos^2x+1}\cdot\frac{\frac{dx}{1}}{1}\cdot\frac{\frac{du}{dx}}{1}\\
&=&\displaystyle-\int\frac{\cos^2x+2}{\cos^2x+1}du\\
&=&\displaystyle-\int\frac{u^2+2}{u^2+1}du\\
\end{array}$$
The reason why I do things this way is so that I can see what's "going on" instead of just following some preset algorithm. This way, i can see the "why" instead of just the "what".
Finishing off we have
$$\begin{array}{lll}
-\displaystyle\int\frac{u^2+2}{u^2+1}du &=&-\displaystyle\int\frac{(u^2+1)+1}{u^2+1}du\\
&=&-\displaystyle\int 1+\frac{1}{u^2+1}du\\
&=&\displaystyle -(u+\tan^{-1}u)+C\\
&=&\displaystyle -(\cos x+\tan^{-1}(\cos x))+C\\
\end{array}$$
