$$ \int \frac{1}{x^2+6x+5} \, dx $$ I thought I did the steps correctly but I may have the wrong substitution.
So first I completed the square: $$ \int\frac{1}{(x+3)^2-4} \, dx $$ Then I used the substitution of $ x= 2\sin \theta -3$ and then found $ dx= 2 \cos \theta \, d\theta $
I then subbed in these values to create $$\int \frac{2\cos\theta}{4( \sin^2 \theta -1)} \, d\theta$$
This leads to $$ -\frac{1}{2}\int \sec \theta \, d \theta $$ And the answer I got is $$ -\frac{1}{2} \ln\lvert\sec x + \tan x\rvert +c $$ However, this is not the correct answer according to an online integration calculator. Can anyone help me figure out where I went wrong (probably the substitution)?
Up to the point where you list the answer as $\frac{-1}{2}\int \sec(\theta)d\theta$ is correct. However, this integral is $\frac{-1}{2}\ln(\sec(\theta)+\tan(\theta)),$ not $\frac{-1}{2}\ln(\sec(x)+\tan(x))$. You must integrate with respect to $\theta$ and then change it back to $x$. When $\sin(\theta) = \frac{x+3}{2}$, $$\frac{-1}{2} \ln(\sec\theta+\tan\theta)= \frac{-1}{2}\ln\left(\frac{2}{\sqrt{4-(x+3)^2}}+\frac{(x+3)}{\sqrt{4-(x+3)^2}}\right)$$ Where I've calculated $\sec\theta$ and $\tan\theta$ using your substitution. Algebra should take you to the answer. I'd collect into one fraction, split into two logarithms, and then take the square roots out as coefficients.
Sidvhid correctly points out that partial fractions is much, much easier.