<s>[INST] Integrating a Rational Function I am studying for a test and I am trying to evauate the integral below. I know how to simplify it with partial fractions, but when I try to solve it, I cannot seem to find a substitution that will simplify it enough to solve in reasonably quick . I plugged it into wolfram and as usual it doesn't give a quick way either. If anybody has a way this integral can be solved quickly, as there will be a time crunch on my test. 
$$\int\frac{x^3+x+2}{x^4+2x^2+1}dx$$
 [/INST] From partial fractions and two variable substitutions
$$\begin{align}
\int \frac{x^3+x+2}{x^4+2x^2+1}dx &= \int\frac{x}{x^2+1}dx + 2\int\frac{1}{x^2+1}\frac{1}{x^2+1}dx \\
&= \frac{1}{2}\int\frac{du}{u}+\int\frac{1}{(\tan v)^2+1}dv
\end{align}$$
where $u=x^2+1$ and $v=\arctan x$ (recall that $\frac{d}{dx}\arctan x = \frac{1}{1+x^2} $).  Now since $\tan^2v+1 = \sec^2 v = 1/\cos^2 v$,
$$\begin{align}
\int \frac{x^3+x+2}{x^4+2x^2+1}dx &= \frac{\ln u}{2} + 2\int \cos^2(v)\, dv \\
&= \frac{\ln u}{2}+2\left(\frac{\sin v \cos v}{2} +\frac{v}{2}\right) \\
&= \frac{\ln \left(x^2+1\right)}{2}+\sin \left(\arctan x\right) \cos \left(\arctan x\right) +\arctan x \\
&= \frac{1}{2}\ln \left(x^2+1\right) + \frac{x}{x^2+1} + \arctan x
\end{align}$$
Hope this helps.
</s>