<s>[INST] $\int\frac{2x+1}{x^2+2x+5}dx$ by partial fractions $$\int\frac{2x+1}{x^2+2x+5}dx$$
I know I'm supposed to make the bottom a perfect square by making it $(x+1)^2 +4$ but I don't know what to do after that. I've tried to make $x+1= \tan x$ because that's what we did in a class example but I keep getting stuck.
 [/INST] Using a trigonometric substitution, let $x+1 = 2\tan u$, so that $dx = 2\sec^2 u\,du$ and $2x+1 = 4\tan u-1$. Then we get
\begin{align*}
\int\frac{2x+1}{(x+1)^2+4}\,dx &= \int\frac{4\tan u-1}{4\tan^2 u+4}\cdot 2\sec^2u\,du \\
     &= \frac{1}{4}\int\frac{4\tan u-1}{\sec^2u}\cdot 2\sec^2u\,du \\
     &= \frac{1}{2}\int (4\tan u-1)\,du \\
     &= \frac{1}{2}\left(4\ln\sec u - u\right) + C \\
     &= 2\ln\frac{\sqrt{x^2+2x+5}}{2} - \frac{1}{2}\tan^{-1}\frac{x+1}{2} + C \\
     &= \ln(x^2+2x+5) - \frac{1}{2}\tan^{-1}\frac{x+1}{2} + C.
\end{align*}
</s>