TITLE: What's the integral of this fraction?
QUESTION [1 upvotes]: 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?

REPLY [1 votes]: 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}$$
{"set_name": "stack_exchange", "score": 1, "question_id": 1579375}