<s>[INST] Can trigonometric substitution be used to solve this integral? The integral in question is $$\int \frac{x+1}{9x^2+6x+5}dx.$$ I first completed the square in the denominator giving $(3x+1)^2+4$ and proceeded to perform a $u$-substitution with $u = 3x+1$, $du=3~dx$, and $x=(u-1)/3$. After simplifying, I was left with $$\frac{1}{9}\int\frac{u+2}{u^2+4}du.$$ It is at this point I used trigonometric substitution with $u = 2\tan\theta$ and $du = 2\sec^2\theta~d\theta$ (I'm aware the integral can be written as $\frac 1 9\int\frac{u}{u^2+4}du+\frac 1 9\int\frac{2}{u^2+4}du$ and solved this way). After performing the trig substitution, I was left with $$\frac 1 9\int(\tan\theta + 1)~d\theta = \frac 1 9 \ln|\sec\theta|+\frac 1 9 \theta + C.$$ Rewriting everything in terms of $x$ gave me $$\frac 1 9\ln\left(\frac{(3x+1)^2+4}{2}\right)+\frac{1}{9}\tan^{-1}\left(\frac 1 2(3x+1)\right)+ C,$$ which is incorrect. The correct answer is $$\frac{1}{18}\ln\left(9x^2+6x+5\right)+\frac{1}{9}\tan^{-1}\left(\frac 1 2(3x+1)\right)+ C.$$ What went wrong with my trig substitution?
 [/INST] Since $u=2\tan\theta$, you have$$u^2=4\tan^2\theta=4(\sec^2\theta-1).$$So,$$\sec\theta=\sqrt{\frac{u^2+4}4}$$and therefore$$\frac19\ln(\sec\theta)=\frac1{18}\ln\left(\frac{u^2+4}4\right).$$
</s>