Integrate $ \int \frac{2\tan x+1}{\sqrt{\tan^2 x+2\tan x+2}} \, \mathrm dx $ I tried writing $\tan^2 x+2\tan x+2$ as $(\tan x+1)^2+1$ and letting $\tan\theta = \tan x+1$ yields
$$ \int \frac{2\tan\theta-1}{\tan^2\theta-2\tan\theta+2}\,\sec\theta\,\mathrm d\theta $$
Then letting $ t = \tan(\frac{\theta}{2})$ yields
$$ \int\frac{t^2+4t-1}{t^4+2t^3-2t+1}\,\mathrm dt $$
Obviously what's next is factoring out the denominator and doing partial fraction decomposition, but this seems very hard.
I wanted to know if there's an easier method.
 A: Let $t=\tan x$ to rewrite the integral as
$$ I=\int \frac{2\tan x+1}{\sqrt{\tan^2 x+2\tan x+2}} dx
=\int \frac{2t+1}{(1+t^2)\sqrt{t^2+2t+2}} dt\tag1
$$
Note that
$$
\bigg( \tan^{-1} \frac{at-a^{-1}}{\sqrt{t^2+2t+2}}\bigg)’
= \frac{a^{-1} t +ab }{(t^2+b)\sqrt{t^2+2t+2}},\>\>\>\>\>
b= \frac{1+2a^2}{a^2+a^4}$$
Set $b=1$ to obtain $a^4-a^2-1=0$, which leads to $a= \sqrt{\phi}$, with $\phi=\frac{1+\sqrt5}2$ the golden ratio. Hence
$$
g(t) = \frac{\phi^{-1/2} t + \phi^{1/2} }{(t^2+1)\sqrt{t^2+2t+2}} =\bigg( \tan^{-1} \frac{\phi^{1/2}t-\phi^{-1/2}}{\sqrt{t^2+2t+2}}\bigg)’
$$
and similarly
$$
h(t) =\frac{\phi^{-1/2}- \phi^{1/2} t }{(t^2+1)\sqrt{t^2+2t+2}} =\bigg( \tanh^{-1} \frac{\phi^{-1/2}t+\phi^{1/2}}{\sqrt{t^2+2t+2}}\bigg)’
$$
Then, the integrand in (1) can be decomposed as
$$
\frac{2t+1}{(1+t^2)\sqrt{t^2+2t+2}} 
= \phi^{1/2} g(t) - \phi^{-1/2} h(t)
$$
resulting in
$$I= \phi^{1/2} \tan^{-1} \frac{\phi^{1/2}t- \phi^{-1/2}}{\sqrt{t^2+2t+2}}
 - \phi^{-1/2}  \tanh^{-1} \frac{\phi^{-1/2}t+ \phi^{1/2} }{\sqrt{t^2+2t+2}}+C
$$
A: Too long for a comment.
If you want to use partial fraction decomposition for$$I=\int\frac{t^2+4t-1}{t^4+2t^3-2t+1}\, dt$$ you could write
$$t^4+2t^3-2t+1=(t^2+a t+b)\,(t^2+c t+d)$$ without trying to make $(a,b,c,d)$ explicit (they are irrational) and this would give
$$\frac{t^2+4t-1}{t^4+2t^3-2t+1}= \frac 1 k \Bigg[\frac {\alpha+\beta\,t}{t^2+a t+b }+\frac {\gamma+\delta\,t}{t^2+c t+d }\Bigg]$$ I do not write here the expression of the different constant (this does not present much interest). Even if we face now simple integrals, the simplification would probably be impossible.
A: $$\int\dfrac{2\tan x+1}{\sqrt{\tan^2x+2\tan x+2}}~dx=\int\dfrac{2(\tan x+1)-1}{\sqrt{(\tan x+1)^2+1}}~dx$$
Let $u=\tan x+1$ ,
Then $x=\tan^{-1}(u-1)$
$dx=\dfrac{1}{(u-1)^2+1}~du$
$$\therefore\int\dfrac{2(\tan x+1)-1}{\sqrt{(\tan x+1)^2+1}}~dx=\int\dfrac{2u-1}{((u-1)^2+1)\sqrt{u^2+1}}~du$$
Introduce the Euler substitution:
Let $v=u+\sqrt{u^2+1}$ ,
Then $u=\dfrac{v^2+1}{2v}$
$du=\dfrac{v^2-1}{2v^2}~dv$
$$\begin{align}\therefore\int\dfrac{2u-1}{((u-1)^2+1)\sqrt{u^2+1}}~du&=\int\dfrac{\dfrac{2(v^2+1)}{2v}-1}{\left(\left(\dfrac{v^2+1}{2v}-1\right)^2+1\right)\left(v-\dfrac{v^2+1}{2v}\right)}\dfrac{v^2-1}{2v^2}~dv\\&=\int\dfrac{\dfrac{2(v^2-v+1)}{2v}}{\dfrac{(v^2-2v+1)^2+4v^2}{4v^2}\dfrac{v^2-1}{2v}}\dfrac{v^2-1}{2v^2}~dv\\&=\int\dfrac{4(v^2-v+1)}{(v^2-2v+1)^2+4v^2}~dv\end{align}$$
