Đặt $t=\tan \frac{x}{2} $ ta được:
$dt=\frac{1}{2}\frac{1}{\cos^2 \frac{x}{2} }dx=\frac{1}{2}(1+\tan ^2
\frac{x}{2} )dx= \frac{1}{2}(1+t^2)dx \Rightarrow dx=\frac{2dt}{1+t^2}
$
Khi đó:
$\int\limits
\frac{\frac{4dt}{1+t^2} }{\frac{4t}{1+t^2}-\frac{1-t^2}{1+t^2}
+1}=\int\limits \frac{2dt}{t^2+2t}=2 \int\limits
\frac{d(t+1)}{(t+1)^2-1}=\ln|\frac{t-1}{t+1} |+C $
$=\ln|\frac{\tan\frac{x}{2}-1}{\tan\frac{x}{2}+1} |+C=\ln|\tan(\frac{x}{2}+\frac{\pi}{4})|+C$