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?
 A: 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).$$
A: There is a simpler way to determine this integral: rewrite first the numerator:
$$x+1=\frac 1{18}(18x+6)+\frac 23,$$
split the integral in two:
\begin{align}
\int \frac{x+1}{9x^2+6x+5}\,\mathrm dx&=\frac 1{18}\int \frac{18x+6}{9x^2+6x+5}\,\mathrm dx+\frac23\int\frac{\mathrm dx}{(3x+1)^2+4}\\
&=\frac 1{18}\ln(9x^2+6x+5)+\frac23\int\frac{\mathrm dx}{(3x+1)^2+4}\\
&=\frac 1{18}\ln(9x^2+6x+5)+\frac29\int\frac{\mathrm d(3x+1)}{(3x+1)^2+4},
\end{align}
and use the standard formula
$$\int\frac{\mathrm dx}{x^2+a^2}=\frac1a\,\arctan \Bigl(\frac xa\Bigr).$$
A: $$\begin{align*}
\int \frac{x+1}{9x^2+6x+5}dx
&=\int\frac{x+1}{(3x+1)^2+2^2}dx\\ (u = 3x+1)\\
& = \frac{1}{9}\int\frac{u+2}{u^2+2^2}du\\ (u = 2\tan\theta)\\
&=\frac{1}{9}\int\frac{(2\tan\theta+2)(2\sec^2\theta)}{2^2(1+\tan^2\theta)}d\theta\\
&=\frac{1}{9}\int(\tan\theta+1)d\theta\\
& = \frac{1}{9}\ln{|\sec\theta|} + \frac{1}{9}\theta + C_0
\end{align*}$$
Now, $|x| = \sqrt{x^2}$
$\implies \ln|\sec\theta| = \ln{(\sqrt{\sec^2{\theta}})} = \frac{1}{2}\ln{\sec^2{\theta}} = \frac{1}{2}\ln{(1+\tan^2{\theta})}$
Which for the above:
$$\begin{align*}
\frac{1}{9}\ln{|\sec\theta|} + \frac{1}{9}\theta + C_0
& = \frac{1}{9}\times\frac{1}{2}\ln{(1+\tan^2{\theta})}+ \frac{1}{9}\theta + C_0\\
& = \frac{1}{9}\times\frac{1}{2}\ln\left(1+\left(\frac{3x+1}{2}\right)^2\right) + \tan^{-1}\left(\frac{3x+1}{2}\right)+C_0\\
& = \frac 1{18}\ln(9x^2 + 6x +5) + \tan^{-1}\left(\frac{3x+1}{2}\right)+(C_0 - \frac 1{18}\ln(4))\\
& = \frac 1{18}\ln(9x^2 + 6x +5) + \tan^{-1}\left(\frac{3x+1}{2}\right)+C
\end{align*}$$
